@Override public Object getProperty(Object object, QName name) throws Exception { if (GML.featureMember.equals(name)) { FeatureCollectionType fc = (FeatureCollectionType) object; if (fc.getFeature().size() == 1 && fc.getFeature().get(0) instanceof SimpleFeatureCollection && encoder.getConfiguration() .hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML2FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) fc.getFeature().get(0), encoder); } } return super.getProperty(object, name); }
@Override public Object getProperty(Object object, QName name) throws Exception { if (GML.featureMember.equals(name)) { FeatureCollectionType fc = (FeatureCollectionType) object; if (fc.getFeature().size() == 1 && fc.getFeature().get(0) instanceof SimpleFeatureCollection && encoder.getConfiguration() .hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML3FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) fc.getFeature().get(0), encoder); } } return super.getProperty(object, name); } }
@Override public Object getProperty(Object object, QName name) throws Exception { FeatureCollectionType fc = (FeatureCollectionType) object; if (!fc.getFeature().isEmpty()) { Object val = WFSParsingUtils.FeatureCollectionType_getProperty(fc, name); if (val != null) { return val; } } return super.getProperty(object, name); }
for (Object entry : collectionType.getFeature()) { SimpleFeatureCollection collection = toFeatureCollection(entry); if (entry != null) {
featureCollectionType.getFeature().add(collection); featureCollectionType.getFeature().add(collection);
@SuppressWarnings({"unchecked", "rawtypes"}) private FeatureCollectionType buildResults(List<FeatureCollection> results) { FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType(); result.setTimeStamp(Calendar.getInstance()); result.getFeature().addAll(results); return result; }
@Override public Object getProperty(Object object, QName name) throws Exception { FeatureCollectionType fc = (FeatureCollectionType) object; if ( !fc.getFeature().isEmpty() ) { Object val = WFSParsingUtils.FeatureCollectionType_getProperty(fc, name); if (val != null) { return val; } } return super.getProperty(object, name); }
private Object handleFeatureCollection(FeatureCollectionType featureCollection) { FeatureCollection result = null; if (featureCollection.getFeature().size() > 1) { // wrap in a single result = new CompositeFeatureCollection(featureCollection.getFeature()); } else { // just return the single result = (FeatureCollection) featureCollection.getFeature().iterator().next(); } if (isSimpleFeatureCollection(result) && encoder.getConfiguration().hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML3FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) result, encoder); } else { return result; } }
/** * Allows subclasses to alter the result generation * @param count * @param results * @param lockId * @return */ protected FeatureCollectionType buildResults(int count, List results, String lockId) { VersionedFeatureCollectionType result = WfsvFactory.eINSTANCE.createVersionedFeatureCollectionType(); result.setNumberOfFeatures(BigInteger.valueOf(count)); result.setTimeStamp(Calendar.getInstance()); result.setLockId(lockId); result.getFeature().addAll(results); result.setVersion("xxx"); return result; }
@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); }
public void testEmptyKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(Filter.EXCLUDE); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(0, dom.getElementsByTagName("Placemark").getLength()); }
public void testAllTypesKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("AllTypes").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // read back Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(6, dom.getElementsByTagName("Placemark").getLength()); }
@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 ); }
public void testSimpleKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(2, dom.getElementsByTagName("Placemark").getLength()); }
@Test public void testEmptyKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(Filter.EXCLUDE); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(0, dom.getElementsByTagName("Placemark").getLength()); }
@Test public void testAllTypesKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("AllTypes").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // read back Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(6, dom.getElementsByTagName("Placemark").getLength()); }
public void testSimpleCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the two lines assertEquals(3, lines.length); assertTrue(csv.contains("123 Main Street")); }
public void testGeometrylessCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Geometryless").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the feature lines assertEquals(4, lines.length); // let's see if one of the expected lines is there assertTrue(csv.contains("Alessia")); }
@Test public void testGeometrylessCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Geometryless").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the feature lines assertEquals(4, lines.length); // let's see if one of the expected lines is there assertTrue(csv.contains("Alessia")); }
@Test public void testSimpleCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the two lines assertEquals(3, lines.length); assertTrue(csv.contains("123 Main Street")); }