/**
   * Getting data for a single radar station, with time range.
   *
   * @param sName radar station name
   * @param dateSelect the date time selection information
   * @param cancel _more_
   * @return list of radialDatasetSweep
   * @throws IOException _more_
   */
  public List getData(String sName, DateSelection dateSelect, ucar.nc2.util.CancelTask cancel)
      throws IOException {
    if ((cancel != null) && cancel.isCancel()) {
      return null;
    }
    TDSRadarDatasetInfo dri =
        queryRadarStation(sName, dateSelect.getStartFixedDate(), dateSelect.getEndFixedDate());
    List datasetList = new ArrayList();

    List datasetINVs = dateSelect.apply(dri.getInvList());

    Iterator it = datasetINVs.iterator();
    while (it.hasNext()) {
      InvDatasetInfo ifo = (InvDatasetInfo) it.next();
      InvDataset tdata = ifo.inv;
      ThreddsDataFactory tdFactory = new ThreddsDataFactory();
      ThreddsDataFactory.Result result;
      result = tdFactory.openFeatureDataset(tdata, null);
      datasetList.add(result.featureDataset);
      if ((cancel != null) && cancel.isCancel()) {
        return null;
      }
    }

    return datasetList;
  }
  /**
   * get all radar station.
   *
   * @return List of type Station objects
   */
  public List<Station> getRadarStations() {
    List<Station> slist = new ArrayList<Station>();
    Iterator it = this.stationHMap.values().iterator();
    while (it.hasNext()) {
      slist.add((Station) it.next());
    }

    return slist;
  }
  /**
   * get all radar station.
   *
   * @return List of type DqcRadarStation objects
   * @throws IOException java io exception
   */
  public List getRadarStations() {
    List sl = selStation.getStations();
    ArrayList dsl = new ArrayList();

    for (Iterator it = sl.iterator(); it.hasNext(); ) {
      Station s = (Station) it.next();
      dsl.add(s);
    }
    return dsl;
  }
  /**
   * get all radar station within box.
   *
   * @param boundingBox _more_
   * @param cancel _more_
   * @return List of type DqcRadarStation objects
   * @throws IOException java io exception
   */
  public List getStations(
      ucar.unidata.geoloc.LatLonRect boundingBox, ucar.nc2.util.CancelTask cancel)
      throws IOException {
    List sl = selStation.getStations();
    ArrayList dsl = new ArrayList();

    for (Iterator it = sl.iterator(); it.hasNext(); ) {
      Station s = (Station) it.next();
      LatLonPointImpl latlonPt = new LatLonPointImpl();
      latlonPt.set(s.getLocation().getLatitude(), s.getLocation().getLongitude());
      if (boundingBox.contains(latlonPt)) {
        dsl.add(s);
      }
      if ((cancel != null) && cancel.isCancel()) {
        return null;
      }
    }

    return dsl;
  }
  /**
   * _more_
   *
   * @param sName _more_
   * @param dateSelect _more_
   * @param cancel _more_
   * @return _more_
   * @throws IOException _more_
   */
  public ArrayList getDataURIs(
      String sName, DateSelection dateSelect, ucar.nc2.util.CancelTask cancel) throws IOException {
    if ((cancel != null) && cancel.isCancel()) {
      return null;
    }
    DqcRadarDatasetInfo dri =
        queryRadarStation(sName, dateSelect.getStartFixedDate(), dateSelect.getEndFixedDate());

    // create a list to hold URIs
    List datasetsURIs = dateSelect.apply(dri.getURIList());
    ArrayList uriList = new ArrayList();

    Iterator it = datasetsURIs.iterator();
    while (it.hasNext()) {
      DatasetURIInfo ufo = (DatasetURIInfo) it.next();
      URI u = ufo.uri;
      uriList.add(u);
      if ((cancel != null) && cancel.isCancel()) {
        return null;
      }
    }

    return uriList;
  }
Esempio n. 6
0
  private void level2level3catalog(
      RadarType radarType,
      String pathInfo,
      PrintWriter pw,
      HttpServletRequest req,
      HttpServletResponse res)
      throws IOException {

    try {
      String type;
      if (pathInfo.contains("level2")) type = radarType.toString() + "/level2";
      else type = radarType.toString() + "/level3";

      ByteArrayOutputStream os = new ByteArrayOutputStream(10000);
      InvCatalogFactory factory = InvCatalogFactory.getDefaultFactory(false);
      factory.writeXML(cat, os, true);
      InvCatalogImpl tCat = factory.readXML(new ByteArrayInputStream(os.toByteArray()), catURI);

      Iterator parents = tCat.getDatasets().iterator();
      while (parents.hasNext()) {
        ArrayList<InvDatasetImpl> delete = new ArrayList<InvDatasetImpl>();
        InvDatasetImpl top = (InvDatasetImpl) parents.next();
        Iterator tDatasets = top.getDatasets().iterator();
        while (tDatasets.hasNext()) {
          InvDatasetImpl ds = (InvDatasetImpl) tDatasets.next();
          if (ds instanceof InvDatasetScan) {
            InvDatasetScan ids = (InvDatasetScan) ds;
            if (ids.getPath() == null) continue;
            if (ids.getPath().contains(type)) {
              ids.setXlinkHref(ids.getPath() + "/dataset.xml");
            } else {
              delete.add(ds);
            }
          }
        }
        // remove datasets
        for (InvDatasetImpl idi : delete) {
          top.removeDataset(idi);
        }
      }
      if (pathInfo.endsWith("xml")) {
        String catAsString = factory.writeXML(tCat);
        pw.println(catAsString);
        pw.flush();
      } else {
        HtmlWriter.getInstance().writeCatalog(req, res, tCat, true); // show catalog as HTML
      }
    } catch (Throwable e) {
      log.error("RadarServer.level2level3catalog failed", e);
      if (!res.isCommitted()) res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    return;
  }