new DefiningConversion( pcrs.getConversionFromBase().getName().getCode(), pcrs.getConversionFromBase().getParameterValues()); return new DefaultProjectedCRS( java.util.Collections.singletonMap(
double centreLat = crs.getConversionFromBase() .getParameterValues() .parameter(centreLatCode) .doubleValue(); double centreLong = crs.getConversionFromBase() .getParameterValues() .parameter(centreLongCode) .doubleValue(); double semiMajor = crs.getConversionFromBase() .getParameterValues() .parameter(semiMajorString) .doubleValue(); double semiMinor = crs.getConversionFromBase() .getParameterValues() .parameter(semiMinorString) .doubleValue();
@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); }
@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); }
wkt2 = parser.format(crs1); crs2 = (DefaultProjectedCRS) parser.parseObject(wkt2); param = crs1.getConversionFromBase().getParameterValues(); assertEquals(crs1, crs2); assertEquals("Mercator_1SP", crs1.getConversionFromBase().getMethod().getName().getCode()); wkt2 = parser.format(crs1); crs2 = (DefaultProjectedCRS) parser.parseObject(wkt2); param = crs1.getConversionFromBase().getParameterValues(); assertEquals(crs1, crs2); assertEquals("Mercator_1SP", crs1.getConversionFromBase().getMethod().getName().getCode()); wkt2 = parser.format(crs1); crs2 = (DefaultProjectedCRS) parser.parseObject(wkt2); param = crs1.getConversionFromBase().getParameterValues(); assertEquals(crs1, crs2); assertFalse(wkt2.contains("semi_major")); wkt2 = parser.format(crs1); crs2 = (DefaultProjectedCRS) parser.parseObject(wkt2); param = crs1.getConversionFromBase().getParameterValues(); assertEquals(crs1, crs2); assertFalse(wkt2.contains("semi_major"));
/** * Creates a projected CRS and verifies its parameters. * Verifies also that the constructor does not accept invalid base CRS. * * @throws FactoryException if the CRS creation failed. */ @Test public void testConstructor() throws FactoryException { final ProjectedCRS crs = create(HardCodedCRS.NTF); verifyParameters(crs.getConversionFromBase().getParameterValues()); try { create(HardCodedCRS.WGS84_3D); fail("Should not accept a three-dimensional base geodetic CRS."); } catch (InvalidGeodeticParameterException e) { final String message = e.getMessage(); assertTrue(message, message.contains("Lambert Conic Conformal (1SP)")); } }
/** * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42005"} code. * * @throws FactoryException if an error occurred while creating a CRS. */ @Test @DependsOnMethod("testAuto42001") @Ignore("Pending implementation of Mollweide projection.") public void testAuto42005() throws FactoryException { final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42005,9001,10,45"); final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues(); assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); }
/** * Verifies the CRS name, datum and conversion parameters for {@code PROJCRS[“NAD27 / Texas South Central”]}. * This method does not verify the axes and remark, since they are not specified in {@code BASEPROJCRS[…]}. * * @param degree value of {@link org.opengis.test.Units#degree()} (for fetching it only once per test). * @param footSurveyUS value of {@link org.opengis.test.Units#footSurveyUS()}. */ private void verifyTexasSouthCentral(final ProjectedCRS crs, final Unit<Angle> degree, final Unit<Length> footSurveyUS) { final GeodeticDatum datum; verifyIdentification (crs, "NAD27 / Texas South Central", null); verifyIdentification (crs.getBaseCRS(), "NAD27", null); verifyIdentification (crs.getConversionFromBase(), "Texas South Central SPCS27", null); verifyDatum (datum = crs.getDatum(), "North American Datum 1927"); verifyFlattenedSphere (datum.getEllipsoid(), "Clarke 1866", 20925832.164, 294.97869821, footSurveyUS); verifyPrimeMeridian (datum.getPrimeMeridian(), null, 0, degree); final ParameterValueGroup group = crs.getConversionFromBase().getParameterValues(); verifyParameter(group, "Latitude of false origin", 27.83333333333333, degree); verifyParameter(group, "Longitude of false origin", -99.0, degree); verifyParameter(group, "Latitude of 1st standard parallel", 28.383333333333, degree); verifyParameter(group, "Latitude of 2nd standard parallel", 30.283333333333, degree); verifyParameter(group, "Easting at false origin", 2000000.0, footSurveyUS); verifyParameter(group, "Northing at false origin", 0.0, footSurveyUS); }
/** * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42003"} code. * * @throws FactoryException if an error occurred while creating a CRS. */ @Test @DependsOnMethod("testAuto42001") @Ignore("Pending the port of Orthographic projection.") public void testAuto42003() throws FactoryException { final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42003,9001,10,45"); final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues(); assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.LATITUDE_OF_ORIGIN, 45, p.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT); }
/** * Verifies the parameters of a “NTF (Paris) / Lambert zone II” projection. */ private static void validateParisFranceII(final ProjectedCRS crs, final int identifier, final boolean hasToWGS84) { assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", identifier, crs); verifyProjectedCS(crs.getCoordinateSystem(), Units.KILOMETRE); final PrimeMeridian pm = verifyNTF(crs.getDatum(), hasToWGS84); assertEquals("angularUnit", Units.GRAD, pm.getAngularUnit()); assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT); final ParameterValue<?> param = verifyNTF(crs.getConversionFromBase().getParameterValues()); assertEquals("angularUnit", Units.GRAD, param.getUnit()); assertEquals("latitude_of_origin", 52.0, param.doubleValue(), STRICT); }
/** * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42004"} code. * * @throws FactoryException if an error occurred while creating a CRS. */ @Test @DependsOnMethod("testAuto42001") public void testAuto42004() throws FactoryException { final ProjectedCRS crs = factory.createProjectedCRS("AUTO2:42004,1,10,45"); final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues(); assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.LATITUDE_OF_ORIGIN, 45, p.parameter(Constants.STANDARD_PARALLEL_1).doubleValue(), STRICT); assertInstanceOf("Opportunistic check: in the special case of Equirectangular projection, " + "SIS should have optimized the MathTransform as an affine transform.", LinearTransform.class, crs.getConversionFromBase().getMathTransform()); }
/** * 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 {@link StandardDefinitions#createUniversal(int, GeographicCRS, boolean, double, double, CartesianCS)} * for a Universal Transverse Mercator (UTM) projection. * * @since 0.7 */ @Test @DependsOnMethod("testCreateGeographicCRS") public void testCreateUTM() { final ProjectedCRS crs = StandardDefinitions.createUniversal(32610, HardCodedCRS.WGS84, true, 15, -122, HardCodedCS.PROJECTED); assertEquals("name", "WGS 84 / UTM zone 10N", crs.getName().getCode()); final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues(); assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT); assertEquals(Constants.CENTRAL_MERIDIAN, -123, pg.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.SCALE_FACTOR, 0.9996, pg.parameter(Constants.SCALE_FACTOR) .doubleValue(), STRICT); assertEquals(Constants.FALSE_EASTING, 500000, pg.parameter(Constants.FALSE_EASTING) .doubleValue(), STRICT); assertEquals(Constants.FALSE_NORTHING, 0, pg.parameter(Constants.FALSE_NORTHING) .doubleValue(), STRICT); }
/** * Tests {@link StandardDefinitions#createUniversal(int, GeographicCRS, boolean, double, double, CartesianCS)} * for a Universal Polar Stereographic (UPS) projection. This test cheats a little bit on the coordinate system * by laziness; we are more interested in the projection parameters. * * @since 0.8 */ @Test @DependsOnMethod("testCreateGeographicCRS") public void testCreateUPS() { final ProjectedCRS crs = StandardDefinitions.createUniversal(5041, HardCodedCRS.WGS84, false, 90, -122, HardCodedCS.PROJECTED); assertEquals("name", "WGS 84 / Universal Polar Stereographic North", crs.getName().getCode()); final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues(); assertEquals(Constants.LATITUDE_OF_ORIGIN, 90, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT); assertEquals(Constants.CENTRAL_MERIDIAN, 0, pg.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.SCALE_FACTOR, 0.994, pg.parameter(Constants.SCALE_FACTOR) .doubleValue(), STRICT); assertEquals(Constants.FALSE_EASTING, 2000000, pg.parameter(Constants.FALSE_EASTING) .doubleValue(), STRICT); assertEquals(Constants.FALSE_NORTHING, 2000000, pg.parameter(Constants.FALSE_NORTHING) .doubleValue(), STRICT); }
/** * Tests {@link CommonCRS#universal(double, double)} with Universal Polar Stereographic (UPS) projections. * * @since 0.8 */ @Test @DependsOnMethod("testGeographic") public void testUPS() { final ProjectedCRS crs = CommonCRS.WGS72.universal(-85, -122); assertEquals("name", "WGS 72 / Universal Polar Stereographic South", crs.getName().getCode()); final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues(); assertEquals(Constants.LATITUDE_OF_ORIGIN, -90, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT); assertEquals(Constants.CENTRAL_MERIDIAN, 0, pg.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.SCALE_FACTOR, 0.994, pg.parameter(Constants.SCALE_FACTOR) .doubleValue(), STRICT); assertEquals(Constants.FALSE_EASTING, 2000000, pg.parameter(Constants.FALSE_EASTING) .doubleValue(), STRICT); assertEquals(Constants.FALSE_NORTHING, 2000000, pg.parameter(Constants.FALSE_NORTHING) .doubleValue(), STRICT); assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.universal(-85, -122)); assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.universal(+85, -122)); }
/** * 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"}); }
assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, crs.getConversionFromBase()); assertAxisDirectionsEqual("EPSG::4400", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH); verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -123); assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, variant.getConversionFromBase().getMethod()); assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, variant.getConversionFromBase()); verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -123);
/** * Tests {@link CommonCRS#universal(double, double)} with Universal Transverse Mercator (UTM) projections. * * @since 0.7 */ @Test @DependsOnMethod("testGeographic") public void testUTM() { final ProjectedCRS crs = CommonCRS.WGS72.universal(-45, -122); assertEquals("name", "WGS 72 / UTM zone 10S", crs.getName().getCode()); final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues(); assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT); assertEquals(Constants.CENTRAL_MERIDIAN, -123, pg.parameter(Constants.CENTRAL_MERIDIAN) .doubleValue(), STRICT); assertEquals(Constants.SCALE_FACTOR, 0.9996, pg.parameter(Constants.SCALE_FACTOR) .doubleValue(), STRICT); assertEquals(Constants.FALSE_EASTING, 500000, pg.parameter(Constants.FALSE_EASTING) .doubleValue(), STRICT); assertEquals(Constants.FALSE_NORTHING, 10000000, pg.parameter(Constants.FALSE_NORTHING) .doubleValue(), STRICT); assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.universal(-45, -122)); assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.universal(+45, -122)); }
/** * 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")); }