Class Utils


  • public class Utils
    extends Object
    Sparse utilities for the various mosaic classes. I use them to extract complex code from other places.
    Author:
    Simone Giannecchini, GeoSolutions S.A.S.
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • getMessageFromException

        public static String getMessageFromException​(Exception exception)
      • parseEnvelope

        public static ReferencedEnvelope parseEnvelope​(String bboxString)
        Parses a bbox in the form of MIX,MINY MAXX,MAXY
        Parameters:
        bboxString - the string to parse the bbox from
        Returns:
        a ReferencedEnvelope with the parse bbox or null
      • excludeFilters

        public static IOFileFilter excludeFilters​(IOFileFilter inputFilter,
                                                  IOFileFilter... filters)
      • checkFileReadable

        public static boolean checkFileReadable​(File file)
        Checks that a File is a real file, exists and is readable.
        Parameters:
        file - the File instance to check. Must not be null.
        Returns:
        true in case the file is a real file, exists and is readable; false otherwise.
      • getFileInfo

        public static String getFileInfo​(File file)
        Creates a human readable message that describe the provided File object in terms of its properties.

        Useful for creating meaningful log messages.

        Parameters:
        file - the File object to create a descriptive message for
        Returns:
        a String containing a descriptive message about the provided File.
      • storeSampleImage

        public static void storeSampleImage​(File sampleImageFile,
                                            SampleModel defaultSM,
                                            ColorModel defaultCM)
                                     throws IOException
        Store a sample image from which we can derive the default SM and CM
        Parameters:
        sampleImageFile - where we should store the image
        defaultSM - the SampleModel for the sample image.
        defaultCM - the ColorModel for the sample image.
        Throws:
        IOException - in case something bad occurs during writing.
      • loadSampleImage

        public static RenderedImage loadSampleImage​(File sampleImageFile)
        Load a sample image from which we can take the sample model and color model to be used to fill holes in responses.
        Parameters:
        sampleImageFile - the path to sample image.
        Returns:
        a sample image from which we can take the sample model and color model to be used to fill holes in responses.
      • getIndexerProperty

        public static String getIndexerProperty​(String locationPath,
                                                String propertyName)
      • getHistogram

        public static Histogram getHistogram​(String file)
        Setup a Histogram object by deserializing a file representing a serialized Histogram.
        Returns:
        the deserialized histogram.
      • getImageLayoutHint

        public static ImageLayout getImageLayoutHint​(RenderingHints renderHints)
      • getTileCacheHint

        public static TileCache getTileCacheHint​(RenderingHints renderHints)
      • getBorderExtenderHint

        public static BorderExtender getBorderExtenderHint​(RenderingHints renderHints)
      • getTileSchedulerHint

        public static TileScheduler getTileSchedulerHint​(RenderingHints renderHints)
      • createRange

        public static Range<? extends Number> createRange​(Object firstValue,
                                                          Object secondValue)
        Create a Range of numbers from a couple of values.
      • minimalIndexCheck

        public static boolean minimalIndexCheck​(Object source)
        Simple minimal check which checks whether and indexer file exists
      • homogeneousCheck

        public static boolean homogeneousCheck​(int numberOfLevels,
                                               double[][] resolutionLevels,
                                               double[][] compareLevels)
        Check whether 2 resolution levels sets are homogeneous (within a tolerance)
      • unmarshal

        public static Indexer unmarshal​(File indexerFile)
                                 throws JAXBException
        Unmarshal the file and return and Indexer object.
        Throws:
        JAXBException
      • marshal

        public static void marshal​(Indexer indexer,
                                   File indexerFile)
                            throws JAXBException
        Marshals the Indexer object to the specified file
        Throws:
        JAXBException
      • checkColorModels

        public static boolean checkColorModels​(ColorModel defaultCM,
                                               byte[][] defaultPalette,
                                               ColorModel actualCM)
        This method checks the ColorModel of the current image with the one of the first image in order to check if they are compatible or not in order to perform a mosaic operation.

        It is worth to point out that we also check if, in case we have two index color model image, we also try to suggest whether or not we should do a color expansion.

        Returns:
        a boolean asking to skip this feature.
      • isOracleStore

        public static boolean isOracleStore​(DataStoreFactorySpi spi)
        Checks if the provided factory spi builds a Oracle store
      • isPostgisStore

        public static boolean isPostgisStore​(DataStoreFactorySpi spi)
        Checks if the provided factory spi builds a Postgis store
      • isSQLServerStore

        public static boolean isSQLServerStore​(DataStoreFactorySpi spi)
        Checks if the provided factory spi builds a SQLServer store
      • mergePamDatasets

        public static PAMDataset mergePamDatasets​(PAMDataset[] pamDatasets)
        Merge statistics across datasets.
      • getCleanupFilter

        public static IOFileFilter getCleanupFilter()
      • fixPostgisDBCreationParams

        public static void fixPostgisDBCreationParams​(Map<String,​Serializable> datastoreParams)
      • isValidMosaicSchema

        public static boolean isValidMosaicSchema​(SimpleFeatureType schema,
                                                  String locationAttributeName)
        Returns true if the type is usable as a mosaic index
      • decimate

        public static Geometry decimate​(Geometry geometry)
        Decimate a geometry (reducing the number of vertices) for incoming buffering
      • roiIntersect

        public static ROI roiIntersect​(ROI roi,
                                       ROIGeometry roiGeometry,
                                       RenderingHints hints)
        Intersects a ROI with a ROI geometry, with fallback on GeometrySnapper if a TopologyException occurs