ProjectedCRS projectedCRS = (ProjectedCRS) crs; Projection projection = projectedCRS.getConversionFromBase(); MathTransform transform = projection.getMathTransform(); if (transform instanceof TransverseMercator) { crsType = TRANSVERSE_MERCATOR;
/** * Returns the {@link MapProjection} driving the specified crs, or {@code null} if none could be * found. * * @param crs The coordinate reference system, or {@code null}. * @return The {@link MapProjection}, or {@code null} if none. */ public static MapProjection getMapProjection(final CoordinateReferenceSystem crs) { ProjectedCRS projectedCRS = CRS.getProjectedCRS(crs); if (projectedCRS == null) return null; Projection conversion = projectedCRS.getConversionFromBase(); MathTransform mt = conversion.getMathTransform(); return unrollProjection(mt); }
conversionFromBase, pcrs.getBaseCRS(), pcrs.getConversionFromBase().getMathTransform(), createProjectedCS(linearUnit));
@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); }
ProjectedCRS projectedCRS = (ProjectedCRS) crs; Projection projection = projectedCRS.getConversionFromBase(); MathTransform transform = projection.getMathTransform(); if (transform instanceof TransverseMercator) { crsType = TRANSVERSE_MERCATOR;
@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); }
/** * Projects a shape and compare with a shape projected by other means. * Current version is only a visual test. * * @throws FactoryException If the transform can not be created. * @throws TransformException If an error occurred while transforming some points. */ @Test public void testWithLambert() throws FactoryException, TransformException { final ProjectedCRS crs = (ProjectedCRS) CRS.fromWKT(WKT.PROJCS_LAMBERT_CONIC_NTF); final GeneralPath path = new GeneralPath(); path.moveTo(10.000000f, 10.0000000f); path.lineTo(56.666667f, -6.6666667f); path.lineTo(56.666667f, -40.000000f); path.lineTo(80.000000f, 10.0000000f); path.lineTo(56.666667f, 60.0000000f); path.lineTo(56.666667f, 26.6666667f); path.closePath(); final Shape reference = createReferenceShape(path, (MathTransform2D) crs.getConversionFromBase().getMathTransform()); final Shape target = ProjectedShape.wrap(path, projection); show(target, reference, false); }
: TransverseMercator.Zoner.NORTH_BOUNDS, 0); double northing = datum.universal(position.x * 1.01, position.y).getConversionFromBase() .getMathTransform().transform(position, position).getOrdinate(1); if (south) { northing = 2*PolarStereographicA.UPS_SHIFT - northing;
/** * Returns the conversion from {@code north} to {@code south}. */ private static Matrix conversion(final ProjectedCRS north, final ProjectedCRS south) throws NoninvertibleTransformException { final MathTransform transform = MathTransforms.concatenate( north.getConversionFromBase().getMathTransform().inverse(), south.getConversionFromBase().getMathTransform()); assertInstanceOf("North to South", LinearTransform.class, transform); return ((LinearTransform) transform).getMatrix(); }
assertTrue( crs1.getConversionFromBase() .getMathTransform() .toWKT() .startsWith("PARAM_MT[\"Mercator_1SP\"")); assertTrue( crs1.getConversionFromBase() .getMathTransform() .toWKT() .startsWith("CONCAT_MT[PARAM_MT["));
ProjectedCRS crs = factory.createProjectedCRS("AUTO:97002,9001,-17.0,23.0"); assertEquals("Stereographic", crs.getConversionFromBase().getMethod().getName().getCode()); assertTrue(crs.getConversionFromBase().getMathTransform() instanceof Stereographic);
proj2Geo = projCrs.getConversionFromBase().getMathTransform().inverse(); } catch (NoninvertibleTransformException ex) { throw new RuntimeException(ex);
/** * Tests two {@code "AUTO:42004"} (Equirectangular projection) case built in such a way that the conversion * from one to the other should be the conversion factor from metres to feet. * * This is an integration test. * * @throws FactoryException if an error occurred while creating a CRS. * @throws NoninvertibleTransformException Should never happen. */ @Test @DependsOnMethod("testAuto42004") public void testUnits() throws FactoryException, NoninvertibleTransformException { AffineTransform tr1, tr2; tr1 = (AffineTransform) factory.createProjectedCRS("AUTO:42004,9001,0,35").getConversionFromBase().getMathTransform(); tr2 = (AffineTransform) factory.createProjectedCRS("AUTO:42004,9002,0,35").getConversionFromBase().getMathTransform(); tr2 = tr2.createInverse(); tr2.concatenate(tr1); assertEquals("Expected any kind of scale.", 0, tr2.getType() & ~AffineTransform.TYPE_MASK_SCALE); assertEquals("Expected the conversion factor from foot to metre.", 0.3048, tr2.getScaleX(), 1E-9); assertEquals("Expected the conversion factor from foot to metre.", 0.3048, tr2.getScaleY(), 1E-9); }
final MathTransform trs = projectedCRS.getConversionFromBase().getMathTransform();
final DirectPosition r = decode(coder, reference); final ProjectedCRS crs = (ProjectedCRS) r.getCoordinateReferenceSystem(); assertSame(expected, crs.getConversionFromBase().getMathTransform().transform(position, expected)); final double distance = expected.distance(r.getOrdinate(0), r.getOrdinate(1)); if (!(distance < 1.5)) { // Use '!' for catching NaN.
/** * 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()); }
toGeographic = projection.getMathTransform().inverse(); return;
final MathTransform mercatMt = ((ProjectedCRS) wilsonCRS).getConversionFromBase().getMathTransform(); final MathTransform mercatT = ((ProjectedCRS) mercatCRS).getConversionFromBase().getMathTransform();
/** * 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"}); }
final MathTransform mt = projCRS.getConversionFromBase().getMathTransform(); //-- source to dest