use of org.opengis.referencing.crs.GeographicCRS in project sis by apache.
the class CommonAuthorityFactoryTest method testCRS84.
/**
* Tests {@link CommonAuthorityFactory#createGeographicCRS(String)} with the {@code "CRS:84"} code.
*
* @throws FactoryException if an error occurred while creating a CRS.
*/
@Test
public void testCRS84() throws FactoryException {
GeographicCRS crs = factory.createGeographicCRS("CRS:84");
assertSame(crs, factory.createGeographicCRS("84"));
assertSame(crs, factory.createGeographicCRS("CRS84"));
assertSame(crs, factory.createGeographicCRS("CRS:CRS84"));
assertSame(crs, factory.createGeographicCRS("crs : crs84"));
// Not in real use as far as I know.
assertSame(crs, factory.createGeographicCRS("OGC:84"));
assertSame(crs, factory.createGeographicCRS("OGC:CRS84"));
assertNotSame(crs, factory.createGeographicCRS("CRS:83"));
assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
}
use of org.opengis.referencing.crs.GeographicCRS in project sis by apache.
the class IdentifiedObjectFinderTest method testFindSingleton.
/**
* Tests the {@link IdentifiedObjectFinder#findSingleton(IdentifiedObject)} method.
*
* @throws FactoryException if the creation of a CRS failed.
*/
@Test
public void testFindSingleton() throws FactoryException {
final GeographicCRS CRS84 = factory.createGeographicCRS("CRS:84");
final IdentifiedObjectFinder finder = factory.newIdentifiedObjectFinder();
assertEquals("Newly created finder should default to full scan.", IdentifiedObjectFinder.Domain.VALID_DATASET, finder.getSearchDomain());
finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION);
assertSame("Should find without the need for scan, since we can use the CRS:84 identifier.", CRS84, finder.findSingleton(CRS84));
finder.setSearchDomain(IdentifiedObjectFinder.Domain.VALID_DATASET);
assertSame("Allowing scanning should not make any difference for this CRS84 instance.", CRS84, finder.findSingleton(CRS84));
/*
* Same test than above, using a CRS without identifier.
* The intent is to force a full scan.
*/
final CoordinateReferenceSystem search = new DefaultGeographicCRS(Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, CRS84.getName()), CRS84.getDatum(), CRS84.getCoordinateSystem());
// Required condition for next test.
assertEqualsIgnoreMetadata(CRS84, search);
finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION);
assertNull("Should not find WGS84 without a full scan, since it does not contains the CRS:84 identifier.", finder.findSingleton(search));
finder.setSearchDomain(IdentifiedObjectFinder.Domain.VALID_DATASET);
assertSame("A full scan should allow us to find WGS84, since it is equals ignoring metadata to CRS:84.", CRS84, finder.findSingleton(search));
}
use of org.opengis.referencing.crs.GeographicCRS in project sis by apache.
the class Proj4FactoryTest method test4326.
/**
* Tests the creation of the {@code "+init=epsg:4326"} geographic CRS.
* Note that the axis order is not the same than standard EPSG:4326.
*
* @throws FactoryException if an error occurred while creating the CRS objects.
*/
@Test
public void test4326() throws FactoryException {
final Proj4Factory factory = Proj4Factory.INSTANCE;
final GeographicCRS crs = factory.createGeographicCRS("+init=epsg:4326");
final PJ pj = (PJ) TestUtilities.getSingleton(crs.getIdentifiers());
assertEquals(PJ.Type.GEOGRAPHIC, pj.getType());
final String definition = pj.getCode();
assertTrue(definition, definition.contains("+proj=longlat"));
assertTrue(definition, definition.contains("+datum=WGS84"));
assertAxisDirectionsEqual(definition, crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
}
use of org.opengis.referencing.crs.GeographicCRS in project sis by apache.
the class Proj4FactoryTest method testTransform.
/**
* Tests the transformation from {@code "+init=epsg:4326"} to {@code "+init=epsg:3395"}.
*
* @throws FactoryException if an error occurred while creating the CRS objects.
* @throws TransformException if an error occurred while projecting a test point.
*/
@Test
public void testTransform() throws FactoryException, TransformException {
final Proj4Factory factory = Proj4Factory.INSTANCE;
final GeographicCRS sourceCRS = factory.createGeographicCRS("+init=epsg:4326");
final ProjectedCRS targetCRS = factory.createProjectedCRS("+init=epsg:3395");
final CoordinateOperation op = factory.createOperation(sourceCRS, targetCRS, true);
assertInstanceOf("createOperation", Conversion.class, op);
testMercatorProjection(op.getMathTransform());
}
use of org.opengis.referencing.crs.GeographicCRS in project sis by apache.
the class CRSBuilder method verify.
/**
* Verifies if the user-defined CRS created from GeoTIFF values
* matches the given CRS created from the EPSG geodetic dataset.
* This method does not verify the EPSG code of the given CRS.
*
* @param crs the CRS created from the EPSG geodetic dataset.
*/
private void verify(final ProjectedCRS crs) throws FactoryException {
final Unit<Length> linearUnit = createUnit(GeoKeys.LinearUnits, GeoKeys.LinearUnitSize, Length.class, Units.METRE);
final Unit<Angle> angularUnit = createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize, Angle.class, Units.DEGREE);
final GeographicCRS baseCRS = crs.getBaseCRS();
verifyIdentifier(crs, baseCRS, GeoKeys.GeographicType);
verify(baseCRS, angularUnit);
final Conversion projection = crs.getConversionFromBase();
verifyIdentifier(crs, projection, GeoKeys.Projection);
verify(projection, angularUnit, linearUnit);
}
Aggregations