use of org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage in project geowave by locationtech.
the class RasterTileResizeMapper method mapNativeValue.
@Override
protected void mapNativeValue(final GeoWaveInputKey key, final GridCoverage value, final MapContext<GeoWaveInputKey, GridCoverage, GeoWaveInputKey, Object> context) throws IOException, InterruptedException {
if (helper.isOriginalCoverage(key.getInternalAdapterId())) {
final InternalDataAdapter<?> adapter = super.serializationTool.getInternalAdapter(key.getInternalAdapterId());
if ((adapter != null) && (adapter.getAdapter() != null) && (adapter.getAdapter() instanceof RasterDataAdapter)) {
final Iterator<GridCoverage> coverages = helper.getCoveragesForIndex(value);
if (coverages == null) {
LOGGER.error("Couldn't get coverages instance, getCoveragesForIndex returned null");
throw new IOException("Couldn't get coverages instance, getCoveragesForIndex returned null");
}
while (coverages.hasNext()) {
final GridCoverage c = coverages.next();
// converted above
if (c instanceof FitToIndexGridCoverage) {
final byte[] partitionKey = ((FitToIndexGridCoverage) c).getPartitionKey();
final byte[] sortKey = ((FitToIndexGridCoverage) c).getSortKey();
final GeoWaveKey geowaveKey = new GeoWaveKeyImpl(helper.getNewDataId(c), key.getInternalAdapterId(), partitionKey, sortKey, 0);
final GeoWaveInputKey inputKey = new GeoWaveInputKey(helper.getNewAdapterId(), geowaveKey, helper.getIndexName());
context.write(inputKey, c);
}
}
}
}
}
use of org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage in project geowave by locationtech.
the class InternalRasterDataAdapter method encode.
@Override
public AdapterPersistenceEncoding encode(final GridCoverage entry, final AdapterToIndexMapping indexMapping, final Index index) {
final PersistentDataset<Object> adapterExtendedData = new SingleFieldPersistentDataset<>();
adapterExtendedData.addValue(RasterDataAdapter.DATA_FIELD_ID, ((RasterDataAdapter) adapter).getRasterTileFromCoverage(entry));
final AdapterPersistenceEncoding encoding;
if (entry instanceof FitToIndexGridCoverage) {
encoding = new FitToIndexPersistenceEncoding(getAdapterId(), new byte[0], new MultiFieldPersistentDataset<>(), adapterExtendedData, ((FitToIndexGridCoverage) entry).getPartitionKey(), ((FitToIndexGridCoverage) entry).getSortKey());
} else {
// this shouldn't happen
LOGGER.warn("Grid coverage is not fit to the index");
encoding = new AdapterPersistenceEncoding(getAdapterId(), new byte[0], new MultiFieldPersistentDataset<>(), adapterExtendedData);
}
return encoding;
}
Aggregations