コード例 #1
0
  /**
   * get all radar station within box.
   *
   * @param boundingBox the bounding box
   * @param cancel the cancel task
   * @return List Station objects
   * @throws IOException java io exception
   */
  public List<Station> getStations(LatLonRect boundingBox, ucar.nc2.util.CancelTask cancel)
      throws IOException {
    Collection<Station> sl = stationHMap.values();
    List<Station> dsl = new ArrayList();

    if (!boundingBox.containedIn(radarRegion)) {
      return null;
    }

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

    return dsl;
  }
コード例 #2
0
  /**
   * 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;
  }
コード例 #3
0
  /**
   * get all radar station.
   *
   * @return List of type Station objects
   */
  public List<Station> getRadarStations() {
    List<Station> slist = new ArrayList();
    Iterator it = this.stationHMap.values().iterator();
    while (it.hasNext()) {
      slist.add((Station) it.next());
    }

    return slist;
  }
コード例 #4
0
  /**
   * Getting data for a single radar station.
   *
   * @param stnName radar station name
   * @param start of the time
   * @param end of the time
   * @return data URI list
   * @throws IOException java io exception
   */
  public List getRadarStationURIs(String stnName, Date start, Date end) throws IOException {

    TDSRadarDatasetInfo dri = queryRadarStation(stnName, start, end);
    List<DatasetURIInfo> uList = dri.getURIList();
    List<URI> datasetsURI = new ArrayList();
    for (DatasetURIInfo du : uList) {
      datasetsURI.add(du.uri);
    }

    return datasetsURI;
  }
コード例 #5
0
  /**
   * get variable list from parent element
   *
   * @param elem _more_
   * @param ns _more_
   * @return list of varibles
   */
  public List<Product> readSelectVariable(Element elem, Namespace ns) {
    // look for stations
    List<Product> varlist = new ArrayList<Product>();
    Element v = elem.getChild("Variables", ns);

    List<Element> varInfo = v.getChildren();
    for (Element p : varInfo) {
      Product s;
      String id = p.getAttributeValue("name");
      if (id.contains("/")) {
        String c[] = id.split("/");
        s = new Product(c[0], c[1]);
        varlist.add(s);

      } else {
        String name = p.getAttributeValue("vocabulary_name");
        s = new Product(id, name);
        varlist.add(s);
      }
    }
    return varlist;
  }
コード例 #6
0
  /**
   * Getting data Iterator for a single radar station.
   *
   * @param stnName radar station name
   * @param start of the time
   * @param end of the time
   * @return dataset list
   * @throws IOException java io exception
   */
  public List getRadarStationDatasets(String stnName, Date start, Date end) throws IOException {

    List datasetList = new ArrayList();

    TDSRadarDatasetInfo dri = queryRadarStation(stnName, start, end);
    List<InvDatasetInfo> iList = dri.getInvList();
    for (InvDatasetInfo iv : iList) {
      InvDataset tdata = iv.inv;
      ThreddsDataFactory tdFactory = new ThreddsDataFactory();
      ThreddsDataFactory.Result result;
      result = tdFactory.openFeatureDataset(tdata, null);
      datasetList.add(result.featureDataset);
    }

    return datasetList;
  }
コード例 #7
0
  /**
   * get start and end elemnt form parent element
   *
   * @param elem _more_
   * @param ns _more_
   * @return list of times
   */
  public List<String> readSelectTime(Element elem, Namespace ns) {
    // look for stations

    Element region = elem.getChild("TimeSpan", ns);

    java.util.List regionInfo = region.getChildren();
    // lat, lon
    Element start = region.getChild("start", ns);
    String sv = start.getValue();
    Element end = region.getChild("end", ns);
    String ev = end.getValue();

    List<String> ll = new ArrayList<String>();
    ll.add(sv);
    ll.add(ev);
    return ll;
  }
コード例 #8
0
  /**
   * getting data uri list
   *
   * @param sName station name
   * @param dateSelect the date selection
   * @param cancel the cancel task
   * @return the list of URIs
   * @throws IOException problem reading URIs
   */
  public List<URI> getDataURIs(
      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());

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

    for (DatasetURIInfo ufo : datasetsURIs) {
      URI u = ufo.uri;
      uriList.add(u);
      if ((cancel != null) && cancel.isCancel()) {
        return null;
      }
    }

    return uriList;
  }
コード例 #9
0
  /**
   * Getting invDataset list for a single radar station.
   *
   * @param stnName radar station name
   * @param productID _more_
   * @param start of the time
   * @param end of the time
   * @return list of invDataset
   * @throws IOException java io exception
   */
  private TDSRadarDatasetInfo queryRadarStation(
      String stnName, String productID, Date start, Date end) throws IOException {
    // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest
    StringBuilder queryb = new StringBuilder();
    String baseURI = dsc_location.replaceFirst("/dataset.xml", "?");
    queryb.append(baseURI);
    queryb.append("&stn=" + stnName);
    if (productID != null) {
      queryb.append("&var=" + productID);
    }
    if ((start == null) && (end == null)) {
      queryb.append("&time=present");
    } else if (end == null) {
      String stime = DateUtil.getTimeAsISO8601(start).replaceAll("GMT", "");
      queryb.append("&time_start=" + stime);
      queryb.append("&time_end=present");
    } else {
      String stime = DateUtil.getTimeAsISO8601(start).replaceAll("GMT", "");
      String etime = DateUtil.getTimeAsISO8601(end).replaceAll("GMT", "");
      queryb.append("&time_start=" + stime);
      queryb.append("&time_end=" + etime);
    }

    URI catalogURI;
    try {
      catalogURI = new URI(queryb.toString());
    } catch (java.net.URISyntaxException e) {
      throw new IOException("** MalformedURLException on URL <" + ">\n" + e.getMessage() + "\n");
    }

    InvCatalogFactory factory = new InvCatalogFactory("default", false);

    // visad.util.Trace.call1("TDSRadarDatasetCollection.readXML");
    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI);
    // visad.util.Trace.call2("TDSRadarDatasetCollection.readXML");
    StringBuilder buff = new StringBuilder();
    // visad.util.Trace.call1("TDSRadarDatasetCollection.checkCatalog");
    if (!catalog.check(buff)) {
      throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString());
    }
    // visad.util.Trace.call2("TDSRadarDatasetCollection.checkCatalog");

    List<InvDataset> datasets = catalog.getDatasets();

    InvDataset idata = (InvDataset) datasets.get(0);

    List<InvDataset> dsets = idata.getDatasets();

    List<Date> absTimeList = new ArrayList<Date>();
    List<DatasetURIInfo> dURIList = new ArrayList<DatasetURIInfo>();
    List<InvDatasetInfo> dInvList = new ArrayList<InvDatasetInfo>();

    // visad.util.Trace.call1("TDSRadarDatasetCollection.getLists");
    for (InvDataset tdata : dsets) {
      List<InvAccess> acess = tdata.getAccess();
      List<DateType> dates = tdata.getDates();
      InvAccess ia = (InvAccess) acess.get(0);
      URI d = ia.getStandardUri();
      Date date = ((DateType) dates.get(0)).getDate();
      absTimeList.add(date);
      dURIList.add(new DatasetURIInfo(d, date));
      dInvList.add(new InvDatasetInfo(tdata, date));
    }
    // visad.util.Trace.call2("TDSRadarDatasetCollection.getLists");

    TDSRadarDatasetInfo dri = new TDSRadarDatasetInfo(absTimeList, dURIList, dInvList);

    return dri;
  }