private static int writeTrajectoryFeatureCollection(FeatureDatasetPoint fdpoint, TrajectoryFeatureCollection pds, String fileOut, CFPointWriterConfig config) throws IOException { WriterCFTrajectoryCollection cfWriter = new WriterCFTrajectoryCollection(fileOut, fdpoint.getGlobalAttributes(), fdpoint.getDataVariables(), pds.getExtraVariables(), pds.getTimeUnit(), pds.getAltUnits(), config); // LOOK not always needed int count = 0; int name_strlen = 0; int ntrajs = pds.size(); if (ntrajs < 0) { pds.resetIteration(); while (pds.hasNext()) { TrajectoryFeature feature = pds.next(); name_strlen = Math.max(name_strlen, feature.getName().length()); count++; } ntrajs = count; } cfWriter.setFeatureAuxInfo(ntrajs, name_strlen); count = 0; pds.resetIteration(); while (pds.hasNext()) { TrajectoryFeature feature = pds.next(); count += cfWriter.writeTrajectory(feature); if (debug && count % 10 == 0) System.out.printf("%d ", count); if (debug && count % 100 == 0) System.out.printf("%n "); } cfWriter.finish(); return count; }