@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. }
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; }