public class Utils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Utils.BBOXFilterExtractor
Extracts a bbox from a filter in case there is at least one.
|
static class |
Utils.Prop |
static class |
Utils.SourceGetter
Given a source object, allow to retrieve (when possible) the related url, the related file or
the original input source object itself.
|
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
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. |
static String |
checkDirectory(String testingDirectory,
boolean writable) |
static boolean |
checkFileReadable(File file)
Checks that a
File is a real file, exists and is readable. |
static Map<String,Serializable> |
createDataStoreParamsFromPropertiesFile(Properties properties,
DataStoreFactorySpi spi) |
static Map<String,Serializable> |
createDataStoreParamsFromPropertiesFile(URL datastoreProperties) |
static Range<? extends Number> |
createRange(Object firstValue,
Object secondValue)
Create a Range of numbers from a couple of values.
|
static Geometry |
decimate(Geometry geometry)
Decimate a geometry (reducing the number of vertices) for incoming buffering
|
static IOFileFilter |
excludeFilters(IOFileFilter inputFilter,
IOFileFilter... filters) |
static byte[][] |
extractPalette(IndexColorModel indexColorModel)
Extract the palette from an
IndexColorModel . |
static Map<String,Serializable> |
filterDataStoreParams(Properties properties,
DataStoreFactorySpi spi) |
static void |
fixH2DatabaseLocation(Map<String,Serializable> params,
String parentLocation) |
static void |
fixH2MVCCParam(Map<String,Serializable> params) |
static void |
fixPostgisDBCreationParams(Map<String,Serializable> datastoreParams) |
static Object |
getAttribute(SimpleFeature feature,
String attribute) |
static BorderExtender |
getBorderExtenderHint(RenderingHints renderHints) |
static IOFileFilter |
getCleanupFilter() |
static File |
getFile(String strValue,
File rootFolder)
Returns the File associated to the rootFolder if not absolute
|
static String |
getFileInfo(File file)
Creates a human readable message that describe the provided
File object in terms of
its properties. |
static Object |
getHintIfAvailable(RenderingHints hints,
RenderingHints.Key key) |
static Histogram |
getHistogram(String file)
Setup a
Histogram object by deserializing a file representing a serialized Histogram. |
static ImageLayout |
getImageLayoutHint(RenderingHints renderHints) |
static String |
getIndexerProperty(String locationPath,
String propertyName) |
static ImageInputStreamSpi |
getInputStreamSPIFromURL(URL granuleUrl) |
static String |
getMessageFromException(Exception exception) |
static ImageReaderSpi |
getReaderSpiFromStream(ImageReaderSpi suggestedSPI,
ImageInputStream inStream) |
static TileCache |
getTileCacheHint(RenderingHints renderHints) |
static TileScheduler |
getTileSchedulerHint(RenderingHints renderHints) |
static boolean |
homogeneousCheck(int numberOfLevels,
double[][] resolutionLevels,
double[][] compareLevels)
Check whether 2 resolution levels sets are homogeneous (within a tolerance)
|
static boolean |
isH2Store(DataStoreFactorySpi spi) |
static boolean |
isOracleStore(DataStoreFactorySpi spi)
Checks if the provided factory spi builds a Oracle store
|
static boolean |
isPostgisStore(DataStoreFactorySpi spi)
Checks if the provided factory spi builds a Postgis store
|
static boolean |
isSQLServerStore(DataStoreFactorySpi spi)
Checks if the provided factory spi builds a SQLServer store
|
static boolean |
isSupportedCRS(GridCoverage2DReader reader,
CoordinateReferenceSystem crs)
Check if the provided reader is a MultiCRS Reader and it can support the specified crs.
|
static boolean |
isValidMosaicSchema(SimpleFeatureType schema,
String locationAttributeName)
Returns true if the type is usable as a mosaic index
|
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.
|
static void |
marshal(Indexer indexer,
File indexerFile)
Marshals the Indexer object to the specified file
|
static PAMDataset |
mergePamDatasets(PAMDataset[] pamDatasets)
Merge statistics across datasets.
|
static boolean |
minimalIndexCheck(Object source)
Simple minimal check which checks whether and indexer file exists
|
static ReferencedEnvelope |
parseEnvelope(String bboxString)
Parses a bbox in the form of MIX,MINY MAXX,MAXY
|
static ReferencedEnvelope |
reprojectEnvelope(ReferencedEnvelope sourceEnvelope,
CoordinateReferenceSystem targetCRS,
ReferencedEnvelope targetReferenceEnvelope) |
static Geometry |
reprojectEnvelopeToGeometry(ReferencedEnvelope sourceEnvelope,
CoordinateReferenceSystem targetCRS,
ReferencedEnvelope targetReferenceEnvelope)
Reprojects an envelope using the
ProjectionHandler machinery. |
static ROI |
roiIntersect(ROI roi,
ROIGeometry roiGeometry,
RenderingHints hints)
Intersects a ROI with a ROI geometry, with fallback on GeometrySnapper if a TopologyException
occurs
|
static Hints |
setupJAIHints(RenderingHints inputHints) |
static void |
storeSampleImage(File sampleImageFile,
SampleModel defaultSM,
ColorModel defaultCM)
Store a sample image from which we can derive the default SM and CM
|
static Indexer |
unmarshal(File indexerFile)
Unmarshal the file and return and Indexer object.
|
public static final FilterFactory2 FF
public static final String DEFAULT_RANGE_READER
public static final Hints.Key EXCLUDE_MOSAIC
public static final Hints EXCLUDE_MOSAIC_HINTS
public static final Hints.Key CHECK_AUXILIARY_METADATA
public static final Hints.Key COG_SETTINGS
public static final Hints.Key AUXILIARY_FILES_PATH
public static final Hints.Key AUXILIARY_DATASTORE_PATH
public static final Hints.Key PARENT_DIR
public static final Hints.Key MOSAIC_READER
public static final String RANGE_SPLITTER_CHAR
@Deprecated public static final String PAM_DATASET
public static final String DATASTORE_PROPERTIES
public static final String PROPERTIES_SEPARATOR
public static final double[][] RGB_TO_GRAY_MATRIX
public static final String DEFAULT_WILCARD
public static final boolean DEFAULT_PATH_BEHAVIOR
public static final int DEFAULT_PRIORITY
Thread
.public static final String DEFAULT_LOCATION_ATTRIBUTE
public static final String DEFAULT_INDEX_NAME
public static final DataStoreFactorySpi SHAPE_SPI
public static final boolean DEFAULT_RECURSION_BEHAVIOR
public static final boolean DEFAULT_FOOTPRINT_MANAGEMENT
public static final boolean DEFAULT_CONFIGURATION_CACHING
public static final boolean DEFAULT_COLOR_EXPANSION_BEHAVIOR
public static final TimeZone UTC_TIME_ZONE
public static final String SAMPLE_IMAGE_NAME_LEGACY
public static final String SAMPLE_IMAGE_NAME
public static final String BBOX
public static final String TIME_DOMAIN
public static final String ELEVATION_DOMAIN
public static final String CRS_DOMAIN
public static final String RESOLUTION_DOMAIN
public static final String RESOLUTION_X_DOMAIN
public static final String RESOLUTION_Y_DOMAIN
public static final String ADDITIONAL_DOMAIN
public static ObjectFactory OBJECT_FACTORY
public static boolean isSupportedCRS(GridCoverage2DReader reader, CoordinateReferenceSystem crs) throws FactoryException, IOException
FactoryException
IOException
public static Object getAttribute(SimpleFeature feature, String attribute)
public static ReferencedEnvelope parseEnvelope(String bboxString)
bboxString
- the string to parse the bbox fromReferencedEnvelope
with the parse bbox or nullpublic static IOFileFilter excludeFilters(IOFileFilter inputFilter, IOFileFilter... filters)
public static boolean checkFileReadable(File file)
File
is a real file, exists and is readable.file
- the File
instance to check. Must not be null.true
in case the file is a real file, exists and is readable;
false
otherwise.public static String getFileInfo(File file)
File
object in terms of
its properties.
Useful for creating meaningful log messages.
public static String checkDirectory(String testingDirectory, boolean writable) throws IllegalArgumentException
IllegalArgumentException
public static Map<String,Serializable> createDataStoreParamsFromPropertiesFile(URL datastoreProperties) throws IOException
IOException
public static void storeSampleImage(File sampleImageFile, SampleModel defaultSM, ColorModel defaultCM) throws IOException
sampleImageFile
- where we should store the imagedefaultSM
- the SampleModel
for the sample image.defaultCM
- the ColorModel
for the sample image.IOException
- in case something bad occurs during writing.public static RenderedImage loadSampleImage(File sampleImageFile)
sampleImageFile
- the path to sample image.public static Map<String,Serializable> createDataStoreParamsFromPropertiesFile(Properties properties, DataStoreFactorySpi spi) throws IOException
IOException
public static Map<String,Serializable> filterDataStoreParams(Properties properties, DataStoreFactorySpi spi) throws IOException
IOException
public static String getIndexerProperty(String locationPath, String propertyName)
public static Histogram getHistogram(String file)
Histogram
object by deserializing a file representing a serialized Histogram.public static ImageLayout getImageLayoutHint(RenderingHints renderHints)
public static TileCache getTileCacheHint(RenderingHints renderHints)
public static BorderExtender getBorderExtenderHint(RenderingHints renderHints)
public static TileScheduler getTileSchedulerHint(RenderingHints renderHints)
public static Object getHintIfAvailable(RenderingHints hints, RenderingHints.Key key)
public static Hints setupJAIHints(RenderingHints inputHints)
public static Range<? extends Number> createRange(Object firstValue, Object secondValue)
public static boolean minimalIndexCheck(Object source)
public static boolean homogeneousCheck(int numberOfLevels, double[][] resolutionLevels, double[][] compareLevels)
public static Indexer unmarshal(File indexerFile) throws JAXBException
JAXBException
public static void marshal(Indexer indexer, File indexerFile) throws JAXBException
JAXBException
public static boolean checkColorModels(ColorModel defaultCM, byte[][] defaultPalette, ColorModel actualCM)
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.
public static boolean isH2Store(DataStoreFactorySpi spi)
public static void fixH2DatabaseLocation(Map<String,Serializable> params, String parentLocation) throws MalformedURLException
MalformedURLException
public static boolean isOracleStore(DataStoreFactorySpi spi)
public static boolean isPostgisStore(DataStoreFactorySpi spi)
public static boolean isSQLServerStore(DataStoreFactorySpi spi)
public static PAMDataset mergePamDatasets(PAMDataset[] pamDatasets)
public static IOFileFilter getCleanupFilter()
public static void fixH2MVCCParam(Map<String,Serializable> params)
public static void fixPostgisDBCreationParams(Map<String,Serializable> datastoreParams)
public static ImageReaderSpi getReaderSpiFromStream(ImageReaderSpi suggestedSPI, ImageInputStream inStream) throws IOException
IOException
public static ImageInputStreamSpi getInputStreamSPIFromURL(URL granuleUrl) throws IOException
IOException
public static byte[][] extractPalette(IndexColorModel indexColorModel)
IndexColorModel
.public static boolean isValidMosaicSchema(SimpleFeatureType schema, String locationAttributeName)
public static ReferencedEnvelope reprojectEnvelope(ReferencedEnvelope sourceEnvelope, CoordinateReferenceSystem targetCRS, ReferencedEnvelope targetReferenceEnvelope) throws FactoryException, TransformException
FactoryException
TransformException
public static Geometry reprojectEnvelopeToGeometry(ReferencedEnvelope sourceEnvelope, CoordinateReferenceSystem targetCRS, ReferencedEnvelope targetReferenceEnvelope) throws FactoryException, TransformException
ProjectionHandler
machinery. The output can be a
multipolygon in case of wrapping, which might or might not be what you want, act accordinglyFactoryException
TransformException
public static File getFile(String strValue, File rootFolder) throws IOException
IOException
public static Geometry decimate(Geometry geometry)
public static ROI roiIntersect(ROI roi, ROIGeometry roiGeometry, RenderingHints hints)
Copyright © 1996–2023 Geotools. All rights reserved.