Search in sources :

Example 1 with FitToIndexGridCoverage

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);
                }
            }
        }
    }
}
Also used : RasterDataAdapter(org.locationtech.geowave.adapter.raster.adapter.RasterDataAdapter) FitToIndexGridCoverage(org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage) GridCoverage(org.opengis.coverage.grid.GridCoverage) FitToIndexGridCoverage(org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage) GeoWaveKey(org.locationtech.geowave.core.store.entities.GeoWaveKey) GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) IOException(java.io.IOException) GeoWaveInputKey(org.locationtech.geowave.mapreduce.input.GeoWaveInputKey)

Example 2 with FitToIndexGridCoverage

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;
}
Also used : FitToIndexGridCoverage(org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage) MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) AdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.AdapterPersistenceEncoding) IndexedAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding) FitToIndexPersistenceEncoding(org.locationtech.geowave.core.store.adapter.FitToIndexPersistenceEncoding) SingleFieldPersistentDataset(org.locationtech.geowave.core.store.data.SingleFieldPersistentDataset)

Aggregations

FitToIndexGridCoverage (org.locationtech.geowave.adapter.raster.FitToIndexGridCoverage)2 IOException (java.io.IOException)1 RasterDataAdapter (org.locationtech.geowave.adapter.raster.adapter.RasterDataAdapter)1 AdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.AdapterPersistenceEncoding)1 FitToIndexPersistenceEncoding (org.locationtech.geowave.core.store.adapter.FitToIndexPersistenceEncoding)1 IndexedAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding)1 MultiFieldPersistentDataset (org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset)1 SingleFieldPersistentDataset (org.locationtech.geowave.core.store.data.SingleFieldPersistentDataset)1 GeoWaveKey (org.locationtech.geowave.core.store.entities.GeoWaveKey)1 GeoWaveKeyImpl (org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl)1 GeoWaveInputKey (org.locationtech.geowave.mapreduce.input.GeoWaveInputKey)1 GridCoverage (org.opengis.coverage.grid.GridCoverage)1