use of org.apache.sis.storage.UnsupportedQueryException in project geotoolkit by Geomatys.
the class DefaultFolderFeatureStore method getFeatureWriter.
/**
* {@inheritDoc}
*/
@Override
public FeatureWriter getFeatureWriter(Query query) throws DataStoreException {
if (!(query instanceof org.geotoolkit.storage.feature.query.Query))
throw new UnsupportedQueryException();
final org.geotoolkit.storage.feature.query.Query gquery = (org.geotoolkit.storage.feature.query.Query) query;
final String typeName = gquery.getTypeName();
typeCheck(typeName);
final FeatureStore store = stores.get(this, typeName);
return store.getFeatureWriter(query);
}
use of org.apache.sis.storage.UnsupportedQueryException in project geotoolkit by Geomatys.
the class DefaultFolderFeatureStore method getFeatureReader.
/**
* {@inheritDoc}
*/
@Override
public FeatureReader getFeatureReader(final Query query) throws DataStoreException {
if (!(query instanceof org.geotoolkit.storage.feature.query.Query))
throw new UnsupportedQueryException();
final org.geotoolkit.storage.feature.query.Query gquery = (org.geotoolkit.storage.feature.query.Query) query;
final String name = gquery.getTypeName();
typeCheck(name);
final FeatureStore store = stores.get(this, name);
return store.getFeatureReader(query);
}
use of org.apache.sis.storage.UnsupportedQueryException in project geotoolkit by Geomatys.
the class ShapefileFeatureStore method getEnvelope.
/**
* Gets the bounding box of the file represented by this data store as a
* whole (that is, off all of the features in the shapefile)
*
* @param query A query to specify which data to use for envelope computing.
* @return The bounding box of the datasource or null if unknown and too
* expensive for the method to calculate.
* @throws DataStoreException If reading of source features fails.
*/
@Override
public Envelope getEnvelope(final Query query) throws DataStoreException, FeatureStoreRuntimeException {
if (!(query instanceof org.geotoolkit.storage.feature.query.Query))
throw new UnsupportedQueryException();
final org.geotoolkit.storage.feature.query.Query gquery = (org.geotoolkit.storage.feature.query.Query) query;
typeCheck(gquery.getTypeName());
if (QueryUtilities.queryAll(gquery)) {
return getHeaderEnvelope();
} else {
return super.getEnvelope(gquery);
}
}
use of org.apache.sis.storage.UnsupportedQueryException in project geotoolkit by Geomatys.
the class ShapefileFeatureStore method getFeatureWriter.
/**
* {@inheritDoc }
*/
@Override
public FeatureWriter getFeatureWriter(Query query) throws DataStoreException {
if (!(query instanceof org.geotoolkit.storage.feature.query.Query))
throw new UnsupportedQueryException();
final org.geotoolkit.storage.feature.query.Query gquery = (org.geotoolkit.storage.feature.query.Query) query;
FeatureType type = getFeatureType(gquery.getTypeName());
final ShapefileAttributeReader attReader = getAttributesReader(true, true, null);
final FeatureIDReader idReader = new DefaultFeatureIDReader(type.getName().tip().toString());
FeatureReader featureReader;
try {
featureReader = ShapefileFeatureReader.create(attReader, idReader, schema, gquery.getHints());
} catch (Exception e) {
featureReader = FeatureStreams.emptyReader(schema);
}
try {
return FeatureStreams.filter(new ShapefileFeatureWriter(this, type.getName().tip().toString(), shpFiles, attReader, featureReader, dbfCharset), gquery.getSelection());
} catch (Exception ex) {
try {
featureReader.close();
} catch (Exception bis) {
ex.addSuppressed(bis);
}
throw new DataStoreException(ex);
}
}
use of org.apache.sis.storage.UnsupportedQueryException in project geotoolkit by Geomatys.
the class IndexedShapefileFeatureStore method getFeatureWriter.
/**
* Create a FeatureWriter for the given type name.
*
* @param query The typeName of the FeatureType to write
* @return A new FeatureWriter.
* @throws DataStoreException If the typeName is not available or some other error occurs.
*/
@Override
public FeatureWriter getFeatureWriter(Query query) throws DataStoreException {
if (!(query instanceof org.geotoolkit.storage.feature.query.Query))
throw new UnsupportedQueryException();
final org.geotoolkit.storage.feature.query.Query gquery = (org.geotoolkit.storage.feature.query.Query) query;
// will raise an error if it does not exist
final FeatureType schema = getFeatureType(gquery.getTypeName());
// we read all properties
final IndexedShapefileAttributeReader attReader = getAttributesReader(getAttributes(schema, false), Filter.include(), true, null);
try {
final FeatureReader reader = createFeatureReader(attReader, schema, null);
FeatureWriter writer = new IndexedShapefileFeatureWriter(schema.getName().tip().toString(), shpFiles, attReader, reader, this, dbfCharset);
return FeatureStreams.filter(writer, gquery.getSelection());
} catch (IOException ex) {
throw new DataStoreException(ex);
}
}
Aggregations