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));
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));
/** 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)); }
final EllipsoidalCS cs = crs.getCoordinateSystem(); final EllipsoidalCS STANDARD = (cs.getDimension() <= 2) ? DefaultEllipsoidalCS.GEODETIC_2D : DefaultEllipsoidalCS.GEODETIC_3D;
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();
/** * 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; }
/** * 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."); }
/** * 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); }
/** * 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); }
/** * A two- or three-dimensional Mercator projection using the given base CRS. * This CRS uses (<var>easting</var>, <var>northing</var>) ordinates in metres. * * @param baseCRS the two- or three-dimensional base CRS. * @return two- or three-dimensional Mercator projection. */ public static DefaultProjectedCRS mercator(final GeographicCRS baseCRS) { return new DefaultProjectedCRS(name("Mercator (other)"), baseCRS, HardCodedConversions.MERCATOR, baseCRS.getCoordinateSystem().getDimension() == 3 ? HardCodedCS.PROJECTED_3D : HardCodedCS.PROJECTED); }
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())){
if (cs.getDimension() < 3) pg.parameter("dim").setValue(2); // Apache SIS specific parameter. return createParameterizedTransform(pg, context);
if (cs.getDimension() < 3) pg.parameter("dim").setValue(2); // Apache SIS specific parameter. return createParameterizedTransform(pg, context);
/** * Tests dimension of constants. */ @Test public void testDimensions() { assertEquals("TIME", 1, TIME .getCoordinateSystem().getDimension()); assertEquals("DEPTH", 1, DEPTH .getCoordinateSystem().getDimension()); assertEquals("WGS84", 2, WGS84 .getCoordinateSystem().getDimension()); assertEquals("WGS84_φλ", 2, WGS84_φλ .getCoordinateSystem().getDimension()); assertEquals("WGS84_3D", 3, WGS84_3D .getCoordinateSystem().getDimension()); assertEquals("CARTESIAN_2D", 2, CARTESIAN_2D.getCoordinateSystem().getDimension()); assertEquals("CARTESIAN_3D", 3, CARTESIAN_3D.getCoordinateSystem().getDimension()); assertEquals("GEOCENTRIC", 3, GEOCENTRIC .getCoordinateSystem().getDimension()); assertEquals("SPHERICAL", 3, SPHERICAL .getCoordinateSystem().getDimension()); assertEquals("GEOID_4D", 4, GEOID_4D .getCoordinateSystem().getDimension()); }
}; double[] target; if (sourceCRS.getCoordinateSystem().getDimension() == 2) { source = TestUtilities.dropLastDimensions(source, 3, 2); target = new double[] { }; if (targetCRS.getCoordinateSystem().getDimension() == 2) { target = TestUtilities.dropLastDimensions(target, 3, 2);
/** * 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()); }
/** * 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)); }
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));
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));
assertEquals("dimension", 2, cs.getDimension()); final CoordinateSystemAxis latitude = cs.getAxis(0); final CoordinateSystemAxis longitude = cs.getAxis(1);