use of org.apache.sis.io.wkt.UnformattableObjectException in project sis by apache.
the class ConsistencyTest method testCoordinateReferenceSystems.
/**
* Verifies the WKT consistency of all CRS instances.
*
* @throws FactoryException if an error other than "unsupported operation method" occurred.
*/
@Test
public void testCoordinateReferenceSystems() throws FactoryException {
assumeTrue(RUN_EXTENSIVE_TESTS);
final WKTFormat v1 = new WKTFormat(null, null);
final WKTFormat v1c = new WKTFormat(null, null);
final WKTFormat v2 = new WKTFormat(null, null);
final WKTFormat v2s = new WKTFormat(null, null);
v1.setConvention(Convention.WKT1);
v1c.setConvention(Convention.WKT1_COMMON_UNITS);
v2.setConvention(Convention.WKT2);
v2s.setConvention(Convention.WKT2_SIMPLIFIED);
for (final String code : CRS.getAuthorityFactory(null).getAuthorityCodes(CoordinateReferenceSystem.class)) {
if (!EXCLUDES.contains(code)) {
final CoordinateReferenceSystem crs;
try {
crs = CRS.forCode(code);
} catch (UnavailableFactoryException | NoSuchIdentifierException | FactoryDataException e) {
print(code, "WARNING", e.getLocalizedMessage());
continue;
}
lookup(parseAndFormat(v2, code, crs), crs);
lookup(parseAndFormat(v2s, code, crs), crs);
/*
* There is more information lost in WKT 1 than in WKT 2, so we can not test everything.
* For example we can not format fully three-dimensional geographic CRS because the unit
* is not the same for all axes. We can not format neither some axis directions.
*/
try {
parseAndFormat(v1, code, crs);
} catch (UnformattableObjectException e) {
print(code, "WARNING", e.getLocalizedMessage());
continue;
}
parseAndFormat(v1c, code, crs);
}
}
}
Aggregations