use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class GeodeticObjectVerifier method assertIsGeodetic2D.
/**
* Asserts that the given coordinate system contains the geodetic (latitude, longitude) axes in degrees.
* This method verifies the following properties:
*
* <table class="sis">
* <caption>Verified properties</caption>
* <tr><th>Property</th> <th colspan="2">Expected value</th></tr>
* <tr><td>{@linkplain EllipsoidalCS#getDimension() Dimension}</td>
* <td colspan="2">2</td></tr>
* <tr><td>Axes {@linkplain Identifier#getCode() Code} of the {@linkplain GeodeticDatum#getName() name}</td>
* <td>{@code "Geodetic latitude"}</td>
* <td>{@code "Geodetic longitude"}</td></tr>
* <tr><td>Axes {@linkplain CoordinateSystemAxis#getDirection() direction}</td>
* <td>{@link AxisDirection#NORTH NORTH}</td>
* <td>{@link AxisDirection#EAST EAST}</td></tr>
* <tr><td>Axes {@linkplain CoordinateSystemAxis#getUnit() units}</td>
* <td>{@link Units#DEGREE}</td>
* <td>{@link Units#DEGREE}</td></tr>
* <tr><td>Axes range</td>
* <td>[-90 … 90] (see below)</td>
* <td>[-180 … 180] (see below)</td></tr>
* <tr><td>Axes range meaning</td>
* <td>{@link RangeMeaning#EXACT} or missing</td>
* <td>{@link RangeMeaning#WRAPAROUND} or missing</td></tr>
* </table>
*
* <b>Notes:</b>
* <ul>
* <li>The axes range may be missing if and only if the range meaning is also missing.</li>
* <li>This method does not verify {@linkplain CoordinateSystemAxis#getAbbreviation() abbreviations}
* because the classical symbols (φ,λ) are often replaced by (lat,long).</li>
* </ul>
*
* @param cs the coordinate system to verify.
* @param isRangeMandatory {@code true} if the axes range and range meaning properties shall be defined,
* or {@code false} if they are optional.
*/
public static void assertIsGeodetic2D(final EllipsoidalCS cs, final boolean isRangeMandatory) {
assertEquals("dimension", 2, cs.getDimension());
final CoordinateSystemAxis latitude = cs.getAxis(0);
final CoordinateSystemAxis longitude = cs.getAxis(1);
assertNotNull("axis", latitude);
assertNotNull("axis", longitude);
assertEquals("axis[0].name", AxisNames.GEODETIC_LATITUDE, latitude.getName().getCode());
assertEquals("axis[1].name", AxisNames.GEODETIC_LONGITUDE, longitude.getName().getCode());
assertEquals("axis[0].direction", AxisDirection.NORTH, latitude.getDirection());
assertEquals("axis[1].direction", AxisDirection.EAST, longitude.getDirection());
assertEquals("axis[0].unit", Units.DEGREE, latitude.getUnit());
assertEquals("axis[1].unit", Units.DEGREE, longitude.getUnit());
verifyRange(latitude, -90, +90, RangeMeaning.EXACT, isRangeMandatory);
verifyRange(longitude, -180, +180, RangeMeaning.WRAPAROUND, isRangeMandatory);
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class Shapes2DTest method createFromExtremums.
/**
* Creates a rectangle for the given CRS and coordinate values.
*/
@Override
Rectangle2D createFromExtremums(CoordinateReferenceSystem crs, double xmin, double ymin, double xmax, double ymax) {
if (xmin > xmax) {
// This implementation does not support spanning anti-meridian.
final CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(0);
xmin = axis.getMinimumValue();
xmax = axis.getMaximumValue();
}
return new Rectangle2D.Double(xmin, ymin, xmax - xmin, ymax - ymin);
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class EPSGFactoryTest method testDeprecatedCoordinateSystems.
/**
* Tests creation of deprecated coordinate systems.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
public void testDeprecatedCoordinateSystems() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
for (final Map.Entry<Integer, Integer> entry : EPSGDataAccess.deprecatedCS().entrySet()) {
final CoordinateSystem expected = factory.createEllipsoidalCS(entry.getValue().toString());
loggings.assertNoUnexpectedLog();
final String code = entry.getKey().toString();
final CoordinateSystem deprecated;
try {
deprecated = factory.createEllipsoidalCS(code);
} catch (FactoryException e) {
final String m = e.getMessage();
if (m.contains("9115") || m.contains("9116") || m.contains("9117") || m.contains("9118") || m.contains("9119") || m.contains("9120")) {
// Unit "9116" to "9120" are known to be unsupported.
continue;
}
throw e;
}
loggings.assertNextLogContains(code);
final int dimension = expected.getDimension();
assertEquals("dimension", dimension, deprecated.getDimension());
for (int i = 0; i < dimension; i++) {
final CoordinateSystemAxis ref = expected.getAxis(i);
final CoordinateSystemAxis axis = deprecated.getAxis(i);
assertEquals("name", ref.getName(), axis.getName());
assertEquals("alias", ref.getAlias(), axis.getAlias());
assertEquals("direction", ref.getDirection(), axis.getDirection());
assertEquals("rangeMeaning", ref.getRangeMeaning(), axis.getRangeMeaning());
assertEquals("unit", ref.getUnit().getSystemUnit(), axis.getUnit().getSystemUnit());
}
}
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class DefaultGeographicCRSTest method testShiftLongitudeRange.
/**
* Tests the {@link DefaultGeographicCRS#forConvention(AxesConvention)} method
* for {@link AxesConvention#POSITIVE_RANGE}.
*/
@Test
public void testShiftLongitudeRange() {
final DefaultGeographicCRS crs = HardCodedCRS.WGS84_3D;
CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(0);
assertEquals("longitude.minimumValue", -180.0, axis.getMinimumValue(), STRICT);
assertEquals("longitude.maximumValue", +180.0, axis.getMaximumValue(), STRICT);
assertSame("Expected a no-op.", crs, crs.forConvention(AxesConvention.RIGHT_HANDED));
final DefaultGeographicCRS shifted = crs.forConvention(AxesConvention.POSITIVE_RANGE);
assertNotSame("Expected a new CRS.", crs, shifted);
Validators.validate(shifted);
axis = shifted.getCoordinateSystem().getAxis(0);
assertEquals("longitude.minimumValue", 0.0, axis.getMinimumValue(), STRICT);
assertEquals("longitude.maximumValue", 360.0, axis.getMaximumValue(), STRICT);
assertSame("Expected a no-op.", shifted, shifted.forConvention(AxesConvention.POSITIVE_RANGE));
assertSame("Expected cached instance.", shifted, crs.forConvention(AxesConvention.POSITIVE_RANGE));
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class CoordinateSystemsTest method testReplaceAxes.
/**
* Tests {@link CoordinateSystems#replaceAxes(CoordinateSystem, AxisFilter)}
* without change of coordinate system type.
*/
@Test
public void testReplaceAxes() {
final EllipsoidalCS sourceCS = HardCodedCS.GEODETIC_3D;
// What we want to get.
final EllipsoidalCS targetCS = HardCodedCS.ELLIPSOIDAL_gon;
final CoordinateSystem actualCS = CoordinateSystems.replaceAxes(sourceCS, new AxisFilter() {
@Override
public boolean accept(final CoordinateSystemAxis axis) {
return Units.isAngular(axis.getUnit());
}
@Override
public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit) {
if (Units.isAngular(unit)) {
unit = Units.GRAD;
}
return unit;
}
});
assertEqualsIgnoreMetadata(targetCS, actualCS);
}
Aggregations