org.opengis.wrapper.netcdf
Class NetcdfCRSTest

Show UML class diagram
Object
  extended by IOTestCase
      extended by NetcdfCRSTest

public class NetcdfCRSTest
extends IOTestCase

Tests the NetcdfCRS class using Coordinate Systems built from test files. Each test defined in this class performs the following steps:

External projects can override the wrap(CoordinateSystem, NetcdfDataset) method in order to test their own NetCDF wrapper, as in the example below:
public class MyTest extends NetcdfCRSTest {
    @Override
    protected CoordinateReferenceSystem wrap(CoordinateSystem cs, NetcdfDataset file) throws IOException {
        return new MyWrapper(cs);
    }
}

Since:
3.1

Field Summary
protected  CoordinateReferenceSystem crs
          The CRS object being tested.
protected  TemporalCRS temporalCRS
          If the tested crs has a temporal component, that component.
protected  CRSValidator validator
          The validator to use for validating the CoordinateReferenceSystem instance.
protected  VerticalCRS verticalCRS
          If the tested crs has a vertical component, that component.
 
Fields inherited from class IOTestCase
CIP, LANDSAT, NCEP, THREDDS
 
Constructor Summary
  NetcdfCRSTest()
          Creates a new test case using the default validator.
protected NetcdfCRSTest(CRSValidator validator)
          Creates a new test case using the given validator.
 
Method Summary
protected  void assertNameEquals(String expected, IdentifiedObject object)
          Asserts that the a name or identifier of the given identified object is equals to the given value.
 void testGeographic_XYT()
          Tests the compound CRS (geographic + time) declared in the "NCEP-SST.nc" file.
 void testGeographic()
          Tests the geographic CRS declared in the "THREDDS.ncml" file.
 void testProjected_XYZT()
          Tests the compound CRS (projected + height + time) declared in the "CIP.nc" file.
protected  CoordinateReferenceSystem wrap(CoordinateSystem cs, NetcdfDataset file)
          Wraps the given NetCDF file into a GeoAPI CRS object.
 
Methods inherited from class IOTestCase
open
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validator

protected final CRSValidator validator
The validator to use for validating the CoordinateReferenceSystem instance. This validator is specified at construction time.


crs

protected CoordinateReferenceSystem crs
The CRS object being tested. This field is set to the value returned by wrap(CoordinateSystem, NetcdfDataset) when a testXXX() method is executed.


verticalCRS

protected VerticalCRS verticalCRS
If the tested crs has a vertical component, that component. Otherwise, null. This field is set when a testXXX() method from this class is executed.


temporalCRS

protected TemporalCRS temporalCRS
If the tested crs has a temporal component, that component. Otherwise, null. This field is set when a testXXX() method from this class is executed.

Constructor Detail

NetcdfCRSTest

public NetcdfCRSTest()
Creates a new test case using the default validator. This constructor sets the CRSValidator.enforceStandardNames field to false, since NetCDF axis names are non-standard.


NetcdfCRSTest

protected NetcdfCRSTest(CRSValidator validator)
Creates a new test case using the given validator. This constructor is provided for subclasses wanting to use different validation methods. It is caller responsibility to configure the given validator (for example whether to enforce standard names or not).

Parameters:
validator - The validator to use for validating the CoordinateReferenceSystem instance.
Method Detail

wrap

protected CoordinateReferenceSystem wrap(CoordinateSystem cs,
                                         NetcdfDataset file)
                                  throws IOException
Wraps the given NetCDF file into a GeoAPI CRS object. The default implementation creates a NetcdfCRS instance. Subclasses can override this method for creating their own instance.

Parameters:
cs - The NetCDF coordinate system to wrap.
file - The originating dataset file, or null if none.
Returns:
A CRS implementation created from the given NetCDF coordinate system.
Throws:
IOException - If an error occurred while wrapping the given NetCDF coordinate system.

assertNameEquals

protected void assertNameEquals(String expected,
                                IdentifiedObject object)
Asserts that the a name or identifier of the given identified object is equals to the given value. The default implementation verifies that the name has the following properties: Subclasses shall override this method if the NetCDF name is stored elsewhere (as an identifier or an alias), or if they use a different code value.

Parameters:
expected - The expected code value.
object - The identified object to verify.

testGeographic

public void testGeographic()
                    throws IOException
Tests the geographic CRS declared in the "THREDDS.ncml" file. The default implementation tests the following conditions: The checks for CRS and axis names can be modified by overriding the assertNameEquals(String, IdentifiedObject) method.

Throws:
IOException - If an error occurred while reading the test file.

testGeographic_XYT

public void testGeographic_XYT()
                        throws IOException
Tests the compound CRS (geographic + time) declared in the "NCEP-SST.nc" file. The default implementation tests the following conditions: The checks for CRS and axis names can be modified by overriding the assertNameEquals(String, IdentifiedObject) method.

Throws:
IOException - If an error occurred while reading the test file.

testProjected_XYZT

public void testProjected_XYZT()
                        throws IOException
Tests the compound CRS (projected + height + time) declared in the "CIP.nc" file. The default implementation tests the following conditions: The checks for CRS and axis names can be modified by overriding the assertNameEquals(String, IdentifiedObject) method.

Throws:
IOException - If an error occurred while reading the test file.


Copyright © 1994-2013 Open Geospatial Consortium. All Rights Reserved.