Search in sources :

Example 1 with DefiningGridCoverageResource

use of org.geotoolkit.storage.coverage.DefiningGridCoverageResource in project geotoolkit by Geomatys.

the class PyramidalModelStoreNDTest method getCoverageStore.

private DataStore getCoverageStore() throws Exception {
    if (store != null) {
        return store;
    }
    // create a small pyramid
    store = createStore();
    final WritableAggregate agg = (WritableAggregate) store;
    final CoordinateReferenceSystem horizontal = CommonCRS.WGS84.normalizedGeographic();
    final CoordinateReferenceSystem vertical = CommonCRS.Vertical.ELLIPSOIDAL.crs();
    crs = new GeodeticObjectBuilder().addName("3dcrs").createCompoundCRS(horizontal, vertical);
    final GenericName name = NamesExt.create("test");
    ref = (T) agg.add(new DefiningGridCoverageResource(name));
    // prepare expected colors
    int color = 0;
    for (int v = 0; v < CORNER_V.length; v++) {
        colors[v][0] = new int[2][2];
        colors[v][1] = new int[4][3];
        colors[v][0][0][0] = color++;
        colors[v][0][1][0] = color++;
        colors[v][0][0][1] = color++;
        colors[v][0][1][1] = color++;
        colors[v][1][0][0] = color++;
        colors[v][1][1][0] = color++;
        colors[v][1][2][0] = color++;
        colors[v][1][3][0] = color++;
        colors[v][1][0][1] = color++;
        colors[v][1][1][1] = color++;
        colors[v][1][2][1] = color++;
        colors[v][1][3][1] = color++;
        colors[v][1][0][2] = color++;
        colors[v][1][1][2] = color++;
        colors[v][1][2][2] = color++;
        colors[v][1][3][2] = color++;
    }
    final TileMatrixSet pyramid = (TileMatrixSet) ref.createTileMatrixSet(new DefiningTileMatrixSet(crs));
    for (int v = 0; v < CORNER_V.length; v++) {
        final TileMatrix mosaic_s0 = pyramid.createTileMatrix(new DefiningTileMatrix(null, createCorner(CORNER_LONG, CORNER_LAT, CORNER_V[v]), 1, new Dimension(10, 10), new Dimension(2, 2)));
        final TileMatrix mosaic_s1 = pyramid.createTileMatrix(new DefiningTileMatrix(null, createCorner(CORNER_LONG, CORNER_LAT, CORNER_V[v]), 0.5, new Dimension(10, 10), new Dimension(4, 3)));
        // insert tiles
        mosaic_s0.writeTiles(Stream.of(new DefaultImageTile(createImage(colors[v][0][0][0]), 0, 0), new DefaultImageTile(createImage(colors[v][0][1][0]), 1, 0), new DefaultImageTile(createImage(colors[v][0][0][1]), 0, 1), new DefaultImageTile(createImage(colors[v][0][1][1]), 1, 1)), null);
        mosaic_s1.writeTiles(Stream.of(new DefaultImageTile(createImage(colors[v][1][0][0]), 0, 0), new DefaultImageTile(createImage(colors[v][1][1][0]), 1, 0), new DefaultImageTile(createImage(colors[v][1][2][0]), 2, 0), new DefaultImageTile(createImage(colors[v][1][3][0]), 3, 0), new DefaultImageTile(createImage(colors[v][1][0][1]), 0, 1), new DefaultImageTile(createImage(colors[v][1][1][1]), 1, 1), new DefaultImageTile(createImage(colors[v][1][2][1]), 2, 1), new DefaultImageTile(createImage(colors[v][1][3][1]), 3, 1), new DefaultImageTile(createImage(colors[v][1][0][2]), 0, 2), new DefaultImageTile(createImage(colors[v][1][1][2]), 1, 2), new DefaultImageTile(createImage(colors[v][1][2][2]), 2, 2), new DefaultImageTile(createImage(colors[v][1][3][2]), 3, 2)), null);
    }
    crs = pyramid.getCoordinateReferenceSystem();
    return store;
}
Also used : TileMatrixSet(org.geotoolkit.storage.multires.TileMatrixSet) DefiningTileMatrixSet(org.geotoolkit.storage.multires.DefiningTileMatrixSet) DefiningTileMatrixSet(org.geotoolkit.storage.multires.DefiningTileMatrixSet) DefiningTileMatrix(org.geotoolkit.storage.multires.DefiningTileMatrix) GenericName(org.opengis.util.GenericName) WritableAggregate(org.apache.sis.storage.WritableAggregate) DefiningGridCoverageResource(org.geotoolkit.storage.coverage.DefiningGridCoverageResource) DefaultImageTile(org.geotoolkit.storage.coverage.DefaultImageTile) GeodeticObjectBuilder(org.apache.sis.internal.referencing.GeodeticObjectBuilder) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Dimension(java.awt.Dimension) TileMatrix(org.geotoolkit.storage.multires.TileMatrix) DefiningTileMatrix(org.geotoolkit.storage.multires.DefiningTileMatrix)

