Search in sources :

Example 36 with GeographicCRS

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);
}
Also used : GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test)

Example 37 with GeographicCRS

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));
}
Also used : GeographicCRS(org.opengis.referencing.crs.GeographicCRS) DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) Test(org.junit.Test)

Example 38 with GeographicCRS

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);
}
Also used : GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test)

Example 39 with GeographicCRS

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());
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test)

Example 40 with GeographicCRS

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);
}
Also used : Angle(javax.measure.quantity.Angle) Length(javax.measure.quantity.Length) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) Conversion(org.opengis.referencing.operation.Conversion)

Aggregations

GeographicCRS (org.opengis.referencing.crs.GeographicCRS)40 Test (org.junit.Test)27 DependsOnMethod (org.apache.sis.test.DependsOnMethod)15 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)10 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)9 Conversion (org.opengis.referencing.operation.Conversion)6 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)6 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)5 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)4 GeographicBoundingBox (org.opengis.metadata.extent.GeographicBoundingBox)4 CartesianCS (org.opengis.referencing.cs.CartesianCS)4 DefaultGeographicBoundingBox (org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox)3 DefaultGeographicCRS (org.apache.sis.referencing.crs.DefaultGeographicCRS)3 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)3 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)3 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)3 TransformException (org.opengis.referencing.operation.TransformException)3 HashMap (java.util.HashMap)2 Angle (javax.measure.quantity.Angle)2 Length (javax.measure.quantity.Length)2