Java Code Examples for ucar.nc2.constants.FeatureType#STATION

The following examples show how to use ucar.nc2.constants.FeatureType#STATION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NcCollectionType.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static StationTimeSeriesFeatureCollection getStationFeatures(FeatureDatasetPoint fdPoint) {
  String datasetFileName = new File(fdPoint.getNetcdfFile().getLocation()).getName();

  if (fdPoint.getFeatureType() != FeatureType.STATION) {
    throw new IllegalArgumentException(String.format("In %s, expected feature type to be STATION, not %s.",
        datasetFileName, fdPoint.getFeatureType()));
  }

  List<DsgFeatureCollection> featCollList = fdPoint.getPointFeatureCollectionList();

  if (featCollList.size() != 1) {
    throw new IllegalArgumentException(
        String.format("Expected %s to contain 1 FeatureCollection, not %s.", datasetFileName, featCollList.size()));
  } else if (!(featCollList.get(0) instanceof StationTimeSeriesFeatureCollection)) {
    String expectedClassName = StationTimeSeriesFeatureCollection.class.getName();
    String actualClassName = featCollList.get(0).getClass().getName();

    throw new IllegalArgumentException(String.format("Expected %s's FeatureCollection to be a %s, not a %s.",
        datasetFileName, expectedClassName, actualClassName));
  }

  return (StationTimeSeriesFeatureCollection) featCollList.get(0);
}
 
Example 2
Source File: UnidataPointObs.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) {
  if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.STATION)
      && (wantFeatureType != FeatureType.POINT))
    return false;

  FeatureType ft = FeatureDatasetFactoryManager.findFeatureType(ds);
  if (((ft != FeatureType.STATION) && (ft != FeatureType.POINT)))
    return false;

  String conv = ds.getRootGroup().findAttributeString(CDM.CONVENTIONS, null);
  if (conv == null)
    return false;

  StringTokenizer stoke = new StringTokenizer(conv, ",");
  while (stoke.hasMoreTokens()) {
    String toke = stoke.nextToken().trim();
    if (toke.equalsIgnoreCase("Unidata Observation Dataset v1.0"))
      return true;
  }

  return false;
}
 
Example 3
Source File: NcssPointController.java    From tds with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping("**")
public void handleRequest(HttpServletRequest req, HttpServletResponse res, @Valid NcssPointParamsBean params,
    BindingResult validationResult) throws Exception {
  if (validationResult.hasErrors())
    throw new BindException(validationResult);

  String datasetPath = getDatasetPath(req);
  try (FeatureDatasetPoint fdp = TdsRequestedDataset.getPointDataset(req, res, datasetPath)) {
    if (fdp == null)
      return;

    Formatter errs = new Formatter();
    if (!params.intersectsTime(fdp.getCalendarDateRange(), errs)) {
      handleValidationErrorMessage(res, HttpServletResponse.SC_BAD_REQUEST, errs.toString());
      return;
    }

    FeatureType ft = fdp.getFeatureType();
    if (ft != FeatureType.POINT && ft != FeatureType.STATION) {
      throw new NcssException("Dataset Feature Type is " + ft.toString() + " but request is for Points or Stations");
    }

    SubsetParams ncssParams = params.makeSubset();
    SupportedFormat format = getSupportedOperation(fdp).getSupportedFormat(params.getAccept());

    DsgSubsetWriter pds =
        DsgSubsetWriterFactory.newInstance(fdp, ncssParams, ncssDiskCache, res.getOutputStream(), format);
    setResponseHeaders(res, pds.getHttpHeaders(datasetPath, format.isStream()));
    pds.respond(res, fdp, datasetPath, ncssParams, format);
  }
}
 
