/** * Getting URI for a single radar station. * * @param stnName radar station name * @param absTime is absolute time * @return URI * @throws IOException java io exception */ public URI getRadarDatasetURI(String stnName, Date absTime) throws IOException { // absTime is a member of datasetsDateURI InvDataset invdata = queryRadarStation(stnName, absTime); List<InvAccess> acess = invdata.getAccess(); InvAccess ia = (InvAccess) acess.get(0); URI ui = ia.getStandardUri(); if (ui == null) { throw new IOException("Invalid time selected: " + absTime.toString() + "\n"); } return ui; }
/** * _more_ * * @param stnName _more_ * @param productID _more_ * @param absTime _more_ * @return _more_ * @throws IOException _more_ */ public URI getRadarDatasetURI(String stnName, String productID, Date absTime) throws IOException { // absTime is a member of datasetsDateURI if (productID == null) { return getRadarDatasetURI(stnName, absTime); } InvDataset invdata = queryRadarStation(stnName, productID, absTime); /* List dsets = idata.getDatasets(); int siz = dsets.size(); if(siz != 1) return null; InvDataset invdata = (InvDataset)dsets.get(0); */ List acess = invdata.getAccess(); InvAccess ia = (InvAccess) acess.get(0); URI ui = ia.getStandardUri(); if (ui == null) { throw new IOException("Invalid time selected: " + absTime.toString() + "\n"); } return ui; }
/** * 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; }