Package org.geotools.gce.imagemosaic
Class Utils
Object
Utils
Sparse utilities for the various mosaic classes. I use them to extract complex code from other places.
- Author:
- Simone Giannecchini, GeoSolutions S.A.S.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classExtracts a bbox from a filter in case there is at least one.static classstatic classGiven a source object, allow to retrieve (when possible) the related url, the related file or the original input source object itself. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Hints.Keystatic final Hints.Keystatic final Stringstatic final Hints.Keystatic final Hints.Keystatic final Stringstatic final Stringstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final Stringstatic final StringDefault location attribute name.static final booleanDefault path behavior with respect to absolute paths.static final intDefault priority for the underlyingThread.static final Stringstatic final booleanstatic final StringDefault wildcard for creating mosaics.static final Stringstatic final Hints.Keystatic final HintsHints to use for avoiding to search for the imagemosaic formatstatic final FilterFactorystatic final Hints.Keystatic ObjectFactorystatic final StringDeprecated.static final Stringstatic final Hints.Keystatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final double[][]RGB to GRAY coefficients (for Luminance computation)static final StringSystem propertyorg.geotools.gce.imagemosaic.sampleimage.allowlistused to validate sample image deserialization.static final Stringstatic final Stringstatic final DataStoreFactorySpistatic final Stringstatic final TimeZone -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckColorModels(ColorModel defaultCM, byte[][] defaultPalette, ColorModel actualCM) This method checks theColorModelof 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.static StringcheckDirectory(String testingDirectory, boolean writable) static booleancheckFileReadable(File file) Checks that aFileis a real file, exists and is readable.static Map<String,Serializable> createDataStoreParamsFromPropertiesFile(URL datastoreProperties) static Map<String,Serializable> createDataStoreParamsFromPropertiesFile(Properties properties, DataStoreFactorySpi spi) createRange(Object firstValue, Object secondValue) Create a Range of numbers from a couple of values.static GeometryDecimate a geometry (reducing the number of vertices) for incoming bufferingstatic IOFileFilterexcludeFilters(IOFileFilter inputFilter, IOFileFilter... filters) static byte[][]extractPalette(IndexColorModel indexColorModel) Extract the palette from anIndexColorModel.static Map<String,Serializable> filterDataStoreParams(Properties properties, DataStoreFactorySpi spi) static voidfixH2DatabaseLocation(Map<String, Serializable> params, String parentLocation) static voidfixH2MVCCParam(Map<String, Serializable> params) static voidfixPostgisDBCreationParams(Map<String, Serializable> datastoreParams) static ObjectgetAttribute(SimpleFeature feature, String attribute) static BorderExtendergetBorderExtenderHint(RenderingHints renderHints) static IOFileFilterstatic FileReturns the File associated to the rootFolder if not absolutestatic StringgetFileInfo(File file) Creates a human readable message that describe the providedFileobject in terms of its properties.static ObjectgetHintIfAvailable(RenderingHints hints, RenderingHints.Key key) static HistogramgetHistogram(String file) Setup aHistogramobject by deserializing a file representing a serialized Histogram.static ImageLayoutgetImageLayoutHint(RenderingHints renderHints) static StringgetIndexerProperty(String locationPath, String propertyName) static ImageInputStreamSpigetInputStreamSPIFromURL(URL granuleUrl) static StringgetMessageFromException(Exception exception) static ImageReaderSpigetReaderSpiFromStream(ImageReaderSpi suggestedSPI, ImageInputStream inStream) static TileCachegetTileCacheHint(RenderingHints renderHints) static TileSchedulergetTileSchedulerHint(RenderingHints renderHints) static booleanhomogeneousCheck(int numberOfLevels, double[][] resolutionLevels, double[][] compareLevels) Check whether 2 resolution levels sets are homogeneous (within a tolerance)static booleanstatic booleanChecks if the provided factory spi builds a Oracle storestatic booleanChecks if the provided factory spi builds a Postgis storestatic booleanChecks if the provided factory spi builds a SQLServer storestatic booleanisSupportedCRS(GridCoverage2DReader reader, CoordinateReferenceSystem crs) Check if the provided reader is a MultiCRS Reader and it can support the specified crs.static booleanisValidMosaicSchema(SimpleFeatureType schema, String locationAttributeName) Returns true if the type is usable as a mosaic indexstatic RenderedImageloadSampleImage(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.static voidMarshals the Indexer object to the specified filestatic PAMDatasetmergePamDatasets(PAMDataset[] pamDatasets) Merge statistics across datasets.static booleanminimalIndexCheck(Object source) Simple minimal check which checks whether and indexer file existsstatic ReferencedEnvelopeparseEnvelope(String bboxString) Parses a bbox in the form of MIX,MINY MAXX,MAXYstatic ReferencedEnvelopereprojectEnvelope(ReferencedEnvelope sourceEnvelope, CoordinateReferenceSystem targetCRS, ReferencedEnvelope targetReferenceEnvelope) static GeometryreprojectEnvelopeToGeometry(ReferencedEnvelope sourceEnvelope, CoordinateReferenceSystem targetCRS, ReferencedEnvelope targetReferenceEnvelope) Reprojects an envelope using theProjectionHandlermachinery.protected static Patternstatic ROIroiIntersect(ROI roi, ROIGeometry roiGeometry, RenderingHints hints) Intersects a ROI with a ROI geometry, with fallback on GeometrySnapper if a TopologyException occursstatic HintssetupJAIHints(RenderingHints inputHints) static voidstoreSampleImage(File sampleImageFile, SampleModel defaultSM, ColorModel defaultCM) Store a sample image from which we can derive the default SM and CMstatic IndexerUnmarshal the file and return and Indexer object.
-
Field Details
-
FF
-
DEFAULT_RANGE_READER
- See Also:
-
EXCLUDE_MOSAIC
-
EXCLUDE_MOSAIC_HINTS
Hints to use for avoiding to search for the imagemosaic format -
CHECK_AUXILIARY_METADATA
-
COG_SETTINGS
-
AUXILIARY_FILES_PATH
-
AUXILIARY_DATASTORE_PATH
-
PARENT_DIR
-
MOSAIC_READER
-
RANGE_SPLITTER_CHAR
- See Also:
-
PAM_DATASET
Deprecated.- See Also:
-
DATASTORE_PROPERTIES
- See Also:
-
PROPERTIES_SEPARATOR
- See Also:
-
LOG_EXCLUDES
-
RGB_TO_GRAY_MATRIX
public static final double[][] RGB_TO_GRAY_MATRIXRGB to GRAY coefficients (for Luminance computation) -
SAMPLE_IMAGE_ALLOWLIST_KEY
System propertyorg.geotools.gce.imagemosaic.sampleimage.allowlistused to validate sample image deserialization.- See Also:
-
DEFAULT_WILCARD
Default wildcard for creating mosaics.- See Also:
-
DEFAULT_PATH_BEHAVIOR
public static final boolean DEFAULT_PATH_BEHAVIORDefault path behavior with respect to absolute paths.- See Also:
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITYDefault priority for the underlyingThread.- See Also:
-
DEFAULT_LOCATION_ATTRIBUTE
Default location attribute name.- See Also:
-
DEFAULT_INDEX_NAME
- See Also:
-
SHAPE_SPI
-
DEFAULT_RECURSION_BEHAVIOR
public static final boolean DEFAULT_RECURSION_BEHAVIOR- See Also:
-
DEFAULT_COLLECT_RAT
public static final boolean DEFAULT_COLLECT_RAT- See Also:
-
DEFAULT_FOOTPRINT_MANAGEMENT
public static final boolean DEFAULT_FOOTPRINT_MANAGEMENT- See Also:
-
DEFAULT_CONFIGURATION_CACHING
public static final boolean DEFAULT_CONFIGURATION_CACHING- See Also:
-
DEFAULT_COLOR_EXPANSION_BEHAVIOR
public static final boolean DEFAULT_COLOR_EXPANSION_BEHAVIOR- See Also:
-
UTC_TIME_ZONE
-
SAMPLE_IMAGE_NAME_LEGACY
- See Also:
-
SAMPLE_IMAGE_NAME
- See Also:
-
PAM_DATASET_NAME
- See Also:
-
BBOX
- See Also:
-
TIME_DOMAIN
- See Also:
-
ELEVATION_DOMAIN
- See Also:
-
CRS_DOMAIN
- See Also:
-
RESOLUTION_DOMAIN
- See Also:
-
RESOLUTION_X_DOMAIN
- See Also:
-
RESOLUTION_Y_DOMAIN
- See Also:
-
ADDITIONAL_DOMAIN
- See Also:
-
OBJECT_FACTORY
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
isSupportedCRS
public static boolean isSupportedCRS(GridCoverage2DReader reader, CoordinateReferenceSystem crs) throws FactoryException, IOException Check if the provided reader is a MultiCRS Reader and it can support the specified crs.- Throws:
FactoryExceptionIOException
-
getAttribute
-
resetSampleImageAllowlist
-
getMessageFromException
-
parseEnvelope
Parses a bbox in the form of MIX,MINY MAXX,MAXY- Parameters:
bboxString- the string to parse the bbox from- Returns:
- a
ReferencedEnvelopewith the parse bbox or null
-
excludeFilters
public static IOFileFilter excludeFilters(IOFileFilter inputFilter, IOFileFilter... filters) -
checkFileReadable
Checks that aFileis a real file, exists and is readable.- Parameters:
file- theFileinstance to check. Must not be null.- Returns:
truein case the file is a real file, exists and is readable;falseotherwise.
-
getFileInfo
Creates a human readable message that describe the providedFileobject in terms of its properties.Useful for creating meaningful log messages.
-
checkDirectory
public static String checkDirectory(String testingDirectory, boolean writable) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
createDataStoreParamsFromPropertiesFile
public static Map<String,Serializable> createDataStoreParamsFromPropertiesFile(URL datastoreProperties) throws IOException - Throws:
IOException
-
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 imagedefaultSM- theSampleModelfor the sample image.defaultCM- theColorModelfor the sample image.- Throws:
IOException- in case something bad occurs during writing.
-
loadSampleImage
Load a sample image from which we can take the sample model and color model to be used to fill holes in responses.Format of sample image is limited and may be customized using
SAMPLE_IMAGE_ALLOWLIST_KEYsystem propertyorg.geotools.gce.imagemosaic.sampleimage.allowlist.- 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.
-
createDataStoreParamsFromPropertiesFile
public static Map<String,Serializable> createDataStoreParamsFromPropertiesFile(Properties properties, DataStoreFactorySpi spi) throws IOException - Throws:
IOException
-
filterDataStoreParams
public static Map<String,Serializable> filterDataStoreParams(Properties properties, DataStoreFactorySpi spi) throws IOException - Throws:
IOException
-
getIndexerProperty
-
getHistogram
Setup aHistogramobject by deserializing a file representing a serialized Histogram.- Returns:
- the deserialized histogram.
-
getImageLayoutHint
-
getTileCacheHint
-
getBorderExtenderHint
-
getTileSchedulerHint
-
getHintIfAvailable
-
setupJAIHints
-
createRange
Create a Range of numbers from a couple of values. -
minimalIndexCheck
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
Unmarshal the file and return and Indexer object.- Throws:
JAXBException
-
marshal
Marshals the Indexer object to the specified file- Throws:
JAXBException
-
checkColorModels
public static boolean checkColorModels(ColorModel defaultCM, byte[][] defaultPalette, ColorModel actualCM) This method checks theColorModelof 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.
-
isH2Store
-
fixH2DatabaseLocation
public static void fixH2DatabaseLocation(Map<String, Serializable> params, String parentLocation) throws MalformedURLException- Throws:
MalformedURLException
-
isOracleStore
Checks if the provided factory spi builds a Oracle store -
isPostgisStore
Checks if the provided factory spi builds a Postgis store -
isSQLServerStore
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() -
fixH2MVCCParam
-
fixPostgisDBCreationParams
-
getReaderSpiFromStream
public static ImageReaderSpi getReaderSpiFromStream(ImageReaderSpi suggestedSPI, ImageInputStream inStream) throws IOException - Throws:
IOException
-
getInputStreamSPIFromURL
- Throws:
IOException
-
extractPalette
Extract the palette from anIndexColorModel. -
isValidMosaicSchema
Returns true if the type is usable as a mosaic index -
reprojectEnvelope
public static ReferencedEnvelope reprojectEnvelope(ReferencedEnvelope sourceEnvelope, CoordinateReferenceSystem targetCRS, ReferencedEnvelope targetReferenceEnvelope) throws FactoryException, TransformException - Throws:
FactoryExceptionTransformException
-
reprojectEnvelopeToGeometry
public static Geometry reprojectEnvelopeToGeometry(ReferencedEnvelope sourceEnvelope, CoordinateReferenceSystem targetCRS, ReferencedEnvelope targetReferenceEnvelope) throws FactoryException, TransformException Reprojects an envelope using theProjectionHandlermachinery. The output can be a multipolygon in case of wrapping, which might or might not be what you want, act accordingly- Throws:
FactoryExceptionTransformException
-
getFile
Returns the File associated to the rootFolder if not absolute- Throws:
IOException
-
decimate
Decimate a geometry (reducing the number of vertices) for incoming buffering -
roiIntersect
Intersects a ROI with a ROI geometry, with fallback on GeometrySnapper if a TopologyException occurs
-