You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/07/01 19:12:42 UTC
svn commit: r1688693 [1/2] - in /sis/trunk: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/
core/sis-referencing/src/main/java/org/apache/sis/parameter/
core/sis-referencing/sr...
Author: desruisseaux
Date: Wed Jul 1 17:12:42 2015
New Revision: 1688693
URL: http://svn.apache.org/r1688693
Log:
Merge WKT 2 work from the JDK6 branch.
Modified:
sis/trunk/ (props changed)
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 1 17:12:42 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK6:1394364-1688485
-/sis/branches/JDK7:1394913-1688483
-/sis/branches/JDK8:1584960-1688481
+/sis/branches/JDK6:1394364-1688691
+/sis/branches/JDK7:1394913-1688689
+/sis/branches/JDK8:1584960-1688688
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -25,6 +25,8 @@ import org.opengis.referencing.cs.Coordi
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.util.StringBuilders;
import org.apache.sis.measure.Units;
+import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.Characters;
/**
@@ -174,6 +176,9 @@ public final class VerticalDatumTypes im
*/
private static VerticalDatumType guess(final String name) {
if (name != null) {
+ if (CharSequences.equalsFiltered("Mean Sea Level", name, Characters.Filter.LETTERS_AND_DIGITS, true)) {
+ return VerticalDatumType.GEOIDAL;
+ }
for (int i=0; i<name.length();) {
final int c = name.codePointAt(i);
if (Character.isLetter(c)) {
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -134,6 +134,7 @@ public final class WKTKeywords extends S
public static final String
ImageDatum = "ImageDatum",
ImageCRS = "ImageCRS",
+ IDatum = "IDatum",
EngineeringDatum = "EngineeringDatum",
EngineeringCRS = "EngineeringCRS",
BaseEngCRS = "BaseEngCRS",
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -173,7 +173,7 @@ public abstract class FormattableObject
formatter = new Formatter();
}
formatter.configure(convention, null, colorize ? Colors.DEFAULT : null,
- convention.majorVersion() == 1, WKTFormat.DEFAULT_INDENTATION);
+ (convention.majorVersion() == 1) ? (byte) 1 : 0, WKTFormat.DEFAULT_INDENTATION);
if (!strict) {
formatter.transliterator = Transliterator.IDENTITY;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -48,6 +48,7 @@ import org.opengis.referencing.Identifie
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.MathTransform;
@@ -245,11 +246,11 @@ public class Formatter implements Locali
private int elementStart;
/**
- * {@code true} if keywords shall be converted to upper cases.
+ * {@code 1} if keywords shall be converted to upper cases, or {@code -1} for lower cases.
*
* @see #configure(Convention, Citation, Colors, boolean, byte)
*/
- private boolean toUpperCase;
+ private byte toUpperCase;
/**
* Incremented when {@link #setColor(ElementKind)} is invoked, and decremented when {@link #resetColor()}
@@ -382,7 +383,7 @@ public class Formatter implements Locali
* or {@link WKTFormat#SINGLE_LINE}.
*/
final void configure(Convention convention, final Citation authority, final Colors colors,
- final boolean toUpperCase, final byte indentation)
+ final byte toUpperCase, final byte indentation)
{
this.convention = convention;
this.authority = (authority != null) ? authority : convention.getNameAuthority();
@@ -540,8 +541,9 @@ public class Formatter implements Locali
newLine();
}
appendSeparator();
- if (toUpperCase) {
- keyword = keyword.toUpperCase(symbols.getLocale());
+ if (toUpperCase != 0) {
+ final Locale locale = symbols.getLocale();
+ keyword = (toUpperCase >= 0) ? keyword.toUpperCase(locale) : keyword.toLowerCase(locale);
}
elementStart = buffer.append(keyword).appendCodePoint(symbols.getOpeningBracket(0)).length();
}
@@ -630,8 +632,9 @@ public class Formatter implements Locali
setInvalidWKT(object.getClass(), null);
keyword = invalidElement;
}
- } else if (toUpperCase) {
- keyword = keyword.toUpperCase(symbols.getLocale());
+ } else if (toUpperCase != 0) {
+ final Locale locale = symbols.getLocale();
+ keyword = (toUpperCase >= 0) ? keyword.toUpperCase(locale) : keyword.toLowerCase(locale);
}
if (highlightError && colors != null) {
final String color = colors.getAnsiSequence(ElementKind.ERROR);
@@ -954,7 +957,18 @@ public class Formatter implements Locali
public void append(final String text, final ElementKind type) {
if (text != null) {
appendSeparator();
- quote(text, type);
+ if (type != ElementKind.CODE_LIST) {
+ quote(text, type);
+ } else {
+ /*
+ * Code lists have no quotes. They are normally formatted by the append(Enumerated) method,
+ * but an important exception is the CS[type] element in which the type is defined by the
+ * interface implemented by the CoordinateSystem rather than a CodeList instance.
+ */
+ setColor(type);
+ buffer.append(text);
+ resetColor();
+ }
}
}
@@ -1155,24 +1169,20 @@ public class Formatter implements Locali
appendExact(conversion);
/*
* The EPSG code in UNIT elements is generally not recommended.
- * But we make an exception for unit that have no exact representation in WKT.
+ * But we make an exception for sexagesimal units (EPSG:9108, 9110 and 9111)
+ * because they can not be represented by a simple scale factor in WKT.
*/
- final Integer code = Units.getEpsgCode(unit, false);
- if (code != null) {
- final int n = code;
- switch (n) {
- case Constants.EPSG_DM:
- case Constants.EPSG_DMS:
- case Constants.EPSG_DMSH: {
- openElement(false, isWKT1 ? WKTKeywords.Authority : WKTKeywords.Id);
- append(Constants.EPSG, null);
- if (isWKT1) {
- append(Integer.toString(n), null);
- } else {
- append(n);
- }
- closeElement(false);
+ if (convention == Convention.INTERNAL || PatchedUnitFormat.toFormattable(unit) != unit) {
+ final Integer code = Units.getEpsgCode(unit, getEnclosingElement(1) instanceof CoordinateSystemAxis);
+ if (code != null) {
+ openElement(false, isWKT1 ? WKTKeywords.Authority : WKTKeywords.Id);
+ append(Constants.EPSG, null);
+ if (isWKT1) {
+ append(code.toString(), null);
+ } else {
+ append(code);
}
+ closeElement(false);
}
}
closeElement(false);
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -320,7 +320,8 @@ final class GeodeticObjectParser extends
(object = parseVerticalDatum (FIRST, element, false)) == null &&
(object = parseTimeDatum (FIRST, element )) == null &&
(object = parseEngineeringDatum (FIRST, element, false)) == null &&
- (object = parseConversion (FIRST, element, false, SI.METRE, NonSI.DEGREE_ANGLE)) == null)
+ (object = parseImageDatum (FIRST, element )) == null &&
+ (object = parseOperation (FIRST, element)) == null)
{
throw element.missingOrUnknownComponent(WKTKeywords.GeodeticCRS);
}
@@ -339,13 +340,14 @@ final class GeodeticObjectParser extends
throws ParseException
{
CoordinateReferenceSystem crs;
- if ((crs = parseGeodeticCRS (FIRST, element, null)) == null &&
- (crs = parseProjectedCRS (FIRST, element)) == null &&
- (crs = parseVerticalCRS (FIRST, element)) == null &&
- (crs = parseTimeCRS (FIRST, element)) == null &&
- (crs = parseEngineeringCRS (FIRST, element)) == null &&
- (crs = parseCompoundCRS (FIRST, element)) == null &&
- (crs = parseFittedCS (FIRST, element)) == null)
+ if ((crs = parseGeodeticCRS (FIRST, element, null )) == null &&
+ (crs = parseProjectedCRS (FIRST, element, false)) == null &&
+ (crs = parseVerticalCRS (FIRST, element, false)) == null &&
+ (crs = parseTimeCRS (FIRST, element, false)) == null &&
+ (crs = parseEngineeringCRS (FIRST, element, false)) == null &&
+ (crs = parseImageCRS (FIRST, element)) == null &&
+ (crs = parseCompoundCRS (FIRST, element)) == null &&
+ (crs = parseFittedCS (FIRST, element)) == null)
{
if (mandatory) {
throw element.missingOrUnknownComponent(WKTKeywords.GeodeticCRS);
@@ -374,15 +376,22 @@ final class GeodeticObjectParser extends
* AUTHORITY["<name>", "<code>"]
* }
*
- * @param parent The parent element.
- * @param name The name of the parent object being parsed, either a {@link String} or {@link Identifier} instance.
+ * <div class="section">Fallback</div>
+ * The name is a mandatory property, but some invalid WKT with an empty string exist. In such case,
+ * we will use the name of the enclosed datum. Indeed, it is not uncommon to have the same name for
+ * a geographic CRS and its geodetic datum.
+ *
+ * @param parent The parent element.
+ * @param name The name of the parent object being parsed.
+ * @param fallback The fallback to use if {@code name} is empty.
* @return A properties map with the parent name and the optional authority code.
* @throws ParseException if an element can not be parsed.
*/
- private Map<String,Object> parseMetadataAndClose(final Element parent, Object name) throws ParseException {
- assert (name instanceof String) || (name instanceof Identifier);
+ private Map<String,Object> parseMetadataAndClose(final Element parent, final String name,
+ final IdentifiedObject fallback) throws ParseException
+ {
properties.clear();
- properties.put(IdentifiedObject.NAME_KEY, name);
+ properties.put(IdentifiedObject.NAME_KEY, (name.isEmpty() && fallback != null) ? fallback.getName() : name);
Element element;
while ((element = parent.pullElement(OPTIONAL, ID_KEYWORDS)) != null) {
final String codeSpace = element.pullString("codeSpace");
@@ -534,7 +543,7 @@ final class GeodeticObjectParser extends
*/
private Map<String,Object> parseAnchorAndClose(final Element element, final String name) throws ParseException {
final Element anchor = element.pullElement(OPTIONAL, WKTKeywords.Anchor);
- final Map<String,Object> properties = parseMetadataAndClose(element, name);
+ final Map<String,Object> properties = parseMetadataAndClose(element, name, null);
if (anchor != null) {
properties.put(Datum.ANCHOR_POINT_KEY, anchor.pullString("anchorDefinition"));
anchor.close(ignoredElements);
@@ -636,7 +645,7 @@ final class GeodeticObjectParser extends
final String expected = type;
type = CharSequences.trimWhitespaces(element.pullVoidElement("type").keyword);
dimension = element.pullInteger("dimension");
- csProperties = new HashMap<String,Object>(parseMetadataAndClose(element, "CS"));
+ csProperties = new HashMap<String,Object>(parseMetadataAndClose(element, "CS", null));
if (expected != null) {
if (!expected.equalsIgnoreCase(type)) {
throw new LocalizedParseException(errorLocale, Errors.Keys.UnexpectedValueInElement_2,
@@ -961,7 +970,7 @@ final class GeodeticObjectParser extends
}
final CoordinateSystemAxis axis;
try {
- axis = csFactory.createCoordinateSystemAxis(parseMetadataAndClose(element, name), abbreviation, direction, unit);
+ axis = csFactory.createCoordinateSystemAxis(parseMetadataAndClose(element, name, null), abbreviation, direction, unit);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1037,7 +1046,7 @@ final class GeodeticObjectParser extends
throw parent.missingComponent(WKTKeywords.AngleUnit);
}
try {
- return datumFactory.createPrimeMeridian(parseMetadataAndClose(element, name), longitude, angularUnit);
+ return datumFactory.createPrimeMeridian(parseMetadataAndClose(element, name, null), longitude, angularUnit);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1102,7 +1111,7 @@ final class GeodeticObjectParser extends
if (unit == null) {
unit = SI.METRE;
}
- final Map<String,?> properties = parseMetadataAndClose(element, name);
+ final Map<String,?> properties = parseMetadataAndClose(element, name, null);
try {
if (inverseFlattening == 0) { // OGC convention for a sphere.
return datumFactory.createEllipsoid(properties, semiMajorAxis, semiMajorAxis, unit);
@@ -1124,30 +1133,30 @@ final class GeodeticObjectParser extends
* PROJECTION["<name>" {,<authority>}]
* }
*
- * Note that in WKT 2, this element is wrapped inside a {@code Conversion} element which is itself inside
- * the {@code ProjectedCRS} element. This is different than WKT 1, which puts this element right into the
- * the {@code ProjectedCRS} element without {@code Conversion} wrapper.
+ * Note that in WKT 2, this element is wrapped inside a {@code Conversion} or {@code DerivingConversion}
+ * element which is itself inside the {@code ProjectedCRS} element. This is different than WKT 1, which
+ * puts this element right into the the {@code ProjectedCRS} element without {@code Conversion} wrapper.
*
* @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
* @param parent The parent element.
- * @param isWKT1 {@code false} if we expect a {@code Conversion} element wrapping the method and parameters.
+ * @param wrapper "Conversion" or "DerivingConversion" wrapper name, or null if parsing a WKT 1.
* @param linearUnit The linear unit of the parent {@code ProjectedCRS} element, or {@code null}.
* @param angularUnit The angular unit of the sibling {@code GeographicCRS} element, or {@code null}.
* @return The {@code "Method"} element and its parameters as a defining conversion.
* @throws ParseException if the {@code "Method"} element can not be parsed.
*/
- private Conversion parseConversion(final int mode, Element parent, final boolean isWKT1,
+ private Conversion parseDerivingConversion(final int mode, Element parent, final String wrapper,
final Unit<Length> linearUnit, final Unit<Angle> angularUnit) throws ParseException
{
final String name;
- if (isWKT1) {
+ if (wrapper == null) {
name = null; // Will actually be ignored. WKT 1 does not provide name for Conversion objects.
} else {
/*
* If we are parsing WKT 2, then there is an additional "Conversion" element between
* the parent (usually a ProjectedCRS) and the other elements parsed by this method.
*/
- parent = parent.pullElement(mode, WKTKeywords.Conversion);
+ parent = parent.pullElement(mode, wrapper);
if (parent == null) {
return null;
}
@@ -1155,7 +1164,7 @@ final class GeodeticObjectParser extends
}
final Element element = parent.pullElement(MANDATORY, WKTKeywords.Method, WKTKeywords.Projection);
final String methodName = element.pullString("method");
- Map<String,?> properties = parseMetadataAndClose(element, methodName);
+ Map<String,?> properties = parseMetadataAndClose(element, methodName, null);
final Identifier id = toIdentifier(properties.remove(IdentifiedObject.IDENTIFIERS_KEY)); // See NOTE 2.
/*
* The map projection method may be specified by an EPSG identifier (or any other authority),
@@ -1189,8 +1198,8 @@ final class GeodeticObjectParser extends
}
final ParameterValueGroup parameters = method.getParameters().createValue();
parseParameters(parent, parameters, linearUnit, angularUnit);
- if (!isWKT1) {
- properties = parseMetadataAndClose(parent, name);
+ if (wrapper != null) {
+ properties = parseMetadataAndClose(parent, name, method);
/*
* DEPARTURE FROM ISO 19162: the specification in §9.3.2 said:
*
@@ -1315,7 +1324,7 @@ final class GeodeticObjectParser extends
final Date epoch = origin .pullDate("origin");
origin.close(ignoredElements);
try {
- return datumFactory.createTemporalDatum(parseMetadataAndClose(element, name), epoch);
+ return datumFactory.createTemporalDatum(parseAnchorAndClose(element, name), epoch);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1352,7 +1361,31 @@ final class GeodeticObjectParser extends
element.pullInteger("datum"); // Ignored for now.
}
try {
- return datumFactory.createEngineeringDatum(parseMetadataAndClose(element, name));
+ return datumFactory.createEngineeringDatum(parseAnchorAndClose(element, name));
+ } catch (FactoryException exception) {
+ throw element.parseFailed(exception);
+ }
+ }
+
+ /**
+ * Parses an {@code "ImageDatum"} (WKT 2) element. The syntax is given by
+ * <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#81">WKT 2 specification §12.2</a>.
+ *
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @return The {@code "ImageDatum"} element as an {@link ImageDatum} object.
+ * @throws ParseException if the {@code "ImageDatum"} element can not be parsed.
+ */
+ private ImageDatum parseImageDatum(final int mode, final Element parent) throws ParseException {
+ final Element element = parent.pullElement(mode, WKTKeywords.ImageDatum, WKTKeywords.IDatum);
+ if (element == null) {
+ return null;
+ }
+ final String name = element.pullString("name");
+ final PixelInCell pixelInCell = Types.forCodeName(PixelInCell.class,
+ element.pullVoidElement("pixelInCell").keyword, true);
+ try {
+ return datumFactory.createImageDatum(parseAnchorAndClose(element, name), pixelInCell);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1368,17 +1401,20 @@ final class GeodeticObjectParser extends
* LOCAL_CS["<name>", <local datum>, <unit>, <axis>, {,<axis>}* {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
* @return The {@code "EngineeringCRS"} element as an {@link EngineeringCRS} object.
* @throws ParseException if the {@code "EngineeringCRS"} element can not be parsed.
*/
- private EngineeringCRS parseEngineeringCRS(final int mode, final Element parent) throws ParseException {
+ private EngineeringCRS parseEngineeringCRS(final int mode, final Element parent, final boolean isBaseCRS)
+ throws ParseException
+ {
final Element element = parent.pullElement(mode,
- WKTKeywords.EngineeringCRS, // [0] WKT 2
- WKTKeywords.EngCRS, // [1] WKT 2
- WKTKeywords.Local_CS, // [2] WKT 1
- WKTKeywords.BaseEngCRS); // [3] WKT 2 in DerivedCRS
+ isBaseCRS ? new String[] {WKTKeywords.BaseEngCRS} // WKT 2 in DerivedCRS
+ : new String[] {WKTKeywords.EngineeringCRS, // [0] WKT 2
+ WKTKeywords.EngCRS, // [1] WKT 2
+ WKTKeywords.Local_CS}); // [2] WKT 1
if (element == null) {
return null;
}
@@ -1388,7 +1424,32 @@ final class GeodeticObjectParser extends
final Unit<?> unit = parseUnit(element);
try {
final CoordinateSystem cs = parseCoordinateSystem(element, null, 1, isWKT1, unit, datum);
- return crsFactory.createEngineeringCRS(parseMetadataAndClose(element, name), datum, cs);
+ return crsFactory.createEngineeringCRS(parseMetadataAndClose(element, name, datum), datum, cs);
+ } catch (FactoryException exception) {
+ throw element.parseFailed(exception);
+ }
+ }
+
+ /**
+ * Parses an {@code "ImageCRS"} (WKT 2) element. The syntax is given by
+ * <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#79">WKT 2 specification §12</a>.
+ *
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @return The {@code "ImageCRS"} element as an {@link ImageCRS} object.
+ * @throws ParseException if the {@code "ImageCRS"} element can not be parsed.
+ */
+ private ImageCRS parseImageCRS(final int mode, final Element parent) throws ParseException {
+ final Element element = parent.pullElement(mode, WKTKeywords.ImageCRS);
+ if (element == null) {
+ return null;
+ }
+ final String name = element.pullString("name");
+ final ImageDatum datum = parseImageDatum(MANDATORY, element);
+ final Unit<?> unit = parseUnit(element);
+ try {
+ final CoordinateSystem cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, false, unit, datum);
+ return crsFactory.createImageCRS(parseMetadataAndClose(element, name, datum), datum, (CartesianCS) cs);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1420,13 +1481,14 @@ final class GeodeticObjectParser extends
* @see org.apache.sis.referencing.crs.DefaultGeographicCRS#formatTo(Formatter)
* @see org.apache.sis.referencing.crs.DefaultGeocentricCRS#formatTo(Formatter)
*/
- private GeodeticCRS parseGeodeticCRS(final int mode, final Element parent, String csType) throws ParseException {
+ private SingleCRS parseGeodeticCRS(final int mode, final Element parent, String csType) throws ParseException {
final Element element = parent.pullElement(mode,
- WKTKeywords.GeodeticCRS, // [0] WKT 2
- WKTKeywords.GeodCRS, // [1] WKT 2
- WKTKeywords.GeogCS, // [2] WKT 1
- WKTKeywords.GeocCS, // [3] WKT 1
- WKTKeywords.BaseGeodCRS); // [4] WKT 2 in ProjectedCRS or DerivedCRS
+ (csType != null) ? new String[] {WKTKeywords.BaseGeodCRS, // [0] WKT 2 in ProjectedCRS or DerivedCRS
+ WKTKeywords.GeogCS} // [1] WKT 1 in ProjectedCRS
+ : new String[] {WKTKeywords.GeodeticCRS, // [0] WKT 2
+ WKTKeywords.GeogCS, // [1] WKT 1
+ WKTKeywords.GeodCRS, // [2] WKT 2
+ WKTKeywords.GeocCS}); // [3] WKT 1
if (element == null) {
return null;
}
@@ -1453,7 +1515,7 @@ final class GeodeticObjectParser extends
}
break;
}
- case 2: { // WKT1 "GeogCS" element.
+ case 1: { // WKT1 "GeogCS" element.
isWKT1 = true;
csType = WKTKeywords.ellipsoidal;
angularUnit = parseScaledUnit(element, WKTKeywords.AngleUnit, SI.RADIAN);
@@ -1470,29 +1532,44 @@ final class GeodeticObjectParser extends
break;
}
}
- Object name = element.pullString("name");
- final PrimeMeridian meridian = parsePrimeMeridian(OPTIONAL, element, isWKT1, angularUnit);
- final GeodeticDatum datum = parseDatum(MANDATORY, element, meridian);
- if (((String) name).isEmpty()) {
- /*
- * GeographicCRS name is a mandatory property, but some invalid WKT with an empty string exist.
- * In such case, we will use the name of the enclosed datum. Indeed, it is not uncommon to have
- * the same name for a geographic CRS and its geodetic datum.
- */
- name = datum.getName();
+ final String name = element.pullString("name");
+ /*
+ * A GeodeticCRS can be either a "normal" one (with a non-null datum), or a DerivedCRS of kind GeodeticCRS.
+ * In the later case, the datum is null and we have instead DerivingConversion element from a BaseGeodCRS.
+ */
+ GeodeticDatum datum = null;
+ SingleCRS baseCRS = null;
+ Conversion fromBase = null;
+ if (!isWKT1 && csType == null) {
+ fromBase = parseDerivingConversion(OPTIONAL, element, WKTKeywords.DerivingConversion, SI.METRE, angularUnit);
+ if (fromBase != null) {
+ baseCRS = parseGeodeticCRS(MANDATORY, element, WKTKeywords.ellipsoidal);
+ }
+ }
+ if (baseCRS == null) {
+ // The most usual case.
+ final PrimeMeridian meridian = parsePrimeMeridian(OPTIONAL, element, isWKT1, angularUnit);
+ datum = parseDatum(MANDATORY, element, meridian);
}
+ /*
+ * At this point, we have either a non-null 'datum' or non-null 'baseCRS' + 'fromBase'.
+ * The coordinate system is parsed in the same way for both cases, but the CRS is created differently.
+ */
final CoordinateSystem cs;
try {
cs = parseCoordinateSystem(element, csType, dimension, isWKT1, defaultUnit, datum);
- final Map<String,?> properties = parseMetadataAndClose(element, name);
- if (cs instanceof EllipsoidalCS) {
+ final Map<String,?> properties = parseMetadataAndClose(element, name, datum);
+ if (baseCRS != null) {
+ return crsFactory.createDerivedCRS(properties, baseCRS, fromBase, cs);
+ }
+ if (cs instanceof EllipsoidalCS) { // By far the most frequent case.
return crsFactory.createGeographicCRS(properties, datum, (EllipsoidalCS) cs);
}
- if (cs instanceof CartesianCS) {
+ if (cs instanceof CartesianCS) { // The second most frequent case.
return crsFactory.createGeocentricCRS(properties, datum,
referencing.upgradeGeocentricCS((CartesianCS) cs));
}
- if (cs instanceof SphericalCS) {
+ if (cs instanceof SphericalCS) { // Not very common case.
return crsFactory.createGeocentricCRS(properties, datum, (SphericalCS) cs);
}
} catch (FactoryException exception) {
@@ -1512,17 +1589,20 @@ final class GeodeticObjectParser extends
* VERT_CS["<name>", <vert datum>, <linear unit>, {<axis>,} {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
* @return The {@code "VerticalCRS"} element as a {@link VerticalCRS} object.
* @throws ParseException if the {@code "VerticalCRS"} element can not be parsed.
*/
- private VerticalCRS parseVerticalCRS(final int mode, final Element parent) throws ParseException {
+ private VerticalCRS parseVerticalCRS(final int mode, final Element parent, final boolean isBaseCRS)
+ throws ParseException
+ {
final Element element = parent.pullElement(mode,
- WKTKeywords.VerticalCRS, // [0] WKT 2
- WKTKeywords.VertCRS, // [1] WKT 2
- WKTKeywords.Vert_CS, // [2] WKT 1
- WKTKeywords.BaseVertCRS); // [3] WKT 2 in DerivedCRS
+ isBaseCRS ? new String[] {WKTKeywords.BaseVertCRS} // WKT 2 in DerivedCRS
+ : new String[] {WKTKeywords.VerticalCRS, // [0] WKT 2
+ WKTKeywords.VertCRS, // [1] WKT 2
+ WKTKeywords.Vert_CS}); // [2] WKT 1
if (element == null) {
return null;
}
@@ -1543,7 +1623,7 @@ final class GeodeticObjectParser extends
datum = datumFactory.createVerticalDatum(referencing.getProperties(datum), type);
}
}
- verticalCRS = crsFactory.createVerticalCRS(parseMetadataAndClose(element, name), datum, (VerticalCS) cs);
+ verticalCRS = crsFactory.createVerticalCRS(parseMetadataAndClose(element, name, datum), datum, (VerticalCS) cs);
/*
* Some DefaultVerticalExtent objects may be waiting for the VerticalCRS before to complete
* their construction. If this is the case, try to complete them now.
@@ -1560,13 +1640,16 @@ final class GeodeticObjectParser extends
/**
* Parses {@code "TimeCRS"} element.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
* @return The {@code "TimeCRS"} element as a {@link TemporalCRS} object.
* @throws ParseException if the {@code "TimeCRS"} element can not be parsed.
*/
- private TemporalCRS parseTimeCRS(final int mode, final Element parent) throws ParseException {
- final Element element = parent.pullElement(mode, WKTKeywords.TimeCRS, WKTKeywords.BaseTimeCRS);
+ private TemporalCRS parseTimeCRS(final int mode, final Element parent, final boolean isBaseCRS)
+ throws ParseException
+ {
+ final Element element = parent.pullElement(mode, isBaseCRS ? WKTKeywords.BaseTimeCRS : WKTKeywords.TimeCRS);
if (element == null) {
return null;
}
@@ -1575,7 +1658,7 @@ final class GeodeticObjectParser extends
final Unit<Duration> timeUnit = parseScaledUnit(element, WKTKeywords.TimeUnit, SI.SECOND);
try {
final CoordinateSystem cs = parseCoordinateSystem(element, WKTKeywords.temporal, 1, false, timeUnit, datum);
- return crsFactory.createTemporalCRS(parseMetadataAndClose(element, name), datum, (TimeCS) cs);
+ return crsFactory.createTemporalCRS(parseMetadataAndClose(element, name, datum), datum, (TimeCS) cs);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1592,34 +1675,42 @@ final class GeodeticObjectParser extends
* <linear unit> {,<twin axes>}{,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
* @return The {@code "ProjectedCRS"} element as a {@link ProjectedCRS} object.
* @throws ParseException if the {@code "ProjectedCRS"} element can not be parsed.
*/
- private ProjectedCRS parseProjectedCRS(final int mode, final Element parent) throws ParseException {
+ private ProjectedCRS parseProjectedCRS(final int mode, final Element parent, final boolean isBaseCRS)
+ throws ParseException
+ {
final Element element = parent.pullElement(mode,
- WKTKeywords.ProjectedCRS, // [0] WKT 2
- WKTKeywords.ProjCRS, // [1] WKT 2
- WKTKeywords.ProjCS, // [2] WKT 1
- WKTKeywords.BaseProjCRS); // [3] WKT 2 in DerivedCRS
+ isBaseCRS ? new String[] {WKTKeywords.BaseProjCRS} // WKT 2 in DerivedCRS
+ : new String[] {WKTKeywords.ProjectedCRS, // [0] WKT 2
+ WKTKeywords.ProjCRS, // [1] WKT 2
+ WKTKeywords.ProjCS}); // [2] WKT 1
+
if (element == null) {
return null;
}
- final boolean isWKT1 = element.getKeywordIndex() == 2; // Index of "ProjCS" above.
- final String name = element.pullString("name");
- final GeodeticCRS geoCRS = parseGeodeticCRS(MANDATORY, element, WKTKeywords.ellipsoidal);
+ final boolean isWKT1 = element.getKeywordIndex() == 2; // Index of "ProjCS" above.
+ final String name = element.pullString("name");
+ final SingleCRS geoCRS = parseGeodeticCRS(MANDATORY, element, WKTKeywords.ellipsoidal);
if (!(geoCRS instanceof GeographicCRS)) {
throw new LocalizedParseException(errorLocale, Errors.Keys.IllegalCRSType_1,
new Object[] {geoCRS.getClass()}, element.offset);
}
final Unit<Length> linearUnit = parseScaledUnit(element, WKTKeywords.LengthUnit, SI.METRE);
final boolean ignoreUnits = isWKT1 && usesCommonUnits;
- final Conversion conversion = parseConversion(MANDATORY, element, isWKT1, ignoreUnits ? SI.METRE : linearUnit,
+ final Conversion conversion = parseDerivingConversion(MANDATORY, element,
+ isWKT1 ? null : WKTKeywords.Conversion, ignoreUnits ? SI.METRE : linearUnit,
ignoreUnits ? NonSI.DEGREE_ANGLE : geoCRS.getCoordinateSystem().getAxis(0).getUnit().asType(Angle.class));
+
+ final CoordinateSystem cs;
try {
- final CoordinateSystem cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, isWKT1, linearUnit, geoCRS.getDatum());
- return crsFactory.createProjectedCRS(parseMetadataAndClose(element, name), (GeographicCRS) geoCRS, conversion, (CartesianCS) cs);
+ cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, isWKT1, linearUnit, geoCRS.getDatum());
+ final Map<String,?> properties = parseMetadataAndClose(element, name, conversion);
+ return crsFactory.createProjectedCRS(properties, (GeographicCRS) geoCRS, conversion, (CartesianCS) cs);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1650,7 +1741,7 @@ final class GeodeticObjectParser extends
components.add(crs);
}
try {
- return crsFactory.createCompoundCRS(parseMetadataAndClose(element, name),
+ return crsFactory.createCompoundCRS(parseMetadataAndClose(element, name, null),
components.toArray(new CoordinateReferenceSystem[components.size()]));
} catch (FactoryException exception) {
throw element.parseFailed(exception);
@@ -1700,7 +1791,7 @@ final class GeodeticObjectParser extends
singletonMap(CoordinateSystemAxis.NAME_KEY, buffer.toString()),
number, AxisDirection.OTHER, Unit.ONE);
}
- final Map<String,Object> properties = parseMetadataAndClose(element, name);
+ final Map<String,Object> properties = parseMetadataAndClose(element, name, baseCRS);
final CoordinateSystem derivedCS = referencing.createAbstractCS(
singletonMap(CoordinateSystem.NAME_KEY, AxisDirections.appendTo(new StringBuilder("CS"), axes)), axes);
/*
@@ -1715,4 +1806,8 @@ final class GeodeticObjectParser extends
throw element.parseFailed(exception);
}
}
+
+ private CoordinateOperation parseOperation(final int mode, final Element parent) throws ParseException {
+ return null; // Not yet implemented.
+ }
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -18,9 +18,9 @@ package org.apache.sis.io.wkt;
/**
- * Whether WKT keywords shall be written with upper case or CamelCase styles.
+ * Whether WKT keywords shall be written with lower, upper or camel case styles.
* The most common usage for WKT keywords is upper case.
- * However with version 2 of Well Known Text, CamelCase keywords may be easier to read
+ * However with version 2 of Well Known Text, camel case keywords may be easier to read
* because WKT 2 has more keywords made by combination of words. Examples:
*
* <table class="sis">
@@ -39,20 +39,20 @@ package org.apache.sis.io.wkt;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
public enum KeywordCase {
/**
- * Keywords case is determined by the WKT {@linkplain Convention convention}.
- * The current mapping is:
- *
- * <ul>
- * <li>Well Known Text version 2 uses camel case.</li>
- * <li>Well Known Text version 1 uses upper case.</li>
- * </ul>
+ * WKT formatting uses lower case keywords.
*/
- DEFAULT,
+ LOWER_CASE,
+
+ /**
+ * WKT formatting uses upper case keywords.
+ * This is the most usual case in WKT 1 strings.
+ */
+ UPPER_CASE,
/**
* WKT formatting uses CamelCase keywords. This is more useful in WKT 2 strings, which
@@ -61,8 +61,13 @@ public enum KeywordCase {
CAMEL_CASE,
/**
- * WKT formatting uses upper case keywords.
- * This is the most usual case in WKT 1 strings.
+ * Keywords case is determined by the WKT {@linkplain Convention convention}.
+ * The current mapping is:
+ *
+ * <ul>
+ * <li>Well Known Text version 2 uses camel case.</li>
+ * <li>Well Known Text version 1 uses upper case.</li>
+ * </ul>
*/
- UPPER_CASE
+ DEFAULT
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -426,11 +426,12 @@ public class WKTFormat extends CompoundF
*/
private void updateFormatter(final Formatter formatter) {
if (formatter != null) {
- final boolean toUpperCase;
+ final byte toUpperCase;
switch (keywordCase) {
- case UPPER_CASE: toUpperCase = true; break;
- case CAMEL_CASE: toUpperCase = false; break;
- default: toUpperCase = (convention.majorVersion() == 1); break;
+ case LOWER_CASE: toUpperCase = -1; break;
+ case UPPER_CASE: toUpperCase = +1; break;
+ case CAMEL_CASE: toUpperCase = 0; break;
+ default: toUpperCase = (convention.majorVersion() == 1) ? (byte) 1 : 0; break;
}
formatter.configure(convention, authority, colors, toUpperCase, indentation);
if (transliterator != null) {
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -35,6 +35,7 @@ import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.ElementKind;
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.util.PatchedUnitFormat;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.ComparisonMode;
@@ -240,7 +241,7 @@ public class DefaultParameterValue<T> ex
if (value instanceof Boolean) {
return (Boolean) value;
}
- throw incompatibleValue(value);
+ throw missingOrIncompatibleValue(value);
}
/**
@@ -267,7 +268,7 @@ public class DefaultParameterValue<T> ex
return integer;
}
}
- throw incompatibleValue(value);
+ throw missingOrIncompatibleValue(value);
}
/**
@@ -291,7 +292,7 @@ public class DefaultParameterValue<T> ex
if (value instanceof int[]) {
return ((int[]) value).clone();
}
- throw incompatibleValue(value);
+ throw missingOrIncompatibleValue(value);
}
/**
@@ -317,7 +318,7 @@ public class DefaultParameterValue<T> ex
if (value instanceof Number) {
return ((Number) value).doubleValue();
}
- throw incompatibleValue(value);
+ throw missingOrIncompatibleValue(value);
}
/**
@@ -342,7 +343,7 @@ public class DefaultParameterValue<T> ex
if (value instanceof double[]) {
return ((double[]) value).clone();
}
- throw incompatibleValue(value);
+ throw missingOrIncompatibleValue(value);
}
/**
@@ -437,7 +438,7 @@ public class DefaultParameterValue<T> ex
if (value instanceof CharSequence) {
return value.toString();
}
- throw incompatibleValue(value);
+ throw missingOrIncompatibleValue(value);
}
/**
@@ -486,7 +487,7 @@ public class DefaultParameterValue<T> ex
/**
* Returns the exception to throw when an incompatible method is invoked for the value type.
*/
- private IllegalStateException incompatibleValue(final Object value) {
+ private IllegalStateException missingOrIncompatibleValue(final Object value) {
final String name = Verifier.getName(descriptor);
if (value != null) {
return new InvalidParameterTypeException(getClassTypeError(), name);
@@ -873,45 +874,70 @@ public class DefaultParameterValue<T> ex
protected String formatTo(final Formatter formatter) {
final ParameterDescriptor<T> descriptor = getDescriptor(); // Gives to users a chance to override this property.
WKTUtilities.appendName(descriptor, formatter, ElementKind.PARAMETER);
- final Unit<?> targetUnit = formatter.toContextualUnit(descriptor.getUnit());
final Convention convention = formatter.getConvention();
final boolean isWKT1 = convention.majorVersion() == 1;
- /*
- * In the WKT 1 specification, the unit of measurement is given by the context.
- * If this parameter value does not use the same unit, then we must convert it.
- * Otherwise we can write the value as-is.
- */
- final T value = getValue(); // Gives to users a chance to override this property.
- final Unit<?> unit = getUnit(); // Gives to users a chance to override this property.
- double convertedValue = Double.NaN;
- boolean sameUnit = Objects.equals(unit, targetUnit);
- if (!sameUnit) try {
- convertedValue = doubleValue(targetUnit);
- sameUnit = (value instanceof Number) && ((Number) value).doubleValue() == convertedValue;
- } catch (IllegalStateException exception) {
- // May happen if a parameter is mandatory (e.g. "semi-major")
- // but no value has been set for this parameter.
- formatter.setInvalidWKT(descriptor, exception);
- }
- if (isWKT1 && !sameUnit) {
- formatter.append(convertedValue);
- } else if (!isWKT1 && (unit == null) && isFile(value)) {
- formatter.append(value.toString(), null);
- return WKTKeywords.ParameterFile;
+ Unit<?> unit = getUnit(); // Gives to users a chance to override this property.
+ if (unit == null) {
+ final T value = getValue(); // Gives to users a chance to override this property.
+ if (!isWKT1 && isFile(value)) {
+ formatter.append(value.toString(), null);
+ return WKTKeywords.ParameterFile;
+ } else {
+ formatter.appendAny(value);
+ }
} else {
- formatter.appendAny(value);
- }
- /*
- * In the WKT 2 specification, the unit and the identifier are optional but recommended.
- * We follow that recommendation in strict WKT2 mode, but omit them in non-strict modes.
- * The only exception is when the parameter unit is not the same than the contextual unit,
- * in which case we have no choice: we must format that unit, unless the numerical value
- * is identical in both units (typically the 0 value).
- */
- if (!isWKT1 && (!sameUnit || !convention.isSimplified() || !hasContextualUnit(formatter))) {
- formatter.append(unit);
- // ID will be added by the Formatter itself.
+ /*
+ * In the WKT 1 specification, the unit of measurement is given by the context.
+ * If this parameter value does not use the same unit, we will need to convert it.
+ * Otherwise we can write the value as-is.
+ *
+ * Note that we take the descriptor unit as a starting point instead than this parameter unit
+ * in order to give precedence to the descriptor units in Convention.WKT1_COMMON_UNITS mode.
+ */
+ Unit<?> contextualUnit = descriptor.getUnit();
+ if (contextualUnit == null) { // Should be very rare (probably a buggy descriptor), but we try to be safe.
+ contextualUnit = unit;
+ }
+ contextualUnit = formatter.toContextualUnit(contextualUnit);
+ boolean ignoreUnits;
+ if (isWKT1) {
+ unit = contextualUnit;
+ ignoreUnits = true;
+ } else {
+ if (convention != Convention.INTERNAL) {
+ unit = PatchedUnitFormat.toFormattable(unit);
+ }
+ ignoreUnits = unit.equals(contextualUnit);
+ }
+ double value;
+ try {
+ value = doubleValue(unit);
+ } catch (IllegalStateException exception) {
+ // May happen if a parameter is mandatory (e.g. "semi-major")
+ // but no value has been set for this parameter.
+ formatter.setInvalidWKT(descriptor, exception);
+ value = Double.NaN;
+ }
+ formatter.append(value);
+ /*
+ * In the WKT 2 specification, the unit and the identifier are optional but recommended.
+ * We follow that recommendation in strict WKT2 mode, but omit them in non-strict modes.
+ * The only exception is when the parameter unit is not the same than the contextual unit,
+ * in which case we have no choice: we must format that unit, unless the numerical value
+ * is identical in both units (typically the 0 value).
+ */
+ if (!ignoreUnits && !Double.isNaN(value)) {
+ ignoreUnits = Numerics.equals(value, doubleValue(contextualUnit));
+ }
+ if (!ignoreUnits || !convention.isSimplified() || !hasContextualUnit(formatter)) {
+ if (!isWKT1) {
+ formatter.append(unit);
+ } else if (!ignoreUnits) {
+ formatter.setInvalidWKT(descriptor, null);
+ }
+ }
}
+ // ID will be added by the Formatter itself.
return WKTKeywords.Parameter;
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -36,6 +36,7 @@ import org.apache.sis.referencing.Abstra
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.metadata.AxisDirections;
import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.io.wkt.ElementKind;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.resources.Errors;
@@ -464,7 +465,7 @@ public class AbstractCS extends Abstract
if (type == null) {
formatter.setInvalidWKT(this, null);
}
- formatter.append(type, null);
+ formatter.append(type, ElementKind.CODE_LIST);
formatter.append(getDimension());
return WKTKeywords.CS;
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -29,6 +29,7 @@ import org.opengis.referencing.Reference
import org.opengis.referencing.datum.PrimeMeridian;
import org.opengis.referencing.crs.GeneralDerivedCRS;
import org.apache.sis.referencing.AbstractIdentifiedObject;
+import org.apache.sis.internal.util.PatchedUnitFormat;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.internal.jaxb.gco.Measure;
import org.apache.sis.internal.util.Numerics;
@@ -235,11 +236,11 @@ public class DefaultPrimeMeridian extend
* double longitudeInDegrees = primeMeridian.getGreenwichLongitude(NonSI.DEGREE_ANGLE);
* }
*
- * @param targetUnit The unit in which to express longitude.
+ * @param unit The unit in which to express longitude.
* @return The Greenwich longitude in the given units.
*/
- public double getGreenwichLongitude(final Unit<Angle> targetUnit) {
- return getAngularUnit().getConverterTo(targetUnit).convert(getGreenwichLongitude());
+ public double getGreenwichLongitude(final Unit<Angle> unit) {
+ return getAngularUnit().getConverterTo(unit).convert(getGreenwichLongitude());
}
/**
@@ -384,8 +385,8 @@ public class DefaultPrimeMeridian extend
* below the {@code PRIMEM[…]} one, which happen if we are inside a base CRS.
* See {@link #isElementOfBaseCRS(Formatter)} for more discussion.
*/
- private static boolean beConservative(final Formatter formatter, final Unit<Angle> targetUnit) {
- return !targetUnit.equals(NonSI.DEGREE_ANGLE) && !isElementOfBaseCRS(formatter);
+ private static boolean beConservative(final Formatter formatter, final Unit<Angle> contextualUnit) {
+ return !contextualUnit.equals(NonSI.DEGREE_ANGLE) && !isElementOfBaseCRS(formatter);
}
/**
@@ -398,16 +399,22 @@ public class DefaultPrimeMeridian extend
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
- final Convention convention = formatter.getConvention();
- final boolean isWKT1 = convention.majorVersion() == 1;
- final Unit<Angle> targetUnit = formatter.toContextualUnit(NonSI.DEGREE_ANGLE);
- formatter.append(isWKT1 ? getGreenwichLongitude(targetUnit) : getGreenwichLongitude());
+ final Convention convention = formatter.getConvention();
+ final boolean isWKT1 = (convention.majorVersion() == 1);
+ final Unit<Angle> contextualUnit = formatter.toContextualUnit(NonSI.DEGREE_ANGLE);
+ Unit<Angle> unit = contextualUnit;
+ if (!isWKT1) {
+ unit = getAngularUnit();
+ if (convention != Convention.INTERNAL) {
+ unit = PatchedUnitFormat.toFormattable(unit);
+ }
+ }
+ formatter.append(getGreenwichLongitude(unit));
if (isWKT1) {
return WKTKeywords.PrimeM;
}
- final Unit<Angle> angularUnit = getAngularUnit(); // Gives to users a chance to override properties.
- if (!convention.isSimplified() || !targetUnit.equals(angularUnit) || beConservative(formatter, targetUnit)) {
- formatter.append(angularUnit);
+ if (!convention.isSimplified() || !contextualUnit.equals(unit) || beConservative(formatter, contextualUnit)) {
+ formatter.append(unit);
}
return WKTKeywords.PrimeMeridian;
}
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -81,6 +81,7 @@ public final strictfp class WKTFormatTes
format.setConvention(Convention.WKT1);
parser = format;
testConsistency();
+ testConsistencyWithDenormalizedBaseCRS();
}
/**
@@ -97,6 +98,22 @@ public final strictfp class WKTFormatTes
parser = new WKTFormat(null, null);
parser.setConvention(Convention.WKT1);
testConsistency();
+ testConsistencyWithDenormalizedBaseCRS();
+ }
+
+ /**
+ * Tests consistency between the parser and the formatter when using the WKT 2 format.
+ * This test parses a WKT, formats it then parses again. We should obtain the same result.
+ *
+ * @throws ParseException if a parsing failed.
+ */
+ @Test
+ @DependsOnMethod("testConsistencyOfWKT1")
+ public void testConsistencyOfWKT2() throws ParseException {
+ format = new WKTFormat(null, null);
+ format.setConvention(Convention.WKT2);
+ parser = format;
+ testConsistency();
}
/**
@@ -108,7 +125,7 @@ public final strictfp class WKTFormatTes
testConsistency(
"GEOGCS[“Tokyo”,"
+ "DATUM[“Tokyo”,"
- + "SPHEROID[“Bessel 1841”,6377397.155,299.1528128,AUTHORITY[“EPSG”,“7004”]],"
+ + "SPHEROID[“Bessel 1841”, 6377397.155, 299.1528128, AUTHORITY[“EPSG”,“7004”]],"
+ "TOWGS84[-148,507,685,0,0,0,0],AUTHORITY[“EPSG”,“6301”]],"
+ "PRIMEM[“Greenwich”,0,AUTHORITY[“EPSG”,“8901”]],"
+ "UNIT[“DMSH”,0.0174532925199433,AUTHORITY[“EPSG”,“9108”]],"
@@ -119,7 +136,7 @@ public final strictfp class WKTFormatTes
testConsistency(
"GEOGCS[“NTF (Paris)”,"
+ "DATUM[“Nouvelle_Triangulation_Francaise”,"
- + "SPHEROID[“Clarke 1880 (IGN)”,6378249.2,293.466021293627,AUTHORITY[“EPSG”,“7011”]],"
+ + "SPHEROID[“Clarke 1880 (IGN)”, 6378249.2, 293.466021293627, AUTHORITY[“EPSG”,“7011”]],"
+ "TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[“EPSG”,“6275”]],"
+ "PRIMEM[“Paris”,2.5969213,AUTHORITY[“EPSG”,“8903”]],"
+ "UNIT[“grad”,0.015707963267949,AUTHORITY[“EPSG”,“9105”]],"
@@ -128,10 +145,44 @@ public final strictfp class WKTFormatTes
+ "AUTHORITY[“EPSG”,“4807”]]");
testConsistency(
+ "PROJCS[“NAD27 / Texas South Central”,"
+ + "GEOGCS[“NAD27”,"
+ + "DATUM[“North American Datum 1927”,"
+ + "SPHEROID[“Clarke 1866”, 6378206.4, 294.97869821]],"
+ + "UNIT[“degree”,0.0174532925199433]],"
+ + "PROJECTION[“Lambert_Conformal_Conic_2SP”],"
+ + "PARAMETER[“latitude_of_origin”,27.83333333333333],"
+ + "PARAMETER[“central_meridian”,-99.0],"
+ + "PARAMETER[“standard_parallel_1”,28.383333333333],"
+ + "PARAMETER[“standard_parallel_2”,30.283333333333],"
+ + "PARAMETER[“false_easting”,2000000],"
+ + "PARAMETER[“false_northing”,0],"
+ + "UNIT[“US survey foot”,0.304800609601219],"
+ + "AXIS[“Y”,NORTH],"
+ + "AXIS[“X”,EAST]]");
+
+ testConsistency(
+ "VERT_CS[“mean sea level depth”,"
+ + "VERT_DATUM[“Mean Sea Level”,2005,AUTHORITY[“EPSG”,“5100”]],"
+ + "UNIT[“kilometre”,1000],AXIS[“Z”,DOWN]]");
+ }
+
+ /**
+ * Similar to {@link #testConsistency()}, but using a base CRS that do not have normalized axes.
+ * Since base CRS axes are formatted in WKT 1 but not in WKT 2, we have an information lost in WKT 2.
+ * This information lost was considered unimportant in WKT 2 because the ISO 19111 ProjectedCRS model
+ * does not have a MathTransform. But in the Apache SIS case, this causes the 'conversionFromBase'
+ * property to have a different MathTransform, and consequently cause a test failure.
+ * In brief, the tests in this class can not be run on those WKT using the WKT 2 format.
+ *
+ * @throws ParseException if a parsing failed.
+ */
+ private void testConsistencyWithDenormalizedBaseCRS() throws ParseException {
+ testConsistency(
"PROJCS[“NTF (Paris) / France I”,"
+ "GEOGCS[“NTF (Paris)”,"
+ "DATUM[“Nouvelle_Triangulation_Francaise”,"
- + "SPHEROID[“Clarke 1880 (IGN)”,6378249.2,293.466021293627,AUTHORITY[“EPSG”,“7011”]],"
+ + "SPHEROID[“Clarke 1880 (IGN)”, 6378249.2, 293.466021293627, AUTHORITY[“EPSG”,“7011”]],"
+ "TOWGS84[-168,-60,320,0,0,0,0],"
+ "AUTHORITY[“EPSG”,“6275”]],"
+ "PRIMEM[“Paris”,2.5969213,AUTHORITY[“EPSG”,“8903”]],"
@@ -148,11 +199,6 @@ public final strictfp class WKTFormatTes
+ "UNIT[“km”,1000],"
+ "AXIS[“X”,EAST],"
+ "AXIS[“Y”,NORTH]]");
-
- testConsistency(
- "VERT_CS[“mean sea level depth”,"
- + "VERT_DATUM[“Mean Sea Level”,2005,AUTHORITY[“EPSG”,“5100”]],"
- + "UNIT[“kilometre”,1000],AXIS[“Z”,DOWN]]");
}
/**
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -26,6 +26,7 @@ import org.opengis.parameter.InvalidPara
import org.opengis.parameter.InvalidParameterValueException;
import org.apache.sis.internal.util.Constants;
import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.measure.Units;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -596,6 +597,22 @@ public final strictfp class DefaultParam
}
/**
+ * Tests WKT formatting of a parameter with sexagesimal units.
+ * Since those units can not be formatted in a {@code UNIT["name", scale]} element,
+ * the formatter should convert them to a formattable unit like degrees.
+ *
+ * @since 0.6
+ */
+ @Test
+ @DependsOnMethod("testWKT")
+ public void testWKT_withUnformattableUnit() {
+ final DefaultParameterValue<Double> p = create("Angle", 10.3, Units.valueOfEPSG(9111));
+ assertWktEquals(Convention.WKT1, "PARAMETER[“Angle”, 10.3]", p); // 10.3 DM == 10.5°
+ assertWktEquals(Convention.WKT2, "Parameter[“Angle”, 10.5, AngleUnit[“degree”, 0.017453292519943295]]", p);
+ assertWktEquals(Convention.INTERNAL, "Parameter[“Angle”, 10.3, Unit[“D.M”, 0.017453292519943295, Id[“EPSG”, 9111]]]", p);
+ }
+
+ /**
* Tests WKT formatting of a parameter having an identifier.
*
* @since 0.6
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -175,18 +175,18 @@ public final strictfp class DefaultCompo
" Datum[“World Geodetic System 1984”,\n" +
" Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”, 1]]],\n" +
" PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n" +
- " CS[“ellipsoidal”, 2],\n" +
+ " CS[ellipsoidal, 2],\n" +
" Axis[“Longitude (L)”, east, Order[1]],\n" +
" Axis[“Latitude (B)”, north, Order[2]],\n" +
" AngleUnit[“degree”, 0.017453292519943295]],\n" +
" VerticalCRS[“Gravity-related height”,\n" +
" VerticalDatum[“Mean Sea Level”],\n" +
- " CS[“vertical”, 1],\n" +
+ " CS[vertical, 1],\n" +
" Axis[“Gravity-related height (H)”, up, Order[1]],\n" +
" LengthUnit[“metre”, 1]],\n" +
" TimeCRS[“Time”,\n" +
" TimeDatum[“Modified Julian”, TimeOrigin[1858-11-17T00:00:00.0Z]],\n" +
- " CS[“temporal”, 1],\n" +
+ " CS[temporal, 1],\n" +
" Axis[“Time (t)”, future, Order[1]],\n" +
" TimeUnit[“day”, 86400]],\n" +
" Area[“World”],\n" +
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -175,7 +175,7 @@ public final strictfp class DefaultDeriv
" DerivingConversion[“Paris to Greenwich”,\n" +
" Method[“Longitude rotation”, Id[“EPSG”, 9601]],\n" +
" Parameter[“Longitude offset”, 2.33722917, Id[“EPSG”, 8602]]],\n" +
- " CS[“ellipsoidal”, 2],\n" +
+ " CS[ellipsoidal, 2],\n" +
" Axis[“Latitude (B)”, north, Order[1]],\n" +
" Axis[“Longitude (L)”, east, Order[2]],\n" +
" AngleUnit[“degree”, 0.017453292519943295]]",
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -100,7 +100,7 @@ public final strictfp class DefaultGeoce
" Datum[“World Geodetic System 1984”,\n" +
" Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”, 1]]],\n" +
" PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n" +
- " CS[“Cartesian”, 3],\n" +
+ " CS[Cartesian, 3],\n" +
" Axis[“(X)”, geocentricX, Order[1]],\n" +
" Axis[“(Y)”, geocentricY, Order[2]],\n" +
" Axis[“(Z)”, geocentricZ, Order[3]],\n" +
@@ -118,7 +118,7 @@ public final strictfp class DefaultGeoce
"GeodeticCRS[“Geocentric”,\n" +
" Datum[“World Geodetic System 1984”,\n" +
" Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
- " CS[“Cartesian”, 3],\n" +
+ " CS[Cartesian, 3],\n" +
" Axis[“(X)”, geocentricX],\n" +
" Axis[“(Y)”, geocentricY],\n" +
" Axis[“(Z)”, geocentricZ],\n" +
@@ -139,11 +139,11 @@ public final strictfp class DefaultGeoce
" Scope[“Satellite navigation.”],\n" +
" Id[“EPSG”, 6326]],\n" +
" PrimeMeridian[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
- " CS[“Cartesian”, 3],\n" +
+ " CS[Cartesian, 3],\n" +
" Axis[“Geocentric X (X)”, geocentricX],\n" +
" Axis[“Geocentric Y (Y)”, geocentricY],\n" +
" Axis[“Geocentric Z (Z)”, geocentricZ],\n" +
- " Unit[“metre”, 1]]",
+ " Unit[“metre”, 1, Id[“EPSG”, 9001]]]",
HardCodedCRS.GEOCENTRIC);
}
}
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -156,7 +156,7 @@ public final strictfp class DefaultGeogr
" Datum[“World Geodetic System 1984”,\n" +
" Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”, 1]]],\n" +
" PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n" +
- " CS[“ellipsoidal”, 2],\n" +
+ " CS[ellipsoidal, 2],\n" +
" Axis[“Longitude (L)”, east, Order[1]],\n" +
" Axis[“Latitude (B)”, north, Order[2]],\n" +
" AngleUnit[“degree”, 0.017453292519943295],\n" +
@@ -175,7 +175,7 @@ public final strictfp class DefaultGeogr
"GeodeticCRS[“WGS 84”,\n" +
" Datum[“World Geodetic System 1984”,\n" +
" Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
- " CS[“ellipsoidal”, 2],\n" +
+ " CS[ellipsoidal, 2],\n" +
" Axis[“Longitude (L)”, east],\n" +
" Axis[“Latitude (B)”, north],\n" +
" Unit[“degree”, 0.017453292519943295],\n" +
@@ -197,10 +197,10 @@ public final strictfp class DefaultGeogr
" Scope[“Satellite navigation.”],\n" +
" Id[“EPSG”, 6326]],\n" +
" PrimeMeridian[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
- " CS[“ellipsoidal”, 2],\n" +
+ " CS[ellipsoidal, 2],\n" +
" Axis[“Geodetic longitude (λ)”, east],\n" +
" Axis[“Geodetic latitude (φ)”, north],\n" +
- " Unit[“degree”, 0.017453292519943295],\n" +
+ " Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]],\n" +
" Area[“World”],\n" +
" BBox[-90.00, -180.00, 90.00, 180.00]]",
HardCodedCRS.WGS84);
@@ -220,7 +220,7 @@ public final strictfp class DefaultGeogr
" Datum[“Nouvelle Triangulation Francaise”,\n" + // Formatter should replace "ç" by "c".
" Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]],\n" +
" PrimeMeridian[“Paris”, 2.5969213, Unit[“grade”, 0.015707963267948967]],\n" +
- " CS[“ellipsoidal”, 2],\n" +
+ " CS[ellipsoidal, 2],\n" +
" Axis[“Longitude (L)”, east],\n" + // See method javadoc.
" Axis[“Latitude (B)”, north],\n" +
" Unit[“grade”, 0.015707963267948967]]",
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -194,7 +194,7 @@ public final strictfp class DefaultProje
" Parameter[“Scale factor at natural origin”, 0.99987742],\n" +
" Parameter[“False easting”, 600000.0],\n" +
" Parameter[“False northing”, 2200000.0]],\n" +
- " CS[“Cartesian”, 2],\n" +
+ " CS[Cartesian, 2],\n" +
" Axis[“Easting (E)”, east],\n" +
" Axis[“Northing (N)”, north],\n" +
" Unit[“metre”, 1],\n" +
@@ -219,7 +219,7 @@ public final strictfp class DefaultProje
" Parameter[“Scale factor at natural origin”, 0.99987742],\n" +
" Parameter[“False easting”, 600000.0],\n" +
" Parameter[“False northing”, 2200000.0]],\n" +
- " CS[“Cartesian”, 2],\n" +
+ " CS[Cartesian, 2],\n" +
" Axis[“Easting (E)”, east],\n" +
" Axis[“Northing (N)”, north],\n" +
" Unit[“metre”, 1],\n" +
@@ -250,7 +250,7 @@ public final strictfp class DefaultProje
" Parameter[“Scale factor at natural origin”, 0.99987742, ScaleUnit[“unity”, 1], Id[“EPSG”, 8805]],\n" +
" Parameter[“False easting”, 600000.0, LengthUnit[“metre”, 1], Id[“EPSG”, 8806]],\n" +
" Parameter[“False northing”, 2200000.0, LengthUnit[“metre”, 1], Id[“EPSG”, 8807]]],\n" +
- " CS[“Cartesian”, 2],\n" +
+ " CS[Cartesian, 2],\n" +
" Axis[“Easting (E)”, east, Order[1]],\n" +
" Axis[“Northing (N)”, north, Order[2]],\n" +
" LengthUnit[“metre”, 1],\n" +
@@ -330,7 +330,7 @@ public final strictfp class DefaultProje
" Parameter[“Longitude of natural origin”, 0.0],\n" +
" Parameter[“False easting”, 1000.0],\n" +
" Parameter[“False northing”, 2000.0]],\n" +
- " CS[“Cartesian”, 2],\n" +
+ " CS[Cartesian, 2],\n" +
" Axis[“Easting (E)”, east],\n" +
" Axis[“Northing (N)”, north],\n" +
" Unit[“metre”, 1]]",
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultTemporalCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -54,7 +54,7 @@ public final strictfp class DefaultTempo
assertWktEquals(Convention.WKT2,
"TimeCRS[“Time”,\n" +
" TimeDatum[“Modified Julian”, TimeOrigin[1858-11-17T00:00:00.0Z]],\n" +
- " CS[“temporal”, 1],\n" +
+ " CS[temporal, 1],\n" +
" Axis[“Time (t)”, future, Order[1]],\n" +
" TimeUnit[“day”, 86400]]",
HardCodedCRS.TIME);
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -55,7 +55,7 @@ public final strictfp class DefaultVerti
assertWktEquals(Convention.WKT2,
"VerticalCRS[“Depth”,\n" +
" VerticalDatum[“Mean Sea Level”],\n" +
- " CS[“vertical”, 1],\n" +
+ " CS[vertical, 1],\n" +
" Axis[“Depth (D)”, down, Order[1]],\n" +
" LengthUnit[“metre”, 1]]",
HardCodedCRS.DEPTH);
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java?rev=1688693&r1=1688692&r2=1688693&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] Wed Jul 1 17:12:42 2015
@@ -104,10 +104,10 @@ public final strictfp class DefaultCoord
assertWktEquals(Convention.WKT1, "AXIS[“x”, EAST]", X);
assertWktEquals(Convention.WKT1, "AXIS[“y”, NORTH]", Y);
assertWktEquals(Convention.WKT1, "AXIS[“z”, UP]", Z);
- assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic longitude (λ)”, east, Unit[“degree”, 0.017453292519943295]]", GEODETIC_LONGITUDE);
- assertWktEquals(Convention.INTERNAL, "Axis[“Spherical longitude (θ)”, east, Unit[“degree”, 0.017453292519943295]]", SPHERICAL_LONGITUDE);
- assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic latitude (φ)”, north, Unit[“degree”, 0.017453292519943295]]", GEODETIC_LATITUDE);
- assertWktEquals(Convention.INTERNAL, "Axis[“Spherical latitude (φ′)”, north, Unit[“degree”, 0.017453292519943295]]", SPHERICAL_LATITUDE);
+ assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic longitude (λ)”, east, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", GEODETIC_LONGITUDE);
+ assertWktEquals(Convention.INTERNAL, "Axis[“Spherical longitude (θ)”, east, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", SPHERICAL_LONGITUDE);
+ assertWktEquals(Convention.INTERNAL, "Axis[“Geodetic latitude (φ)”, north, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", GEODETIC_LATITUDE);
+ assertWktEquals(Convention.INTERNAL, "Axis[“Spherical latitude (φ′)”, north, Unit[“degree”, 0.017453292519943295, Id[“EPSG”, 9102]]]", SPHERICAL_LATITUDE);
}
/**