@Override public Object decode(InputStream input) throws Exception { Parser p = getParser(configuration); byte[] streamBytes = null; if (LOGGER.isLoggable(Level.FINEST)) { // allow WFS result to be logged for debugging purposes // WFS result can be large, so use only for debugging ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteStreams.copy(input, outputStream); streamBytes = outputStream.toByteArray(); input = new ByteArrayInputStream(streamBytes); } Object result = p.parse(input); if (result instanceof FeatureCollectionType) { FeatureCollectionType fct = (FeatureCollectionType) result; return decode(fct); } else { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log( Level.FINEST, "Decoding the following WFS response did not result in an object of type FeatureCollectionType: \n" + new String(streamBytes)); } throw new IllegalArgumentException( "Decoded WFS result is not a feature collection, got a: " + result); } }
Parser p = getParser(configuration); input = p.parse(new StringReader((String) input)); CoordinateReferenceSystem crs = getCollectionCRS(fc); if (crs != null) { return eliminateFeatureBounds(fc);
CoordinateReferenceSystem crs = getCollectionCRS(fc); if(crs != null) { return eliminateFeatureBounds(fc);
@Override public void encode(Object object, ContentHandler handler) throws Exception { FeatureCollection features = (FeatureCollection) object; SimpleFeatureType featureType = (SimpleFeatureType) features.getSchema(); FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType(); fc.getFeature().add(features); Encoder e = new Encoder(configuration); e.getNamespaces().declarePrefix("feature", featureType.getName().getNamespaceURI()); e.encode(fc, getElement(), handler); }
@Override public Object decode(InputStream input) throws Exception { Parser p = new Parser(configuration); FeatureCollectionType fct = (FeatureCollectionType) p.parse(input); return decode(fct); }
@Override public void encode(Object object, ContentHandler handler) throws Exception { FeatureCollection features = (FeatureCollection) object; SimpleFeatureType featureType = (SimpleFeatureType) features.getSchema(); FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType(); fc.getFeature().add( features ); Encoder e = new Encoder(configuration); e.getNamespaces().declarePrefix( "feature", featureType.getName().getNamespaceURI() ); e.encode( fc, getElement(), handler ); }