Example 4
Source File: PointFeatureDatasetViewer.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void subset(LatLonRect geoRegion, DateRange dateRange) throws IOException {
  PointFeatureCollection pc = null;
  CalendarDateRange cdr = CalendarDateRange.of(dateRange);

  if (selectedType == FeatureType.POINT) {
    PointFeatureCollection ptCollection = (PointFeatureCollection) selectedCollection;
    pc = ptCollection.subset(geoRegion, cdr);

  } else if (selectedType == FeatureType.STATION) {
    StationTimeSeriesFeatureCollection stationCollection = (StationTimeSeriesFeatureCollection) selectedCollection;
    /*
     * if (geoRegion != null) {
     * StationTimeSeriesFeatureCollection stationSubset = stationCollection.subset(geoRegion);
     * setStations( stationSubset);
     * return;
     * } else {
     */
    pc = stationCollection.flatten(geoRegion, cdr);
    // } LOOK
  }
  /*
   * else if (selectedType == FeatureType.STATION_PROFILE) {
   * StationProfileFeatureCollection stationProfileCollection = (StationProfileFeatureCollection) selectedCollection;
   * pc = stationProfileCollection.flatten(geoRegion, cdr);
   * }
   */

  if (null != pc) {
    setObservations(pc);
  }
}
 
Example 5
Source File: PointFeatureDatasetViewer.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
  if (pfDataset == null) {
    return;
  }

  if (pfDataset.getFeatureType() != FeatureType.STATION) {
    Component parentComponent = PointFeatureDatasetViewer.this;
    Object message = "Currently, only the STATION feature type is supported, not " + pfDataset.getFeatureType();
    String title = "Invalid feature type";
    int messageType = JOptionPane.ERROR_MESSAGE;

    JOptionPane.showMessageDialog(parentComponent, message, title, messageType);
    return;
  }

  try {
    ByteArrayOutputStream outStream = new ByteArrayOutputStream(5000);
    MarshallingUtil.marshalPointDataset(pfDataset, pfDataset.getDataVariables(), outStream);

    infoTA.setText(outStream.toString(StandardCharsets.UTF_8.name()));
    infoTA.gotoTop();
    infoWindow.setVisible(true);
  } catch (IOException | XmlException ex) {
    StringWriter sw = new StringWriter(5000);
    ex.printStackTrace(new PrintWriter(sw));

    infoTA.setText(sw.toString());
    infoTA.gotoTop();
    infoWindow.setVisible(true);
  }
}
 
Example 6
Source File: Madis.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) {
  if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.STATION)
      && (wantFeatureType != FeatureType.POINT) && (wantFeatureType != FeatureType.STATION_PROFILE))
    return false;

  if (!ds.hasUnlimitedDimension())
    return false;
  if (ds.findDimension("recNum") == null)
    return false;

  if (ds.findVariable("staticIds") == null)
    return false;
  if (ds.findVariable("nStaticIds") == null)
    return false;
  if (ds.findVariable("lastRecord") == null)
    return false;
  if (ds.findVariable("prevRecord") == null)
    return false;

  VNames vn = getVariableNames(ds, null);
  if (ds.findVariable(vn.lat) == null)
    return false;
  if (ds.findVariable(vn.lon) == null)
    return false;
  return ds.findVariable(vn.obsTime) != null;

}
 
Example 7
Source File: BufrConfig.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private FeatureType guessFeatureType(StandardFields.StandardFieldsFromMessage standardFields) {
  if (standardFields.hasStation())
    return FeatureType.STATION;
  if (standardFields.hasTime())
    return FeatureType.POINT;
  return FeatureType.ANY;
}
 
Example 8
Source File: NdbcNetcdf4.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
  Dimension obsDim = ds.findDimension("time");
  if (obsDim == null) {
    CoordinateAxis axis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time);
    if ((axis != null) && axis.isScalar())
      obsDim = axis.getDimension(0);
  }

  if (obsDim == null) {
    errlog.format("Must have an Observation dimension: unlimited dimension, or from Time Coordinate");
    return null;
  }
  boolean hasStruct = Evaluator.hasNetcdf3RecordStructure(ds);



  // otherwise, make it a Station
  TableConfig nt = new TableConfig(Table.Type.Top, "station");
  nt.featureType = FeatureType.STATION;

  nt.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat);
  nt.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon);

  nt.stnId = ds.getRootGroup().findAttributeString("station_name", null);
  nt.stnWmoId = ds.getRootGroup().findAttributeString("wmo_id", null);

  nt.stnDesc = ds.getRootGroup().findAttributeString("description", null);
  if (nt.stnDesc == null)
    nt.stnDesc = ds.getRootGroup().findAttributeString("comment", null);

  TableConfig obs = new TableConfig(Table.Type.Structure, hasStruct ? "record" : obsDim.getShortName());
  obs.structName = "record";
  obs.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure;
  obs.dimName = obsDim.getShortName();
  obs.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time);
  nt.addChild(obs);

  return nt;
}
 
