public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException { final SimpleFeatureIterator iterator = features(); return new FeatureReader<SimpleFeatureType, SimpleFeature>() { public SimpleFeatureType getFeatureType() { return getSchema(); } public SimpleFeature next() throws IOException, IllegalAttributeException, NoSuchElementException { return iterator.next(); } public boolean hasNext() throws IOException { return iterator.hasNext(); } public void close() throws IOException { DefaultFeatureCollection.this.close(iterator); } }; }
features.add(f); FeatureIterator it = features.features();
public SimpleFeatureCollection collection() throws IOException { DefaultFeatureCollection copy = new DefaultFeatureCollection(null, getSchema()); List<SimpleFeature> list = new ArrayList<SimpleFeature>(contents.size()); SimpleFeatureIterator iterator = features(); try { while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); SimpleFeature duplicate; try { duplicate = SimpleFeatureBuilder.copy(feature); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to copy " + feature.getID(), e); } list.add(duplicate); } } finally { iterator.close(); } copy.addAll(list); return copy; }
@Test public void testIteratorSortReduce() throws IOException { // make it so that we are not going to hit the disk SimpleFeatureIterator fi = null; try { fi = new SortedFeatureIterator(fc.features(), schema, peopleAsc, 1000); assertSortedOnPeopleAsc(fi); } finally { if (fi != null) { fi.close(); } } }
public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException { final SimpleFeatureIterator iterator = features(); return new FeatureReader<SimpleFeatureType, SimpleFeature>(){ public SimpleFeatureType getFeatureType() { return getSchema(); } public SimpleFeature next() throws IOException, IllegalAttributeException, NoSuchElementException { return iterator.next(); } public boolean hasNext() throws IOException { return iterator.hasNext(); } public void close() throws IOException { DefaultFeatureCollection.this.close( iterator ); } }; }
public FeatureReader reader() throws IOException { final FeatureIterator iterator = features(); return new FeatureReader(){ public FeatureType getFeatureType() { return getSchema(); } public Feature next() throws IOException, IllegalAttributeException, NoSuchElementException { return iterator.next(); } public boolean hasNext() throws IOException { return iterator.hasNext(); } public void close() throws IOException { DefaultFeatureCollection.this.close( iterator ); } }; }
fc.add(builder.buildFeature((features + 1) + "")); fr = new DelegateSimpleFeatureReader(schema, fc.features());
private void setMaskRegionName(Mask selectedMask, VectorDataNode vectorDataNode) { FeatureIterator<SimpleFeature> features = vectorDataNode.getFeatureCollection().features(); mask2RegionName.put(selectedMask, Util.getFeatureName(features.next())); features.close(); }
public FeatureCollection collection() throws IOException { FeatureCollection copy = new DefaultFeatureCollection( null, featureType ); List list = new ArrayList( contents.size() ); for( FeatureIterator iterator = features(); iterator.hasNext(); ){ Feature feature = iterator.next(); Feature duplicate; try { duplicate = feature.getFeatureType().duplicate( feature ); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to copy "+feature.getID(), e ); } list.add( duplicate ); } copy.addAll( list ); return copy; }
public void testNormal() throws Exception { SimpleFeatureIterator reproject = new ReprojectingFeatureCollection(delegate, target).features(); SimpleFeatureIterator reader = delegate.features(); try { while (reader.hasNext()) { SimpleFeature normal = (SimpleFeature) reader.next(); SimpleFeature reprojected = (SimpleFeature) reproject.next(); Point p1 = (Point) normal.getAttribute("defaultGeom"); Point p2 = (Point) reprojected.getAttribute("defaultGeom"); if (p1 != null) { p1 = (Point) transformer.transform(p1); assertTrue(p1.equalsExact(p2)); } else { assertNull(p2); } LineString l1 = (LineString) normal.getAttribute("otherGeom"); LineString l2 = (LineString) reprojected.getAttribute("otherGeom"); if (l1 != null) { l1 = (LineString) transformer.transform(l1); assertTrue(l1.equalsExact(l2)); } else { assertNull(l2); } } } finally { reproject.close(); reader.close(); } }
private void computeChartDataIfPossible() { // need to do this later: all GUI events must be processed first in order to get the correct state SwingUtilities.invokeLater(() -> { if (scatterPlotModel.pointDataSource != null && scatterPlotModel.dataField != null && scatterPlotModel.pointDataSource.getFeatureCollection() != null && scatterPlotModel.pointDataSource.getFeatureCollection().features() != null && scatterPlotModel.pointDataSource.getFeatureCollection().features().hasNext() && scatterPlotModel.pointDataSource.getFeatureCollection().features().next() != null && scatterPlotModel.pointDataSource.getFeatureCollection().features().next().getAttribute( scatterPlotModel.dataField.getLocalName()) != null && getRaster() != null) { compute(scatterPlotModel.useRoiMask ? scatterPlotModel.roiMask : null); } else { scatterpointsDataset.removeAllSeries(); acceptableDeviationDataset.removeAllSeries(); regressionDataset.removeAllSeries(); getPlot().removeAnnotation(r2Annotation); computedDatas = null; } }); }
public SimpleFeatureCollection collection() throws IOException { SimpleFeatureCollection copy = new DefaultFeatureCollection( null, getSchema() ); List<SimpleFeature> list = new ArrayList<SimpleFeature>( contents.size() ); SimpleFeatureIterator iterator = features(); try { while( iterator.hasNext() ){ SimpleFeature feature = iterator.next(); SimpleFeature duplicate; try { duplicate = SimpleFeatureBuilder.copy(feature); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to copy "+feature.getID(), e ); } list.add( duplicate ); } } finally { iterator.close(); } copy.addAll( list ); return copy; }
try (FeatureIterator<SimpleFeature> iterator = featureCollection.features()) { while (iterator.hasNext()) { featuresToStyle.add(iterator.next());
private void doExportImport(ArrayList<SimpleFeature> features, Class<? extends Geometry> geomType) throws IOException { File tempFile = File.createTempFile("pins", null, tempDir); try { ExportGeometryAction.writeEsriShapefile(geomType, features, tempFile); assertTrue(tempFile.exists()); VectorDataNode vectorDataNode = readIn(new File(String.format("%s_%s.shp", tempFile.getAbsolutePath(), geomType.getSimpleName())), product); assertEquals(1, vectorDataNode.getFeatureCollection().getCount()); try (SimpleFeatureIterator readFeatures = vectorDataNode.getFeatureCollection().features()) { while (readFeatures.hasNext()) { SimpleFeature next = readFeatures.next(); assertNotNull(next.getDefaultGeometry()); } } } catch (Throwable t) { t.printStackTrace(); fail(String.format("Throwable '%s: %s' not expected", t.getClass().getSimpleName(), t.getMessage())); } finally { boolean deleted = tempFile.delete(); if (!deleted) { tempFile.deleteOnExit(); } } }
SimpleFeatureIterator simpleFeatureIterator = collection.features(); while(simpleFeatureIterator.hasNext()){ SimpleFeature simpleFeature = simpleFeatureIterator.next(); for(String subId : distictPolygonsOrdered) { final DefaultFeatureCollection subCollection = new DefaultFeatureCollection(subId, type); simpleFeatureIterator = collection.features(); while (simpleFeatureIterator.hasNext()) { SimpleFeature simpleFeature = simpleFeatureIterator.next(); } else { Set<String> distictPolygons = new HashSet<>(); SimpleFeatureIterator simpleFeatureIterator = collection.features(); while(simpleFeatureIterator.hasNext()){ SimpleFeature simpleFeature = simpleFeatureIterator.next(); for(String subId : distictPolygonsOrdered) { final DefaultFeatureCollection subCollection = new DefaultFeatureCollection(subId, type); simpleFeatureIterator = collection.features(); while (simpleFeatureIterator.hasNext()) { SimpleFeature simpleFeature = simpleFeatureIterator.next();
@Test public void testDecodingDelimiter() throws IOException { final FeatureCollection<SimpleFeatureType, SimpleFeature> readCollection = VectorDataNodeReader.read("mem", new StringReader(stringWriter.toString()), createDummyProduct(), new FeatureUtils.FeatureCrsProvider() { @Override public CoordinateReferenceSystem getFeatureCrs(Product product) { return DefaultGeographicCRS.WGS84; } }, placemarkDescriptorProvider, DefaultGeographicCRS.WGS84, VectorDataNodeIO.DEFAULT_DELIMITER_CHAR, ProgressMonitor.NULL).getFeatureCollection(); assertEquals(testCollection.size(), readCollection.size()); final FeatureIterator<SimpleFeature> expectedIterator = testCollection.features(); final FeatureIterator<SimpleFeature> actualIterator = readCollection.features(); while (expectedIterator.hasNext()) { final SimpleFeature expectedFeature = expectedIterator.next(); final SimpleFeature actualFeature = actualIterator.next(); final Object expectedAttribute = expectedFeature.getAttribute(ATTRIBUTE_NAME_LABEL); final Object actualAttribute = actualFeature.getAttribute(ATTRIBUTE_NAME_LABEL); assertEquals(expectedAttribute, actualAttribute); } }
SimpleFeatureIterator iterator = output.features(); Geometry expected = (Geometry) features.features().next().getDefaultGeometry(); SimpleFeature sf = iterator.next(); assertTrue(expected.equals((Geometry) sf.getDefaultGeometry()));
Coordinate centre = ((Polygon) secondFeatures.features().next().getDefaultGeometry()) .getCentroid().getCoordinate(); Point p = gf.createPoint(centre); SimpleFeatureIterator iterator = output.features(); Geometry expected = (Geometry) features.features().next().getDefaultGeometry(); SimpleFeature sf = iterator.next(); assertTrue(expected.equals((Geometry) sf.getDefaultGeometry()));
SimpleFeatureIterator iterator = collection.features(); while (iterator.hasNext()) { SimpleFeature feature = iterator.next();