Author: desruisseaux
Date: Fri Sep 4 10:32:24 2015
New Revision: 1701205
URL: http://svn.apache.org/r1701205
Log:
Add test case for ImageCRS WKT and XML formatting.
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultImageCRSTest.java
- copied, changed from r1701187,
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1701205&r1=1701204&r2=1701205&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Fri Sep 4 10:32:24 2015
@@ -63,6 +63,7 @@ import static org.apache.sis.test.Refere
org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
org.apache.sis.referencing.crs.DefaultCompoundCRSTest.class,
org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class
})
public final strictfp class GeodeticObjectParserTest extends TestCase {
Copied:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultImageCRSTest.java
(from r1701187,
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultImageCRSTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultImageCRSTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java&r1=1701187&r2=1701205&rev=1701205&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultImageCRSTest.java
[UTF-8] Fri Sep 4 10:32:24 2015
@@ -17,13 +17,16 @@
package org.apache.sis.referencing.crs;
import java.util.Collections;
-import org.opengis.referencing.cs.AxisDirection;
import javax.xml.bind.JAXBException;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.AffineCS;
import org.opengis.referencing.cs.CartesianCS;
-import org.opengis.referencing.cs.SphericalCS;
import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.datum.PixelInCell;
import org.apache.sis.referencing.cs.HardCodedCS;
-import org.apache.sis.referencing.datum.DefaultEngineeringDatum;
+import org.apache.sis.referencing.datum.DefaultImageDatum;
+import org.apache.sis.referencing.cs.DefaultAffineCS;
+import org.apache.sis.referencing.cs.HardCodedAxes;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.test.XMLTestCase;
import org.apache.sis.xml.Namespaces;
@@ -33,45 +36,25 @@ import static org.apache.sis.test.Metada
/**
- * Tests {@link DefaultEngineeringCRS}.
+ * Tests {@link DefaultImageCRS}.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.6
* @version 0.6
* @module
*/
-public final strictfp class DefaultEngineeringCRSTest extends XMLTestCase {
+public final strictfp class DefaultImageCRSTest extends XMLTestCase {
/**
- * Creates an engineering CRS using a two-dimensional Cartesian coordinate
system.
- */
- private static DefaultEngineeringCRS createCartesian() {
- return new
DefaultEngineeringCRS(Collections.singletonMap(DefaultEngineeringCRS.NAME_KEY,
"A construction site CRS"),
- new
DefaultEngineeringDatum(Collections.singletonMap(DefaultEngineeringDatum.NAME_KEY,
"P1")),
- HardCodedCS.CARTESIAN_2D);
- }
-
- /**
- * Creates an engineering CRS using a three-dimensional Spherical
coordinate system.
- */
- private static DefaultEngineeringCRS createSpherical() {
- return new
DefaultEngineeringCRS(Collections.singletonMap(DefaultEngineeringCRS.NAME_KEY,
"A spherical CRS"),
- new
DefaultEngineeringDatum(Collections.singletonMap(DefaultEngineeringDatum.NAME_KEY,
"Centre")),
- HardCodedCS.SPHERICAL);
- }
-
- /**
- * Tests WKT 1 formatting.
+ * Creates an image CRS using a two-dimensional affine or Cartesian
coordinate system.
+ *
+ * @param cartesian {@code true} for a Cartesian coordinate system, or
{@code false} for an affine one.
*/
- @Test
- public void testWKT1() {
- final DefaultEngineeringCRS crs = createCartesian();
- assertWktEquals(Convention.WKT1,
- "LOCAL_CS[“A construction site CRS”,\n" +
- " LOCAL_DATUM[“P1”, 0],\n" +
- " UNIT[“metre”, 1],\n" +
- " AXIS[“x”, EAST],\n" +
- " AXIS[“y”, NORTH]]",
- crs);
+ private static DefaultImageCRS create(final boolean cartesian) {
+ return new
DefaultImageCRS(Collections.singletonMap(DefaultImageCRS.NAME_KEY, "An image
CRS"),
+ new
DefaultImageDatum(Collections.singletonMap(DefaultImageDatum.NAME_KEY, "C1"),
PixelInCell.CELL_CENTER),
+ cartesian ? HardCodedCS.GRID : new DefaultAffineCS(
+ Collections.singletonMap(DefaultAffineCS.NAME_KEY,
"Grid"),
+ HardCodedAxes.COLUMN, HardCodedAxes.ROW));
}
/**
@@ -79,133 +62,90 @@ public final strictfp class DefaultEngin
*/
@Test
public void testWKT2() {
- final DefaultEngineeringCRS crs = createSpherical();
+ final DefaultImageCRS crs = create(true);
assertWktEquals(Convention.WKT2,
- "EngineeringCRS[“A spherical CRS”,\n" +
- " EngineeringDatum[“Centre”],\n" +
- " CS[spherical, 3],\n" +
- " Axis[“Spherical latitude (U)”, north, Order[1],
AngleUnit[“degree”, 0.017453292519943295]],\n" +
- " Axis[“Spherical longitude (V)”, east, Order[2],
AngleUnit[“degree”, 0.017453292519943295]],\n" +
- " Axis[“Geocentric radius (r)”, up, Order[3],
LengthUnit[“metre”, 1]]]",
+ "ImageCRS[“An image CRS”,\n" +
+ " ImageDatum[“C1”],\n" +
+ " CS[Cartesian, 2],\n" +
+ " Axis[“Column (i)”, columnPositive, Order[1]],\n" +
+ " Axis[“Row (j)”, rowPositive, Order[2]],\n" +
+ " ScaleUnit[“unity”, 1]]",
crs);
}
/**
- * Tests XML (un)marshalling of an engineering CRS using a Cartesian CS.
+ * Tests XML (un)marshalling of an image CRS using a Cartesian CS.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
public void testCartesianXML() throws JAXBException {
- final String xml = marshal(createCartesian());
- assertXmlEquals(
- "<gml:EngineeringCRS xmlns:gml=\"" + Namespaces.GML + "\">\n" +
- " <gml:name>A construction site CRS</gml:name>\n" +
- " <gml:cartesianCS gml:id=\"Cartesian2D\">\n" +
- " <gml:name>Cartesian 2D</gml:name>\n" +
- " <gml:axis>\n" +
- " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9001\" gml:id=\"x\">\n" +
- " <gml:name>x</gml:name>\n" +
- " <gml:axisAbbrev>x</gml:axisAbbrev>\n" +
- " <gml:axisDirection
codeSpace=\"EPSG\">east</gml:axisDirection>\n" +
- " </gml:CoordinateSystemAxis>\n" +
- " </gml:axis>\n" +
- " <gml:axis>\n" +
- " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9001\" gml:id=\"y\">\n" +
- " <gml:name>y</gml:name>\n" +
- " <gml:axisAbbrev>y</gml:axisAbbrev>\n" +
- " <gml:axisDirection
codeSpace=\"EPSG\">north</gml:axisDirection>\n" +
- " </gml:CoordinateSystemAxis>\n" +
- " </gml:axis>\n" +
- " </gml:cartesianCS>\n" +
- " <gml:engineeringDatum>\n" +
- " <gml:EngineeringDatum gml:id=\"P1\">\n" +
- " <gml:name>P1</gml:name>\n" +
- " </gml:EngineeringDatum>\n" +
- " </gml:engineeringDatum>\n" +
- "</gml:EngineeringCRS>",
- xml, "xmlns:*");
-
- final DefaultEngineeringCRS crs =
unmarshal(DefaultEngineeringCRS.class, xml);
- assertEquals("name", "A construction site CRS",
crs.getName().getCode());
- assertEquals("datum.name", "P1", crs.getDatum().getName().getCode());
-
- final CoordinateSystem cs = crs.getCoordinateSystem();
- assertInstanceOf("coordinateSystem", CartesianCS.class, cs);
- assertEquals("cs.name", "Cartesian 2D", cs.getName().getCode());
- assertEquals("cs.dimension", 2, cs.getDimension());
- assertAxisDirectionsEqual("cartesianCS", cs, AxisDirection.EAST,
AxisDirection.NORTH);
-
- assertEquals("cs.axis[0].name", "x",
cs.getAxis(0).getName().getCode());
- assertEquals("cs.axis[1].name", "y",
cs.getAxis(1).getName().getCode());
+ testXML(true);
}
/**
- * Tests XML (un)marshalling of an engineering CRS using a Spherical CS.
+ * Tests XML (un)marshalling of an image CRS using an affine CS.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
- public void testSphericalXML() throws JAXBException {
- final String xml = marshal(createSpherical());
- assertXmlEquals(
- "<gml:EngineeringCRS xmlns:gml=\"" + Namespaces.GML + "\">\n" +
- " <gml:name>A spherical CRS</gml:name>\n" +
- " <gml:sphericalCS gml:id=\"Spherical\">\n" +
- " <gml:name>Spherical</gml:name>\n" +
- " <gml:axis>\n" +
- " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9122\" gml:id=\"SphericalLatitude\">\n" +
- " <gml:name>Spherical latitude</gml:name>\n" +
- " <gml:axisAbbrev>φ′</gml:axisAbbrev>\n" +
- " <gml:axisDirection
codeSpace=\"EPSG\">north</gml:axisDirection>\n" +
- " <gml:minimumValue>-90.0</gml:minimumValue>\n" +
- " <gml:maximumValue>90.0</gml:maximumValue>\n" +
- " <gml:rangeMeaning
codeSpace=\"EPSG\">exact</gml:rangeMeaning>\n" +
- " </gml:CoordinateSystemAxis>\n" +
- " </gml:axis>\n" +
- " <gml:axis>\n" +
- " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9122\" gml:id=\"SphericalLongitude\">\n" +
- " <gml:name>Spherical longitude</gml:name>\n" +
- " <gml:axisAbbrev>θ</gml:axisAbbrev>\n" +
- " <gml:axisDirection
codeSpace=\"EPSG\">east</gml:axisDirection>\n" +
- " <gml:minimumValue>-180.0</gml:minimumValue>\n" +
- " <gml:maximumValue>180.0</gml:maximumValue>\n" +
- " <gml:rangeMeaning
codeSpace=\"EPSG\">wraparound</gml:rangeMeaning>\n" +
- " </gml:CoordinateSystemAxis>\n" +
- " </gml:axis>\n" +
- " <gml:axis>\n" +
- " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9001\" gml:id=\"GeocentricRadius\">\n" +
- " <gml:name>Geocentric radius</gml:name>\n" +
- " <gml:axisAbbrev>r</gml:axisAbbrev>\n" +
- " <gml:axisDirection
codeSpace=\"EPSG\">up</gml:axisDirection>\n" +
- " <gml:minimumValue>0.0</gml:minimumValue>\n" +
- " <gml:rangeMeaning
codeSpace=\"EPSG\">exact</gml:rangeMeaning>\n" +
- " </gml:CoordinateSystemAxis>\n" +
- " </gml:axis>\n" +
- " </gml:sphericalCS>\n" +
- " <gml:engineeringDatum>\n" +
- " <gml:EngineeringDatum gml:id=\"Centre\">\n" +
- " <gml:name>Centre</gml:name>\n" +
- " </gml:EngineeringDatum>\n" +
- " </gml:engineeringDatum>\n" +
- "</gml:EngineeringCRS>",
- xml, "xmlns:*");
-
- final DefaultEngineeringCRS crs =
unmarshal(DefaultEngineeringCRS.class, xml);
- assertEquals("name", "A spherical CRS", crs.getName().getCode());
- assertEquals("datum.name", "Centre",
crs.getDatum().getName().getCode());
+ public void testAffineXML() throws JAXBException {
+ testXML(false);
+ }
+
+ /**
+ * Implementation of {@link #testCartesianXML()} and {@link
#testAffineXML()}.
+ */
+ private void testXML(final boolean cartesian) throws JAXBException {
+ String expected =
+ "<gml:ImageCRS xmlns:gml=\"" + Namespaces.GML + "\">\n" +
+ " <gml:name>An image CRS</gml:name>\n" +
+ " <gml:cartesianCS>\n" +
+ " <gml:CartesianCS gml:id=\"Grid\">\n" +
+ " <gml:name>Grid</gml:name>\n" +
+ " <gml:axis>\n" +
+ " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9201\" gml:id=\"Column\">\n" +
+ " <gml:name>Column</gml:name>\n" +
+ " <gml:axisAbbrev>i</gml:axisAbbrev>\n" +
+ " <gml:axisDirection
codeSpace=\"EPSG\">columnPositive</gml:axisDirection>\n" +
+ " </gml:CoordinateSystemAxis>\n" +
+ " </gml:axis>\n" +
+ " <gml:axis>\n" +
+ " <gml:CoordinateSystemAxis
uom=\"urn:ogc:def:uom:EPSG::9201\" gml:id=\"Row\">\n" +
+ " <gml:name>Row</gml:name>\n" +
+ " <gml:axisAbbrev>j</gml:axisAbbrev>\n" +
+ " <gml:axisDirection
codeSpace=\"EPSG\">rowPositive</gml:axisDirection>\n" +
+ " </gml:CoordinateSystemAxis>\n" +
+ " </gml:axis>\n" +
+ " </gml:CartesianCS>\n" +
+ " </gml:cartesianCS>\n" +
+ " <gml:imageDatum>\n" +
+ " <gml:ImageDatum gml:id=\"C1\">\n" +
+ " <gml:name>C1</gml:name>\n" +
+ " <gml:pixelInCell>cell center</gml:pixelInCell>\n" +
+ " </gml:ImageDatum>\n" +
+ " </gml:imageDatum>\n" +
+ "</gml:ImageCRS>";
+ if (!cartesian) {
+ expected = expected.replace("CartesianCS",
"AffineCS").replace("cartesianCS", "affineCS");
+ }
+ final String xml = marshal(create(cartesian));
+ assertXmlEquals(expected, xml, "xmlns:*");
+
+ final DefaultImageCRS crs = unmarshal(DefaultImageCRS.class, xml);
+ assertEquals("name", "An image CRS", crs.getName().getCode());
+ assertEquals("datum.name", "C1", crs.getDatum().getName().getCode());
final CoordinateSystem cs = crs.getCoordinateSystem();
- assertInstanceOf("coordinateSystem", SphericalCS.class, cs);
- assertEquals("cs.name", "Spherical", cs.getName().getCode());
- assertEquals("cs.dimension", 3, cs.getDimension());
- assertAxisDirectionsEqual("cartesianCS", cs, AxisDirection.NORTH,
AxisDirection.EAST, AxisDirection.UP);
-
- assertEquals("cs.axis[0].name", "Spherical latitude",
cs.getAxis(0).getName().getCode());
- assertEquals("cs.axis[1].name", "Spherical longitude",
cs.getAxis(1).getName().getCode());
- assertEquals("cs.axis[2].name", "Geocentric radius",
cs.getAxis(2).getName().getCode());
- assertEquals("cs.axis[0].abbreviation", "φ′",
cs.getAxis(0).getAbbreviation());
- assertEquals("cs.axis[1].abbreviation", "θ",
cs.getAxis(1).getAbbreviation());
- assertEquals("cs.axis[2].abbreviation", "r",
cs.getAxis(2).getAbbreviation());
+ assertInstanceOf("coordinateSystem", cartesian ? CartesianCS.class :
AffineCS.class, cs);
+ assertEquals("cs.isCartesian", cartesian, cs instanceof CartesianCS);
+ assertEquals("cs.name", "Grid", cs.getName().getCode());
+ assertEquals("cs.dimension", 2, cs.getDimension());
+ assertAxisDirectionsEqual("cartesianCS", cs,
AxisDirection.COLUMN_POSITIVE, AxisDirection.ROW_POSITIVE);
+
+ assertEquals("cs.axis[0].name", "Column",
cs.getAxis(0).getName().getCode());
+ assertEquals("cs.axis[1].name", "Row",
cs.getAxis(1).getName().getCode());
+ assertEquals("cs.axis[0].abbreviation", "i",
cs.getAxis(0).getAbbreviation());
+ assertEquals("cs.axis[1].abbreviation", "j",
cs.getAxis(1).getAbbreviation());
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1701205&r1=1701204&r2=1701205&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Sep 4 10:32:24 2015
@@ -135,6 +135,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
org.apache.sis.referencing.operation.DefaultTransformationTest.class,
org.apache.sis.referencing.operation.DefaultConversionTest.class,
org.apache.sis.referencing.operation.OperationMarshallingTest.class,