Example 2 with DefiningGridCoverageResource

use of org.geotoolkit.storage.coverage.DefiningGridCoverageResource in project geotoolkit by Geomatys.

the class FileCoverageStore method add.

@Override
public GridCoverageResource add(org.apache.sis.storage.Resource resource) throws DataStoreException {
    if (!(resource instanceof DefiningGridCoverageResource)) {
        throw new DataStoreException("Unsupported resource " + resource);
    }
    final DefiningGridCoverageResource cr = (DefiningGridCoverageResource) resource;
    final GenericName name = cr.getName();
    final Collection<GenericName> names = DataStores.getNames(this, true, DataSet.class);
    if (names.contains(name)) {
        throw new IllegalNameException("Coverage " + name + " already exist in this datastore.");
    }
    final String fileName = name.tip().toString();
    final URI filePath = rootPath.resolve(fileName + ".tiff");
    final FileCoverageResource fcr = new FileCoverageResource(this, name, Paths.get(filePath));
    resources.add(fcr);
    return fcr;
}
Also used : DataStoreException(org.apache.sis.storage.DataStoreException) GenericName(org.opengis.util.GenericName) DefiningGridCoverageResource(org.geotoolkit.storage.coverage.DefiningGridCoverageResource) IllegalNameException(org.apache.sis.storage.IllegalNameException) URI(java.net.URI)

Example 3 with DefiningGridCoverageResource

use of org.geotoolkit.storage.coverage.DefiningGridCoverageResource in project geotoolkit by Geomatys.

the class XMLCoverageStore method add.

@Override
public GridCoverageResource add(org.apache.sis.storage.Resource resource) throws DataStoreException {
    if (!(resource instanceof DefiningGridCoverageResource)) {
        throw new DataStoreException("Unsupported resource " + resource);
    }
    final DefiningGridCoverageResource cr = (DefiningGridCoverageResource) resource;
    final GenericName name = cr.getName();
    return create(name, null, null);
}
Also used : DataStoreException(org.apache.sis.storage.DataStoreException) GenericName(org.opengis.util.GenericName) DefiningGridCoverageResource(org.geotoolkit.storage.coverage.DefiningGridCoverageResource)

Example 4 with DefiningGridCoverageResource

use of org.geotoolkit.storage.coverage.DefiningGridCoverageResource in project geotoolkit by Geomatys.

the class InMemoryAggregate method add.

