throws OperationNotFoundException { final Matrix matrix = swapAndScaleAxis(sourceCS, targetCS); for (int i = targetCS.getDimension(); --i >= 0; ) { final CoordinateSystemAxis axis = targetCS.getAxis(i); final AxisDirection direction = axis.getDirection(); if (AxisDirection.EAST.equals(direction.absolute())) {
new GeneralDirectPosition(envelope.getCoordinateReferenceSystem()); for (int i = 0; i < spatialCRS.getCoordinateSystem().getDimension(); i++) { lowerCorner.setOrdinate(i, envelope.getLowerCorner().getOrdinate(i)); upperCorner.setOrdinate(i, envelope.getUpperCorner().getOrdinate(i));
geogCode.toString()); if (angularUnit != null && !angularUnit.equals(gcs.getCoordinateSystem().getAxis(0).getUnit())) {
/** * Tests the {@link CommonCRS#geographic3D()} method. */ @Test @DependsOnMethod("testGeographic") public void testGeographic3D() { final GeographicCRS crs = CommonCRS.WGS72.geographic3D(); Validators.validate(crs); assertEquals ("WGS 72", crs.getName().getCode()); assertSame (CommonCRS.WGS72.geographic().getDatum(), crs.getDatum()); assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum()); final EllipsoidalCS cs = crs.getCoordinateSystem(); final String name = cs.getName().getCode(); assertTrue(name, name.startsWith("Ellipsoidal 3D")); assertEquals("dimension", 3, cs.getDimension()); assertAxisDirectionsEqual(name, cs, AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP); assertSame("Cached value", crs, CommonCRS.WGS72.geographic3D()); }
new GeneralDirectPosition(envelope.getCoordinateReferenceSystem()); for (int i = 0; i < spatialCRS.getCoordinateSystem().getDimension(); i++) { lowerCorner.setOrdinate(i, envelope.getLowerCorner().getOrdinate(i)); upperCorner.setOrdinate(i, envelope.getUpperCorner().getOrdinate(i));
final Unit<?> angularUnit = (geographicCRS.getCoordinateSystem()).getAxis(0).getUnit(); parseUnit(angularUnit, 0, metadata);
/** * Test if given CRS is longitude/latitude or latitude/longitude. Works * with ND geographic systems, as long as longitude and latitude axes can * be found. * * @param in The coordinate reference system * @return True if the first geographical axis of the given CRS is latitude. * False if the longitude appears before the latitude. * @throws IllegalArgumentException If neither latitude nor longitude axis * is found in input system. */ static boolean isLatLon(final GeographicCRS in) throws IllegalArgumentException { final EllipsoidalCS cs = in.getCoordinateSystem(); for (int i = 0 ; i < cs.getDimension() ; i++) { final AxisDirection axis = cs.getAxis(i).getDirection(); // Most common cases if (AxisDirection.NORTH.equals(axis)) { return true; } else if (AxisDirection.EAST.equals(axis)) { return false; // less common } else if (AxisDirection.SOUTH.equals(axis)) { return true; } else if (AxisDirection.WEST.equals(axis)) { return false; } } throw new IllegalArgumentException("Given geographic CRS use neither north nor east axis directions."); }
/** Tests {@link AbstractCRS}. */ @Test public void testCoordinateReferenceSystems() { // Test dimensions assertEquals( "WGS84 2D", 2, DefaultGeographicCRS.WGS84.getCoordinateSystem().getDimension()); assertEquals( "WGS84 3D", 3, DefaultGeographicCRS.WGS84_3D.getCoordinateSystem().getDimension()); // Test WKT assertEquals( "WGS84", "GEOGCS[\"WGS84(DD)\", " + "DATUM[\"WGS84\", " + "SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], " + "PRIMEM[\"Greenwich\", 0.0], " + "UNIT[\"degree\", 0.017453292519943295], " + "AXIS[\"Geodetic longitude\", EAST], " + "AXIS[\"Geodetic latitude\", NORTH]]", DefaultGeographicCRS.WGS84.toWKT(0)); }
Unit<Length> linearUnit = parseUnit(element, SI.METRE); Unit<Angle> angularUnit = geoCRS.getCoordinateSystem().getAxis(0).getUnit().asType(Angle.class); ParameterValueGroup projection = parseProjection(element, ellipsoid, linearUnit, angularUnit);
if(crs instanceof GeographicCRS){ final EllipsoidalCS cs = ((GeographicCRS)crs).getCoordinateSystem(); for(int i=0,n=cs.getDimension();i<n;i++){ final CoordinateSystemAxis axis = cs.getAxis(i); if(RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning())){ final DirectPosition start = new GeneralDirectPosition(crs);
final EllipsoidalCS cs = crs.getCoordinateSystem(); final EllipsoidalCS STANDARD = (cs.getDimension() <= 2) ? DefaultEllipsoidalCS.GEODETIC_2D : DefaultEllipsoidalCS.GEODETIC_3D;
/** * Tests the {@link DefaultGeographicCRS#forConvention(AxesConvention)} method * for {@link AxesConvention#DISPLAY_ORIENTED}. */ @Test public void testConventionalOrientation() { final DefaultGeographicCRS crs = DefaultGeographicCRS.castOrCopy(CommonCRS.WGS84.geographic3D()); final DefaultGeographicCRS normalized = crs.forConvention(AxesConvention.DISPLAY_ORIENTED); assertNotSame(crs, normalized); final EllipsoidalCS cs = normalized.getCoordinateSystem(); final EllipsoidalCS ref = crs.getCoordinateSystem(); assertEqualsIgnoreMetadata(ref.getAxis(1), cs.getAxis(0)); // EPSG codes differ because of different axis order. assertEqualsIgnoreMetadata(ref.getAxis(0), cs.getAxis(1)); assertEqualsIgnoreMetadata(ref.getAxis(2), cs.getAxis(2)); }
/** * Implementation of {@link #testGeographicCRS()} and related test methods. * This test expects no {@code AUTHORITY} element on any component. * * @param swap 1 if axes are expected to be swapped, or 0 otherwise. */ private void verifyGeographicCRS(final int swap, final GeographicCRS crs) throws ParseException { assertNameAndIdentifierEqual("WGS 84", 0, crs); final GeodeticDatum datum = crs.getDatum(); assertNameAndIdentifierEqual("World Geodetic System 1984", 0, datum); assertNameAndIdentifierEqual("Greenwich", 0, datum.getPrimeMeridian()); final Ellipsoid ellipsoid = datum.getEllipsoid(); assertNameAndIdentifierEqual("WGS84", 0, ellipsoid); assertEquals("semiMajor", 6378137, ellipsoid.getSemiMajorAxis(), STRICT); assertEquals("inverseFlattening", 298.257223563, ellipsoid.getInverseFlattening(), STRICT); final EllipsoidalCS cs = crs.getCoordinateSystem(); assertEquals("dimension", 2, cs.getDimension()); assertLongitudeAxisEquals(cs.getAxis(0 ^ swap)); assertLatitudeAxisEquals (cs.getAxis(1 ^ swap)); }
/** * Gets the dimension of input points. The default implementation returns * the dimension of the {@linkplain #getSourceCRS() source CRS}. * * @return the dimension of input points. */ @Override public int getSourceDimensions() { return (sourceCRS != null) ? sourceCRS.getCoordinateSystem().getDimension() : 2; }
if (angularUnit != null && !angularUnit.equals(gcs.getCoordinateSystem() .getAxis(0).getUnit())) {
assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT); EllipsoidalCS cs = crs.getCoordinateSystem(); assertEquals("dimension", 2, cs.getDimension()); assertAxisEquals(AxisNames.GEODETIC_LATITUDE, "φ", AxisDirection.NORTH, -100, +100, Units.GRAD, RangeMeaning.EXACT, cs.getAxis(0)); assertAxisEquals(AxisNames.GEODETIC_LONGITUDE, "λ", AxisDirection.EAST, -200, +200, Units.GRAD, RangeMeaning.WRAPAROUND, cs.getAxis(1)); assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(), STRICT); cs = crs.getCoordinateSystem(); assertEquals("dimension", 2, cs.getDimension()); assertAxisEquals(AxisNames.GEODETIC_LONGITUDE, "λ", AxisDirection.EAST, -200, +200, Units.GRAD, RangeMeaning.WRAPAROUND, cs.getAxis(0)); assertAxisEquals(AxisNames.GEODETIC_LATITUDE, "φ", AxisDirection.NORTH, -100, +100, Units.GRAD, RangeMeaning.EXACT, cs.getAxis(1));
/** * Validates the given coordinate system. * * @param object The object to validate, or {@code null}. */ public void validate(final EllipsoidalCS object) { if (object == null) { return; } validateIdentifiedObject(object); validateAxes(object); final int dimension = object.getDimension(); assertBetween("EllipsoidalCS: wrong number of dimensions.", 2, 3, dimension); }
assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(), STRICT); EllipsoidalCS cs = crs.getCoordinateSystem(); assertEquals("dimension", 2, cs.getDimension()); assertAxisEquals(AxisNames.GEODETIC_LATITUDE, "φ", AxisDirection.NORTH, -90, +90, Units.DEGREE, RangeMeaning.EXACT, cs.getAxis(0)); assertAxisEquals(AxisNames.GEODETIC_LONGITUDE, "λ", AxisDirection.EAST, -180, +180, Units.DEGREE, RangeMeaning.WRAPAROUND, cs.getAxis(1));
/** * Validates the given coordinate system. * * @param object the object to validate, or {@code null}. */ public void validate(final EllipsoidalCS object) { if (object == null) { return; } validateIdentifiedObject(object); validateAxes(object); final int dimension = object.getDimension(); assertBetween("EllipsoidalCS: wrong number of dimensions.", 2, 3, dimension); }