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;
}
Aggregations