Search in sources :

Example 6 with CoordinateSystemAxis

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));
}
Also used : CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) Test(org.junit.Test)

Example 7 with CoordinateSystemAxis

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));
}
Also used : CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) Test(org.junit.Test)

Example 8 with CoordinateSystemAxis

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");
}
Also used : CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) Test(org.junit.Test)

Example 9 with CoordinateSystemAxis

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");
}
Also used : CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) Test(org.junit.Test)

Example 10 with CoordinateSystemAxis

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);
    }
}
Also used : CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) InternationalString(org.opengis.util.InternationalString)

Aggregations

CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)50 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)15 Test (org.junit.Test)14 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)9 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)5 Unit (javax.measure.Unit)4 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)4 AxisDirection (org.opengis.referencing.cs.AxisDirection)4 FactoryException (org.opengis.util.FactoryException)4 IdentifiedObject (org.opengis.referencing.IdentifiedObject)3 VerticalCS (org.opengis.referencing.cs.VerticalCS)3 InternationalString (org.opengis.util.InternationalString)3 DefaultVerticalCRS (org.apache.sis.referencing.crs.DefaultVerticalCRS)2 DefaultCoordinateSystemAxis (org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis)2 DefaultVerticalCS (org.apache.sis.referencing.cs.DefaultVerticalCS)2 AbstractCoordinateOperation (org.apache.sis.referencing.operation.AbstractCoordinateOperation)2 DependsOnMethod (org.apache.sis.test.DependsOnMethod)2 Identifier (org.opengis.metadata.Identifier)2 VerticalExtent (org.opengis.metadata.extent.VerticalExtent)2 GeodeticCRS (org.opengis.referencing.crs.GeodeticCRS)2