Search in sources :

Example 1 with GetFeaturesResponse

use of org.polymap.core.data.feature.GetFeaturesResponse in project polymap4-core by Polymap4.

the class PipelineFeatureSource method fetchFeatures.

/**
 * Called by {@link SyncPipelineFeatureCollection} to fetch feature chunks.
 */
@SuppressWarnings("hiding")
protected void fetchFeatures(Query query, final FeatureResponseHandler handler) throws Exception {
    try {
        log.debug("fetchFeatures(): maxFeatures= " + query.getMaxFeatures());
        GetFeaturesRequest request = new GetFeaturesRequest(query);
        newExecutor().execute(pipeline, request, new ResponseHandler() {

            public void handle(ProcessorResponse r) throws Exception {
                GetFeaturesResponse response = (GetFeaturesResponse) r;
                handler.handle(response.getFeatures());
            }
        });
    } finally {
        handler.endOfResponse();
    }
}
Also used : GetFeaturesResponse(org.polymap.core.data.feature.GetFeaturesResponse) GetFeaturesRequest(org.polymap.core.data.feature.GetFeaturesRequest) ProcessorResponse(org.polymap.core.data.pipeline.ProcessorResponse) ResponseHandler(org.polymap.core.data.pipeline.ResponseHandler) IOException(java.io.IOException)

Example 2 with GetFeaturesResponse

use of org.polymap.core.data.feature.GetFeaturesResponse in project polymap4-core by Polymap4.

the class FeatureRenameProcessor method featuresResponse.

@Produces(GetFeaturesResponse.class)
public void featuresResponse(GetFeaturesResponse response, ProcessorContext context) throws Exception {
    assert schema != null : "Target schema is not yet initialized. Call getSchema() first.";
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder((SimpleFeatureType) schema);
    // log.debug( "       received features: " + chunk.count() );
    List<Feature> result = new ArrayList(response.count());
    for (Feature feature : response) {
        for (PropertyDescriptor prop : schema.getDescriptors()) {
            Property featureProp = feature.getProperty(prop.getName());
            // the feature may not contain the property if it was not requested
            if (featureProp != null) {
                builder.set(prop.getName(), featureProp.getValue());
            }
        }
        result.add(builder.buildFeature(feature.getIdentifier().getID()));
    }
    // log.debug( "       sending features: " + result.size() );
    context.sendResponse(new GetFeaturesResponse(result));
}
Also used : GetFeaturesResponse(org.polymap.core.data.feature.GetFeaturesResponse) PropertyDescriptor(org.opengis.feature.type.PropertyDescriptor) ArrayList(java.util.ArrayList) Feature(org.opengis.feature.Feature) Property(org.opengis.feature.Property) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder) Produces(org.polymap.core.data.pipeline.Produces)

Aggregations

GetFeaturesResponse (org.polymap.core.data.feature.GetFeaturesResponse)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)1 Feature (org.opengis.feature.Feature)1 Property (org.opengis.feature.Property)1 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)1 GetFeaturesRequest (org.polymap.core.data.feature.GetFeaturesRequest)1 ProcessorResponse (org.polymap.core.data.pipeline.ProcessorResponse)1 Produces (org.polymap.core.data.pipeline.Produces)1 ResponseHandler (org.polymap.core.data.pipeline.ResponseHandler)1