@Override public void getDetailInfo(java.util.Formatter sf) { super.getDetailInfo(sf); int count = 0; for (DsgFeatureCollection pfc : collectionList) { sf.format("%nPointFeatureCollection %d %n", count); sf.format(" %s %s %n", pfc.getCollectionFeatureType(), pfc.getName()); sf.format(" npts = %d %n", pfc.size()); /* List<Variable> extra = pfc.getExtraVariables(); if (extra.size() > 0) { sf.format(" extra variables = "); for (Variable v : extra) sf.format("%s,", v.getNameAndDimensions()); sf.format("%n"); } */ sf.format(" timeUnit = %s %n", pfc.getTimeUnit()); sf.format(" altUnit = %s %n", pfc.getAltUnits()); count++; } }
private void copyFieldsFrom(DsgFeatureCollection featCol) { this.timeUnit = featCol.getTimeUnit(); this.altUnits = featCol.getAltUnits(); }
DsgFeatureCollection fc = list.get(0); // LOOK maybe should pass in the dsg? rootElem.addContent(writeTimeUnit(fc.getTimeUnit())); rootElem.addContent(new Element("AltitudeUnits").addContent(fc.getAltUnits())); LatLonRect bb = fc.getBoundingBox(); if (bb != null) rootElem.addContent(writeBoundingBox(bb)); CalendarDateRange dateRange = fc.getCalendarDateRange(); if (dateRange != null) { Element drElem = new Element("TimeSpan"); // from KML
static void checkDsgFeatureCollection( DsgFeatureCollection dsg) throws IOException { String what = dsg.getClass().getName(); Assert.assertNotNull(what + " name", dsg.getName()); Assert.assertNotNull(what + " featureTYpe", dsg.getCollectionFeatureType()); Assert.assertNotNull(what + " timeUnit", dsg.getTimeUnit()); // Assert.assertNotNull(what + " altUnits", dsg.getAltUnits()); // Assert.assertNotNull(what + " extraVars", dsg.getExtraVariables()); }
static void checkInfo( DsgFeatureCollection dsg) throws IOException { Assert.assertNotNull(dsg.getBoundingBox()); Assert.assertNotNull(dsg.getCalendarDateRange()); Assert.assertNotNull(dsg.size() > 0); }
@Override public void calcBounds(java.util.Formatter sf) { for (DsgFeatureCollection pfc : collectionList) { try { CollectionInfo info = new DsgCollectionHelper(pfc).calcBounds(); sf.format(" bb = %s %n", info.bbox == null ? "" :info.bbox.toString2()); sf.format(" dates = %s %n", info.getCalendarDateRange(pfc.getTimeUnit())); } catch (IOException e) { e.printStackTrace(); } } }
@Test public void testAltUnits() throws Exception { String file = TestDir.cdmLocalTestDataDir + "point/stationRaggedContig.ncml"; Formatter buf = new Formatter(); try (FeatureDatasetPoint pods = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(ucar.nc2.constants.FeatureType.STATION, file, null, buf)) { List<DsgFeatureCollection> collectionList = pods.getPointFeatureCollectionList(); assert (collectionList.size() == 1) : "Can't handle point data with multiple collections"; DsgFeatureCollection fc = collectionList.get(0); assert fc.getAltUnits() != null : "no Alt Units"; assert fc.getAltUnits().equalsIgnoreCase("m") : "Alt Units should be 'm'"; } }
DsgFeatureCollection fc = fdp.getPointFeatureCollectionList().get(0); Assert.assertNotNull("FeatureCollection", fc); Assert.assertEquals(FeatureType.STATION, fc.getCollectionFeatureType());
StationPointFeatureCopy(StationFeature station, PointFeature pf) { super(pf.getFeatureCollection(), station, pf.getObservationTime(), pf.getNominalTime(), pf.getFeatureCollection().getTimeUnit()); this.station = station; }
@Test public void testAltUnits() throws Exception { // Ignore this test if NetCDF-4 isn't present. Assume.assumeTrue("NetCDF-4 C library not present.", Nc4Iosp.isClibraryPresent()); String file = TestDir.cdmLocalTestDataDir + "point/stationRaggedContig.ncml"; Formatter buf = new Formatter(); try (FeatureDatasetPoint pods = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(ucar.nc2.constants.FeatureType.STATION, file, null, buf)) { List<DsgFeatureCollection> collectionList = pods.getPointFeatureCollectionList(); assert (collectionList.size() == 1) : "Can't handle point data with multiple collections"; DsgFeatureCollection fc1 = collectionList.get(0); assert fc1.getAltUnits() != null : "no Alt Units"; assert fc1.getAltUnits().equalsIgnoreCase("m") : "Alt Units should be 'm'"; FeatureDatasetPoint rewrite = rewriteDataset(pods, "nc4", new CFPointWriterConfig(NetcdfFileWriter.Version.netcdf4)); collectionList = rewrite.getPointFeatureCollectionList(); DsgFeatureCollection fc2 = collectionList.get(0); assert fc2 instanceof PointFeatureCC; assert fc2.getAltUnits() != null : "no Alt Units"; assert fc2.getAltUnits().equalsIgnoreCase("m") : "Alt Units should be 'm'"; rewrite.close(); } }
PointFeatureCopy(PointFeature pf) { super(pf.getFeatureCollection(), pf.getLocation(), pf.getObservationTime(), pf.getNominalTime(), pf.getFeatureCollection().getTimeUnit()); }
private CollectionInfo calcBounds(PointFeatureCollection pfc) { LatLonRect bbox = null; double minTime = Double.MAX_VALUE; double maxTime = -Double.MAX_VALUE; int count = 0; for (PointFeature pf : pfc) { if (bbox == null) bbox = new LatLonRect(pf.getLocation().getLatLon(), .001, .001); else bbox.extend(pf.getLocation().getLatLon()); double obsTime = pf.getObservationTime(); minTime = Math.min(minTime, obsTime); maxTime = Math.max(maxTime, obsTime); count++; } if (count == 0) { return new CollectionInfo(null, null, 0, 0); } CalendarDateUnit cdu = dsg.getTimeUnit(); CalendarDateRange dateRange = CalendarDateRange.of(cdu.makeCalendarDate(minTime), cdu.makeCalendarDate(maxTime)); return new CollectionInfo(bbox, dateRange, count, count); }