Example 9
Source File: BufrFeatureDatasetFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private BufrStationDataset(NetcdfDataset ncfile, BufrCdmIndex index) {
  super(ncfile, FeatureType.STATION);
  this.index = index;

  // create the list of data variables
  munger = new Munge();
  obs = (SequenceDS) ncfile.findVariable(BufrIosp2.obsRecordName);
  this.dataVariables = munger.makeDataVariables(index, obs);

  BufrStationCollection bufrCollection = new BufrStationCollection(ncfile.getLocation());
  setPointFeatureCollection(bufrCollection);

  CalendarDateRange dateRange = CalendarDateRange.of(CalendarDate.of(index.start), CalendarDate.of(index.end));
  setDateRange(dateRange);
}
 
Example 10
Source File: SortingStationPointFeatureCacheTest.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void test1() throws Exception {
  StructureMembers.Builder smb = StructureMembers.builder().setName("StationFeature");
  smb.addMemberString("name", null, null, "Foo", 3);
  smb.addMemberString("desc", null, null, "Bar", 3);
  smb.addMemberString("wmoId", null, null, "123", 3);
  smb.addMemberScalar("lat", null, "degrees_north", DataType.DOUBLE, 30);
  smb.addMemberScalar("lon", null, "degrees_east", DataType.DOUBLE, 60);
  smb.addMemberScalar("alt", null, "meters", DataType.DOUBLE, 5000);
  StructureData stationData = new StructureDataFromMember(smb.build());

  StationFeature stationFeat = new StationFeatureImpl("Foo", "Bar", "123", 30, 60, 5000, 4, stationData);

  CalendarDateUnit timeUnit = CalendarDateUnit.of(null, "days since 1970-01-01");
  DsgFeatureCollection dummyDsg = new SimplePointFeatureCC("dummy", timeUnit, "m", FeatureType.STATION);

  List<StationPointFeature> spfList = new ArrayList<>();
  spfList.add(makeStationPointFeature(dummyDsg, stationFeat, timeUnit, 10, 10, 103));
  spfList.add(makeStationPointFeature(dummyDsg, stationFeat, timeUnit, 20, 20, 96));
  spfList.add(makeStationPointFeature(dummyDsg, stationFeat, timeUnit, 30, 30, 118));
  spfList.add(makeStationPointFeature(dummyDsg, stationFeat, timeUnit, 40, 40, 110));

  Comparator<StationPointFeature> revObsTimeComp =
      (left, right) -> -Double.compare(left.getObservationTime(), right.getObservationTime());

  SortingStationPointFeatureCache cache = new SortingStationPointFeatureCache(revObsTimeComp);

  for (StationPointFeature stationPointFeat : spfList) {
    cache.add(stationPointFeat);
  }

  Collections.reverse(spfList);
  Assert.assertTrue(
      PointTestUtil.equals(new PointIteratorAdapter(spfList.iterator()), cache.getPointFeatureIterator()));
}
 
Example 11
Source File: StationTimeSeriesCollectionImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public StationTimeSeriesCollectionImpl(String name, CalendarDateUnit timeUnit, String altUnits) {
  super(name, timeUnit, altUnits, FeatureType.STATION);
}
 
Example 12
Source File: BufrFeatureDatasetFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public FeatureType getFeatureType() {
  return FeatureType.STATION;
}
 
Example 13
Source File: StationTimeSeriesFeatureImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nonnull
@Override
public FeatureType getCollectionFeatureType() {
  return FeatureType.STATION;
}
 
