@Nonnull @Override public StructureData getFeatureData() throws IOException { return from.getFeatureData(); }
public boolean filter(NestedPointFeatureCollection pointFeatureCollection) { StationProfileFeature stationFeature = (StationProfileFeature) pointFeatureCollection; return stationHelper.getStation(stationFeature.getName()) != null; } }
@Override public ProfileFeature getProfileByDate(CalendarDate date) throws IOException { return from.getProfileByDate(date); }
while (fc.hasNext()) { StationProfileFeature spf = fc.next(); name_strlen = Math.max(name_strlen, spf.getName().length()); if (spf.size() >= 0) countProfiles += spf.size(); else { while (spf.hasNext()) { spf.next(); countProfiles++; StationProfileFeature spf = fc.next(); spf.resetIteration(); while (spf.hasNext()) { ProfileFeature pf = spf.next(); if (pf.getTime() == null) continue; // assume this means its a "incomplete multidimensional"
static int checkStationProfileFeatureCollection(StationProfileFeatureCollection stationProfileFeatureCollection, boolean show) throws IOException { long start = System.currentTimeMillis(); int count = 0; for (StationProfileFeature spf : stationProfileFeatureCollection) { checkDsgFeatureCollection(spf); Assert.assertNotNull("StationProfileFeature latlon", spf.getLatLon()); Assert.assertNotNull("StationProfileFeature featureData", spf.getFeatureData()); // iterates through the profile but not the profile data List<CalendarDate> times = spf.getTimes(); if (showAll) { System.out.printf(" times= "); for (CalendarDate t : times) System.out.printf("%s, ", t); System.out.printf("%n"); } Set<String> profileNames = new HashSet<>(); for (ProfileFeature profile : spf) { checkDsgFeatureCollection(profile); Assert.assertNotNull("ProfileFeature time", profile.getTime()); Assert.assertNotNull("ProfileFeature latlon", profile.getLatLon()); Assert.assertNotNull("ProfileFeature featureData", profile.getFeatureData()); Assert.assertTrue(!profileNames.contains(profile.getName())); profileNames.add(profile.getName()); if (show) System.out.printf(" ProfileFeature=%s %n", profile.getName()); count += checkPointFeatureCollection(profile, show); } } long took = System.currentTimeMillis() - start; if (show) System.out.println(" testStationProfileFeatureCollection complete count= " + count + " full iter took= " + took + " msec"); return count; }
@Override // new way public IOIterator<PointFeatureCollection> getCollectionIterator() throws IOException { return new PointCollectionIteratorFiltered( from.getPointFeatureCollectionIterator(), new DateFilter()); }
@Test public void testStationProfileMultidim1dTime() throws IOException { FeatureType type = FeatureType.STATION_PROFILE; String location = TestCFPointDatasets.CFpointObs_topdir + "stationProfileMultidim1dTime.ncml"; ucar.nc2.util.CancelTask task = null; Formatter out = new Formatter(); FeatureDataset featDset = FeatureDatasetFactoryManager.open(type, location, task, out); assert featDset != null && featDset instanceof FeatureDatasetPoint; FeatureDatasetPoint featDsetPoint = (FeatureDatasetPoint) featDset; List<DsgFeatureCollection> featCols = featDsetPoint.getPointFeatureCollectionList(); assert !featCols.isEmpty(); DsgFeatureCollection featCol = featCols.get(0); // We only care about the first one. assert featCol instanceof StationProfileFeatureCollection; StationProfileFeatureCollection stationProfileFeatCol = (StationProfileFeatureCollection) featCol; assert stationProfileFeatCol.hasNext(); StationProfileFeature stationProfileFeat = stationProfileFeatCol.next(); // We only care about the first one. List<CalendarDate> timesList = stationProfileFeat.getTimes(); Set<CalendarDate> timesSet = new TreeSet<>(stationProfileFeat.getTimes()); // Nukes dupes. Assert.assertEquals(timesList.size(), timesSet.size()); // Assert that the times are unique. }
@Override // old way public PointFeatureCollectionIterator getPointFeatureCollectionIterator() throws IOException { return new PointCollectionIteratorFiltered( from.getPointFeatureCollectionIterator(), new DateFilter()); }
public boolean filter(NestedPointFeatureCollection pointFeatureCollection) { StationProfileFeature stationFeature = (StationProfileFeature) pointFeatureCollection; return getStationHelper().getStation(stationFeature.getName()) != null; } }
private void writeHeader(StationProfileFeature stn, ProfileFeature profile, PointFeature obs) throws IOException { StructureData stnData = stn.getFeatureData(); StructureData profileData = profile.getFeatureData(); StructureData obsData = obs.getFeatureData();
@Override public boolean filter(PointFeatureCC pointFeatureCollection) { StationProfileFeature stationFeature = (StationProfileFeature) pointFeatureCollection; return getStationHelper().getStation(stationFeature.getName()) != null; } }
private void writeHeader(StationProfileFeature stn, ProfileFeature profile, PointFeature obs) throws IOException { StructureData stnData = stn.getFeatureData(); StructureData profileData = profile.getFeatureData(); StructureData obsData = obs.getFeatureData();
public int writeProfile (StationProfileFeature spf, ProfileFeature profile) throws IOException { int count = 0; for (PointFeature pf : profile) { if (!headerDone) { if (id_strlen == 0) id_strlen = profile.getName().length() * 2; writeHeader(spf, profile, pf); headerDone = true; } writeObsData(pf); count++; } Integer stnIndex = stationIndexMap.get(spf.getName()); if (stnIndex == null) { System.out.printf("BAD station %s%n", spf.getName()); } else { writeProfileData(stnIndex, profile, count); } return count; }
public int writeProfile (StationProfileFeature spf, ProfileFeature profile) throws IOException { profile.resetIteration(); int count = 0; while (profile.hasNext()) { PointFeature pf = profile.next(); if (!headerDone) { if (id_strlen == 0) id_strlen = profile.getName().length() * 2; writeHeader(spf, profile, pf); headerDone = true; } writeObsData(pf); count++; } Integer stnIndex = stationIndexMap.get(spf.getName()); if (stnIndex == null) { System.out.printf("BAD station %s%n", spf.getName()); } else { writeProfileData(stnIndex, profile, count); } return count; }