@Override
public synchronized Resource add(Resource resource) throws DataStoreException {
    Resource newr;
    if (resource instanceof FeatureSet) {
        final FeatureSet fs = (FeatureSet) resource;
        final InMemoryFeatureSet newres = new InMemoryFeatureSet(fs.getType());
        try (Stream<Feature> stream = fs.features(false)) {
            newres.add(stream.iterator());
        }
        newr = newres;
    } else if (resource instanceof DefiningTiledGridCoverageResource) {
        final DefiningTiledGridCoverageResource cr = (DefiningTiledGridCoverageResource) resource;
        final GenericName name = cr.getIdentifier().orElse(null);
        newr = new InMemoryTiledGridCoverageResource(name);
    } else if (resource instanceof GridCoverageResource && resource instanceof TiledResource) {
        final GridCoverageResource cr = (GridCoverageResource) resource;
        final GenericName name = cr.getIdentifier().orElse(null);
        newr = new InMemoryTiledGridCoverageResource(name);
    } else if (resource instanceof GridCoverageResource) {
        final GridCoverageResource cr = (GridCoverageResource) resource;
        final GenericName name = cr.getIdentifier().orElse(null);
        final InMemoryGridCoverageResource newres = new InMemoryGridCoverageResource(name);
        newres.write(cr.read(null));
        newr = newres;
    } else if (resource instanceof DefiningGridCoverageResource) {
        final DefiningGridCoverageResource cr = (DefiningGridCoverageResource) resource;
        final GenericName name = cr.getIdentifier().orElse(null);
        newr = new InMemoryGridCoverageResource(name);
    } else if (resource instanceof Aggregate) {
        final Aggregate agg = (Aggregate) resource;
        final InMemoryAggregate newres = new InMemoryAggregate(agg.getIdentifier().orElse(null));
        for (Resource r : agg.components()) {
            newres.add(r);
        }
        newr = newres;
    } else {
        throw new DataStoreException("Unsupported resource type " + resource);
    }
    resources.add(newr);
    listeners.fire(new AggregationEvent(this, AggregationEvent.TYPE_ADD, newr), AggregationEvent.class);
    return newr;
}
Also used : DataStoreException(org.apache.sis.storage.DataStoreException) DefiningGridCoverageResource(org.geotoolkit.storage.coverage.DefiningGridCoverageResource) AggregationEvent(org.geotoolkit.storage.event.AggregationEvent) DefiningTiledGridCoverageResource(org.geotoolkit.storage.coverage.DefiningTiledGridCoverageResource) Resource(org.apache.sis.storage.Resource) AbstractResource(org.apache.sis.storage.AbstractResource) TiledResource(org.geotoolkit.storage.multires.TiledResource) GridCoverageResource(org.apache.sis.storage.GridCoverageResource) DefiningGridCoverageResource(org.geotoolkit.storage.coverage.DefiningGridCoverageResource) DefiningTiledGridCoverageResource(org.geotoolkit.storage.coverage.DefiningTiledGridCoverageResource) Feature(org.opengis.feature.Feature) GenericName(org.opengis.util.GenericName) TiledResource(org.geotoolkit.storage.multires.TiledResource) DefiningTiledGridCoverageResource(org.geotoolkit.storage.coverage.DefiningTiledGridCoverageResource) GridCoverageResource(org.apache.sis.storage.GridCoverageResource) DefiningGridCoverageResource(org.geotoolkit.storage.coverage.DefiningGridCoverageResource) FeatureSet(org.apache.sis.storage.FeatureSet) WritableAggregate(org.apache.sis.storage.WritableAggregate) Aggregate(org.apache.sis.storage.Aggregate)

Aggregations

DefiningGridCoverageResource (org.geotoolkit.storage.coverage.DefiningGridCoverageResource)4 GenericName (org.opengis.util.GenericName)4 DataStoreException (org.apache.sis.storage.DataStoreException)3 WritableAggregate (org.apache.sis.storage.WritableAggregate)2 Dimension (java.awt.Dimension)1 URI (java.net.URI)1 GeodeticObjectBuilder (org.apache.sis.internal.referencing.GeodeticObjectBuilder)1 AbstractResource (org.apache.sis.storage.AbstractResource)1 Aggregate (org.apache.sis.storage.Aggregate)1 FeatureSet (org.apache.sis.storage.FeatureSet)1 GridCoverageResource (org.apache.sis.storage.GridCoverageResource)1 IllegalNameException (org.apache.sis.storage.IllegalNameException)1 Resource (org.apache.sis.storage.Resource)1 DefaultImageTile (org.geotoolkit.storage.coverage.DefaultImageTile)1 DefiningTiledGridCoverageResource (org.geotoolkit.storage.coverage.DefiningTiledGridCoverageResource)1 AggregationEvent (org.geotoolkit.storage.event.AggregationEvent)1 DefiningTileMatrix (org.geotoolkit.storage.multires.DefiningTileMatrix)1 DefiningTileMatrixSet (org.geotoolkit.storage.multires.DefiningTileMatrixSet)1 TileMatrix (org.geotoolkit.storage.multires.TileMatrix)1 TileMatrixSet (org.geotoolkit.storage.multires.TileMatrixSet)1