Example 14
Source File: StationObsDatasetImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public FeatureType getScientificDataType() {
  return FeatureType.STATION;
}
 
Example 15
Source File: CdmDirect.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected TableConfig getStationConfig(NetcdfDataset ds, Formatter errlog) {
  // find lat coord
  Variable lat = CoordSysEvaluator.findCoordByType(ds, AxisType.Lat);
  if (lat == null) {
    errlog.format("CdmDirect: Must have a Latitude coordinate%n");
    return null;
  }

  // find lon coord
  Variable lon = CoordSysEvaluator.findCoordByType(ds, AxisType.Lon);
  if (lon == null) {
    errlog.format("CdmDirect: Must have a Longitude coordinate%n");
    return null;
  }

  if (lat.getRank() != lon.getRank()) {
    errlog.format("CdmDirect: Lat and Lon coordinate must have same rank");
    return null;
  }

  // should be a top level struct or sequence
  TableConfig stnTable = new TableConfig(Table.Type.Structure, "station");
  stnTable.featureType = FeatureType.STATION;
  stnTable.structureType = TableConfig.StructureType.Structure;

  stnTable.lat = lat.getShortName();
  stnTable.lon = lon.getShortName();

  // optional alt coord
  Variable alt = CoordSysEvaluator.findCoordByType(ds, AxisType.Height);
  if (alt != null)
    stnTable.stnAlt = alt.getShortName();

  // station id
  stnTable.stnId = Evaluator.findNameOfVariableWithAttributeValue(ds, CF.CF_ROLE, CF.STATION_ID);
  if (stnTable.stnId == null)
    stnTable.stnId = Evaluator.findNameOfVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.STATION_ID); // old way
  if (stnTable.stnId == null) {
    errlog.format("Must have a Station id variable with standard name station_id%n");
    return null;
  }

  // other station
  stnTable.stnDesc = Evaluator.findNameOfVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.PLATFORM_NAME);
  if (stnTable.stnDesc == null)
    stnTable.stnDesc = Evaluator.findNameOfVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.STATION_DESC);
  stnTable.stnWmoId = Evaluator.findNameOfVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.STATION_WMOID);

  // obs table
  Structure stnv = (Structure) ds.findVariable("station");
  Structure obsv = null;
  for (Variable v : stnv.getVariables()) {
    if (v.getDataType() == DataType.SEQUENCE)
      obsv = (Structure) v;
  }
  if (obsv == null) {
    errlog.format("Must have a SEQUENCE variable%n");
    return null;
  }
  TableConfig obs = new TableConfig(Table.Type.NestedStructure, obsv.getFullName());
  obs.nestedTableName = obsv.getShortName();
  obs.time = CoordSysEvaluator.findCoordShortNameByType(ds, AxisType.Time);
  if (obs.time == null) {
    errlog.format("Must have a time coordinate%n");
    return null;
  }
  stnTable.addChild(obs);

  return stnTable;
}
 
Example 16
Source File: Iridl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
  Dimension stationDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Lat);
  if (stationDim == null) {
    errlog.format("Must have a latitude coordinate");
    return null;
  }

  Variable stationVar = ds.findVariable(stationDim.getShortName());
  if (stationVar == null) {
    errlog.format("Must have a station coordinate variable");
    return null;
  }

  Dimension obsDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Time);
  if (obsDim == null) {
    errlog.format("Must have a Time coordinate");
    return null;
  }

  // station table
  TableConfig stationTable = new TableConfig(Table.Type.Structure, "station");
  stationTable.structName = "station";
  stationTable.structureType = TableConfig.StructureType.PsuedoStructure;
  stationTable.featureType = FeatureType.STATION;
  stationTable.dimName = stationDim.getShortName();

  stationTable.stnId = stationVar.getShortName();

  stationTable.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat);
  stationTable.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon);
  stationTable.stnAlt = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Height);

  // obs table
  TableConfig obsTable;
  obsTable = new TableConfig(Table.Type.MultidimInner, "obs");
  obsTable.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time);
  obsTable.outerName = stationDim.getShortName();
  obsTable.dimName = obsDim.getShortName();

  stationTable.addChild(obsTable);
  return stationTable;
}
 
