Search in sources :

Example 1 with UnsupportedQueryException

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);
}
Also used : Query(org.apache.sis.storage.Query) UnsupportedQueryException(org.apache.sis.storage.UnsupportedQueryException) FeatureStore(org.geotoolkit.storage.feature.FeatureStore) AbstractFeatureStore(org.geotoolkit.storage.feature.AbstractFeatureStore)

Example 2 with UnsupportedQueryException

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);
}
Also used : Query(org.apache.sis.storage.Query) UnsupportedQueryException(org.apache.sis.storage.UnsupportedQueryException) FeatureStore(org.geotoolkit.storage.feature.FeatureStore) AbstractFeatureStore(org.geotoolkit.storage.feature.AbstractFeatureStore)

Example 3 with UnsupportedQueryException

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);
    }
}
Also used : Query(org.apache.sis.storage.Query) UnsupportedQueryException(org.apache.sis.storage.UnsupportedQueryException)

Example 4 with UnsupportedQueryException

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);
    }
}
Also used : FeatureType(org.opengis.feature.FeatureType) DataStoreException(org.apache.sis.storage.DataStoreException) Query(org.apache.sis.storage.Query) UnsupportedQueryException(org.apache.sis.storage.UnsupportedQueryException) DataStoreException(org.apache.sis.storage.DataStoreException) FeatureStoreRuntimeException(org.geotoolkit.storage.feature.FeatureStoreRuntimeException) UnsupportedQueryException(org.apache.sis.storage.UnsupportedQueryException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) PropertyNotFoundException(org.opengis.feature.PropertyNotFoundException) FeatureReader(org.geotoolkit.storage.feature.FeatureReader)

Example 5 with UnsupportedQueryException

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);
    }
}
Also used : FeatureType(org.opengis.feature.FeatureType) FeatureWriter(org.geotoolkit.storage.feature.FeatureWriter) DataStoreException(org.apache.sis.storage.DataStoreException) Query(org.apache.sis.storage.Query) UnsupportedQueryException(org.apache.sis.storage.UnsupportedQueryException) IOException(java.io.IOException) ShapefileFeatureReader(org.geotoolkit.data.shapefile.ShapefileFeatureReader) FeatureReader(org.geotoolkit.storage.feature.FeatureReader)

Aggregations

Query (org.apache.sis.storage.Query)15 UnsupportedQueryException (org.apache.sis.storage.UnsupportedQueryException)15 DataStoreException (org.apache.sis.storage.DataStoreException)7 FeatureReader (org.geotoolkit.storage.feature.FeatureReader)7 FeatureType (org.opengis.feature.FeatureType)7 Filter (org.opengis.filter.Filter)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)2 AbstractOperation (org.apache.sis.feature.AbstractOperation)2 Hints (org.geotoolkit.factory.Hints)2 AbstractFeatureStore (org.geotoolkit.storage.feature.AbstractFeatureStore)2 FeatureStore (org.geotoolkit.storage.feature.FeatureStore)2 PropertyType (org.opengis.feature.PropertyType)2 ResourceId (org.opengis.filter.ResourceId)2 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 AbstractMap (java.util.AbstractMap)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1