Author: desruisseaux
Date: Thu Feb 25 14:07:40 2016
New Revision: 1732307
URL: http://svn.apache.org/viewvc?rev=1732307&view=rev
Log:
When formatting a three-dimensional geographic CRS in WKT 1 format, temporarily
split in a CompoundCRS (SIS-317).
Note that this is illegal according ISO 19111. This split is done only
on-the-fly and discarded, and only for compliance with the legacy WKT 1 format.
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -1070,14 +1070,24 @@ public class Formatter implements Locali
* Appends an enumeration or code list value.
* The {@linkplain Symbols#getSeparator() element separator} will be
written before the code list if needed.
*
+ * <p>For the WKT 2 format, this method uses the {@linkplain
Types#getCodeName ISO name if available}
+ * (for example {@code "northEast"}).
+ * For the WKT 1 format, this method uses the programmatic name instead
(for example {@code "NORTH_EAST"}).</p>
+ *
* @param code The code list to append to the WKT, or {@code null} if none.
*/
public void append(final ControlledVocabulary code) {
if (code != null) {
appendSeparator();
- setColor(ElementKind.CODE_LIST);
- buffer.append(convention.majorVersion() == 1 ? code.name() :
Types.getCodeName(code));
- resetColor();
+ final String name = convention.majorVersion() == 1 ? code.name() :
Types.getCodeName(code);
+ if (CharSequences.isUnicodeIdentifier(name)) {
+ setColor(ElementKind.CODE_LIST);
+ buffer.append(name);
+ resetColor();
+ } else {
+ quote(name, ElementKind.CODE_LIST);
+ setInvalidWKT(code.getClass(), null);
+ }
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -97,7 +97,7 @@ public final class Legacy implements Axi
/**
* Returns the coordinate system of a geocentric CRS using axes in the
given unit of measurement.
- * This method presume that the given {@code cs} uses {@link SI#METRE}
(this is not verified).
+ * This method presumes that the given {@code cs} uses {@link SI#METRE}
(this is not verified).
*
* @param cs The coordinate system for which to perform the unit
replacement.
* @param unit The unit of measurement for the geocentric CRS axes.
@@ -112,17 +112,25 @@ public final class Legacy implements Axi
return cs;
}
+
+
+
+ // -----------------------------------------------------------------
+ // AxisFilter implementation for internal usage only
+ // -----------------------------------------------------------------
+
/**
- * For internal usage by {@link #replaceUnit(CartesianCS, Unit)} only.
+ * The value to be returned by {@link #getUnitReplacement(Unit)},
+ * or {@code null} if no replacement should be done.
*/
- private Legacy(final Unit<?> unit) {
- this.unit = unit;
- }
+ private final Unit<?> replacement;
/**
- * The value to be returned by {@link #getUnitReplacement(Unit)}.
+ * For internal usage by {@link #replaceUnit(CartesianCS, Unit)} only.
*/
- private final Unit<?> unit;
+ private Legacy(final Unit<?> unit) {
+ replacement = unit;
+ }
/**
* For internal usage by {@link #replaceUnit(CartesianCS, Unit)} only.
@@ -132,6 +140,6 @@ public final class Legacy implements Axi
*/
@Override
public Unit<?> getUnitReplacement(final Unit<?> unit) {
- return this.unit;
+ return replacement;
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -16,13 +16,17 @@
*/
package org.apache.sis.internal.referencing;
+import java.util.Map;
+import java.util.HashMap;
import java.util.Collection;
import javax.measure.unit.Unit;
import javax.measure.quantity.Angle;
import org.opengis.annotation.UML;
import org.opengis.annotation.Specification;
+import org.opengis.metadata.Identifier;
import org.opengis.referencing.cs.*;
import org.opengis.referencing.crs.*;
+import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.PrimeMeridian;
import org.apache.sis.util.Static;
@@ -31,6 +35,7 @@ import org.apache.sis.util.CharSequences
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.datum.DefaultPrimeMeridian;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.cs.AxesConvention;
@@ -47,7 +52,7 @@ import static java.util.Collections.sing
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.5
- * @version 0.6
+ * @version 0.7
* @module
*/
public final class ReferencingUtilities extends Static {
@@ -239,6 +244,48 @@ public final class ReferencingUtilities
}
/**
+ * Returns the properties of the given object but potentially with a
modified name.
+ * Current implement truncates the name at the first non-white character
which is not
+ * a valid Unicode identifier part.
+ *
+ * <div class="note"><b>Example:</b><ul>
+ * <li><cite>"WGS 84 (3D)"</cite> is truncated as <cite>"WGS
84"</cite>.</li>
+ * <li><cite>"Ellipsoidal 2D CS. Axes: latitude, longitude.
Orientations: north, east. UoM: degree"</cite>
+ * is truncated as <cite>"Ellipsoidal 2D CS"</cite>.</li>
+ * </ul></div>
+ *
+ * @param object The identified object to view as a properties map.
+ * @param excludes The keys of properties to exclude from the map.
+ * @return A view of the identified object properties.
+ *
+ * @see IdentifiedObjects#getProperties(IdentifiedObject, String...)
+ *
+ * @since 0.7
+ */
+ public static Map<String,?> getPropertiesForModifiedCRS(final
IdentifiedObject object, final String... excludes) {
+ final Map<String,?> properties =
IdentifiedObjects.getProperties(object, excludes);
+ final Identifier id = (Identifier)
properties.get(IdentifiedObject.NAME_KEY);
+ if (id != null) {
+ String name = id.getCode();
+ if (name != null) {
+ for (int i=0; i < name.length();) {
+ final int c = name.codePointAt(i);
+ if (!Character.isUnicodeIdentifierPart(c) &&
!Character.isSpaceChar(c)) {
+ name = CharSequences.trimWhitespaces(name, 0,
i).toString();
+ if (!name.isEmpty()) {
+ final Map<String,Object> copy = new
HashMap<>(properties);
+ copy.put(IdentifiedObject.NAME_KEY, name);
+ return copy;
+ }
+ }
+ i += Character.charCount(c);
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
* Returns the XML property name of the given interface.
*
* For {@link CoordinateSystem} base type, the returned value shall be one
of
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -83,7 +83,7 @@ import static java.util.Collections.sing
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.6
+ * @version 0.7
* @module
*/
public final class CRS extends Static {
@@ -290,27 +290,26 @@ public final class CRS extends Static {
* @category information
*/
public static SingleCRS getHorizontalComponent(final
CoordinateReferenceSystem crs) {
- if (isHorizontalCRS(crs)) {
- return (SingleCRS) crs;
- }
if (crs instanceof GeodeticCRS) {
CoordinateSystem cs = crs.getCoordinateSystem();
- if (cs instanceof EllipsoidalCS) { // See comment in
isHorizontalCRS(…) method.
+ if (cs instanceof EllipsoidalCS) { // See
comment in isHorizontalCRS(…) method.
final int i = AxisDirections.indexOfColinear(cs,
AxisDirection.UP);
- if (i >= 0) {
- final CoordinateSystemAxis xAxis = cs.getAxis(i > 0 ? 0 :
1);
- final CoordinateSystemAxis yAxis = cs.getAxis(i > 1 ? 1 :
2);
- cs = CommonCRS.DEFAULT.geographic().getCoordinateSystem();
- if (!Utilities.equalsIgnoreMetadata(cs.getAxis(0), xAxis)
||
- !Utilities.equalsIgnoreMetadata(cs.getAxis(1), yAxis))
- {
- // We can not reuse the name of the existing CS,
because it typically
- // contains text about axes including the axis that we
just dropped.
- cs = new
DefaultEllipsoidalCS(singletonMap(EllipsoidalCS.NAME_KEY, "Ellipsoidal 2D"),
xAxis, yAxis);
- }
- return new
DefaultGeographicCRS(IdentifiedObjects.getProperties(crs),
- ((GeodeticCRS) crs).getDatum(), (EllipsoidalCS)
cs);
+ if (i < 0) {
+ return (SingleCRS) crs;
+ }
+ final CoordinateSystemAxis xAxis = cs.getAxis(i > 0 ? 0 : 1);
+ final CoordinateSystemAxis yAxis = cs.getAxis(i > 1 ? 1 : 2);
+ cs = CommonCRS.DEFAULT.geographic().getCoordinateSystem();
+ if (!Utilities.equalsIgnoreMetadata(cs.getAxis(0), xAxis) ||
+ !Utilities.equalsIgnoreMetadata(cs.getAxis(1), yAxis))
+ {
+ // We can not reuse the name of the existing CS, because
it typically
+ // contains text about axes including the axis that we
just dropped.
+ cs = new
DefaultEllipsoidalCS(singletonMap(EllipsoidalCS.NAME_KEY, "Ellipsoidal 2D"),
xAxis, yAxis);
}
+ return new DefaultGeographicCRS(
+ ReferencingUtilities.getPropertiesForModifiedCRS(crs,
CoordinateReferenceSystem.IDENTIFIERS_KEY),
+ ((GeodeticCRS) crs).getDatum(), (EllipsoidalCS) cs);
}
}
if (crs instanceof CompoundCRS) {
@@ -322,7 +321,7 @@ public final class CRS extends Static {
}
}
}
- return null;
+ return isHorizontalCRS(crs) ? (SingleCRS) crs : null;
}
/**
@@ -375,7 +374,7 @@ public final class CRS extends Static {
}
if (allowCreateEllipsoidal && crs instanceof GeodeticCRS) {
final CoordinateSystem cs = crs.getCoordinateSystem();
- if (cs instanceof EllipsoidalCS) { // See comment in
isHorizontalCRS(…) method.
+ if (cs instanceof EllipsoidalCS) { // See
comment in isHorizontalCRS(…) method.
final int i = AxisDirections.indexOfColinear(cs,
AxisDirection.UP);
if (i >= 0) {
final CoordinateSystemAxis axis = cs.getAxis(i);
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -103,7 +103,7 @@ public final class IdentifiedObjects ext
*
* @param object The identified object to view as a properties map.
* @param excludes The keys of properties to exclude from the map.
- * @return An view of the identified object as an immutable map.
+ * @return A view of the identified object properties as an immutable map.
*/
public static Map<String,?> getProperties(final IdentifiedObject object,
final String... excludes) {
ArgumentChecks.ensureNonNull("object", object);
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -49,14 +49,12 @@ import org.apache.sis.internal.jaxb.refe
import org.apache.sis.util.collection.CheckedContainer;
import org.apache.sis.util.collection.Containers;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Utilities;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;
-import static org.apache.sis.util.ArgumentChecks.*;
-import static org.apache.sis.util.Utilities.deepEquals;
-import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
-
/**
* A CRS describing the position of points through two or more independent
coordinate reference systems.
@@ -204,7 +202,7 @@ public class DefaultCompoundCRS extends
private static CoordinateSystem createCoordinateSystem(final Map<String,?>
properties,
final CoordinateReferenceSystem[] components)
{
- ensureNonNull("components", components);
+ ArgumentChecks.ensureNonNull("components", components);
if (components.length < 2) {
throw new
IllegalArgumentException(Errors.getResources(properties).getString(
Errors.Keys.TooFewArguments_2, 2, components.length));
@@ -212,7 +210,7 @@ public class DefaultCompoundCRS extends
final CoordinateSystem[] cs = new CoordinateSystem[components.length];
for (int i=0; i<components.length; i++) {
final CoordinateReferenceSystem crs = components[i];
- ensureNonNullElement("components", i, crs);
+ ArgumentChecks.ensureNonNullElement("components", i, crs);
cs[i] = crs.getCoordinateSystem();
}
return new DefaultCompoundCS(cs);
@@ -438,7 +436,7 @@ public class DefaultCompoundCRS extends
*/
@Override
public synchronized DefaultCompoundCRS forConvention(final AxesConvention
convention) {
- ensureNonNull("convention", convention);
+ ArgumentChecks.ensureNonNull("convention", convention);
DefaultCompoundCRS crs = (DefaultCompoundCRS) getCached(convention);
if (crs == null) {
crs = this;
@@ -494,7 +492,7 @@ public class DefaultCompoundCRS extends
return components.equals(((DefaultCompoundCRS)
object).components);
}
default: {
- return deepEquals(getComponents(), ((CompoundCRS)
object).getComponents(), mode);
+ return Utilities.deepEquals(getComponents(),
((CompoundCRS) object).getComponents(), mode);
}
}
}
@@ -539,16 +537,16 @@ public class DefaultCompoundCRS extends
final boolean isWKT1 = convention.majorVersion() == 1;
if (isWKT1 || convention == Convention.INTERNAL) {
crs = getComponents();
- isStandardCompliant = true; // WKT 1 does not put any
restriction.
+ isStandardCompliant = true; // WKT 1 does not
put any restriction.
} else {
crs = getSingleComponents();
isStandardCompliant = isStandardCompliant(crs);
}
for (final CoordinateReferenceSystem element : crs) {
formatter.newLine();
- formatter.append(toFormattable(element));
+ formatter.append(WKTUtilities.toFormattable(element));
}
- formatter.newLine(); // For writing the ID[…] element on its own
line.
+ formatter.newLine(); // For writing the
ID[…] element on its own line.
if (!isStandardCompliant) {
formatter.setInvalidWKT(this, null);
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -27,7 +27,9 @@ import org.opengis.referencing.cs.Cartes
import org.opengis.referencing.cs.SphericalCS;
import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.crs.GeodeticCRS;
+import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.datum.PrimeMeridian;
import org.apache.sis.internal.referencing.Legacy;
@@ -38,6 +40,7 @@ import org.apache.sis.internal.referenci
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.referencing.CRS;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -161,21 +164,43 @@ class DefaultGeodeticCRS extends Abstrac
@Override
protected String formatTo(final Formatter formatter) {
WKTUtilities.appendName(this, formatter, null);
+ CoordinateSystem cs = getCoordinateSystem();
final Convention convention = formatter.getConvention();
final boolean isWKT1 = (convention.majorVersion() == 1);
- CoordinateSystem cs = getCoordinateSystem();
+ final boolean isGeographicWKT1 = isWKT1 && (cs instanceof
EllipsoidalCS);
+ if (isGeographicWKT1 && cs.getDimension() == 3) {
+ /*
+ * Version 1 of WKT format did not have three-dimensional
GeographicCRS. Instead, such CRS were formatted
+ * as a CompoundCRS made of a two-dimensional GeographicCRS with a
VerticalCRS for the ellipsoidal height.
+ * Note that such compound is illegal in WKT 2 and ISO 19111
standard, as ellipsoidal height shall not be
+ * separated from the geographic component. So we perform this
separation only at WKT 1 formatting time.
+ */
+ SingleCRS first = CRS.getHorizontalComponent(this);
+ SingleCRS second = CRS.getVerticalComponent(this, true);
+ if (first != null && second != null) { //
Should not be null, but we are paranoiac.
+ if
(AxisDirection.UP.equals(AxisDirections.absolute(cs.getAxis(0).getDirection())))
{
+ // It is very unusual to have VerticalCRS first, but our
code tries to be robust.
+ final SingleCRS t = first;
+ first = second; second = t;
+ }
+ formatter.newLine();
formatter.append(WKTUtilities.toFormattable(first));
+ formatter.newLine();
formatter.append(WKTUtilities.toFormattable(second));
+ formatter.newLine();
+ return WKTKeywords.Compd_CS;
+ }
+ }
/*
* Unconditionally format the datum element, followed by the prime
meridian.
* The prime meridian is part of datum according ISO 19111, but is
formatted
* as a sibling (rather than a child) element in WKT for historical
reasons.
*/
- final GeodeticDatum datum = getDatum(); // Gives subclasses a
chance to override.
+ final GeodeticDatum datum = getDatum(); // Gives
subclasses a chance to override.
formatter.newLine();
formatter.append(WKTUtilities.toFormattable(datum));
formatter.newLine();
final PrimeMeridian pm = datum.getPrimeMeridian();
final Unit<Angle> angularUnit = AxisDirections.getAngularUnit(cs,
null);
- if (convention != Convention.WKT2_SIMPLIFIED || // Really this
specific enum, not Convention.isSimplified().
+ if (convention != Convention.WKT2_SIMPLIFIED || // Really this
specific enum, not Convention.isSimplified().
ReferencingUtilities.getGreenwichLongitude(pm,
NonSI.DEGREE_ANGLE) != 0)
{
final Unit<Angle> oldUnit =
formatter.addContextualUnit(angularUnit);
@@ -196,11 +221,11 @@ class DefaultGeodeticCRS extends Abstrac
*/
final boolean isBaseCRS;
if (isWKT1) {
- if (!(cs instanceof EllipsoidalCS)) { // Tested first because this
is the most common case.
+ if (!isGeographicWKT1) { // If not
geographic, then presumed geocentric.
if (cs instanceof CartesianCS) {
cs = Legacy.forGeocentricCRS((CartesianCS) cs, true);
} else {
- formatter.setInvalidWKT(cs, null); // SphericalCS was not
supported in WKT 1.
+ formatter.setInvalidWKT(cs, null); // SphericalCS was
not supported in WKT 1.
}
}
isBaseCRS = false;
@@ -230,7 +255,7 @@ class DefaultGeodeticCRS extends Abstrac
* have a GeodeticCRS. We need to make the choice in this base class.
The CS type is a sufficient criterion.
*/
if (isWKT1) {
- return (cs instanceof EllipsoidalCS) ? WKTKeywords.GeogCS :
WKTKeywords.GeocCS;
+ return isGeographicWKT1 ? WKTKeywords.GeogCS : WKTKeywords.GeocCS;
} else {
return isBaseCRS ? WKTKeywords.BaseGeodCRS
: formatter.shortOrLong(WKTKeywords.GeodCRS,
WKTKeywords.GeodeticCRS);
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -20,7 +20,7 @@ import javax.measure.unit.Unit;
import javax.measure.unit.SI;
import javax.measure.unit.NonSI;
import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystem; // For javadoc
+import org.opengis.referencing.cs.CoordinateSystem; // For
javadoc
import org.apache.sis.internal.metadata.AxisDirections;
import org.apache.sis.measure.Units;
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -54,7 +54,6 @@ import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.ElementKind;
import org.apache.sis.io.wkt.Transliterator;
import org.apache.sis.io.wkt.FormattableObject;
-import org.apache.sis.io.wkt.UnformattableObjectException;
import static java.lang.Double.doubleToLongBits;
import static java.lang.Double.NEGATIVE_INFINITY;
@@ -776,11 +775,10 @@ public class DefaultCoordinateSystemAxis
if (AxisDirections.isUserDefined(dir)) {
meridian = DirectionAlongMeridian.parse(dir);
if (meridian != null) {
+ dir = meridian.baseDirection;
if (isWKT1) {
- throw new UnformattableObjectException(Errors.format(
- Errors.Keys.CanNotRepresentInFormat_2, "WKT 1",
meridian));
+ formatter.setInvalidWKT(this, null);
}
- dir = meridian.baseDirection;
}
}
formatter.append(dir);
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -22,6 +22,7 @@ import org.opengis.referencing.cs.*;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.IdentifiedObject;
import org.apache.sis.referencing.datum.HardCodedDatum;
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.internal.metadata.WKTKeywords;
@@ -38,7 +39,7 @@ import static org.apache.sis.internal.re
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5 (derived from 0.4)
- * @version 0.6
+ * @version 0.7
* @module
*/
public final strictfp class ReferencingUtilitiesTest extends TestCase {
@@ -84,6 +85,17 @@ public final strictfp class ReferencingU
}
/**
+ * Tests {@link
ReferencingUtilities#getPropertiesForModifiedCRS(IdentifiedObject, String...)}.
+ *
+ * @since 0.7
+ */
+ @Test
+ public void testGetPropertiesForModifiedCRS() {
+ assertEquals("WGS 84",
getPropertiesForModifiedCRS(HardCodedCRS.WGS84_3D).get(IdentifiedObject.NAME_KEY));
+ assertEquals("WGS 84",
getPropertiesForModifiedCRS(HardCodedCRS.GEOID_4D).get(IdentifiedObject.NAME_KEY));
+ }
+
+ /**
* Tests {@link ReferencingUtilities#toPropertyName(Class, Class)}.
*
* @since 0.6
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1732307&r1=1732306&r2=1732307&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] Thu Feb 25 14:07:40 2016
@@ -38,11 +38,12 @@ import static org.apache.sis.test.TestUt
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.6
+ * @version 0.7
* @module
*/
@DependsOn({
- DefaultGeodeticCRSTest.class
+ DefaultGeodeticCRSTest.class,
+ DefaultVerticalCRSTest.class
})
public final strictfp class DefaultGeographicCRSTest extends TestCase {
/**
@@ -166,6 +167,33 @@ public final strictfp class DefaultGeogr
}
/**
+ * Tests WKT 2 formatting of a three-dimensional CRS.
+ *
+ * <p>This CRS used in this test is equivalent to {@code EPSG:4979} except
for axis order,
+ * since EPSG puts latitude before longitude.</p>
+ *
+ * @since 0.7
+ *
+ * @see #testWKT1_For3D()
+ */
+ @Test
+ @DependsOnMethod("testWKT2")
+ public void testWKT2_For3D() {
+ assertWktEquals(Convention.WKT2,
+ "GEODCRS[“WGS 84 (3D)”,\n" +
+ " DATUM[“World Geodetic System 1984”,\n" +
+ " ELLIPSOID[“WGS84”, 6378137.0, 298.257223563,
LENGTHUNIT[“metre”, 1]]],\n" +
+ " PRIMEM[“Greenwich”, 0.0, ANGLEUNIT[“degree”,
0.017453292519943295]],\n" +
+ " CS[ellipsoidal, 3],\n" +
+ " AXIS[“Longitude (L)”, east, ORDER[1], ANGLEUNIT[“degree”,
0.017453292519943295]],\n" +
+ " AXIS[“Latitude (B)”, north, ORDER[2], ANGLEUNIT[“degree”,
0.017453292519943295]],\n" +
+ " AXIS[“Ellipsoidal height (h)”, up, ORDER[3],
LENGTHUNIT[“metre”, 1]],\n" +
+ " AREA[“World”],\n" +
+ " BBOX[-90.00, -180.00, 90.00, 180.00]]",
+ HardCodedCRS.WGS84_3D);
+ }
+
+ /**
* Tests WKT 2 simplified formatting.
*/
@Test
@@ -207,7 +235,7 @@ public final strictfp class DefaultGeogr
}
/**
- * Tests WKT 2 formatting on a CRS using a prime meridian other than
Greenwich.
+ * Tests WKT 2 formatting of a CRS using a prime meridian other than
Greenwich.
*
* <p>This CRS used in this test is equivalent to {@code EPSG:4807} except
for axis order,
* since EPSG defines (<var>latitude</var>, <var>longitude</var>) in
grades.</p>
@@ -265,4 +293,33 @@ public final strictfp class DefaultGeogr
" AXIS[“Latitude”, NORTH]]",
HardCodedCRS.NTF);
}
+
+ /**
+ * Tests WKT 1 formatting of a three-dimensional CRS. Such CRS can not be
represented directly in WKT 1 format.
+ * Consequently, the formatter will need to split the three-dimensional
geographic CRS into a two-dimensional
+ * geographic CRS followed by an ellipsoidal height. Such construction is
illegal according ISO 19111, so this
+ * split shall be done on-the-fly only for formatting purpose.
+ *
+ * @since 0.7
+ *
+ * @see #testWKT2_For3D()
+ */
+ @Test
+ @DependsOnMethod("testWKT1")
+ public void testWKT1_For3D() {
+ assertWktEquals(Convention.WKT1,
+ "COMPD_CS[“WGS 84 (3D)”,\n" +
+ " GEOGCS[“WGS 84”,\n" +
+ " DATUM[“World Geodetic System 1984”,\n" +
+ " SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
+ " PRIMEM[“Greenwich”, 0.0],\n" +
+ " UNIT[“degree”, 0.017453292519943295],\n" +
+ " AXIS[“Longitude”, EAST],\n" +
+ " AXIS[“Latitude”, NORTH]],\n" +
+ " VERT_CS[“Ellipsoidal height”,\n" +
+ " VERT_DATUM[“Ellipsoid”, 2002],\n" +
+ " UNIT[“metre”, 1],\n" +
+ " AXIS[“Ellipsoidal height”, UP]]]",
+ HardCodedCRS.WGS84_3D);
+ }
}
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=1732307&r1=1732306&r2=1732307&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] Thu Feb 25 14:07:40 2016
@@ -94,10 +94,10 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
org.apache.sis.referencing.cs.HardCodedCSTest.class,
org.apache.sis.referencing.crs.AbstractCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
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.crs.DefaultImageCRSTest.class,