コード例 #1
0
  /**
   * initiate a new TDS radar dataset collection object
   *
   * @param desc description
   * @param dsc_location location of dataset
   * @param elem dataset root element
   * @param ns dataset namespace
   * @param errlog error log
   * @throws IOException _more_
   */
  private IdvRadarDatasetCollection(
      String desc, String dsc_location, Element elem, Namespace ns, StringBuffer errlog)
      throws IOException {
    super();
    Element serviceElem = readElements(elem, "service");
    Element dsElem = readElements(elem, "dataset");

    Element metaElem = readElements(dsElem, "metadata");
    // HashMap stationHMap = readSelectStations(metaElem, ns);
    String sts = dsc_location.replaceFirst("dataset.xml", "stations.xml");
    HashMap stationHMap = readRadarStations(sts);
    LatLonRect radarRegion = readSelectRegion(metaElem, ns);
    List<String> radarTimeSpan = readSelectTime(metaElem, ns);
    List<Product> productList = readSelectVariable(metaElem, ns);
    String summary = readSelectDocument(metaElem, ns);

    // gotta have these
    if (stationHMap == null) {
      errlog.append("TDSRadarDatasetCollection must have station selected");
      return;
    }
    if (radarRegion == null) {
      errlog.append("TDSRadarDatasetCollection must have region selected");
      return;
    }
    if (radarTimeSpan == null) {
      errlog.append("TDSRadarDatasetCollection must have time span selected");
      return;
    }

    this.desc = desc;
    this.dsc_location = dsc_location;
    this.radarProducts = productList;
    this.summary = summary;
    this.stationHMap = stationHMap;
    this.radarRegion = radarRegion;
    this.radarTimeSpan = radarTimeSpan;
    this.startDate = DateUnit.getStandardOrISO((String) radarTimeSpan.get(0));
    this.endDate = DateUnit.getStandardOrISO((String) radarTimeSpan.get(1));

    try {
      timeUnit = new DateUnit("hours since 1991-01-01T00:00");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  /**
   * tds radar dataset collection factory
   *
   * @param desc _more_
   * @param dsc_location _more_
   * @param errlog _more_
   * @return dataset collection
   * @throws IOException _more_
   */
  public static IdvRadarDatasetCollection factory(
      String desc, String dsc_location, StringBuffer errlog) throws IOException {
    // super();
    SAXBuilder builder;
    Document doc = null;
    XMLEntityResolver jaxp = new XMLEntityResolver(true);
    builder = jaxp.getSAXBuilder();

    try {
      doc = builder.build(dsc_location);
    } catch (JDOMException e) {
      errlog.append(e.toString());
    }

    Element qcElem = doc.getRootElement();
    Namespace ns = qcElem.getNamespace();

    return new IdvRadarDatasetCollection(desc, dsc_location, qcElem, ns, errlog);
  }