Search in sources :

Example 1 with CSAuthorityFactory

use of org.opengis.referencing.cs.CSAuthorityFactory in project sis by apache.

the class CodesTest method verify.

/**
 * Compares the axis directions and units with EPSG definitions.
 *
 * @throws Exception if an error occurred while fetching the codes or querying the database.
 */
@Test
@SuppressWarnings("unchecked")
public void verify() throws Exception {
    final CSAuthorityFactory factory = TestFactorySource.getSharedFactory();
    final Field field = Codes.class.getDeclaredField("EPSG");
    field.setAccessible(true);
    for (final Codes c : ((Map<Codes, ?>) field.get(null)).keySet()) {
        final CoordinateSystem cs = factory.createCoordinateSystem(String.valueOf(c.epsg));
        final Unit<?> unit = cs.getAxis(0).getUnit();
        final AxisDirection[] directions = new AxisDirection[cs.getDimension()];
        for (int i = 0; i < directions.length; i++) {
            assertEquals(unit, cs.getAxis(i).getUnit());
            directions[i] = cs.getAxis(i).getDirection();
        }
        assertEquals("Codes.lookpup(…)", c.epsg, Codes.lookup(unit, directions));
    }
}
Also used : Field(java.lang.reflect.Field) CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) CSAuthorityFactory(org.opengis.referencing.cs.CSAuthorityFactory) AxisDirection(org.opengis.referencing.cs.AxisDirection) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Field (java.lang.reflect.Field)1 Map (java.util.Map)1 Test (org.junit.Test)1 AxisDirection (org.opengis.referencing.cs.AxisDirection)1 CSAuthorityFactory (org.opengis.referencing.cs.CSAuthorityFactory)1 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)1