Author: desruisseaux
Date: Sun Jan 5 21:53:37 2014
New Revision: 1555635
URL: http://svn.apache.org/r1555635
Log:
Added partial GML 3.1 tests, and a note about our incomplete support of GML
3.1.1 (SIS-160).
Added:
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level (GML 3.1).xml
- copied, changed from r1555453,
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1555635&r1=1555634&r2=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Sun Jan 5 21:53:37 2014
@@ -419,7 +419,10 @@ public class AbstractIdentifiedObject ex
}
}
// In last ressort, append code without codespace since the name are
often verbose.
- return appendUnicodeIdentifier(id, '-', name.getCode(), ":", false) ?
id.toString() : null;
+ if (name != null && appendUnicodeIdentifier(id, '-', name.getCode(),
":", false)) {
+ return id.toString();
+ }
+ return null;
}
/**
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1555635&r1=1555634&r2=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Sun Jan 5 21:53:37 2014
@@ -68,7 +68,12 @@ import java.util.Objects;
* @see org.apache.sis.referencing.cs.AbstractCS
* @see org.apache.sis.referencing.crs.AbstractCRS
*/
-@XmlType(name = "AbstractDatumType")
+@XmlType(name = "AbstractDatumType", propOrder = {
+ "domainOfValidity",
+ "scope",
+ "anchorDefinition",
+ "realizationEpoch"
+})
@XmlRootElement(name = "AbstractDatum")
@XmlSeeAlso({
DefaultGeodeticDatum.class,
@@ -92,8 +97,8 @@ public class AbstractDatum extends Abstr
* Description, possibly including coordinates, of the point or points
used to anchor the datum
* to the Earth. Also known as the "origin", especially for Engineering
and Image Datums.
*/
- @XmlElement(name = "anchorDefinition")
- private final InternationalString anchorPoint;
+ @XmlElement
+ private final InternationalString anchorDefinition;
/**
* The time after which this datum definition is valid. This time may be
precise
@@ -124,7 +129,7 @@ public class AbstractDatum extends Abstr
*/
AbstractDatum() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
- anchorPoint = null;
+ anchorDefinition = null;
realizationEpoch = Long.MIN_VALUE;
domainOfValidity = null;
scope = null;
@@ -193,7 +198,7 @@ public class AbstractDatum extends Abstr
super(properties);
realizationEpoch =
MetadataUtilities.toMilliseconds(property(properties, REALIZATION_EPOCH_KEY,
Date.class));
domainOfValidity = property(properties, DOMAIN_OF_VALIDITY_KEY,
Extent.class);
- anchorPoint = Types.toInternationalString(properties,
ANCHOR_POINT_KEY);
+ anchorDefinition = Types.toInternationalString(properties,
ANCHOR_POINT_KEY);
scope = Types.toInternationalString(properties, SCOPE_KEY);
}
@@ -211,7 +216,7 @@ public class AbstractDatum extends Abstr
realizationEpoch =
MetadataUtilities.toMilliseconds(datum.getRealizationEpoch());
domainOfValidity = datum.getDomainOfValidity();
scope = datum.getScope();
- anchorPoint = datum.getAnchorPoint();
+ anchorDefinition = datum.getAnchorPoint();
}
/**
@@ -280,7 +285,7 @@ public class AbstractDatum extends Abstr
*/
@Override
public InternationalString getAnchorPoint() {
- return anchorPoint;
+ return anchorDefinition;
}
/**
@@ -397,7 +402,7 @@ public class AbstractDatum extends Abstr
final AbstractDatum that = (AbstractDatum) object;
return this.realizationEpoch == that.realizationEpoch &&
Objects.equals(this.domainOfValidity,
that.domainOfValidity) &&
- Objects.equals(this.anchorPoint, that.anchorPoint)
&&
+ Objects.equals(this.anchorDefinition,
that.anchorDefinition) &&
Objects.equals(this.scope, that.scope);
}
case BY_CONTRACT: {
@@ -430,7 +435,7 @@ public class AbstractDatum extends Abstr
*/
@Override
protected long computeHashCode() {
- return super.computeHashCode() + Objects.hash(anchorPoint,
realizationEpoch, domainOfValidity, scope);
+ return super.computeHashCode() + Objects.hash(anchorDefinition,
realizationEpoch, domainOfValidity, scope);
}
/**
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1555635&r1=1555634&r2=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] Sun Jan 5 21:53:37 2014
@@ -92,6 +92,9 @@ public class DefaultVerticalDatum extend
/**
* The type of this vertical datum.
* If {@code null}, a value will be inferred from the name by {@link
#type()}.
+ *
+ * @see #type()
+ * @see #getVerticalDatumType()
*/
private VerticalDatumType type;
@@ -221,6 +224,9 @@ public class DefaultVerticalDatum extend
*
* <p>No synchronization needed; this is not a problem if this value is
computed twice.
* This method returns only existing immutable instances.</p>
+ *
+ * @see #getVerticalDatumType()
+ * @see #getTypeElement()
*/
private VerticalDatumType type() {
VerticalDatumType t = type;
@@ -253,6 +259,8 @@ public class DefaultVerticalDatum extend
/**
* Returns the type to be marshalled to XML.
* This element was present in GML 3.0 and 3.1, but has been removed from
GML 3.2.
+ *
+ * @see <a href="http://issues.apache.org/jira/browse/SIS-160">SIS-160:
Need XSLT between GML 3.1 and 3.2</a>
*/
@XmlElement(name = "verticalDatumType")
private VerticalDatumType getTypeElement() {
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java?rev=1555635&r1=1555634&r2=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] Sun Jan 5 21:53:37 2014
@@ -17,9 +17,15 @@
package org.apache.sis.referencing.datum;
import java.lang.reflect.Field;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
import javax.xml.bind.JAXBException;
import org.opengis.referencing.datum.VerticalDatumType;
import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
+import org.apache.sis.util.Version;
+import org.apache.sis.xml.XML;
+import org.apache.sis.xml.MarshallerPool;
import org.apache.sis.test.XMLTestCase;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -45,6 +51,11 @@ public final strictfp class DefaultVerti
private static final String XML_FILE = "Mean Sea Level.xml";
/**
+ * An XML file with the same content than {@link #XML_FILE}, but written
in an older GML format.
+ */
+ private static final String GML31_FILE = "Mean Sea Level (GML 3.1).xml";
+
+ /**
* Tests the {@link DefaultVerticalDatum#getVerticalDatumType()} method in
a state
* simulating unmarshalling of GML 3.2 document.
*
@@ -85,20 +96,74 @@ public final strictfp class DefaultVerti
}
/**
- * Tests unmarshalling.
+ * Tests XML (un)marshalling.
*
- * @throws JAXBException If an error occurred during unmarshalling.
+ * @throws JAXBException If an error occurred during (un)marshalling.
*/
@Test
- public void testUnmarshalling() throws JAXBException {
+ public void testXML() throws JAXBException {
final DefaultVerticalDatum datum =
unmarshalFile(DefaultVerticalDatum.class, XML_FILE);
assertIsMeanSeaLevel(datum, true);
/*
+ * Following attribute does not exist in GML 3.2, so it has been
inferred.
+ * Our datum name is "Mean Sea Level", which for now is not yet mapped
to
+ * the geoidal type (this could change in any future SIS version).
+ */
+ assertEquals("vertDatumType", VerticalDatumType.OTHER_SURFACE,
datum.getVerticalDatumType());
+ /*
* Values in the following tests are specific to our XML file.
* The actual texts in the EPSG database are more descriptive.
*/
assertEquals("remarks", "Approximates geoid.",
datum.getRemarks().toString());
assertEquals("scope", "Hydrography.",
datum.getScope().toString());
assertEquals("anchorDefinition", "Averaged over a 19-year period.",
datum.getAnchorPoint().toString());
+ /*
+ * Test marshalling and compare with the original file.
+ */
+ assertMarshalEqualsFile(XML_FILE, datum, "xmlns:*",
"xsi:schemaLocation");
+ }
+
+ /**
+ * Tests (un)marshalling of an older version, GML 3.1.
+ *
+ * @throws JAXBException If an error occurred during unmarshalling.
+ *
+ * @see <a href="http://issues.apache.org/jira/browse/SIS-160">SIS-160:
Need XSLT between GML 3.1 and 3.2</a>
+ */
+ @Test
+ public void testGML31() throws JAXBException {
+ final Version version = new Version("3.1");
+ final MarshallerPool pool = getMarshallerPool();
+ final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
+ unmarshaller.setProperty(XML.GML_VERSION, version);
+ final DefaultVerticalDatum datum =
+ (DefaultVerticalDatum)
unmarshaller.unmarshal(getClass().getResource(GML31_FILE));
+ pool.recycle(unmarshaller);
+ /*
+ * Following attribute exists in GML 3.1 only.
+ */
+ assertEquals("vertDatumType", VerticalDatumType.GEOIDAL,
datum.getVerticalDatumType());
+ /*
+ * The name, anchor definition and domain of validity are lost because
+ * those property does not have the same XML element name (SIS-160).
+ * Below is all we have.
+ */
+ assertEquals("remarks", "Approximates geoid.",
datum.getRemarks().toString());
+ assertEquals("scope", "Hydrography.",
datum.getScope().toString());
+ /*
+ * Test marshaling. We can not yet compare with the original XML file
+ * because of all the information lost. This may be fixed in a future
+ * SIS version (SIS-160).
+ */
+ final Marshaller marshaller = pool.acquireMarshaller();
+ marshaller.setProperty(XML.GML_VERSION, version);
+ final String xml = marshal(marshaller, datum);
+ pool.recycle(marshaller);
+ assertXmlEquals(
+ "<gml:VerticalDatum xmlns:gml=\"" + LegacyNamespaces.GML +
"\">\n" +
+ " <gml:remarks>Approximates geoid.</gml:remarks>\n" +
+ " <gml:scope>Hydrography.</gml:scope>\n" +
+ " <gml:verticalDatumType>geoidal</gml:verticalDatumType>\n" +
+ "</gml:VerticalDatum>", xml, "xmlns:*");
}
}
Copied:
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level (GML 3.1).xml (from r1555453,
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean%20Sea%20Level%20%28GML%203.1%29.xml?p2=sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean%20Sea%20Level%20%28GML%203.1%29.xml&p1=sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean%20Sea%20Level.xml&r1=1555453&r2=1555635&rev=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level (GML 3.1).xml Sun Jan 5 21:53:37 2014
@@ -17,31 +17,36 @@
specific language governing permissions and limitations
under the License.
-->
-<gml:VerticalDatum xsi:schemaLocation = "http://www.opengis.net/gml/3.2
http://schemas.opengis.net/gml/3.2.1/datums.xsd"
- xmlns:gml = "http://www.opengis.net/gml/3.2"
- xmlns:gmd = "http://www.isotc211.org/2005/gmd"
- xmlns:gco = "http://www.isotc211.org/2005/gco"
- xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
- gml:id = "epsg-datum-6326">
- <gml:identifier codeSpace="OGP">urn:ogc:def:datum:EPSG::5100</gml:identifier>
- <gml:name>Mean Sea Level</gml:name>
+<gml:VerticalDatum xsi:schemaLocation = "http://www.opengis.net/gml
http://schemas.opengis.net/gml/3.1.1/base/datums.xsd"
+ xmlns:gml = "http://www.opengis.net/gml"
+ xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
+ gml:id = "epsg-datum-5100">
+ <!--
+ Below is the same content than in the "Mean Sea Level.xml" file, but using
+ the GML 3.1.1 schema instead of 3.2.1. Some elements have different names:
+
âââââââââââââââââââââ¬ââââââââââââââââââââ
+ â GML 3.1 â GML 3.2 â
+
âââââââââââââââââââââ¼ââââââââââââââââââââ¤
+ â datumName â name â
+ â anchorPoint â anchorDefinition â
+ â validArea â domainOfValidity â
+
âââââââââââââââââââââ´ââââââââââââââââââââ
+ However the element of interest for this test is the
<gml:verticalDatumType>,
+ which does not exist in GML 3.2.1. Since this information is uneasy to
infer
+ from other properties, DefaultVerticalDatum has a special method for it.
+ See http://issues.apache.org/jira/browse/SIS-160
+ -->
+ <gml:datumName>Mean Sea Level</gml:datumName>
<gml:remarks>Approximates geoid.</gml:remarks>
- <gml:domainOfValidity>
- <gmd:EX_Extent>
- <gmd:description>
- <gco:CharacterString>World.</gco:CharacterString>
- </gmd:description>
- <gmd:geographicElement>
- <gmd:EX_GeographicBoundingBox>
-
<gmd:westBoundLongitude><gco:Decimal>-180</gco:Decimal></gmd:westBoundLongitude>
-
<gmd:eastBoundLongitude><gco:Decimal>+180</gco:Decimal></gmd:eastBoundLongitude>
- <gmd:southBoundLatitude><gco:Decimal>
-90</gco:Decimal></gmd:southBoundLatitude>
- <gmd:northBoundLatitude><gco:Decimal>
+90</gco:Decimal></gmd:northBoundLatitude>
- </gmd:EX_GeographicBoundingBox>
- </gmd:geographicElement>
- </gmd:EX_Extent>
- </gml:domainOfValidity>
+ <gml:anchorPoint>Averaged over a 19-year period.</gml:anchorPoint>
+ <gml:validArea>
+ <gml:description>World.</gml:description>
+ <gml:boundingBox>
+ <gml:lowerCorner>-180 -90</gml:lowerCorner>
+ <gml:upperCorner>+180 +90</gml:upperCorner>
+ </gml:boundingBox>
+ </gml:validArea>
<gml:scope>Hydrography.</gml:scope>
- <gml:anchorDefinition>Averaged over a 19-year period.</gml:anchorDefinition>
+ <gml:verticalDatumType codeSpace="EPSG">geoidal</gml:verticalDatumType>
</gml:VerticalDatum>
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean%20Sea%20Level.xml?rev=1555635&r1=1555634&r2=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Mean
Sea Level.xml Sun Jan 5 21:53:37 2014
@@ -22,7 +22,7 @@
xmlns:gmd = "http://www.isotc211.org/2005/gmd"
xmlns:gco = "http://www.isotc211.org/2005/gco"
xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
- gml:id = "epsg-datum-6326">
+ gml:id = "epsg-datum-5100">
<gml:identifier codeSpace="OGP">urn:ogc:def:datum:EPSG::5100</gml:identifier>
<gml:name>Mean Sea Level</gml:name>
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java?rev=1555635&r1=1555634&r2=1555635&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
[UTF-8] Sun Jan 5 21:53:37 2014
@@ -158,6 +158,13 @@ public final class XML extends Static {
*
* <p>The value can be {@link String} or {@link Version} objects.
* If no version is specified, then the most recent GML version is
assumed.</p>
+ *
+ * {@section Supported GML versions}
+ * Apache SIS currently supports GML 3.2.1 by default. SIS can read and
write GML 3.2
+ * if this property is set to "3.2". It is also possible to set this
property to "3.1",
+ * but the marshalled XML is not GML 3.1.1 conformant because of the
differences between the two schemas.
+ * See <a href="http://issues.apache.org/jira/browse/SIS-160">SIS-160:
Need XSLT between GML 3.1 and 3.2</a>
+ * for information about the status of GML 3.1.1 support.
*/
public static final String GML_VERSION = "org.apache.sis.gml.version";