Author: desruisseaux
Date: Fri Sep 4 09:13:26 2015
New Revision: 1701187
URL: http://svn.apache.org/r1701187
Log:
Replace set of methods annotated with @XmlElement by a single method annotated
with @XmlElements.
https://issues.apache.org/jira/browse/SIS-166
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
(with props)
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
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
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java?rev=1701187&r1=1701186&r2=1701187&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
[UTF-8] Fri Sep 4 09:13:26 2015
@@ -19,18 +19,12 @@ package org.apache.sis.referencing.crs;
import java.util.Map;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opengis.referencing.cs.AffineCS;
-import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.crs.EngineeringCRS;
-import org.opengis.referencing.cs.CylindricalCS;
-import org.opengis.referencing.cs.LinearCS;
-import org.opengis.referencing.cs.PolarCS;
-import org.opengis.referencing.cs.SphericalCS;
-import org.opengis.referencing.cs.UserDefinedCS;
import org.opengis.referencing.datum.EngineeringDatum;
-import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.*;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.io.wkt.Formatter;
@@ -68,13 +62,7 @@ import static org.apache.sis.util.Argume
* @module
*/
@XmlType(name = "EngineeringCRSType", propOrder = {
- "affineCS",
- "cartesianCS",
- "cylindricalCS",
- "linearCS",
- "polarCS",
- "sphericalCS",
- "userDefinedCS",
+ "coordinateSystem",
"datum"
})
@XmlRootElement(name = "EngineeringCRS")
@@ -215,26 +203,30 @@ public class DefaultEngineeringCRS exten
}
/**
- * Invoked by JAXB at marshalling time.
+ * Returns the coordinate system.
+ *
+ * @return The coordinate system.
*/
- @XmlElement(name="affineCS") private AffineCS getAffineCS()
{return getCoordinateSystem(AffineCS .class);}
- @XmlElement(name="cartesianCS") private CartesianCS getCartesianCS()
{return getCoordinateSystem(CartesianCS .class);}
- @XmlElement(name="cylindricalCS") private CylindricalCS getCylindricalCS()
{return getCoordinateSystem(CylindricalCS.class);}
- @XmlElement(name="linearCS") private LinearCS getLinearCS()
{return getCoordinateSystem(LinearCS .class);}
- @XmlElement(name="polarCS") private PolarCS getPolarCS()
{return getCoordinateSystem(PolarCS .class);}
- @XmlElement(name="sphericalCS") private SphericalCS getSphericalCS()
{return getCoordinateSystem(SphericalCS .class);}
- @XmlElement(name="userDefinedCS") private UserDefinedCS getUserDefinedCS()
{return getCoordinateSystem(UserDefinedCS.class);}
-
- /**
- * Invoked by JAXB at unmarshalling time.
- */
- private void setAffineCS (final AffineCS cs)
{super.setCoordinateSystem("affineCS", cs);}
- private void setCartesianCS (final CartesianCS cs)
{super.setCoordinateSystem("cartesianCS", cs);}
- private void setCylindricalCS(final CylindricalCS cs)
{super.setCoordinateSystem("cylindricalCS", cs);}
- private void setLinearCS (final LinearCS cs)
{super.setCoordinateSystem("linearCS", cs);}
- private void setPolarCS (final PolarCS cs)
{super.setCoordinateSystem("polarCS", cs);}
- private void setSphericalCS (final SphericalCS cs)
{super.setCoordinateSystem("sphericalCS", cs);}
- private void setUserDefinedCS(final UserDefinedCS cs)
{super.setCoordinateSystem("userDefinedCS", cs);}
+ @Override
+ @XmlElements({
+ @XmlElement(name = "cartesianCS", type = DefaultCartesianCS.class),
+ @XmlElement(name = "affineCS", type = DefaultAffineCS.class),
+ @XmlElement(name = "cylindricalCS", type = DefaultCylindricalCS.class),
+ @XmlElement(name = "linearCS", type = DefaultLinearCS.class),
+ @XmlElement(name = "polarCS", type = DefaultPolarCS.class),
+ @XmlElement(name = "sphericalCS", type = DefaultSphericalCS.class),
+ @XmlElement(name = "userDefinedCS", type = DefaultUserDefinedCS.class)
+ })
+ public CoordinateSystem getCoordinateSystem() {
+ return super.getCoordinateSystem();
+ }
+
+ /**
+ * Used by JAXB only (invoked by reflection).
+ */
+ private void setCoordinateSystem(final CoordinateSystem cs) {
+ super.setCoordinateSystem("coordinateSystem", cs);
+ }
/**
* {@inheritDoc}
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=1701187&r1=1701186&r2=1701187&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 09:13:26 2015
@@ -62,6 +62,7 @@ import static org.apache.sis.test.Refere
org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
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.cs.DirectionAlongMeridianTest.class
})
public final strictfp class GeodeticObjectParserTest extends TestCase {
Added:
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/DefaultEngineeringCRSTest.java?rev=1701187&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
(added)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
[UTF-8] Fri Sep 4 09:13:26 2015
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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.CartesianCS;
+import org.opengis.referencing.cs.SphericalCS;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.apache.sis.referencing.cs.HardCodedCS;
+import org.apache.sis.referencing.datum.DefaultEngineeringDatum;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.test.XMLTestCase;
+import org.apache.sis.xml.Namespaces;
+import org.junit.Test;
+
+import static org.apache.sis.test.MetadataAssert.*;
+
+
+/**
+ * Tests {@link DefaultEngineeringCRS}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+public final strictfp class DefaultEngineeringCRSTest 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.
+ */
+ @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);
+ }
+
+ /**
+ * Tests WKT 2 formatting.
+ */
+ @Test
+ public void testWKT2() {
+ final DefaultEngineeringCRS crs = createSpherical();
+ 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]]]",
+ crs);
+ }
+
+ /**
+ * Tests XML (un)marshalling of an engineering 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());
+ }
+
+ /**
+ * Tests XML (un)marshalling of an engineering CRS using a Spherical 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());
+
+ 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());
+ }
+}
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
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=1701187&r1=1701186&r2=1701187&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 09:13:26 2015
@@ -134,6 +134,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
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.operation.DefaultTransformationTest.class,
org.apache.sis.referencing.operation.DefaultConversionTest.class,
org.apache.sis.referencing.operation.OperationMarshallingTest.class,
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java?rev=1701187&r1=1701186&r2=1701187&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
[UTF-8] Fri Sep 4 09:13:26 2015
@@ -49,8 +49,8 @@ public final class TimePeriod extends GM
* The GML2 way is more verbose.
*/
@XmlElements({
- @XmlElement(type=TimePeriodBound.GML3.class, name="beginPosition"),
- @XmlElement(type=TimePeriodBound.GML2.class, name="begin")
+ @XmlElement(type = TimePeriodBound.GML3.class, name = "beginPosition"),
+ @XmlElement(type = TimePeriodBound.GML2.class, name = "begin")
})
TimePeriodBound begin;
@@ -59,8 +59,8 @@ public final class TimePeriod extends GM
* The GML2 way is more verbose.
*/
@XmlElements({
- @XmlElement(type=TimePeriodBound.GML3.class, name="endPosition"),
- @XmlElement(type=TimePeriodBound.GML2.class, name="end")
+ @XmlElement(type = TimePeriodBound.GML3.class, name = "endPosition"),
+ @XmlElement(type = TimePeriodBound.GML2.class, name = "end")
})
TimePeriodBound end;