Search in sources :

Example 1 with FeatureStore

use of org.geotools.data.FeatureStore in project incubator-rya by apache.

the class GeoMesaGeoIndexer method initInternal.

private void initInternal() throws IOException {
    validPredicates = ConfigUtils.getGeoPredicates(conf);
    final DataStore dataStore = createDataStore(conf);
    try {
        featureType = getStatementFeatureType(dataStore);
    } catch (final IOException | SchemaException e) {
        throw new IOException(e);
    }
    featureSource = dataStore.getFeatureSource(featureType.getName());
    if (!(featureSource instanceof FeatureStore)) {
        throw new IllegalStateException("Could not retrieve feature store");
    }
    featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
}
Also used : SchemaException(org.geotools.feature.SchemaException) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) DataStore(org.geotools.data.DataStore) AccumuloDataStore(org.locationtech.geomesa.accumulo.data.AccumuloDataStore) IOException(java.io.IOException) FeatureStore(org.geotools.data.FeatureStore) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 2 with FeatureStore

use of org.geotools.data.FeatureStore in project polymap4-core by Polymap4.

the class DataSourceProcessor method addFeaturesRequest.

@Override
public void addFeaturesRequest(AddFeaturesRequest request, ProcessorContext context) throws Exception {
    Collection<Feature> features = request.getFeatures();
    log.debug("addFeatures(): Features: " + features.size());
    FeatureCollection fc = new AdaptorFeatureCollection("features", (SimpleFeatureType) fs.getSchema()) {

        @Override
        protected void closeIterator(Iterator it) {
        }

        @Override
        protected Iterator openIterator() {
            return features.iterator();
        }

        @Override
        public int size() {
            return features.size();
        }
    };
    List<FeatureId> result = ((FeatureStore) fs).addFeatures(fc);
    context.sendResponse(new ModifyFeaturesResponse(new FidSet(result)));
    context.sendResponse(ProcessorResponse.EOP);
}
Also used : FeatureId(org.opengis.filter.identity.FeatureId) FeatureCollection(org.geotools.feature.FeatureCollection) AdaptorFeatureCollection(org.geotools.feature.collection.AdaptorFeatureCollection) AdaptorFeatureCollection(org.geotools.feature.collection.AdaptorFeatureCollection) FeatureIterator(org.geotools.feature.FeatureIterator) Iterator(java.util.Iterator) Feature(org.opengis.feature.Feature) FeatureStore(org.geotools.data.FeatureStore)

Example 3 with FeatureStore

use of org.geotools.data.FeatureStore in project incubator-rya by apache.

the class GeoWaveGeoIndexer method initInternal.

private void initInternal() throws IOException {
    validPredicates = ConfigUtils.getGeoPredicates(conf);
    try {
        geoToolsDataStore = createDataStore(conf);
        geoWaveDataStore = ((GeoWaveGTDataStore) geoToolsDataStore).getDataStore();
    } catch (final GeoWavePluginException e) {
        logger.error("Failed to create GeoWave data store", e);
    }
    try {
        featureType = getStatementFeatureType(geoToolsDataStore);
    } catch (final IOException | SchemaException e) {
        throw new IOException(e);
    }
    featureDataAdapter = new FeatureDataAdapter(featureType);
    featureSource = geoToolsDataStore.getFeatureSource(featureType.getName());
    if (!(featureSource instanceof FeatureStore)) {
        throw new IllegalStateException("Could not retrieve feature store");
    }
    featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
}
Also used : SchemaException(org.geotools.feature.SchemaException) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) IOException(java.io.IOException) FeatureDataAdapter(mil.nga.giat.geowave.adapter.vector.FeatureDataAdapter) FeatureStore(org.geotools.data.FeatureStore) SimpleFeature(org.opengis.feature.simple.SimpleFeature) GeoWavePluginException(mil.nga.giat.geowave.adapter.vector.plugin.GeoWavePluginException)

Example 4 with FeatureStore

use of org.geotools.data.FeatureStore in project polymap4-core by Polymap4.

the class FullDataStoreSyncStrategy method checkUpdateSchema.

protected void checkUpdateSchema() throws IOException {
    FeatureStore cacheFs = (FeatureStore) cacheDs.getFeatureSource(resName);
    FeatureType cacheSchema = cacheFs.getSchema();
    FeatureType schema = fs.getSchema();
    // simple check as equals() does not work for us here
    boolean needsUpdate = false;
    if (!schema.getName().equals(cacheSchema.getName())) {
        needsUpdate = true;
    }
    if (schema.getDescriptors().equals(cacheSchema.getDescriptors())) {
        needsUpdate = true;
    }
    if (needsUpdate) {
        // XXX
        log.warn("Not implemented: schema update");
    }
}
Also used : FeatureType(org.opengis.feature.type.FeatureType) FeatureStore(org.geotools.data.FeatureStore)

Aggregations

FeatureStore (org.geotools.data.FeatureStore)4 IOException (java.io.IOException)2 SchemaException (org.geotools.feature.SchemaException)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)2 Iterator (java.util.Iterator)1 FeatureDataAdapter (mil.nga.giat.geowave.adapter.vector.FeatureDataAdapter)1 GeoWavePluginException (mil.nga.giat.geowave.adapter.vector.plugin.GeoWavePluginException)1 DataStore (org.geotools.data.DataStore)1 FeatureCollection (org.geotools.feature.FeatureCollection)1 FeatureIterator (org.geotools.feature.FeatureIterator)1 AdaptorFeatureCollection (org.geotools.feature.collection.AdaptorFeatureCollection)1 AccumuloDataStore (org.locationtech.geomesa.accumulo.data.AccumuloDataStore)1 Feature (org.opengis.feature.Feature)1 FeatureType (org.opengis.feature.type.FeatureType)1 FeatureId (org.opengis.filter.identity.FeatureId)1