//pods.calcBounds();
System.out.printf("Opened file %s%n dateRange= %s", file, pods.getDateRange());
List<FeatureCollection> collectionList = pods.getPointFeatureCollectionList();
FeatureCollection fc = collectionList.get(0);
LatLonRect llr = new LatLonRect(new LatLonPointImpl(33.4, -92.2), new LatLonPointImpl(47.9, -75.89));
System.out.println("llr = " + llr);
DateRange dr;
if (usePresent) {
//Date now = new Date();
//Date ago = new Date(now.getTime()-3600000);
dr = new DateRange(null, new DateType(true, null), new TimeDuration("2 hour"), null);
//dr = new DateRange(null, new DateType(true, null), new TimeDuration("1 hour"), null);
//dr = new DateRange(dr.getStart().getDate(), dr.getEnd().getDate()); // get rid of reletive time
} else {
Date startd = pods.getDateRange().getStart().getDate();
dr = new DateRange(startd, new TimeDuration("1 hour"));
}
System.out.println("date range = " + dr);
long start = System.currentTimeMillis();
PointFeatureCollection collection = null;
if (fc instanceof PointFeatureCollection) {
collection = (PointFeatureCollection) fc;
if (llr != null) {
collection = collection.subset(llr, dr);
}
} else if (fc instanceof NestedPointFeatureCollection) {
NestedPointFeatureCollection npfc = (NestedPointFeatureCollection) fc;
collection = npfc.flatten(llr, dr);
} else {
throw new IllegalArgumentException("Can't handle collection of type " + fc.getClass().getName());
}
DateRange track = null;
DateFormatter df = new DateFormatter();
PointFeatureIterator dataIterator = collection.getPointFeatureIterator(-1);
int numObs = 0;
while (dataIterator.hasNext()) {
PointFeature po = (PointFeature) dataIterator.next();
numObs++;
ucar.unidata.geoloc.EarthLocation el = po.getLocation();
StructureData structure = po.getData();
assert llr.contains(el.getLatLon()) : el.getLatLon() + " not in " + llr;
Date obsDate = po.getObservationTimeAsDate();
assert dr.included(obsDate) : df.toDateTimeString(obsDate) + " not in " + dr;
if (numObs % 1000 == 0)
System.out.printf("%d el = %s %s %n", numObs, el, df.toDateTimeString(obsDate));