Example 17
Source File: NestedTable.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
NestedTable(NetcdfDataset ds, TableConfig config, Formatter errlog) {
  this.ds = ds;
  this.errlog = errlog;

  this.leaf = Table.factory(ds, config);
  this.root = getRoot();

  // use the featureType from the highest level table
  nlevels = 0;
  Table t = leaf;
  while (t != null) {
    if (t.getFeatureType() != null)
      featureType = t.getFeatureType();
    t = t.parent;
    // if (!(t instanceof Table.TableTop)) // LOOK using nlevels is fishy
    nlevels++;
  }
  if (featureType == null)
    featureType = FeatureDatasetFactoryManager.findFeatureType(ds);

  /*
   * find joins with extra variables
   * t = leaf;
   * while (t != null) {
   * if (t.extraJoins != null) {
   * for (Join j : t.extraJoins) {
   * addExtraVariable(j.getExtraVariable());
   * }
   * }
   * t = t.parent; // recurse upwards
   * }
   */

  // will find the first one, starting at the leaf and going up
  timeVE = findCoordinateAxis(Table.CoordName.Time, leaf, 0);
  latVE = findCoordinateAxis(Table.CoordName.Lat, leaf, 0);
  lonVE = findCoordinateAxis(Table.CoordName.Lon, leaf, 0);
  altVE = findCoordinateAxis(Table.CoordName.Elev, leaf, 0);
  nomTimeVE = findCoordinateAxis(Table.CoordName.TimeNominal, leaf, 0);

  // search for station info
  stnVE = findCoordinateAxis(Table.CoordName.StnId, leaf, 0);
  stnDescVE = findCoordinateAxis(Table.CoordName.StnDesc, leaf, 0);
  wmoVE = findCoordinateAxis(Table.CoordName.WmoId, leaf, 0);
  stnAltVE = findCoordinateAxis(Table.CoordName.StnAlt, leaf, 0);

  missingVE = findCoordinateAxis(Table.CoordName.MissingVar, leaf, 0);
  idVE = findCoordinateAxis(Table.CoordName.FeatureId, root, nlevels - 1); // LOOK start at root ??

  // LOOK: Major kludge
  if (featureType == null) {
    if (nlevels == 1)
      featureType = FeatureType.POINT;
    if (nlevels == 2)
      featureType = FeatureType.STATION;
    if (nlevels == 3)
      featureType = FeatureType.STATION_PROFILE;
  }

  // find coordinates that are not part of the extras
  for (CoordinateAxis axis : ds.getCoordinateAxes()) {
    if (!isCoordinate(axis) && !isExtra(axis) && axis.getDimensionsAll().size() <= 1) // Only permit 0-D and 1-D axes
                                                                                      // as extra variables.
      addExtraVariable(axis);
  }

  /*
   * check for singleton
   * if (((nlevels == 1) && (featureType == FeatureType.STATION) || (featureType == FeatureType.PROFILE) ||
   * (featureType == FeatureType.TRAJECTORY)) ||
   * ((nlevels == 2) && (featureType == FeatureType.STATION_PROFILE) || (featureType ==
   * FeatureType.TRAJECTORY_PROFILE))) {
   * 
   * // singleton. use file name as feature name, so aggregation will work
   * StructureData sdata = StructureDataFactory.make(featureVariableName, ds.getLocation());
   * TableConfig parentConfig = new TableConfig(Table.Type.Singleton, featureType.toString());
   * parentConfig.sdata = sdata;
   * root = Table.factory(ds, parentConfig);
   * 
   * nlevels++;
   * } //
   */
}
 
