Java Code Examples for ucar.nc2.constants.FeatureType#ANY_POINT
The following examples show how to use
ucar.nc2.constants.FeatureType#ANY_POINT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MadisAcars.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) { if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.TRAJECTORY)) return false; String title = ds.getRootGroup().findAttributeString("title", null); if (!"MADIS ACARS data".equals(title)) return false; if (!ds.hasUnlimitedDimension()) return false; if (ds.findDimension("recNum") == null) return false; VNames vn = getVariableNames(ds, null); if (ds.findVariable(vn.lat) == null) return false; if (ds.findVariable(vn.lon) == null) return false; if (ds.findVariable(vn.obsTime) == null) return false; return ds.findVariable(TRAJ_ID) != null; }
Example 2
Source File: UnidataPointObs.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) { if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.STATION) && (wantFeatureType != FeatureType.POINT)) return false; FeatureType ft = FeatureDatasetFactoryManager.findFeatureType(ds); if (((ft != FeatureType.STATION) && (ft != FeatureType.POINT))) return false; String conv = ds.getRootGroup().findAttributeString(CDM.CONVENTIONS, null); if (conv == null) return false; StringTokenizer stoke = new StringTokenizer(conv, ","); while (stoke.hasMoreTokens()) { String toke = stoke.nextToken().trim(); if (toke.equalsIgnoreCase("Unidata Observation Dataset v1.0")) return true; } return false; }
Example 3
Source File: Madis.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) { if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.STATION) && (wantFeatureType != FeatureType.POINT) && (wantFeatureType != FeatureType.STATION_PROFILE)) return false; if (!ds.hasUnlimitedDimension()) return false; if (ds.findDimension("recNum") == null) return false; if (ds.findVariable("staticIds") == null) return false; if (ds.findVariable("nStaticIds") == null) return false; if (ds.findVariable("lastRecord") == null) return false; if (ds.findVariable("prevRecord") == null) return false; VNames vn = getVariableNames(ds, null); if (ds.findVariable(vn.lat) == null) return false; if (ds.findVariable(vn.lon) == null) return false; return ds.findVariable(vn.obsTime) != null; }
Example 4
Source File: CFPointWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(String[] args) throws Exception { String progName = CFPointWriter.class.getName(); try { CommandLine cmdLine = new CommandLine(progName, args); if (cmdLine.help) { cmdLine.printUsage(); return; } FeatureType wantFeatureType = FeatureType.ANY_POINT; String location = cmdLine.inputFile.getAbsolutePath(); CancelTask cancel = null; Formatter errlog = new Formatter(); try (FeatureDatasetPoint fdPoint = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(wantFeatureType, location, cancel, errlog)) { if (fdPoint == null) { System.err.println(errlog); } else { System.out.printf("CFPointWriter: reading from %s, writing to %s%n", cmdLine.inputFile, cmdLine.outputFile); writeFeatureCollection(fdPoint, cmdLine.outputFile.getAbsolutePath(), cmdLine.getCFPointWriterConfig()); System.out.println("Done."); } } } catch (ParameterException e) { System.err.println(e.getMessage()); System.err.printf("Try \"%s --help\" for more information.%n", progName); } }
Example 5
Source File: FeatureDatasetFactoryManager.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Determine if factory type matches wanted feature type. * * @param want want this FeatureType * @param facType factory is of this type * @return true if match */ public static boolean featureTypeOk(FeatureType want, FeatureType facType) { if (want == null) return true; if (want == facType) return true; if (want == FeatureType.ANY_POINT) { return facType.isPointFeatureType(); } if (facType == FeatureType.ANY_POINT) { return want.isPointFeatureType(); } if (want == FeatureType.COVERAGE) { return facType.isCoverageFeatureType(); } if (want == FeatureType.GRID) { // for backwards compatibility return facType.isCoverageFeatureType(); } if (want == FeatureType.SIMPLE_GEOMETRY) { return facType.isCoverageFeatureType(); } if (want == FeatureType.UGRID) { return facType.isUnstructuredGridFeatureType(); } return false; }
Example 6
Source File: PointDatasetStandardFactory.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Check if this is a POINT datatype. If so, a TableAnalyser is used to analyze its structure. * The TableAnalyser is reused when the dataset is opened. * <ol> * <li>Can handle ANY_POINT FeatureType. * <li>Must have time, lat, lon axis (from CoordSysBuilder) * <li>Call TableAnalyzer.factory() to create a TableAnalyzer * <li>TableAnalyzer must agree it can handle the requested FeatureType * </ol> * * @param wantFeatureType desired feature type, null means FeatureType.ANY_POINT * @param ds analyse this dataset * @param errlog log error messages here (may not be null) * @return if successful, return non-null. This object is then passed back into open(), so analysis can be reused. */ @Override public Object isMine(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { if (wantFeatureType == null) wantFeatureType = FeatureType.ANY_POINT; if (wantFeatureType != FeatureType.ANY_POINT) { if (!wantFeatureType.isPointFeatureType()) return null; } TableConfigurer tc = TableAnalyzer.getTableConfigurer(wantFeatureType, ds); // if no explicit tc, then check whatever we can before expensive analysis) if (tc == null) { boolean hasTime = false; boolean hasLat = false; boolean hasLon = false; for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == AxisType.Time) // && (axis.getRank() == 1)) hasTime = true; if (axis.getAxisType() == AxisType.Lat) // && (axis.getRank() == 1)) hasLat = true; if (axis.getAxisType() == AxisType.Lon) // && (axis.getRank() == 1)) hasLon = true; } // minimum we need if (!(hasTime && hasLon && hasLat)) { errlog.format("PointDataset must have lat,lon,time"); return null; } } else if (showTables) { System.out.printf("TableConfigurer = %s%n", tc.getClass().getName()); } try { // gotta do some work TableAnalyzer analyser = TableAnalyzer.factory(tc, wantFeatureType, ds); if (analyser == null) return null; if (!analyser.featureTypeOk(wantFeatureType, errlog)) { return null; } return analyser; } catch (Throwable t) { return null; } }
Example 7
Source File: PointDatasetStandardFactory.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public FeatureType[] getFeatureTypes() { return new FeatureType[] {FeatureType.ANY_POINT}; }
Example 8
Source File: CompositeDatasetFactory.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static FeatureDataset factory(String location, FeatureType wantFeatureType, MFileCollectionManager dcm, Formatter errlog) throws IOException { TimedCollection collection = new TimedCollection(dcm, errlog); if (collection.getDatasets().isEmpty()) { throw new FileNotFoundException("Collection is empty; spec=" + dcm); } DsgFeatureCollection first; TimedCollection.Dataset d = collection.getPrototype(); try (FeatureDatasetPoint proto = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(wantFeatureType, d.getLocation(), null, errlog)) { if (proto == null) { throw new FileNotFoundException("Collection dataset is not a FeatureDatasetPoint; spec=" + dcm); } if (wantFeatureType == FeatureType.ANY_POINT) wantFeatureType = proto.getFeatureType(); List<DsgFeatureCollection> fcList = proto.getPointFeatureCollectionList(); if (fcList.isEmpty()) { throw new FileNotFoundException("FeatureCollectionList is empty; spec=" + dcm); } first = fcList.get(0); // LatLonRect bb = null; DsgFeatureCollection fc; switch (wantFeatureType) { case POINT: PointFeatureCollection firstPc = (PointFeatureCollection) first; CompositePointCollection pfc = new CompositePointCollection(dcm.getCollectionName(), firstPc.getTimeUnit(), firstPc.getAltUnits(), collection); // bb = pfc.getBoundingBox(); fc = pfc; break; case STATION: PointFeatureCC firstNpc = (PointFeatureCC) first; CompositeStationCollection sfc = new CompositeStationCollection(dcm.getCollectionName(), firstNpc.getTimeUnit(), firstNpc.getAltUnits(), collection); // bb = sfc.getBoundingBox(); fc = sfc; break; default: return null; } return new CompositePointDataset(location, wantFeatureType, fc, collection, null); } }
Example 9
Source File: BufrFeatureDatasetFactory.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public FeatureType[] getFeatureTypes() { return new FeatureType[] {FeatureType.ANY_POINT}; }