public SimpleFeature next() throws IOException, NoSuchElementException { if (hasNext()) { // existing content live = iterator.next(); try { current = SimpleFeatureBuilder.copy(live); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to edit " + live.getID() + " of " + typeName); } } else { // new content live = null; try { current = SimpleFeatureBuilder.template(featureType, null); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to add additional Features of " + typeName); } } return current; }
public void testCallingAddFeaturesWithCollectionTwiceAndExtentInitialCollection() throws IOException { MemoryDataStore mds = new MemoryDataStore(); mds.addFeatures(Arrays.asList(roadFeatures)); SimpleFeature road1 = SimpleFeatureBuilder.template(roadType, null); mds.addFeatures(Collections.singletonList(road1)); assertEquals(roadFeatures.length + 1, mds.entry("road").getMemory().size()); }
public void testCallingAddFeaturesWithArrayTwiceAndExtentInitialCollection() throws IOException { MemoryDataStore mds = new MemoryDataStore(); mds.addFeatures(roadFeatures); SimpleFeature road1 = SimpleFeatureBuilder.template(roadType, null); mds.addFeatures(new SimpleFeature[] {road1}); assertEquals(roadFeatures.length + 1, mds.entry("road").getMemory().size()); }
public void testCallingAddFeaturesWithReaderTwiceAndExtentInitialCollection() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = DataUtilities.reader(roadFeatures); MemoryDataStore mds = new MemoryDataStore(reader); assertEquals(roadFeatures.length, mds.entry(roadType.getTypeName()).getMemory().size()); FeatureReader<SimpleFeatureType, SimpleFeature> secondReader = DataUtilities.reader( new SimpleFeature[] {SimpleFeatureBuilder.template(roadType, null)}); mds.addFeatures(secondReader); assertEquals(roadFeatures.length + 1, mds.entry("road").getMemory().size()); }
public void testCallingAddFeaturesWithIteratorTwiceAndExtentInitialCollection() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = DataUtilities.reader(roadFeatures); MemoryDataStore mds = new MemoryDataStore(reader); assertEquals(roadFeatures.length, mds.entry(roadType.getTypeName()).getMemory().size()); SimpleFeatureIterator featureIterator = DataUtilities.collection( new SimpleFeature[] {SimpleFeatureBuilder.template(roadType, null)}) .features(); mds.addFeatures(featureIterator); assertEquals(roadFeatures.length + 1, mds.entry("road").getMemory().size()); } }
public void testReaderIsNotBrokenWhileWritingFeatureDirectly() throws IOException { // a write should not "destroy" readers int expectedFeatureCount = roadFeatures.length; int currentFeatureCount = 0; FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = memoryDataStore.getFeatureReader( new Query(roadType.getTypeName(), Filter.INCLUDE), transaction); // start iterating through content if (featureReader.hasNext()) { featureReader.next(); currentFeatureCount++; } SimpleFeature newFeature = SimpleFeatureBuilder.template(roadType, null); memoryDataStore.addFeature(newFeature); assertReaderHasFeatureCount(expectedFeatureCount, currentFeatureCount, featureReader); }
private SimpleFeature createSampleFeature() { SimpleFeatureType type; try { type = DataUtilities.createType("Sample", "the_geom:Geometry"); } catch (SchemaException e) { throw new RuntimeException(e); } return SimpleFeatureBuilder.template(type, null); }
private SimpleFeature createSampleFeature() { SimpleFeatureType type; try { type = DataUtilities.createType("Sample", "the_geom:Geometry"); } catch (SchemaException e) { throw new RuntimeException(e); } return SimpleFeatureBuilder.template((SimpleFeatureType) type, null); }
/** * Creates a sample Feature instance in the hope that it can be used in the * rendering of the legend graphic. * * @param schema the schema for which to create a sample Feature instance * * @return * * @throws WmsException */ private SimpleFeature createSampleFeature(SimpleFeatureType schema) throws WmsException { SimpleFeature sampleFeature; try { sampleFeature = SimpleFeatureBuilder.template(schema, null); } catch (IllegalAttributeException e) { e.printStackTrace(); throw new WmsException(e); } return sampleFeature; }
private SimpleFeature createCrsBoundsFeature(Geometry geom, CoordinateReferenceSystem crs) { SimpleFeatureType featureType; SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setName("Bounds"); try { sftb.add("the_geom", Geometry.class, CRS.decode("EPSG:4326", true)); } catch (Exception e) { throw new RuntimeException(e); } featureType = sftb.buildFeatureType(); SimpleFeature feature = SimpleFeatureBuilder.template(featureType, null); feature.setAttribute("the_geom", geom); return feature; }
public SimpleFeature next() throws IOException { if (live != null) { write(); } if (reader.hasNext()) { original = reader.next(); live = SimpleFeatureBuilder.copy(original); } else { original = null; live = SimpleFeatureBuilder.template(featureType, null); } return live; }
/** * Creates a sample Feature instance in the hope that it can be used in the rendering of the * legend graphic. * * @param schema the schema for which to create a sample Feature instance * @throws ServiceException */ private Feature createSampleFeature(FeatureType schema) throws ServiceException { Feature sampleFeature; try { if (schema instanceof SimpleFeatureType) { if (hasMixedGeometry((SimpleFeatureType) schema)) { // we can't create a sample for a generic Geometry type sampleFeature = null; } else { sampleFeature = SimpleFeatureBuilder.template((SimpleFeatureType) schema, null); } } else { sampleFeature = DataUtilities.templateFeature(schema); } } catch (IllegalAttributeException e) { throw new ServiceException(e); } return sampleFeature; }
public SimpleFeature next() throws IOException, NoSuchElementException { if (hasNext()) { // existing content live = (SimpleFeature) iterator.next(); try { current = SimpleFeatureBuilder.copy(live); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to edit " + live.getID() + " of " + typeName); } } else { // new content live = null; try { current = SimpleFeatureBuilder.template(featureType, null); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to add additional Features of " + typeName); } } return current; }
/** * Creates a sample Feature instance in the hope that it can be used in the rendering of the * legend graphic. * * @param schema the schema for which to create a sample Feature instance * @throws ServiceException */ private Feature createSampleFeature(FeatureType schema) throws ServiceException { Feature sampleFeature; try { if (schema instanceof SimpleFeatureType) { if (hasMixedGeometry((SimpleFeatureType) schema)) { // we can't create a sample for a generic Geometry type sampleFeature = null; } else { sampleFeature = SimpleFeatureBuilder.template((SimpleFeatureType) schema, null); } } else { sampleFeature = DataUtilities.templateFeature(schema); } } catch (IllegalAttributeException e) { throw new ServiceException(e); } return sampleFeature; }
public SimpleFeature next() throws IOException, NoSuchElementException { if (hasNext()) { // existing content live = iterator.next(); try { current = SimpleFeatureBuilder.copy(live); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to edit " + live.getID() + " of " + typeName); } } else { // new content live = null; try { current = SimpleFeatureBuilder.template(featureType, null); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to add additional Features of " + typeName); } } return current; }
public SimpleFeature next() throws IOException, NoSuchElementException { if (hasNext()) { // existing content live = iterator.next(); try { current = SimpleFeatureBuilder.copy(live); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to edit " + live.getID() + " of " + featureType.getTypeName()); } } else { // new content live = null; try { current = SimpleFeatureBuilder.template(featureType, null); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to add additional Features of " + featureType.getTypeName()); } } return current; }
public SimpleFeature next() throws IOException, NoSuchElementException { if (hasNext()) { // existing content live = iterator.next(); try { current = SimpleFeatureBuilder.copy(live); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to edit " + live.getID() + " of " + featureType.getTypeName()); } } else { // new content live = null; try { current = SimpleFeatureBuilder.template(featureType, null); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to add additional Features of " + featureType.getTypeName()); } } return current; }