static int countLocations(PointFeatureCollection pfc) throws IOException { int count = 0; Set<MyLocation> locs = new HashSet<>(80000); pfc.resetIteration(); while (pfc.hasNext()) { PointFeature pf = pfc.next(); MyLocation loc = new MyLocation(pf.getLocation()); if (!locs.contains(loc)) locs.add(loc); count++; //if (count % 1000 == 0) System.out.printf("Count %d%n", count); } System.out.printf("Count Points = %d Unique points = %d %n", count, locs.size()); return locs.size(); //The problem is that all the locations are coming up with the same value. This: //always returns the same lat/lon/alt (of the first observation). //(pos was populated going through the PointFeatureIterator). }
pointFeatureCollection.resetIteration(); while (pointFeatureCollection.hasNext()) { PointFeature pointFeature = (PointFeature) pointFeatureCollection.next();
pointFeatureCollection.resetIteration(); while (pointFeatureCollection.hasNext()) { PointFeature pointFeature = (PointFeature) pointFeatureCollection.next();
pointFeatureCollection.resetIteration(); while (pointFeatureCollection.hasNext()) { PointFeature pointFeature = (PointFeature) pointFeatureCollection.next();
pointFeatureCollection.resetIteration(); while (pointFeatureCollection.hasNext()) { PointFeature pointFeature = (PointFeature) pointFeatureCollection.next();
static int countObs(PointFeatureCollection pfc) throws IOException { int count = 0; pfc.resetIteration(); while (pfc.hasNext()) { PointFeature pf = pfc.next(); StructureData sd = pf.getDataAll(); count++; } return count; }
private static int writePointFeatureCollection(FeatureDatasetPoint fdpoint, PointFeatureCollection pfc, String fileOut, CFPointWriterConfig config) throws IOException { try (WriterCFPointCollection pointWriter = new WriterCFPointCollection(fileOut, fdpoint.getGlobalAttributes(), fdpoint.getDataVariables(), pfc.getExtraVariables(), pfc.getTimeUnit(), pfc.getAltUnits(), config)) { int count = 0; pfc.resetIteration(); while(pfc.hasNext()) { PointFeature pf = pfc.next(); if (count == 0) pointWriter.writeHeader(pf); pointWriter.writeRecord(pf, pf.getFeatureData()); count++; if (debug && count % 100 == 0) System.out.printf("%d ", count); if (debug && count % 1000 == 0) System.out.printf("%n "); } pointWriter.finish(); return count; } }