@Override protected Object getValueInternal(ProgressListener listener) throws Exception { WebFeatureService wfs = (WebFeatureService) context.getBean("wfsServiceTarget"); GetFeatureType gft = null; InputReferenceType ref = input.getReference(); if (ref.getMethod() == MethodType.POST_LITERAL) { gft = (GetFeatureType) ref.getBody(); } else { GetFeatureKvpRequestReader reader = (GetFeatureKvpRequestReader) context.getBean("getFeatureKvpReader"); gft = (GetFeatureType) kvpParse(ref.getHref(), reader); } FeatureCollectionResponse featureCollectionType = wfs.getFeature(gft); // this will also deal with axis order issues return ((ComplexPPIO) ppio).decode(featureCollectionType.getAdaptee()); }
/** * Process the request as an internal one, without going through GML encoding/decoding * * @param ppio * @param ref * @param method * @return * @throws Exception */ Object handleAsInternalWFS(ProcessParameterIO ppio, InputReferenceType ref) throws Exception { WebFeatureService wfs = (WebFeatureService) context.getBean("wfsServiceTarget"); GetFeatureType gft = null; if (ref.getMethod() == MethodType.POST_LITERAL) { gft = (GetFeatureType) ref.getBody(); } else { GetFeatureKvpRequestReader reader = (GetFeatureKvpRequestReader) context .getBean("getFeatureKvpReader"); gft = (GetFeatureType) kvpParse(ref.getHref(), reader); } FeatureCollectionResponse featureCollectionType = wfs.getFeature(gft); // this will also deal with axis order issues return ((ComplexPPIO) ppio).decode(featureCollectionType.getAdaptee()); }
@Override protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { hits.setNumberOfFeatures(BigInteger.valueOf(0)); Encoder e = new Encoder(new WFSConfiguration()); e.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); e.setSchemaLocation( WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/2.0/wfs.xsd")); e.encode(hits.getAdaptee(), WFS.FeatureCollection, output); } }
protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/1.1.0/wfs.xsd")); encoder.encode( hits.getAdaptee(), org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output); } }
encoder.encode(results.getAdaptee(), org.geotools.wfs.v1_0.WFS.FeatureCollection, output);
@Override protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { hits.setNumberOfFeatures(BigInteger.ZERO); // instantiate the XML encoder Encoder encoder = new Encoder(new WFSConfiguration()); encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); encoder.setSchemaLocation( WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/2.0/wfs.xsd")); Document document; try { // encode the HITS result using FeatureCollection as the root XML element document = encoder.encodeAsDOM(hits.getAdaptee(), WFS.FeatureCollection); } catch (Exception exception) { throw new RuntimeException("Error encoding INDEX result.", exception); } // add the resultSetID attribute to the result addResultSetIdElement(document, resultSetId); // write the XML document to response output stream writeDocument(document, output); }
delegate.run(GetFeatureRequest.adapt(getFeature)).getAdaptee();