use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class DefaultCompoundCRSTest method testShiftLongitudeRange.
/**
* Tests {@link DefaultCompoundCRS#forConvention(AxesConvention)} with {@link AxesConvention#POSITIVE_RANGE}.
*/
@Test
public void testShiftLongitudeRange() {
final DefaultGeographicCRS crs3 = HardCodedCRS.WGS84_3D;
final DefaultCompoundCRS crs4 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "4D"), crs3, TIME);
CoordinateSystemAxis axis = crs4.getCoordinateSystem().getAxis(0);
assertEquals("longitude.minimumValue", -180.0, axis.getMinimumValue(), STRICT);
assertEquals("longitude.maximumValue", +180.0, axis.getMaximumValue(), STRICT);
assertSame("Expected a no-op.", crs4, crs4.forConvention(AxesConvention.RIGHT_HANDED));
final DefaultCompoundCRS shifted = crs4.forConvention(AxesConvention.POSITIVE_RANGE);
assertNotSame("Expected a new CRS.", crs4, 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, crs4.forConvention(AxesConvention.POSITIVE_RANGE));
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class DefaultGeocentricCRSTest method testShiftLongitudeRange.
/**
* Tests the {@link DefaultGeocentricCRS#forConvention(AxesConvention)} method
* for {@link AxesConvention#POSITIVE_RANGE}.
*
* @since 0.7
*/
@Test
public void testShiftLongitudeRange() {
final DefaultGeocentricCRS crs = HardCodedCRS.SPHERICAL;
CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(1);
assertEquals("longitude.minimumValue", -180.0, axis.getMinimumValue(), STRICT);
assertEquals("longitude.maximumValue", +180.0, axis.getMaximumValue(), STRICT);
final DefaultGeocentricCRS shifted = crs.forConvention(AxesConvention.POSITIVE_RANGE);
assertNotSame("Expected a new CRS.", crs, shifted);
Validators.validate(shifted);
axis = shifted.getCoordinateSystem().getAxis(1);
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 DefaultCartesianCSTest method testXML.
/**
* Tests (un)marshalling of a Cartesian coordinate system.
*
* @throws JAXBException if an error occurred during unmarshalling.
*/
@Test
public void testXML() throws JAXBException {
final DefaultCartesianCS cs = unmarshalFile(DefaultCartesianCS.class, XML_FILE);
Validators.validate(cs);
GeodeticObjectVerifier.assertIsProjected2D(cs);
/*
* Values in the following tests are specific to our XML file.
* The actual texts in the EPSG database are more descriptive.
*/
final CoordinateSystemAxis E = cs.getAxis(0);
final CoordinateSystemAxis N = cs.getAxis(1);
assertEquals("name", "Easting, northing (E,N)", cs.getName().getCode());
assertEquals("remarks", "Used in ProjectedCRS.", cs.getRemarks().toString());
assertEpsgIdentifierEquals(String.valueOf(Constants.EPSG_PROJECTED_CS), getSingleton(cs.getIdentifiers()));
assertEpsgIdentifierEquals("1", getSingleton(E.getIdentifiers()));
assertEpsgIdentifierEquals("2", getSingleton(N.getIdentifiers()));
assertAxisEquals("Easting", "E", AxisDirection.EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.METRE, null, E);
assertAxisEquals("Northing", "N", AxisDirection.NORTH, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.METRE, null, N);
/*
* Marshal and compare with the original file.
*/
assertMarshalEqualsFile(XML_FILE, cs, "xmlns:*", "xsi:schemaLocation");
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class DefaultEllipsoidalCSTest method testXML.
/**
* Tests (un)marshalling of an ellipsoidal coordinate system.
*
* @throws JAXBException if an error occurred during unmarshalling.
*/
@Test
public void testXML() throws JAXBException {
final DefaultEllipsoidalCS cs = unmarshalFile(DefaultEllipsoidalCS.class, XML_FILE);
Validators.validate(cs);
GeodeticObjectVerifier.assertIsGeodetic2D(cs, true);
/*
* Values in the following tests are specific to our XML file.
* The actual texts in the EPSG database are more descriptive.
*/
final CoordinateSystemAxis φ = cs.getAxis(0);
final CoordinateSystemAxis λ = cs.getAxis(1);
assertEquals("name", "Latitude (north), Longitude (east)", cs.getName().getCode());
assertEquals("remarks", "Used in two-dimensional GeographicCRS.", cs.getRemarks().toString());
assertAxisEquals("Geodetic latitude", "φ", AxisDirection.NORTH, -90, +90, Units.DEGREE, RangeMeaning.EXACT, φ);
assertAxisEquals("Geodetic longitude", "λ", AxisDirection.EAST, -180, +180, Units.DEGREE, RangeMeaning.WRAPAROUND, λ);
assertEpsgIdentifierEquals("6422", getSingleton(cs.getIdentifiers()));
assertEpsgIdentifierEquals("106", getSingleton(φ.getIdentifiers()));
assertEpsgIdentifierEquals("107", getSingleton(λ.getIdentifiers()));
/*
* Marshal and compare with the original file.
*/
assertMarshalEqualsFile(XML_FILE, cs, "xmlns:*", "xsi:schemaLocation");
}
use of org.opengis.referencing.cs.CoordinateSystemAxis in project sis by apache.
the class TransformCommand method printAxes.
/*
* Prints the names of all coordinate system axes on the first row.
* This method does not add EOL character.
* This method opportunistically computes the suggested precision for formatting values.
*
* @throws ConversionException should never happen.
*/
private void printAxes(final CoordinateSystem cs) {
final int targetDim = cs.getDimension();
for (int i = 0; i < targetDim; i++) {
if (i != 0) {
out.print(',');
}
final CoordinateSystemAxis axis = cs.getAxis(i);
String name = axis.getName().getCode();
name = Transliterator.DEFAULT.toShortAxisName(cs, axis.getDirection(), name);
final String unit = axis.getUnit().toString();
if (!unit.isEmpty()) {
name = name + " (" + unit + ')';
}
printQuotedText(name, ordinateWidth, X364.FOREGROUND_CYAN);
}
}
Aggregations