/** * Getting invDataset list for a single radar station. * * @param stnName radar station name * @param start of the time * @param end of the time * @return list of invDataset * @throws IOException java io exception */ private DqcRadarDatasetInfo queryRadarStation(String stnName, Date start, Date end) throws IOException { // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest StringBuffer queryb = new StringBuffer(); queryb.append(dqc.getQuery().getUriResolved().toString()); queryb.append("serviceType=OPENDAP"); queryb.append("&stn=" + stnName); if ((start == null) && (end == null)) { queryb.append("&dtime=all"); } else { String stime = DateUtil.getTimeAsISO8601(start); String etime = DateUtil.getTimeAsISO8601(end); queryb.append("&dateStart=" + stime); queryb.append("&dateEnd=" + 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); InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI); StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString()); } List datasets = catalog.getDatasets(); InvDataset idata = (InvDataset) datasets.get(0); // List ddate = idata.getDates(); ArrayList dsets = (ArrayList) idata.getDatasets(); ArrayList absTimeList = new ArrayList(); ArrayList dURIList = new ArrayList(); ArrayList dInvList = new ArrayList(); for (int i = 0; i < dsets.size(); i++) { InvDataset tdata = (InvDataset) dsets.get(i); List acess = tdata.getAccess(); List dates = tdata.getDates(); InvAccess ia = (InvAccess) acess.get(0); URI d = ia.getStandardUri(); Date date = DateUnit.getStandardOrISO(dates.get(0).toString()); absTimeList.add(date); dURIList.add(new DatasetURIInfo(d, date)); dInvList.add(new InvDatasetInfo(tdata, date)); } DqcRadarDatasetInfo dri = new DqcRadarDatasetInfo(absTimeList, dURIList, dInvList); return dri; }
/** * 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 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 URI for a single radar station. * * @param stnName radar station name * @param absTime is absolute time * @return InvDataset * @throws IOException java io exception */ private InvDataset queryRadarStation(String stnName, Date absTime) throws IOException { String stime = DateUtil.getTimeAsISO8601(absTime); // construct a query like this: // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest StringBuffer queryb = new StringBuffer(); queryb.append(dqc.getQuery().getUriResolved().toString()); queryb.append("serviceType=OPENDAP"); queryb.append("&stn=" + stnName); queryb.append("&dtime=" + stime); 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); InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI); StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString()); } List datasets = catalog.getDatasets(); InvDataset idata = (InvDataset) datasets.get(0); ArrayList dsets = (ArrayList) idata.getDatasets(); InvDataset tdata = (InvDataset) dsets.get(0); return tdata; }
/** * _more_ * * @param ds _more_ * @param dqc_location _more_ * @param errlog _more_ * @return _more_ * @throws IOException _more_ */ public static DqcRadarDatasetCollection factory( InvDataset ds, String dqc_location, StringBuffer errlog) throws IOException { return factory(ds.getDocumentation("summary"), dqc_location, errlog); }