final GeographicCRS sourceCRS, final ProjectedCRS targetCRS, int limit) throws FactoryException { GeographicCRS base = targetCRS.getBaseCRS(); CoordinateOperation step2 = targetCRS.getConversionFromBase(); HashSet<CoordinateOperation> result = new HashSet<CoordinateOperation>(); Set<CoordinateOperation> step1Candidates = tryDB(sourceCRS, base, limit);
if (linearUnit == null || isDefaultUnit || linearUnit.equals(pcrs.getCoordinateSystem().getAxis(0).getUnit())) { return pcrs; pcrs.getConversionFromBase().getName().getCode(), pcrs.getConversionFromBase().getParameterValues()); return new DefaultProjectedCRS( java.util.Collections.singletonMap( "name", DefaultEllipsoidalCS.getName(pcrs, new CitationImpl("EPSG"))), conversionFromBase, pcrs.getBaseCRS(), pcrs.getConversionFromBase().getMathTransform(), createProjectedCS(linearUnit));
@Test public void testOverride() throws Exception { CoordinateReferenceSystem epsg3003 = CRS.decode("EPSG:3003"); DefaultGeodeticDatum datum3003 = (DefaultGeodeticDatum) (((ProjectedCRS) epsg3003).getDatum()); BursaWolfParameters[] bwParamArray3003 = datum3003.getBursaWolfParameters(); assertEquals(1, bwParamArray3003.length); BursaWolfParameters bw3003 = bwParamArray3003[0]; double tol = 1E-7; assertEquals(-104.1, bw3003.dx, tol); assertEquals(-49.1, bw3003.dy, tol); assertEquals(-9.9, bw3003.dz, tol); assertEquals(0.971, bw3003.ex, tol); assertEquals(-2.917, bw3003.ey, tol); assertEquals(0.714, bw3003.ez, tol); assertEquals(-11.68, bw3003.ppm, tol); // without an override they should be the same as 3002 CoordinateReferenceSystem epsg3002 = CRS.decode("EPSG:3002"); DefaultGeodeticDatum datum3002 = (DefaultGeodeticDatum) (((ProjectedCRS) epsg3002).getDatum()); BursaWolfParameters[] bwParamArray3002 = datum3002.getBursaWolfParameters(); assertEquals(1, bwParamArray3002.length); BursaWolfParameters bw3002 = bwParamArray3002[0]; assertFalse(bw3002.equals(bw3003)); } }
Matrix geographicScale = null; Matrix projectedScale = null; projection = crs.getConversionFromBase(); MathTransform candidate = projection.getMathTransform(); while (candidate instanceof ConcatenatedTransform) { final CoordinateSystem cs = crs.getCoordinateSystem(); projectedScale = AbstractCS.swapAndScaleAxis(AbstractCS.standard(cs), cs);
final ProjectedCRS crs = factory.createProjectedCRS("32210"); assertEpsgNameAndIdentifierEqual("WGS 72 / UTM zone 10N", 32210, crs); 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); verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -123); 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()); assertNotDeepEquals(crs.getConversionFromBase(), variant.getConversionFromBase()); assertNotDeepEquals(crs, variant);
/** Creates an object for the specified code. */ protected IdentifiedObject createObject(final String code) throws FactoryException { if (projections != null) { final String crs = (String) projections.get(code); if (crs != null) { return ((CRSAuthorityFactory) factory) .createProjectedCRS(crs) .getConversionFromBase(); } } return ((CoordinateOperationAuthorityFactory) factory).createCoordinateOperation(code); } }
private static boolean isPole(DirectPosition point, CoordinateReferenceSystem crs) { DirectPosition result = new DirectPosition2D(); GeographicCRS geographic; try { ProjectedCRS projectedCRS = getProjectedCRS(crs); if (projectedCRS != null) { geographic = projectedCRS.getBaseCRS(); MathTransform mt = CRS.findMathTransform(projectedCRS, geographic); mt.transform(point, result); } else if (crs instanceof GeographicCRS) { result = point; geographic = (GeographicCRS) crs; } else { return false; } } catch (MismatchedDimensionException | TransformException | FactoryException e) { return false; } final double EPS = 1e-6; if (getAxisOrder(geographic) == AxisOrder.NORTH_EAST) { return Math.abs(result.getOrdinate(0) - 90) < EPS || Math.abs(result.getOrdinate(0) + 90) < EPS; } else { return Math.abs(result.getOrdinate(1) - 90) < EPS || Math.abs(result.getOrdinate(1) + 90) < EPS; } }
verifyIdentification (crs.getBaseCRS(), "ETRS89", null); verifyIdentification (crs.getConversionFromBase(), "LAEA", null); verifyDatum (datum = crs.getDatum(), "ETRS89"); verifyFlattenedSphere (datum.getEllipsoid(), "GRS 80", 6378137, 298.257222101, metre); verifyPrimeMeridian (datum.getPrimeMeridian(), null, 0, degree); verifyAxisAbbreviations(cs = crs.getCoordinateSystem(), "Y", "X"); verifyCoordinateSystem (cs, CartesianCS.class, new AxisDirection[] {NORTH,EAST}, metre); final ParameterValueGroup group = crs.getConversionFromBase().getParameterValues(); verifyParameter(group, "Latitude of natural origin", 52.0, degree); verifyParameter(group, "Longitude of natural origin", 10.0, degree); verifyParameter(group, "False northing", 3210000.0, metre); verifyGeographicExtent(crs.getDomainOfValidity(), "An area description", NaN, NaN, NaN, NaN); assertNullOrEquals("scope", "Description of a purpose", crs.getScope());
parameters = null; } else if (crs instanceof ProjectedCRS) { Projection c = ((ProjectedCRS) crs).getConversionFromBase(); datum = ((ProjectedCRS) crs).getDatum(); method = name(c.getMethod()); parameters = c.getParameterValues();
/** * 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); }
final GeographicCRS baseCRS = crs.getBaseCRS(); if (baseCRS != null) { verifyAxisDirection("BaseCRS", baseCRS.getCoordinateSystem(), swapλφ, false); verifyAxisDirection("ProjectedCRS", crs.getCoordinateSystem(), swapxy, flipxy); final Conversion conversion = crs.getConversionFromBase(); if (conversion != null) { final MathTransform projection = conversion.getMathTransform(); double φmin = areaOfValidity.getMinY(); double φmax = areaOfValidity.getMaxY(); final Extent extent = crs.getDomainOfValidity(); validators.validate(extent); if (extent != null) {
/** * Validates the given coordinate reference system. * * @param object The object to validate, or {@code null}. */ public void validate(final ProjectedCRS object) { if (object == null) { return; } validateReferenceSystem(object); final GeographicCRS baseCRS = object.getBaseCRS(); mandatory("ProjectedCRS: must have a base CRS.", baseCRS); validate(baseCRS); final CartesianCS cs = object.getCoordinateSystem(); mandatory("ProjectedCRS: must have a CoordinateSystem.", cs); container.cs.validate(cs); final GeodeticDatum datum = object.getDatum(); mandatory("ProjectedCRS: must have a Datum.", datum); container.datum.validate(datum); validateGeneralDerivedCRS(object); }
/** * 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); }
/** * 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); }
return crs; baseCRS = crs.getBaseCRS(); cs = crs.getCoordinateSystem(); } else { cs = projectedCS; if (cs == null) { crs = datum.universal(Math.signum(latitude), longitude); projectedCS = cs = crs.getCoordinateSystem(); baseCRS = crs.getBaseCRS(); } else { crs = null; if (isUTM != null) { if (isUTM && crs != null) { builder.addName(crs.getName());
assertContainsCode("ProjectedCRS.getIdentifiers()", "EPSG", code, crs.getIdentifiers()); "EPSG", datumCode, crs.getDatum().getIdentifiers()); assertEquals("ProjectedCRS.getBaseCRS().getName()", name, getVerifiableName(crs.getBaseCRS())); final CartesianCS cs = crs.getCoordinateSystem(); assertNotNull("ProjectedCRS.getCoordinateSystem()", crs); assertEquals("ProjectedCRS.getCoordinateSystem().getDimension()", 2, cs.getDimension());
/** * 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); }
final Unit<?> unit = CRSUtilities.getUnit(projectedCRS.getCoordinateSystem()); if (unit != null && !SI.METRE.isCompatible(unit)) { throw new IllegalArgumentException(Errors.format(ErrorKeys.NON_LINEAR_UNIT_$1, unit));
metadata.addGeoAscii(GeoTiffPCSCodes.PCSCitationGeoKey, projectedCRS.getName().getCode()); parseGeoGCS((DefaultGeographicCRS) (projectedCRS.getBaseCRS()), metadata);
/** * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the same {@code "AUTO:42001"} code * than {@link #testAuto42001()} except that axes are feet. * * @throws FactoryException if an error occurred while creating a CRS. */ @Test @DependsOnMethod("testAuto42001") public void testAuto42001_foot() throws FactoryException { final ProjectedCRS crs = factory.createProjectedCRS("AUTO2:42001, 0.3048, -123, 0"); assertSame("Legacy namespace.", crs, factory.createProjectedCRS("AUTO:42001,9002,-123,0")); assertEquals("name", "WGS 84 / UTM zone 10N", crs.getName().getCode()); assertTrue("Expected no EPSG identifier because the axes are not in metres.", crs.getIdentifiers().isEmpty()); assertEquals("axis[0].unit", Units.FOOT, crs.getCoordinateSystem().getAxis(0).getUnit()); }