private InvDataset processLocation( String location, ucar.nc2.util.CancelTask task, Result result) { location = location.trim(); location = ucar.unidata.util.StringUtil.replace(location, '\\', "/"); if (location.startsWith(SCHEME)) location = location.substring(8); if (location.startsWith("resolve:")) { location = location.substring(8); return openResolver(location, task, result); } if (!location.startsWith("http:") && !location.startsWith("file:")) // LOOK whats this for?? location = "http:" + location; InvCatalog catalog; InvDataset invDataset; String datasetId; int pos = location.indexOf('#'); if (pos < 0) { result.fatalError = true; result.errLog.format("Must have the form catalog.xml#datasetId%n"); return null; } InvCatalogFactory catFactory = new InvCatalogFactory("", false); String catalogLocation = location.substring(0, pos); catalog = catFactory.readXML(catalogLocation); StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format( "Invalid catalog from Resolver <%s>%n%s%n", catalogLocation, buff.toString()); result.fatalError = true; return null; } datasetId = location.substring(pos + 1); invDataset = catalog.findDatasetByID(datasetId); if (invDataset == null) { result.fatalError = true; result.errLog.format("Could not find dataset %s in %s %n", datasetId, catalogLocation); return null; } return invDataset; }
private InvDatasetImpl openResolver( String urlString, ucar.nc2.util.CancelTask task, Result result) { InvCatalogFactory catFactory = new InvCatalogFactory("", false); InvCatalogImpl catalog = catFactory.readXML(urlString); if (catalog == null) { result.errLog.format("Couldnt open Resolver %s %n ", urlString); return null; } StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format("Invalid catalog from Resolver <%s>%n%s%n", urlString, buff.toString()); result.fatalError = true; return null; } InvDataset top = catalog.getDataset(); if (top.hasAccess()) return (InvDatasetImpl) top; else { java.util.List datasets = top.getDatasets(); return (InvDatasetImpl) datasets.get(0); } }
private ThreddsDataFactory.Result openFeatureDataset( FeatureType wantFeatureType, InvAccess access, ucar.nc2.util.CancelTask task, Result result) throws IOException { result.featureType = wantFeatureType; result.accessUsed = access; // special handling for IMAGE if (result.featureType == FeatureType.IMAGE) { result.imageURL = access.getStandardUrlName(); result.location = result.imageURL; return result; } if (access.getService().getServiceType() == ServiceType.CdmrFeature) { result.featureDataset = CdmrFeatureDataset.factory(wantFeatureType, access.getStandardUrlName()); } else { // all other datatypes NetcdfDataset ncd = openDataset(access, true, task, result); if (null != ncd) { result.featureDataset = FeatureDatasetFactoryManager.wrap(result.featureType, ncd, task, result.errLog); } } if (null == result.featureDataset) result.fatalError = true; else { result.location = result.featureDataset.getLocation(); if ((result.featureType == null) && (result.featureDataset != null)) result.featureType = result.featureDataset.getFeatureType(); } return result; }
public ThreddsDataFactory.Result openFeatureDataset( FeatureType wantFeatureType, InvDataset invDataset, ucar.nc2.util.CancelTask task, Result result) throws IOException { result.featureType = invDataset.getDataType(); if (result.featureType == null) result.featureType = wantFeatureType; // look for remote FeatureDataset if ((result.featureType != null) && result.featureType.isPointFeatureType()) { InvAccess access = findAccessByServiceType(invDataset.getAccess(), ServiceType.CdmrFeature); if (access != null) return openFeatureDataset(result.featureType, access, task, result); } // special handling for images if (result.featureType == FeatureType.IMAGE) { InvAccess access = getImageAccess(invDataset, task, result); if (access != null) { return openFeatureDataset(result.featureType, access, task, result); } else result.fatalError = true; return result; } // special handling for DQC InvAccess qc = invDataset.getAccess(ServiceType.QC); if (qc != null) { String dqc_location = qc.getStandardUrlName(); if (result.featureType == FeatureType.STATION) { /* DqcFactory dqcFactory = new DqcFactory(true); QueryCapability dqc = dqcFactory.readXML(dqc_location); if (dqc.hasFatalError()) { result.errLog.append(dqc.getErrorMessages()); result.fatalError = true; } */ result.featureDataset = null; // LOOK FIX ucar.nc2.thredds.DqcStationObsDataset.factory(invDataset, // dqc_location, result.errLog); result.fatalError = (result.featureDataset == null); } else { result.errLog.format("DQC must be station DQC, dataset = %s %n", invDataset.getName()); result.fatalError = true; } return result; } NetcdfDataset ncd = openDataset(invDataset, true, task, result.errLog); if (null != ncd) result.featureDataset = FeatureDatasetFactoryManager.wrap(result.featureType, ncd, task, result.errLog); if (null == result.featureDataset) result.fatalError = true; else { result.location = result.featureDataset.getLocation(); if ((result.featureType == null) && (result.featureDataset != null)) result.featureType = result.featureDataset.getFeatureType(); } return result; }