/** * 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 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 ArrayList getData(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()); ArrayList 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 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; }
/** * 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 ArrayList getRadarStationURIs(String stnName, Date start, Date end) throws IOException { DqcRadarDatasetInfo dri = queryRadarStation(stnName, start, end); ArrayList uList = dri.getURIList(); int size = uList.size(); ArrayList datasetsURI = new ArrayList(); for (int i = 0; i < size; i++) { DatasetURIInfo du = (DatasetURIInfo) uList.get(i); datasetsURI.add(du.uri); } return datasetsURI; }
/** * 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 ArrayList getRadarStationDatasets(String stnName, Date start, Date end) throws IOException { ArrayList datasetList = new ArrayList(); DqcRadarDatasetInfo dri = queryRadarStation(stnName, start, end); ArrayList iList = dri.getInvList(); int size = iList.size(); for (int i = 0; i < size; i++) { InvDatasetInfo iv = (InvDatasetInfo) iList.get(i); InvDataset tdata = iv.inv; ThreddsDataFactory tdFactory = new ThreddsDataFactory(); ThreddsDataFactory.Result result; result = tdFactory.openFeatureDataset(tdata, null); datasetList.add(result.featureDataset); } return datasetList; }
/** * 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; }