Search in sources :

Example 11 with Query

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

the class FeatureRenameProcessor method featuresRequest.

@Produces(GetFeaturesRequest.class)
public void featuresRequest(GetFeaturesRequest request, ProcessorContext context) throws Exception {
    Query transformed = transformQuery(request.getQuery(), context);
    context.sendRequest(new GetFeaturesRequest(transformed));
}
Also used : GetFeaturesRequest(org.polymap.core.data.feature.GetFeaturesRequest) Query(org.geotools.data.Query) Produces(org.polymap.core.data.pipeline.Produces)

Example 12 with Query

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

the class FeatureRenameProcessor method featuresSizeRequest.

@Produces(GetFeaturesSizeRequest.class)
public void featuresSizeRequest(GetFeaturesSizeRequest request, ProcessorContext context) throws Exception {
    Query transformed = transformQuery(request.getQuery(), context);
    context.sendRequest(new GetFeaturesSizeRequest(transformed));
}
Also used : GetFeaturesSizeRequest(org.polymap.core.data.feature.GetFeaturesSizeRequest) Query(org.geotools.data.Query) Produces(org.polymap.core.data.pipeline.Produces)

Example 13 with Query

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

the class FeatureRenameProcessor method boundsRequest.

@Produces(GetBoundsRequest.class)
public void boundsRequest(GetBoundsRequest request, ProcessorContext context) throws Exception {
    Query transformed = transformQuery(request.query.get(), context);
    context.sendRequest(new GetBoundsRequest(transformed));
}
Also used : Query(org.geotools.data.Query) GetBoundsRequest(org.polymap.core.data.feature.GetBoundsRequest) Produces(org.polymap.core.data.pipeline.Produces)

Example 14 with Query

use of org.geotools.data.Query in project OpenTripPlanner by opentripplanner.

the class WFSNotePollingGraphUpdater method setup.

/**
 * Setup the WFS data source and add the DynamicStreetNotesSource to the graph
 */
@Override
public void setup() throws IOException, FactoryException {
    LOG.info("Setup WFS polling updater");
    HashMap<String, Object> connectionParameters = new HashMap<>();
    connectionParameters.put(WFSDataStoreFactory.URL.key, url);
    WFSDataStore data = (new WFSDataStoreFactory()).createDataStore(connectionParameters);
    // Read only single feature type from the source
    query = new Query(featureType);
    // Get coordinates in WGS-84
    query.setCoordinateSystem(CRS.decode("EPSG:4326", true));
    featureSource = data.getFeatureSource(featureType);
    graph.streetNotesService.addNotesSource(notesSource);
}
Also used : Query(org.geotools.data.Query) HashMap(java.util.HashMap) WFSDataStore(org.geotools.data.wfs.WFSDataStore) WFSDataStoreFactory(org.geotools.data.wfs.WFSDataStoreFactory)

Example 15 with Query

use of org.geotools.data.Query in project GeoGig by boundlessgeo.

the class GeoGigDataStoreTest method testFeatureWriterAppend.

@Test
public void testFeatureWriterAppend() throws Exception {
    dataStore.createSchema(linesType);
    Transaction tx = new DefaultTransaction();
    FeatureWriter<SimpleFeatureType, SimpleFeature> fw = dataStore.getFeatureWriterAppend(linesTypeName.getLocalPart(), tx);
    LineString line = new GeometryBuilder().lineString(0, 0, 1, 1);
    SimpleFeature f = (SimpleFeature) fw.next();
    f.setAttribute("sp", "foo");
    f.setAttribute("ip", 10);
    f.setAttribute("pp", line);
    fw.write();
    fw.close();
    tx.commit();
    FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(linesTypeName);
    assertEquals(1, source.getCount(null));
    FeatureReader<SimpleFeatureType, SimpleFeature> r = dataStore.getFeatureReader(new Query(linesTypeName.getLocalPart()), Transaction.AUTO_COMMIT);
    assertTrue(r.hasNext());
    f = r.next();
    assertEquals("foo", f.getAttribute("sp"));
    assertEquals(10, f.getAttribute("ip"));
    assertTrue(line.equals((Geometry) f.getAttribute("pp")));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Transaction(org.geotools.data.Transaction) DefaultTransaction(org.geotools.data.DefaultTransaction) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Query(org.geotools.data.Query) LineString(com.vividsolutions.jts.geom.LineString) GeometryBuilder(org.geotools.geometry.jts.GeometryBuilder) DefaultTransaction(org.geotools.data.DefaultTransaction) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Aggregations

Query (org.geotools.data.Query)34 SimpleFeature (org.opengis.feature.simple.SimpleFeature)18 Test (org.junit.Test)16 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)13 HashMap (java.util.HashMap)6 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)6 SimpleFeatureIterator (org.geotools.data.simple.SimpleFeatureIterator)6 Filter (org.opengis.filter.Filter)6 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)6 Geometry (com.vividsolutions.jts.geom.Geometry)5 DefaultTransaction (org.geotools.data.DefaultTransaction)5 Transaction (org.geotools.data.Transaction)5 Polygon (com.vividsolutions.jts.geom.Polygon)4 IOException (java.io.IOException)4 Map (java.util.Map)4 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)4 ArrayList (java.util.ArrayList)3 FileDataStoreFactorySpi (org.geotools.data.FileDataStoreFactorySpi)3 ShapefileDataStore (org.geotools.data.shapefile.ShapefileDataStore)3 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)3