@Test public void test42003() throws FactoryException { ProjectedCRS eqc = factory.createProjectedCRS("AUTO:42003,9001,0.0,0"); assertEquals("Orthographic", eqc.getConversionFromBase().getMethod().getName().getCode()); assertTrue( eqc.getConversionFromBase().getMathTransform() instanceof EquatorialOrthographic); eqc = factory.createProjectedCRS("AUTO:42003,9001,0.0,90"); assertEquals("Orthographic", eqc.getConversionFromBase().getMethod().getName().getCode()); assertTrue(eqc.getConversionFromBase().getMathTransform() instanceof PolarOrthographic); eqc = factory.createProjectedCRS("AUTO:42003,9001,0.0,45"); assertEquals("Orthographic", eqc.getConversionFromBase().getMethod().getName().getCode()); assertTrue(eqc.getConversionFromBase().getMathTransform() instanceof ObliqueOrthographic); }
assertEquals( "Transverse_Mercator", geocrs.getConversionFromBase().getMethod().getName().toString());
assertEquals( "Popular Visualisation Pseudo Mercator", esriCrs.getConversionFromBase().getMethod().getName().getCode());
/** Check we can parse also the unit */ @Test public void test42001Units() throws FactoryException { final ProjectedCRS utm = factory.createProjectedCRS("AUTO:42001,9001,0.0,0.0"); assertNotNull("auto-utm", utm); assertSame(utm, factory.createObject("AUTO :42001, 9001,0,0")); assertSame(utm, factory.createObject("AUTO2:42001, 9001,0,0")); assertSame(utm, factory.createObject("42001, 9001,0,0")); assertNotSame(utm, factory.createObject("AUTO :42001, 9001,30,0")); assertEquals( "Transverse_Mercator", utm.getConversionFromBase().getMethod().getName().getCode()); }
@Test public void test42004() throws FactoryException { final ProjectedCRS eqc = factory.createProjectedCRS("AUTO:42004,9001,0.0,35"); assertEquals( "Equidistant_Cylindrical", eqc.getConversionFromBase().getMethod().getName().getCode()); String stdParallel1Code = EquidistantCylindrical.Provider.STANDARD_PARALLEL_1.getName().getCode(); double stdParallel1 = eqc.getConversionFromBase() .getParameterValues() .parameter(stdParallel1Code) .doubleValue(); assertEquals(35.0, stdParallel1, 1e-9); }
/** UDIG requires this to work. */ @Test public void test42001() throws FactoryException { final ProjectedCRS utm = factory.createProjectedCRS("AUTO:42001,0.0,0.0"); assertNotNull("auto-utm", utm); assertSame(utm, factory.createObject("AUTO :42001 ,0,0")); assertSame(utm, factory.createObject("AUTO2:42001 ,0,0")); assertSame(utm, factory.createObject("42001 ,0,0")); assertNotSame(utm, factory.createObject("AUTO :42001 ,30,0")); assertEquals( "Transverse_Mercator", utm.getConversionFromBase().getMethod().getName().getCode()); }
@Test public void test97001() throws FactoryException { ProjectedCRS crs = factory.createProjectedCRS("AUTO:97001,9001,-17.0,23.0"); assertEquals("Gnomonic", crs.getConversionFromBase().getMethod().getName().getCode()); assertTrue(crs.getConversionFromBase().getMathTransform() instanceof Gnomonic); String centreLatCode = Gnomonic.Provider.LATITUDE_OF_CENTRE.getName().getCode(); double centreLat = crs.getConversionFromBase() .getParameterValues() .parameter(centreLatCode) .doubleValue(); assertEquals(23.0, centreLat, 1e-9); String centreLongCode = Gnomonic.Provider.LONGITUDE_OF_CENTRE.getName().getCode(); double centreLong = crs.getConversionFromBase() .getParameterValues() .parameter(centreLongCode) .doubleValue(); assertEquals(-17.0, centreLong, 1e-9); }
param = crs1.getConversionFromBase().getParameterValues(); assertEquals(crs1, crs2); assertEquals("Mercator_1SP", crs1.getConversionFromBase().getMethod().getName().getCode()); assertTrue( crs1.getConversionFromBase() param = crs1.getConversionFromBase().getParameterValues(); assertEquals(crs1, crs2); assertEquals("Mercator_1SP", crs1.getConversionFromBase().getMethod().getName().getCode()); assertTrue( crs1.getConversionFromBase() assertEquals( "Transverse_Mercator", crs1.getConversionFromBase().getMethod().getName().getCode()); assertEquals("semi_major", 6377563.396, param.parameter("semi_major").doubleValue(), 1E-4); assertEquals("semi_minor", 6356256.909, param.parameter("semi_minor").doubleValue(), 1E-3); assertEquals( "Transverse_Mercator", crs1.getConversionFromBase().getMethod().getName().getCode()); assertEquals("semi_major", 6370997.0, param.parameter("semi_major").doubleValue(), 1E-5); assertEquals("semi_minor", 6370997.0, param.parameter("semi_minor").doubleValue(), 1E-5);
@Test public void test97002() throws FactoryException { ProjectedCRS crs = factory.createProjectedCRS("AUTO:97002,9001,-17.0,23.0"); assertEquals("Stereographic", crs.getConversionFromBase().getMethod().getName().getCode()); assertTrue(crs.getConversionFromBase().getMathTransform() instanceof Stereographic);
assertEpsgNameAndIdentifierEqual("WGS 72", 4322, crs.getBaseCRS()); assertEpsgNameAndIdentifierEqual("World Geodetic System 1972", 6322, crs.getDatum()); assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, crs.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, crs.getConversionFromBase()); assertAxisDirectionsEqual("EPSG::4400", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertEpsgNameAndIdentifierEqual("WGS 72BE", 4324, variant.getBaseCRS()); assertEpsgNameAndIdentifierEqual("WGS 72 Transit Broadcast Ephemeris", 6324, variant.getDatum()); assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, variant.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, variant.getConversionFromBase()); verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -123); assertSame("Operation method", crs.getConversionFromBase().getMethod(), variant.getConversionFromBase().getMethod()); assertSame("Coordinate system", crs.getCoordinateSystem(), variant.getCoordinateSystem());
/** * Tests a projected CRS located on the North pole. * Axis directions are "South along 90°E" and "South along 180°E". * * @throws FactoryException if an error occurred while querying the factory. */ @Test @Ignore("“Lambert Azimuthal Equal Area (Spherical)” projection is not yet implemented.") public void testProjectedOnPole() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final ProjectedCRS crs = factory.createProjectedCRS("3408"); assertEpsgNameAndIdentifierEqual("NSIDC EASE-Grid North", 3408, crs); assertEpsgNameAndIdentifierEqual("Unspecified datum based upon the International 1924 Authalic Sphere", 4053, crs.getBaseCRS()); assertEpsgNameAndIdentifierEqual("Lambert Azimuthal Equal Area (Spherical)", 1027, crs.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("US NSIDC Equal Area north projection", 3897, crs.getConversionFromBase()); // TODO: test axis directions. assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("3408")); }
/** * Tests the Google projected CRS. * * @throws FactoryException if an error occurred while querying the factory. */ @Test public void testGoogleProjection() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final ProjectedCRS crs = factory.createProjectedCRS("3857"); assertEpsgNameAndIdentifierEqual("WGS 84 / Pseudo-Mercator", 3857, crs); assertEpsgNameAndIdentifierEqual("WGS 84", 4326, crs.getBaseCRS()); assertEpsgNameAndIdentifierEqual("Popular Visualisation Pseudo Mercator", 1024, crs.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("Popular Visualisation Pseudo-Mercator", 3856, crs.getConversionFromBase()); assertAxisDirectionsEqual("EPSG::4499", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("3857")); }
/** * Tests a deprecated projected CRS. * This test verifies that the expected warnings are logged. * * @throws FactoryException if an error occurred while querying the factory. */ @Test @DependsOnMethod({"testDeprecatedGeographic", "testDeprecatedCoordinateSystems"}) public void testDeprecatedProjected() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final ProjectedCRS crs = factory.createProjectedCRS("3786"); assertEpsgNameAndIdentifierEqual("World Equidistant Cylindrical (Sphere)", 3786, crs); assertEpsgNameAndIdentifierEqual("Equidistant Cylindrical (Spherical)", 9823, crs.getConversionFromBase().getMethod()); assertAxisDirectionsEqual("EPSG::4499", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); loggings.assertNextLogContains("EPSG:9823", "1029"); // Operation method 9823 has been replaced by 1029 loggings.assertNextLogContains("EPSG:19968", "4086"); // Coordinate Operation 19968 has been replaced by 4086 loggings.assertNextLogContains("EPSG:3786", "4088"); // Coordinate Reference System 3786 has been replaced by 4088 loggings.assertNoUnexpectedLog(); final ProjectedCRS replacement = factory.createProjectedCRS("4088"); assertEpsgNameAndIdentifierEqual("World Equidistant Cylindrical (Sphere)", 4088, replacement); assertEpsgNameAndIdentifierEqual("Equidistant Cylindrical (Spherical)", 1029, replacement.getConversionFromBase().getMethod()); assertSame("Base CRS", crs.getBaseCRS(), replacement.getBaseCRS()); assertSame("Coordinate system", crs.getCoordinateSystem(), replacement.getCoordinateSystem()); assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("3786")); assertSame("CRS shall be cached", replacement, factory.createCoordinateReferenceSystem("4088")); }
/** * Tests the "NAD27(76) / UTM zone 15N" projected CRS (EPSG:2027). * * @throws FactoryException if an error occurred while querying the factory. */ @Test @DependsOnMethod("testGeographic2D") public void testProjected() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final ProjectedCRS crs = factory.createProjectedCRS("2027"); assertEpsgNameAndIdentifierEqual("NAD27(76) / UTM zone 15N", 2027, crs); assertEpsgNameAndIdentifierEqual("NAD27(76)", 4608, crs.getBaseCRS()); assertEpsgNameAndIdentifierEqual("North American Datum 1927 (1976)", 6608, crs.getDatum()); assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, crs.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("UTM zone 15N", 16015, crs.getConversionFromBase()); assertAxisDirectionsEqual("EPSG::4400", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -93); assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("2027")); }
/** * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42002"} code. * * @throws FactoryException if an error occurred while creating a CRS. */ @Test @DependsOnMethod("testAuto42001") public void testAuto42002() throws FactoryException { final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42002,-122,10"); assertSame("Omitting namespace.", crs, factory.createProjectedCRS(" 42002, -122 , 10 ")); assertSame("With explicit unit.", crs, factory.createProjectedCRS("AUTO2 : 42002, 1, -122 , 10 ")); assertEquals("name", "Transverse Mercator", crs.getName().getCode()); assertTrue("Expected no EPSG identifier.", crs.getIdentifiers().isEmpty()); final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues(); assertEquals(TransverseMercator.NAME, crs.getConversionFromBase().getMethod().getName().getCode()); assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertEquals(Constants.CENTRAL_MERIDIAN, -122, p.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.LATITUDE_OF_ORIGIN, 10, p.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT); assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING) .doubleValue(), STRICT); }
/** * Tests (un)marshalling of a projected coordinate reference system. * * @throws FactoryException if the CRS creation failed. * @throws JAXBException if an error occurred during (un)marshalling. */ @Test public void testXML() throws FactoryException, JAXBException { final DefaultProjectedCRS crs = unmarshalFile(DefaultProjectedCRS.class, XML_FILE); Validators.validate(crs); assertEpsgNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 27572, crs); assertEpsgNameAndIdentifierEqual("NTF (Paris)", 4807, crs.getBaseCRS()); assertEquals("scope", "Large and medium scale topographic mapping and engineering survey.", crs.getScope().toString()); assertAxisDirectionsEqual("baseCRS", crs.getBaseCRS().getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST); assertAxisDirectionsEqual("coordinateSystem", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); final Projection conversion = crs.getConversionFromBase(); assertEpsgNameAndIdentifierEqual("Lambert zone II", 18082, conversion); assertEpsgNameAndIdentifierEqual("Lambert Conic Conformal (1SP)", 9801, conversion.getMethod()); assertNotNull("conversion.mathTransform", conversion.getMathTransform()); verifyParameters(conversion.getParameterValues()); /* * Test marshalling and compare with the original file. The comparison ignores the <gml:name> nodes because the * marshalled CRS contains many operation method and parameter aliases which were not in the original XML file. */ assertMarshalEqualsFile(XML_FILE, crs, null, STRICT, new String[] {"gml:name"}, new String[] {"xmlns:*", "xsi:schemaLocation", "gml:id"}); }
/** * Tests a projected CRS fetched by its name instead than its code. * Tests also {@link EPSGDataAccess#createObject(String)}. * * @throws FactoryException if an error occurred while querying the factory. * * @see #testCreateByName() */ @Test @DependsOnMethod("testCreateByName") public void testProjectedByName() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final ProjectedCRS crs = factory.createProjectedCRS("NTF (Paris) / Lambert zone I"); assertEpsgNameAndIdentifierEqual("NTF (Paris) / Lambert zone I", 27571, crs); assertEpsgNameAndIdentifierEqual("NTF (Paris)", 4807, crs.getBaseCRS()); assertEpsgNameAndIdentifierEqual("Lambert Conic Conformal (1SP)", 9801, crs.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("Lambert zone I", 18081, crs.getConversionFromBase()); assertAxisDirectionsEqual("EPSG::4499", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertSame(crs, factory.createProjectedCRS("27571")); /* * Gets the CRS using 'createObject'. It will require more SQL * statement internally in order to determines the object type. */ assertSame(crs, factory.createObject("27571")); assertSame(crs, factory.createObject("NTF (Paris) / Lambert zone I")); assertSame(crs, factory.createProjectedCRS("NTF Paris Lambert zone I")); assertSame(crs, factory.createObject("NTF Paris Lambert zone I")); }
/** * Tests the "Beijing 1954 / 3-degree Gauss-Kruger CM 135E" projected CRS (EPSG:2442). * This projected CRS has (North, East) axis orientations instead of (East, North). * * @throws FactoryException if an error occurred while querying the factory. */ @Test @DependsOnMethod("testProjected") public void testProjectedNorthEast() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final ProjectedCRS crs = factory.createProjectedCRS(" EPSG : 2442 "); assertEpsgNameAndIdentifierEqual("Beijing 1954 / 3-degree Gauss-Kruger CM 135E", 2442, crs); assertAliasTipEquals ("Beijing 1954 / 3GK 135E", crs); assertEpsgNameAndIdentifierEqual("Beijing 1954", 4214, crs.getBaseCRS()); assertEpsgNameAndIdentifierEqual("Beijing 1954", 6214, crs.getDatum()); assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, crs.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("Gauss-Kruger CM 135E", 16323, crs.getConversionFromBase()); assertAxisDirectionsEqual("EPSG::4530", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST); final ParameterValueGroup parameters = crs.getConversionFromBase().getParameterValues(); assertEquals("Transverse Mercator", parameters.getDescriptor().getName().getCode()); assertEquals("central_meridian", 135, parameters.parameter("central_meridian" ).doubleValue(), STRICT); assertEquals("latitude_of_origin", 0, parameters.parameter("latitude_of_origin").doubleValue(), STRICT); assertEquals("scale_factor", 1, parameters.parameter("scale_factor" ).doubleValue(), STRICT); assertEquals("false_easting", 500000, parameters.parameter("false_easting" ).doubleValue(), STRICT); assertEquals("false_northing", 0, parameters.parameter("false_northing" ).doubleValue(), STRICT); assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("2442")); }
assertEquals(TransverseMercator.NAME, crs.getConversionFromBase().getMethod().getName().getCode()); assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT);
assertEquals("Transverse Mercator", crs.getConversionFromBase().getMethod().getName().getCode()); assertEquals("semi_major", 6377563.396, param.parameter("semi_major" ).doubleValue(), 1E-4); assertEquals("semi_minor", 6356256.909, param.parameter("semi_minor" ).doubleValue(), 1E-3);