Example 18
Source File: PointDatasetStandardFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
PointDatasetStandard(FeatureType wantFeatureType, TableAnalyzer analyser, NetcdfDataset ds, Formatter errlog) {
  super(ds, null);
  parseInfo.format(" PointFeatureDatasetImpl=%s%n", getClass().getName());
  this.analyser = analyser;

  List<DsgFeatureCollection> featureCollections = new ArrayList<>();
  for (NestedTable flatTable : analyser.getFlatTables()) { // each flat table becomes a "feature collection"

    CalendarDateUnit timeUnit;
    try {
      timeUnit = flatTable.getTimeUnit();
    } catch (Exception e) {
      if (null != errlog)
        errlog.format("%s%n", e.getMessage());
      timeUnit = CalendarDateUnit.unixDateUnit;
    }

    String altUnits = flatTable.getAltUnits();

    // create member variables
    dataVariables = new ArrayList<>(flatTable.getDataVariables());

    featureType = flatTable.getFeatureType(); // hope they're all the same
    if (flatTable.getFeatureType() == FeatureType.POINT)
      featureCollections.add(new StandardPointCollectionImpl(flatTable, timeUnit, altUnits));

    else if (flatTable.getFeatureType() == FeatureType.PROFILE)
      featureCollections.add(new StandardProfileCollectionImpl(flatTable, timeUnit, altUnits));

    else if (flatTable.getFeatureType() == FeatureType.STATION)
      featureCollections.add(new StandardStationCollectionImpl(flatTable, timeUnit, altUnits));

    else if (flatTable.getFeatureType() == FeatureType.STATION_PROFILE)
      featureCollections.add(new StandardStationProfileCollectionImpl(flatTable, timeUnit, altUnits));

    else if (flatTable.getFeatureType() == FeatureType.TRAJECTORY_PROFILE)
      featureCollections.add(new StandardSectionCollectionImpl(flatTable, timeUnit, altUnits));

    else if (flatTable.getFeatureType() == FeatureType.TRAJECTORY)
      featureCollections.add(new StandardTrajectoryCollectionImpl(flatTable, timeUnit, altUnits));
  }

  if (featureCollections.isEmpty())
    throw new IllegalStateException("No feature collections found");

  setPointFeatureCollection(featureCollections);
}
 
Example 19
Source File: CoverageAsPoint.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public FeatureDatasetPoint asFeatureDatasetPoint() {
  // for the moment, assume a single station, no vert coord, single lat/lon
  return new CoverageAsFeatureDatasetPoint(FeatureType.STATION);
}
 
Example 20
Source File: MetadataExtractor.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Extract a list of data variables (and their canonical names if possible) from the dataset.
 * 
 * @param threddsDataset open this dataset
 * @return ThreddsMetadata.Variables, or null if unable.
 * @throws IOException on read error
 */
public static ThreddsMetadata.Variables extractVariables(InvDatasetImpl threddsDataset) throws IOException {
  ThreddsDataFactory.Result result = null;

  try {
    result = new ThreddsDataFactory().openFeatureDataset(threddsDataset, null);
    if (result.fatalError) {
      System.out.println(" openDatatype errs=" + result.errLog);
      return null;
    }

    if (result.featureType == FeatureType.GRID) {
      // System.out.println(" extractVariables GRID=" + result.location);
      GridDataset gridDataset = (GridDataset) result.featureDataset;
      return extractVariables(threddsDataset, gridDataset);

    } else if ((result.featureType == FeatureType.STATION) || (result.featureType == FeatureType.POINT)) {
      PointObsDataset pobsDataset = (PointObsDataset) result.featureDataset;
      ThreddsMetadata.Variables vars = new ThreddsMetadata.Variables("CF-1.0");
      for (VariableSimpleIF vs : pobsDataset.getDataVariables()) {
        ThreddsMetadata.Variable v = new ThreddsMetadata.Variable();
        vars.addVariable(v);

        v.setName(vs.getShortName());
        v.setDescription(vs.getDescription());
        v.setUnits(vs.getUnitsString());

        ucar.nc2.Attribute att = vs.findAttributeIgnoreCase("standard_name");
        if (att != null)
          v.setVocabularyName(att.getStringValue());
      }
      vars.sort();
      return vars;
    }

  } finally {
    try {
      if ((result != null) && (result.featureDataset != null))
        result.featureDataset.close();
    } catch (IOException ioe) {
      logger.error("Closing dataset " + result.featureDataset, ioe);
    }
  }

  return null;
}