Search in sources :

Example 1 with CustomCRSSpatialDimension

use of org.locationtech.geowave.core.geotime.store.dimension.CustomCRSSpatialDimension in project geowave by locationtech.

the class RasterDataAdapter method getCoverageFromRasterTile.

public GridCoverage getCoverageFromRasterTile(final RasterTile rasterTile, final byte[] partitionKey, final byte[] sortKey, final Index index) {
    final MultiDimensionalNumericData indexRange = index.getIndexStrategy().getRangeForId(partitionKey, sortKey);
    final NumericDimensionDefinition[] orderedDimensions = index.getIndexStrategy().getOrderedDimensionDefinitions();
    final Double[] minsPerDimension = indexRange.getMinValuesPerDimension();
    final Double[] maxesPerDimension = indexRange.getMaxValuesPerDimension();
    Double minX = null;
    Double maxX = null;
    Double minY = null;
    Double maxY = null;
    boolean wgs84 = true;
    for (int d = 0; d < orderedDimensions.length; d++) {
        if (orderedDimensions[d] instanceof LongitudeDefinition) {
            minX = minsPerDimension[d];
            maxX = maxesPerDimension[d];
        } else if (orderedDimensions[d] instanceof LatitudeDefinition) {
            minY = minsPerDimension[d];
            maxY = maxesPerDimension[d];
        } else if (orderedDimensions[d] instanceof CustomCRSSpatialDimension) {
            wgs84 = false;
        }
    }
    if (wgs84 && ((minX == null) || (minY == null) || (maxX == null) || (maxY == null))) {
        return null;
    }
    final CoordinateReferenceSystem indexCrs = GeometryUtils.getIndexCrs(index);
    final ReferencedEnvelope mapExtent = new ReferencedEnvelope(minsPerDimension[0], maxesPerDimension[0], minsPerDimension[1], maxesPerDimension[1], indexCrs);
    try {
        return prepareCoverage(rasterTile, tileSize, mapExtent);
    } catch (final IOException e) {
        LOGGER.warn("Unable to build grid coverage from adapter encoded data", e);
    }
    return null;
}
Also used : LatitudeDefinition(org.locationtech.geowave.core.geotime.index.dimension.LatitudeDefinition) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) NumericDimensionDefinition(org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition) IOException(java.io.IOException) Point(java.awt.Point) CustomCRSSpatialDimension(org.locationtech.geowave.core.geotime.store.dimension.CustomCRSSpatialDimension) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) LongitudeDefinition(org.locationtech.geowave.core.geotime.index.dimension.LongitudeDefinition)

Aggregations

Point (java.awt.Point)1 IOException (java.io.IOException)1 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)1 LatitudeDefinition (org.locationtech.geowave.core.geotime.index.dimension.LatitudeDefinition)1 LongitudeDefinition (org.locationtech.geowave.core.geotime.index.dimension.LongitudeDefinition)1 CustomCRSSpatialDimension (org.locationtech.geowave.core.geotime.store.dimension.CustomCRSSpatialDimension)1 NumericDimensionDefinition (org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition)1 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1