use of ucar.nc2.dataset.NetcdfDataset in project sis by apache.
the class DecoderWrapper method getDiscreteSampling.
/**
* If this decoder can handle the file content as features, returns handlers for them.
*
* @return {@inheritDoc}
* @throws IOException if an I/O operation was necessary but failed.
* @throws DataStoreException if the library of geometric objects is not available.
*/
@Override
@SuppressWarnings("null")
public DiscreteSampling[] getDiscreteSampling() throws IOException, DataStoreException {
if (features == null && file instanceof NetcdfDataset) {
features = FeatureDatasetFactoryManager.wrap(null, (NetcdfDataset) file, this, new Formatter(new LogAdapter(listeners), listeners.getLocale()));
}
List<FeatureCollection> fc = null;
if (features instanceof FeatureDatasetPoint) {
fc = ((FeatureDatasetPoint) features).getPointFeatureCollectionList();
}
final FeaturesWrapper[] wrappers = new FeaturesWrapper[(fc != null) ? fc.size() : 0];
try {
for (int i = 0; i < wrappers.length; i++) {
wrappers[i] = new FeaturesWrapper(fc.get(i), geomlib, listeners);
}
} catch (IllegalArgumentException e) {
throw new DataStoreException(e.getLocalizedMessage(), e);
}
return wrappers;
}
use of ucar.nc2.dataset.NetcdfDataset in project sis by apache.
the class DecoderWrapper method getGridGeometries.
/**
* Returns all grid geometries (related to coordinate systems) found in the netCDF file.
* This method returns a direct reference to an internal array - do not modify.
*
* @return all grid geometries, or an empty array if none.
* @throws IOException if an I/O operation was necessary but failed.
*/
@Override
@SuppressWarnings({ "ReturnOfCollectionOrArrayField", "null" })
public GridGeometry[] getGridGeometries() throws IOException {
if (geometries == null) {
List<CoordinateSystem> systems = null;
if (file instanceof NetcdfDataset) {
final NetcdfDataset ds = (NetcdfDataset) file;
final EnumSet<NetcdfDataset.Enhance> mode = EnumSet.copyOf(ds.getEnhanceMode());
if (mode.add(NetcdfDataset.Enhance.CoordSystems)) {
ds.enhance(mode);
}
systems = ds.getCoordinateSystems();
}
geometries = new GridGeometry[(systems != null) ? systems.size() : 0];
for (int i = 0; i < geometries.length; i++) {
geometries[i] = new GridGeometryWrapper(systems.get(i));
}
}
return geometries;
}
use of ucar.nc2.dataset.NetcdfDataset in project sis by apache.
the class MetadataReaderTest method testUCAR.
/**
* Reads the metadata using the UCAR library and compares
* its string representation with the expected one.
*
* @throws IOException if an I/O error occurred.
* @throws DataStoreException if a logical error occurred.
*/
@Test
public void testUCAR() throws IOException, DataStoreException {
final Metadata metadata;
try (Decoder input = new DecoderWrapper(new NetcdfDataset(open(NCEP)), GeometryLibrary.JAVA2D, TestCase.LISTENERS)) {
metadata = new MetadataReader(input).read();
}
compareToExpected(metadata);
}
Aggregations