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 2014/02/19 22:32:00 UTC
svn commit: r1569926 [3/6] - in /sis/branches/JDK6: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/io/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/
core/sis-metadata/src/mai...
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlRoot
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.cs.RangeMeaning;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -45,13 +46,16 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.io.wkt.ElementKind;
import static java.lang.Double.doubleToLongBits;
import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.POSITIVE_INFINITY;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import static org.apache.sis.util.ArgumentChecks.*;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.util.collection.Containers.property;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -96,6 +100,24 @@ public class DefaultCoordinateSystemAxis
private static final long serialVersionUID = -7883614853277827689L;
/**
+ * Key for the <code>{@value}</code> property to be given to the constructor.
+ * This is used for setting the value to be returned by {@link #getMinimumValue()}.
+ */
+ public static final String MINIMUM_VALUE_KEY = "minimumValue";
+
+ /**
+ * Key for the <code>{@value}</code> property to be given to the constructor.
+ * This is used for setting the value to be returned by {@link #getMaximumValue()}.
+ */
+ public static final String MAXIMUM_VALUE_KEY = "maximumValue";
+
+ /**
+ * Key for the <code>{@value}</code> property to be given to the constructor.
+ * This is used for setting the value to be returned by {@link #getRangeMeaning()}.
+ */
+ public static final String RANGE_MEANING_KEY = "rangeMeaning";
+
+ /**
* The identifier for axis of unknown name. We have to use this identifier when the axis direction changed,
* because such change often implies a name change too (e.g. "Westing" → "Easting"), and we can not always
* guess what the new name should be.
@@ -200,10 +222,9 @@ public class DefaultCoordinateSystemAxis
}
/**
- * Constructs an axis from a set of properties and a given range.
- * The properties map is given unchanged to the
- * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
- * The following table is a reminder of main (not all) properties:
+ * Constructs an axis from a set of properties. The properties given in argument follow the same rules
+ * than for the {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
+ * Additionally, the following properties are understood by this constructor:
*
* <table class="sis">
* <tr>
@@ -212,6 +233,24 @@ public class DefaultCoordinateSystemAxis
* <th>Returned by</th>
* </tr>
* <tr>
+ * <td>{@value #MINIMUM_VALUE_KEY}</td>
+ * <td>{@link Number}</td>
+ * <td>{@link #getMinimumValue()}</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #MAXIMUM_VALUE_KEY}</td>
+ * <td>{@link Number}</td>
+ * <td>{@link #getMaximumValue()}</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #RANGE_MEANING_KEY}</td>
+ * <td>{@link RangeMeaning}</td>
+ * <td>{@link #getRangeMeaning()}</td>
+ * </tr>
+ * <tr>
+ * <th colspan="3" class="hsep">Defined in parent class (reminder)</th>
+ * </tr>
+ * <tr>
* <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
* <td>{@link ReferenceIdentifier} or {@link String}</td>
* <td>{@link #getName()}</td>
@@ -233,47 +272,13 @@ public class DefaultCoordinateSystemAxis
* </tr>
* </table>
*
- * @param properties The properties to be given to the identified object.
- * @param abbreviation The {@linkplain #getAbbreviation() abbreviation} used for this coordinate system axis.
- * @param direction The {@linkplain #getDirection() direction} of this coordinate system axis.
- * @param unit The {@linkplain #getUnit() unit of measure} used for this coordinate system axis.
- * @param minimumValue The minimum value normally allowed for this axis, or {@link Double#NEGATIVE_INFINITY} if none.
- * @param maximumValue The maximum value normally allowed for this axis, or {@link Double#POSITIVE_INFINITY} if none.
- * @param rangeMeaning The meaning of axis value range specified by the minimum and maximum values, or {@code null}
- * if it does not apply. Shall not be null if the minimum and maximum values are not infinite.
- */
- public DefaultCoordinateSystemAxis(final Map<String,?> properties,
- final String abbreviation,
- final AxisDirection direction,
- final Unit<?> unit,
- final double minimumValue,
- final double maximumValue,
- RangeMeaning rangeMeaning)
- {
- super(properties);
- this.abbreviation = abbreviation;
- this.direction = direction;
- this.unit = unit;
- this.minimumValue = minimumValue;
- this.maximumValue = maximumValue;
- ensureNonNull("abbreviation", abbreviation);
- ensureNonNull("direction", direction);
- ensureNonNull("unit", unit);
- if (!(minimumValue < maximumValue)) { // Use '!' for catching NaN
- throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalRange_2, minimumValue, maximumValue));
- }
- if ((minimumValue != NEGATIVE_INFINITY) || (maximumValue != POSITIVE_INFINITY)) {
- ensureNonNull("rangeMeaning", rangeMeaning);
- } else {
- rangeMeaning = null;
- }
- this.rangeMeaning = rangeMeaning;
- }
-
- /**
- * Constructs an axis from a set of properties and a range inferred from the axis unit and direction.
- * The properties map is the same than for the {@linkplain #DefaultCoordinateSystemAxis(Map, String,
- * AxisDirection, Unit, double, double, RangeMeaning) above constructor}.
+ * Generally speaking, information provided in the {@code properties} map are considered ignorable metadata
+ * (except the axis name) while information provided as explicit arguments may have an impact on coordinate
+ * transformation results. Exceptions to this rule are the {@code minimumValue} and {@code maximumValue} in
+ * the particular case where {@code rangeMeaning} is {@link RangeMeaning#WRAPAROUND}.
+ *
+ * <p>If no minimum, maximum and range meaning are specified, then this constructor will infer them
+ * from the axis unit and direction.</p>
*
* @param properties The properties to be given to the identified object.
* @param abbreviation The {@linkplain #getAbbreviation() abbreviation} used for this coordinate system axis.
@@ -285,39 +290,53 @@ public class DefaultCoordinateSystemAxis
final AxisDirection direction,
final Unit<?> unit)
{
- // NOTE: we would invoke this(properties, abbreviation, ...) instead if Oracle fixed
- // RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").
super(properties);
this.abbreviation = abbreviation;
this.direction = direction;
this.unit = unit;
- ensureNonNull("abbreviation", abbreviation);
- ensureNonNull("direction", direction);
- ensureNonNull("unit", unit);
- double min = NEGATIVE_INFINITY;
- double max = POSITIVE_INFINITY;
- RangeMeaning r = null;
- if (Units.isAngular(unit)) {
- final UnitConverter fromDegrees = NonSI.DEGREE_ANGLE.getConverterTo(unit.asType(Angle.class));
- final AxisDirection dir = AxisDirections.absolute(direction);
- if (dir.equals(AxisDirection.NORTH)) {
- min = fromDegrees.convert(Latitude.MIN_VALUE);
- max = fromDegrees.convert(Latitude.MAX_VALUE);
- r = RangeMeaning.EXACT;
- } else if (dir.equals(AxisDirection.EAST)) {
- min = fromDegrees.convert(Longitude.MIN_VALUE);
- max = fromDegrees.convert(Longitude.MAX_VALUE);
- r = RangeMeaning.WRAPAROUND; // 180°E wraps to 180°W
- }
- if (min > max) {
- final double t = min;
- min = max;
- max = t;
- }
- }
- minimumValue = min;
- maximumValue = max;
- rangeMeaning = r;
+ ensureNonEmpty("abbreviation", abbreviation);
+ ensureNonNull ("direction", direction);
+ ensureNonNull ("unit", unit);
+ Number minimum = property(properties, MINIMUM_VALUE_KEY, Number.class);
+ Number maximum = property(properties, MAXIMUM_VALUE_KEY, Number.class);
+ RangeMeaning rm = property(properties, RANGE_MEANING_KEY, RangeMeaning.class);
+ if (minimum == null && maximum == null && rm == null) {
+ double min = Double.NEGATIVE_INFINITY;
+ double max = Double.POSITIVE_INFINITY;
+ if (Units.isAngular(unit)) {
+ final UnitConverter fromDegrees = NonSI.DEGREE_ANGLE.getConverterTo(unit.asType(Angle.class));
+ final AxisDirection dir = AxisDirections.absolute(direction);
+ if (dir.equals(AxisDirection.NORTH)) {
+ min = fromDegrees.convert(Latitude.MIN_VALUE);
+ max = fromDegrees.convert(Latitude.MAX_VALUE);
+ rm = RangeMeaning.EXACT;
+ } else if (dir.equals(AxisDirection.EAST)) {
+ min = fromDegrees.convert(Longitude.MIN_VALUE);
+ max = fromDegrees.convert(Longitude.MAX_VALUE);
+ rm = RangeMeaning.WRAPAROUND; // 180°E wraps to 180°W
+ }
+ if (min > max) {
+ final double t = min;
+ min = max;
+ max = t;
+ }
+ }
+ minimumValue = min;
+ maximumValue = max;
+ } else {
+ minimumValue = (minimum != null) ? minimum.doubleValue() : Double.NEGATIVE_INFINITY;
+ maximumValue = (maximum != null) ? maximum.doubleValue() : Double.POSITIVE_INFINITY;
+ if (!(minimumValue < maximumValue)) { // Use '!' for catching NaN
+ throw new IllegalArgumentException(Errors.getResources(properties).getString(
+ Errors.Keys.IllegalRange_2, minimumValue, maximumValue));
+ }
+ if ((minimumValue != NEGATIVE_INFINITY) || (maximumValue != POSITIVE_INFINITY)) {
+ ensureNonNull(RANGE_MEANING_KEY, rm);
+ } else {
+ rm = null;
+ }
+ }
+ rangeMeaning = rm;
}
/**
@@ -588,6 +607,18 @@ public class DefaultCoordinateSystemAxis
/**
* Compares the specified object with this axis for equality.
+ * The strictness level is controlled by the second argument.
+ * This method compares the following properties in every cases:
+ *
+ * <ul>
+ * <li>{@link #getName()}</li>
+ * <li>{@link #getDirection()}</li>
+ * <li>{@link #getUnit()}</li>
+ * </ul>
+ *
+ * In the particular case where {@link #getRangeMeaning()} is {@code WRAPAROUND}, then {@link #getMinimumValue()}
+ * and {@link #getMaximumValue()} are considered non-ignorable metadata and will be compared for every modes.
+ * All other properties are compared only for modes stricter than {@link ComparisonMode#IGNORE_METADATA}.
*
* @param object The object to compare to {@code this}.
* @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
@@ -686,14 +717,84 @@ public class DefaultCoordinateSystemAxis
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element.
+ * Returns {@code true} if writing an axis in the given formatter should omit the axis name.
+ * From ISO 19162: For geodetic CRSs having a geocentric Cartesian coordinate system,
+ * the axis name should be omitted as it is given through the mandatory axis direction,
+ * but the axis abbreviation, respectively ‘X’, 'Y' and ‘Z’, shall be given.
+ */
+ private boolean omitName(final Formatter formatter) {
+ return AxisDirections.isGeocentric(direction) && formatter.getEnclosingElement(1) instanceof GeodeticCRS;
+ }
+
+ /**
+ * Formats this axis as a <cite>Well Known Text</cite> {@code Axis[…]} element.
+ *
+ * {@section Constraints for WKT validity}
+ * The ISO 19162 specification puts many constraints on axis names, abbreviations and directions allowed in WKT.
+ * Most of those constraints are inherited from ISO 19111 — see {@link CoordinateSystemAxis} javadoc for some of
+ * those. The current Apache SIS implementation does not verify whether this axis name and abbreviation are
+ * compliant; we assume that the user created a valid axis.
+ * The only actions (derived from ISO 19162 rules) taken by this method are:
*
- * @param formatter The formatter to use.
- * @return The WKT element name, which is {@code "AXIS"}.
+ * <ul>
+ * <li>Replace “<cite>Geodetic latitude</cite>” and “<cite>Geodetic longitude</cite>” names (case insensitive)
+ * by “<cite>Latitude</cite>” and “<cite>Longitude</cite>” respectively.</li>
+ * </ul>
+ *
+ * @return {@code "Axis"}.
*/
@Override
protected String formatTo(final Formatter formatter) {
- formatter.append(direction);
- return "AXIS";
+ final Convention convention = formatter.getConvention();
+ final boolean isWKT1 = convention.majorVersion() == 1;
+ final boolean isInternal = (convention == Convention.INTERNAL);
+ String name = null;
+ if (isWKT1 || isInternal || !omitName(formatter)) {
+ name = IdentifiedObjects.getName(this, formatter.getNameAuthority());
+ if (name == null) {
+ name = IdentifiedObjects.getName(this, null);
+ }
+ if (!isInternal && name != null) {
+ if (name.equalsIgnoreCase("Geodetic latitude")) {
+ name = "Latitude"; // ISO 19162 §7.5.3(ii)
+ } else if (name.equalsIgnoreCase("Geodetic longitude")) {
+ name = "Longitude";
+ }
+ }
+ }
+ /*
+ * ISO 19162 §7.5.3 suggests to put abbreviation in parentheses, e.g. "Easting (x)".
+ */
+ if (!isWKT1 && (name == null || !name.equals(abbreviation))) {
+ final StringBuilder buffer = new StringBuilder();
+ if (name != null) {
+ buffer.append(name).append(' ');
+ }
+ name = buffer.append('(').append(abbreviation).append(')').toString();
+ }
+ formatter.append(name, ElementKind.AXIS);
+ /*
+ * Format the axis direction, optionally followed by a MERIDIAN[…] element
+ * if the direction is of the kind "South along 90°N" for instance.
+ */
+ AxisDirection dir = direction;
+ DirectionAlongMeridian meridian = null;
+ if (!isWKT1 && AxisDirections.isUserDefined(dir)) {
+ meridian = DirectionAlongMeridian.parse(dir);
+ if (meridian != null) {
+ dir = meridian.baseDirection;
+ }
+ }
+ formatter.append(dir);
+ formatter.append(meridian);
+ /*
+ * Formats the axis unit only if the enclosing CRS element does not provide one.
+ * If the enclosing CRS provided a contextual unit, then it is assumed to apply
+ * to all axes (we do not verify).
+ */
+ if (!isWKT1 && !formatter.hasContextualUnit(1)) {
+ formatter.append(unit);
+ }
+ return "Axis";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -164,7 +164,7 @@ public class DefaultCylindricalCS extend
*/
@Override
final int validateAxis(final AxisDirection direction, final Unit<?> unit) {
- if (!AxisDirections.isSpatialOrCustom(direction, false)) {
+ if (!AxisDirections.isSpatialOrUserDefined(direction, false)) {
return INVALID_DIRECTION;
}
if (!Units.isLinear(unit)) {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -24,6 +24,7 @@ import org.opengis.referencing.cs.Ellips
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.measure.Units;
@@ -36,9 +37,6 @@ import org.apache.sis.measure.Units;
* </tr><tr>
* <td>{@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS Geographic}</td>
* <td>“Geodetic latitude”, “Geodetic longitude”, “Ellipsoidal height” (if 3D)</td>
- * </tr><tr>
- * <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
- * <td>unspecified</td>
* </tr></table>
*
* {@section Immutability and thread safety}
@@ -120,6 +118,13 @@ public class DefaultEllipsoidalCS extend
final CoordinateSystemAxis axis1)
{
super(properties, axis0, axis1);
+ for (int i=0; i<2; i++) {
+ final AxisDirection direction = super.getAxis(i).getDirection();
+ if (AxisDirections.isVertical(direction)) {
+ throw new IllegalArgumentException(Errors.format(
+ Errors.Keys.IllegalAxisDirection_2, "EllipdoicalCS (2D)", direction));
+ }
+ }
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -157,7 +157,7 @@ public class DefaultLinearCS extends Abs
*/
@Override
final int validateAxis(final AxisDirection direction, final Unit<?> unit) {
- if (!AxisDirections.isSpatialOrCustom(direction, false)) {
+ if (!AxisDirections.isSpatialOrUserDefined(direction, false)) {
return INVALID_DIRECTION;
}
if (!Units.isLinear(unit)) {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -160,7 +160,7 @@ public class DefaultPolarCS extends Abst
*/
@Override
final int validateAxis(final AxisDirection direction, final Unit<?> unit) {
- if (!AxisDirections.isSpatialOrCustom(direction, false)) {
+ if (!AxisDirections.isSpatialOrUserDefined(direction, false)) {
return INVALID_DIRECTION;
}
if (!Units.isLinear(unit) && !Units.isAngular(unit)) {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -164,7 +164,7 @@ public class DefaultSphericalCS extends
*/
@Override
final int validateAxis(final AxisDirection direction, final Unit<?> unit) {
- if (!AxisDirections.isSpatialOrCustom(direction, false)) {
+ if (!AxisDirections.isSpatialOrUserDefined(direction, false)) {
return INVALID_DIRECTION;
}
if (!Units.isAngular(unit) && !Units.isLinear(unit)) {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -26,6 +26,14 @@ import org.opengis.referencing.cs.Coordi
/**
* A 2- or 3-dimensional coordinate system for any combination of coordinate axes not covered by other CS types.
*
+ * <table class="sis"><tr>
+ * <th>Used with CRS</th>
+ * <th>Permitted axis names</th>
+ * </tr><tr>
+ * <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
+ * <td>unspecified</td>
+ * </tr></table>
+ *
* {@section Immutability and thread safety}
* This class is immutable and thus thread-safe if the property <em>values</em> (not necessarily the map itself)
* and the {@link CoordinateSystemAxis} instances given to the constructor are also immutable. Unless otherwise
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -17,6 +17,7 @@
package org.apache.sis.referencing.cs;
import java.util.Map;
+import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlRootElement;
@@ -46,9 +47,6 @@ import org.apache.sis.internal.referenci
* </tr><tr>
* <td>{@linkplain org.apache.sis.referencing.crs.DefaultVerticalCRS Vertical}</td>
* <td>“Gravity-related height” or “Depth”</td>
- * </tr><tr>
- * <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
- * <td>unspecified</td>
* </tr></table>
*
* {@section Immutability and thread safety}
@@ -166,16 +164,21 @@ public class DefaultVerticalCS extends A
* or an {@code INVALID_*} error code otherwise. This method is invoked at construction time.
* The current implementation accepts only temporal directions (i.e. {@link AxisDirection#UP}
* and {@link AxisDirection#DOWN}).
- *
- * <p>We currently put no restriction on the unit because it may be linear, temporal (time
- * needed for echo to travel), pressure, or dimensionless (sigma-level).</p>
*/
@Override
- final int validateAxis(final AxisDirection direction, final Unit<?> unit) {
+ final int validateAxis(final AxisDirection direction, Unit<?> unit) {
if (!AxisDirection.UP.equals(AxisDirections.absolute(direction))) {
return INVALID_DIRECTION;
}
- return VALID;
+ unit = unit.toSI();
+ if (unit.equals(SI.METRE) || // Most usual case.
+ unit.equals(SI.PASCAL) || // Height or depth estimated by the atmospheric or ocean pressure.
+ unit.equals(SI.SECOND) || // Depth estimated by the time needed for an echo to travel.
+ unit.equals(Unit.ONE)) // Sigma-level (percentage from sea surface to ocean floor).
+ {
+ return VALID;
+ }
+ return INVALID_UNIT;
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -16,20 +16,28 @@
*/
package org.apache.sis.referencing.cs;
-import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.measure.unit.NonSI;
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.util.iso.Types;
import org.apache.sis.measure.Longitude;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.io.wkt.FormattableObject;
+import org.apache.sis.io.wkt.Formatter;
/**
* Parses {@linkplain AxisDirection axis direction} of the kind "<cite>South along 90 deg East</cite>".
* Those directions are used in the EPSG database for polar stereographic projections.
*
+ * {@section Reference meridian}
+ * This class does not know whether the meridian is relative to Greenwich or any other reference meridian.
+ * The reference meridian shall be inferred from the geodetic datum of the {@code GeographicCRS} instance
+ * that contains (through its coordinate system) the axes having those directions. This is consistent with
+ * ISO 19162 §7.5.4(iv) - WKT 2 formatting.
+ *
* {@section Immutability and thread safety}
* This final class is immutable and thus inherently thread-safe.
*
@@ -38,12 +46,7 @@ import org.apache.sis.internal.referenci
* @version 0.4
* @module
*/
-final class DirectionAlongMeridian implements Comparable<DirectionAlongMeridian>, Serializable {
- /**
- * For cross-version compatibility.
- */
- private static final long serialVersionUID = 1602711631943838328L;
-
+final class DirectionAlongMeridian extends FormattableObject implements Comparable<DirectionAlongMeridian> {
/**
* A parser for EPSG axis names. Examples:
*
@@ -94,6 +97,9 @@ final class DirectionAlongMeridian imple
/**
* Returns the direction along meridian for the specified axis direction, or {@code null} if none.
+ *
+ * <p>TIP: caller can check {@link AxisDirections#isUserDefined(AxisDirection)} before to invoke this method
+ * for avoiding {@code DirectionAlongMeridian} initialization in the common case where it is not needed.</p>
*/
public static DirectionAlongMeridian parse(final AxisDirection direction) {
final DirectionAlongMeridian candidate = parse(direction.name());
@@ -236,7 +242,7 @@ final class DirectionAlongMeridian imple
*/
@Override
public int hashCode() {
- return Numerics.hashCode(serialVersionUID ^ (Double.doubleToLongBits(meridian) + baseDirection.hashCode()));
+ return Numerics.hashCode(Double.doubleToLongBits(meridian) + baseDirection.hashCode());
}
/**
@@ -273,4 +279,21 @@ final class DirectionAlongMeridian imple
assert EPSG.matcher(name).matches() : name;
return name;
}
+
+ /**
+ * Formats this object as a <cite>Well Known Text</cite> {@code Meridian[…]} element.
+ * This element contains the meridian value and the unit of measurement.
+ * The unit is currently fixed to degrees, but this may change in any future implementation.
+ *
+ * {@note <code>Meridian</code> is defined in the WKT 2 specification only.}
+ *
+ * @param formatter The formatter where to format the inner content of this WKT element.
+ * @return {@code "Meridian"}.
+ */
+ @Override
+ protected String formatTo(final Formatter formatter) {
+ formatter.append(meridian);
+ formatter.append(NonSI.DEGREE_ANGLE);
+ return "Meridian";
+ }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -17,6 +17,7 @@
package org.apache.sis.referencing.cs;
import java.util.Map;
+import java.util.HashMap;
import java.util.Arrays;
import javax.measure.unit.Unit;
import javax.measure.unit.SI;
@@ -74,7 +75,8 @@ final class Normalizer implements Compar
*/
private Normalizer(final CoordinateSystemAxis axis) {
this.axis = axis;
- meridian = DirectionAlongMeridian.parse(axis.getDirection());
+ final AxisDirection dir = axis.getDirection();
+ meridian = AxisDirections.isUserDefined(dir) ? DirectionAlongMeridian.parse(dir) : null;
}
/**
@@ -177,11 +179,11 @@ final class Normalizer implements Compar
newAbbr = "t";
}
}
- final Map<String,?> properties;
+ final Map<String,Object> properties = new HashMap<String,Object>();
if (newAbbr.equals(abbreviation)) {
- properties = IdentifiedObjects.getProperties(axis, EXCLUDES);
+ properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES));
} else {
- properties = singletonMap(NAME_KEY, DefaultCoordinateSystemAxis.UNNAMED);
+ properties.put(NAME_KEY, DefaultCoordinateSystemAxis.UNNAMED);
}
/*
* Converts the axis range and build the new axis.
@@ -193,8 +195,10 @@ final class Normalizer implements Compar
// Use IllegalStateException because the public API is an AbstractCS member method.
throw new IllegalStateException(Errors.format(Errors.Keys.IllegalUnitFor_2, "axis", unit), e);
}
- return new DefaultCoordinateSystemAxis(properties, newAbbr, newDir, newUnit,
- c.convert(axis.getMinimumValue()), c.convert(axis.getMaximumValue()), axis.getRangeMeaning());
+ properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, c.convert(axis.getMinimumValue()));
+ properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, c.convert(axis.getMaximumValue()));
+ properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, axis.getRangeMeaning());
+ return new DefaultCoordinateSystemAxis(properties, newAbbr, newDir, newUnit);
}
/**
@@ -256,8 +260,13 @@ final class Normalizer implements Compar
min -= offset;
max -= offset;
if (min < max) { // Paranoiac check, but also a way to filter NaN values when offset is infinite.
- axis = new DefaultCoordinateSystemAxis(IdentifiedObjects.getProperties(axis, EXCLUDES),
- axis.getAbbreviation(), axis.getDirection(), axis.getUnit(), min, max, rangeMeaning);
+ final Map<String,Object> properties = new HashMap<String,Object>();
+ properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES));
+ properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, min);
+ properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, max);
+ properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, rangeMeaning);
+ axis = new DefaultCoordinateSystemAxis(properties,
+ axis.getAbbreviation(), axis.getDirection(), axis.getUnit());
changed = true;
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -17,7 +17,7 @@
/**
* Coordinate system definitions as the set of coordinate system axes that spans the coordinate space.
- * An explanation for this package is provided in the {@linkplain org.opengis.referencing.cs OpenGIS® javadoc}.
+ * An explanation for this package is provided in the {@linkplain org.opengis.referencing.cs OpenGIS® javadoc}.
* The remaining discussion on this page is specific to the SIS implementation.
*
* <p>The root class in this package is {@link org.apache.sis.referencing.cs.AbstractCS}.
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -29,15 +29,13 @@ import org.opengis.referencing.datum.Dat
import org.opengis.referencing.ReferenceIdentifier;
import org.apache.sis.referencing.AbstractIdentifiedObject;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.util.iso.Types;
-import org.apache.sis.util.Classes;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.internal.metadata.MetadataUtilities;
import static org.apache.sis.util.Utilities.deepEquals;
import static org.apache.sis.util.collection.Containers.property;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -335,17 +333,6 @@ public class AbstractDatum extends Abstr
}
/**
- * Gets the type of the datum as an enumerated code. Datum type was provided for all kind of datum
- * in the legacy OGC 01-009 specification. In the new OGC 03-73 (ISO 19111) specification,
- * datum type is provided only for vertical datum. Nevertheless, we keep this method around
- * since it is needed for WKT formatting. Note that we return the datum type ordinal value,
- * not the code list object.
- */
- int getLegacyDatumType() {
- return 0;
- }
-
- /**
* Returns {@code true} if either the {@linkplain #getName() primary name} or at least
* one {@linkplain #getAlias() alias} matches the given string according heuristic rules.
* This method performs the comparison documented in the
@@ -437,20 +424,4 @@ public class AbstractDatum extends Abstr
protected long computeHashCode() {
return super.computeHashCode() + Objects.hash(anchorDefinition, realizationEpoch, domainOfValidity, scope);
}
-
- /**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a> element.
- *
- * {@note All subclasses will override this method, but only <code>DefaultGeodeticDatum</code>
- * will <strong>not</strong> invoke this parent method, because horizontal datum do not
- * write the datum type.}
- *
- * @param formatter The formatter to use.
- * @return The WKT element name.
- */
- @Override
- protected String formatTo(final Formatter formatter) {
- formatter.append(getLegacyDatumType());
- return Classes.getShortClassName(this);
- }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -30,11 +30,11 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.internal.util.DoubleDouble;
import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import static java.lang.Math.abs;
import static org.apache.sis.util.ArgumentChecks.*;
import static org.apache.sis.referencing.operation.matrix.Matrix4.SIZE;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.getNumber;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -535,6 +535,23 @@ public class BursaWolfParameters extends
}
/**
+ * Retrieves the value at the specified row and column of the given matrix, wrapped in a {@code Number}.
+ * The {@code Number} type depends on the matrix accuracy.
+ *
+ * @param matrix The matrix from which to get the number.
+ * @param row The row index, from 0 inclusive to {@link Matrix#getNumRow()} exclusive.
+ * @param column The column index, from 0 inclusive to {@link Matrix#getNumCol()} exclusive.
+ * @return The current value at the given row and column.
+ */
+ private static Number getNumber(final Matrix matrix, final int row, final int column) {
+ if (matrix instanceof MatrixSIS) {
+ return ((MatrixSIS) matrix).getNumber(row, column);
+ } else {
+ return matrix.getElement(row, column);
+ }
+ }
+
+ /**
* Returns the region or timeframe in which a coordinate transformation based on those Bursa-Wolf parameters is
* valid, or {@code null} if unspecified. If an extent was specified at construction time, then that extent is
* returned. Otherwise the datum domain of validity (which may be {@code null}) is returned.
@@ -600,17 +617,20 @@ public class BursaWolfParameters extends
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element. The WKT contains the
- * parameters in <var>translation</var>, <var>rotation</var>, <var>scale</var> order, like below:
+ * Formats this object as a <cite>Well Known Text</cite> {@code ToWGS84[…]} element.
+ * The WKT contains the parameters in <var>translation</var>, <var>rotation</var>, <var>scale</var> order,
+ * like below:
*
* <blockquote><code>TOWGS84[{@linkplain #tX}, {@linkplain #tY}, {@linkplain #tZ}, {@linkplain #rX},
* {@linkplain #rY}, {@linkplain #rZ}, {@linkplain #dS}]</code></blockquote>
*
- * The element name is {@code "TOWGS84"} in the common case where the {@linkplain #getTargetDatum() target datum}
+ * {@note <code>TOWGS84</code> is defined in the WKT 1 specification only.}
+ *
+ * The element name is {@code "ToWGS84"} in the common case where the {@linkplain #getTargetDatum() target datum}
* is WGS 84. For other targets, the element name will be derived from the datum name.
*
- * @param formatter The formatter to use.
- * @return The WKT element name, usually {@code "TOWGS84"}.
+ * @param formatter The formatter where to format the inner content of this WKT element.
+ * @return Usually {@code "ToWGS84"}.
*/
@Override
protected String formatTo(final Formatter formatter) {
@@ -622,14 +642,14 @@ public class BursaWolfParameters extends
formatter.append(rZ);
formatter.append(dS);
if (isToWGS84()) {
- return "TOWGS84";
+ return "ToWGS84";
}
- String keyword = super.formatTo(formatter); // Declare the WKT as invalid.
- final String name = IdentifiedObjects.getUnicodeIdentifier(targetDatum);
- if (name != null) {
- // We may try to build something better here in future SIS versions, if there is a need for that.
- keyword = "TO" + name;
+ formatter.setInvalidWKT(BursaWolfParameters.class, null);
+ String name = IdentifiedObjects.getUnicodeIdentifier(targetDatum);
+ if (name == null) {
+ name = "Unknown";
}
- return keyword;
+ // We may try to build something better here in future SIS versions, if there is a need for that.
+ return "To" + name;
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -37,6 +37,7 @@ import org.apache.sis.internal.referenci
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.AbstractIdentifiedObject;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.resources.Errors;
@@ -71,8 +72,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* {@section Distance calculations}
* This class contains an {@link #orthodromicDistance(double, double, double, double)} convenience method
- * for calculating distances on great circles. This convenience method is provided as an alternative to
- * the {@link org.apache.sis.referencing.GeodeticCalculator}.
+ * for calculating distances on great circles.
*
* {@section Creating new ellipsoid instances}
* New instances can be created either directly by specifying all information to a factory method (choices 3
@@ -606,8 +606,6 @@ public class DefaultEllipsoid extends Ab
* @param λ2 Longitude of second point (in decimal degrees).
* @param φ2 Latitude of second point (in decimal degrees).
* @return The orthodromic distance (in the units of this ellipsoid's axis).
- *
- * @see org.apache.sis.referencing.GeodeticCalculator
*/
public double orthodromicDistance(double λ1, double φ1, double λ2, double φ2) {
λ1 = toRadians(λ1);
@@ -752,16 +750,27 @@ public class DefaultEllipsoid extends Ab
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element.
+ * Formats this ellipsoid as a <cite>Well Known Text</cite> {@code Ellipsoid[…]} element.
*
- * @param formatter The formatter to use.
- * @return The WKT element name, which is {@code "SPHEROID"}.
+ * @return {@code "Ellipsoid"} (WKT 2) or {@code "Spheroid"} (WKT 1).
*/
@Override
protected String formatTo(final Formatter formatter) {
- final double ivf = getInverseFlattening();
- formatter.append(getAxisUnit().getConverterTo(SI.METRE).convert(getSemiMajorAxis()));
- formatter.append(isInfinite(ivf) ? 0 : ivf);
- return "SPHEROID";
+ super.formatTo(formatter);
+ final Convention convention = formatter.getConvention();
+ final boolean isWKT1 = convention.majorVersion() == 1;
+ double length = semiMajorAxis;
+ if (isWKT1) {
+ length = unit.getConverterTo(SI.METRE).convert(length);
+ }
+ formatter.append(length);
+ formatter.append(isInfinite(inverseFlattening) ? 0 : inverseFlattening);
+ if (isWKT1) {
+ return "Spheroid";
+ }
+ if (!convention.isSimplified() || !SI.METRE.equals(unit)) {
+ formatter.append(unit);
+ }
+ return "Ellipsoid";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -163,15 +163,23 @@ public class DefaultEngineeringDatum ext
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a> element.
- * The keyword is "{@code LOCAL_DATUM}" in WKT 1.
+ * Formats this datum as a <cite>Well Known Text</cite> {@code EngineeringDatum[…]} element.
*
- * @param formatter The formatter to use.
- * @return The WKT element name, which is {@code "LOCAL_DATUM"}.
+ * @return {@code "EngineeringDatum"} (WKT 2) or {@code "Local_Datum"} (WKT 1).
*/
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
- return "LOCAL_DATUM";
+ if (formatter.getConvention().majorVersion() == 1) {
+ /*
+ * Datum type was provided for all kind of datum in the legacy OGC 01-009 specification.
+ * Datum types became provided only for vertical datum in the ISO 19111:2003 specification,
+ * then removed completely in the ISO 19111:2007 revision. We are supposed to format them
+ * in WKT 1, but do not have any indication about what the values should be.
+ */
+ formatter.append(0);
+ return "Local_Datum";
+ }
+ return "EngineeringDatum";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -497,25 +497,49 @@ public class DefaultGeodeticDatum extend
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element.
+ * Formats this datum as a <cite>Well Known Text</cite> {@code Datum[…]} element.
*
- * @param formatter The formatter to use.
- * @return The WKT element name, which is {@code "DATUM"}.
+ * <blockquote><font size="-1"><b>Example:</b> Well-Known Text of a WGS 84 datum.
+ *
+ * {@preformat wkt
+ * Datum["World Geodetic System 1984",
+ * Ellipsoid["WGS84", 6378137.0, 298.257223563, LengthUnit["metre", 1]],
+ * Id["EPSG", 6326, Citation["OGP"], URI["urn:ogc:def:datum:EPSG::6326"]]]
+ * }
+ *
+ * <p>Same datum using WKT 1.</p>
+ *
+ * {@preformat wkt
+ * DATUM["World Geodetic System 1984"
+ * SPHEROID["WGS84", 6378137.0, 298.257223563],
+ * AUTHORITY["EPSG", "6326"]]
+ * }
+ * </font></blockquote>
+ *
+ * @return {@code "Datum"}.
*/
@Override
protected String formatTo(final Formatter formatter) {
- // Do NOT invokes the super-class method, because
- // horizontal datum do not write the datum type.
+ super.formatTo(formatter);
+ formatter.newLine();
formatter.append(ellipsoid instanceof FormattableObject ? (FormattableObject) ellipsoid :
DefaultEllipsoid.castOrCopy(ellipsoid));
- if (bursaWolf != null) {
- for (final BursaWolfParameters candidate : bursaWolf) {
- if (candidate.isToWGS84()) {
- formatter.append(candidate);
- break;
+ if (formatter.getConvention().majorVersion() == 1) {
+ /*
+ * Note that at the different of other datum (in particular vertical datum),
+ * WKT of geodetic datum do not have a numerical code for the datum type.
+ */
+ if (bursaWolf != null) {
+ for (final BursaWolfParameters candidate : bursaWolf) {
+ if (candidate.isToWGS84()) {
+ formatter.newLine();
+ formatter.append(candidate);
+ break;
+ }
}
}
}
- return "DATUM";
+ formatter.newLine(); // For writing the ID[…] element on its own line.
+ return "Datum";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -26,6 +26,7 @@ import org.opengis.referencing.Reference
import org.opengis.referencing.datum.ImageDatum;
import org.opengis.referencing.datum.PixelInCell;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
import org.apache.sis.util.ComparisonMode;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -230,17 +231,21 @@ public class DefaultImageDatum extends A
}
/**
- * Format the inner part of a <cite>Well Known Text</cite> (WKT) element.
- * {@code ImageDatum} are defined in the WKT 2 specification only.
+ * Formats this datum as a <cite>Well Known Text</cite> {@code ImageDatum[…]} element.
*
- * @param formatter The formatter to use.
- * @return The WKT element name.
+ * {@note <code>ImageDatum</code> is defined in the WKT 2 specification only.}
+ *
+ * @return {@code "ImageDatum"}.
*/
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
- formatter.append(pixelInCell);
- formatter.setInvalidWKT(this);
- return "GENDATUM"; // Generic datum (WKT 2)
+ final Convention convention = formatter.getConvention();
+ if (convention == Convention.INTERNAL) {
+ formatter.append(pixelInCell); // This is an extension compared to ISO 19162.
+ } else if (convention.majorVersion() == 1) {
+ formatter.setInvalidWKT(this, null);
+ }
+ return "ImageDatum";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -31,11 +31,12 @@ import org.apache.sis.referencing.Abstra
import org.apache.sis.internal.jaxb.gco.Measure;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
import org.apache.sis.util.ComparisonMode;
import static org.apache.sis.util.ArgumentChecks.ensureFinite;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -331,26 +332,23 @@ public class DefaultPrimeMeridian extend
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element.
+ * Formats this prime meridian as a <cite>Well Known Text</cite> {@code PrimeMeridian[…]} element.
*
- * @param formatter The formatter to use.
- * @return The WKT element name, which is {@code "PRIMEM"}.
+ * @return {@code "PrimeMeridian"} (WKT 2) or {@code "PrimeM"} (WKT 1).
*/
@Override
protected String formatTo(final Formatter formatter) {
- /*
- * If the PrimeMeridian is written inside a "GEOGCS", then OGC say that it must be
- * written in the unit of the enclosing geographic coordinate system. Otherwise,
- * default to decimal degrees. Note that ESRI and GDAL don't follow this rule.
- */
- Unit<Angle> context = formatter.getConvention().getForcedUnit(Angle.class);
- if (context == null) {
- context = formatter.getAngularUnit();
- if (context == null) {
- context = NonSI.DEGREE_ANGLE;
- }
+ 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) : greenwichLongitude);
+ if (isWKT1) {
+ return "PrimeM";
+ }
+ if (!convention.isSimplified() || !targetUnit.equals(angularUnit)) {
+ formatter.append(angularUnit);
}
- formatter.append(getGreenwichLongitude(context));
- return "PRIMEM";
+ return "PrimeMeridian";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java Wed Feb 19 21:31:56 2014
@@ -29,9 +29,11 @@ import org.opengis.referencing.datum.Tem
import org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter;
import org.apache.sis.internal.metadata.MetadataUtilities;
import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.io.wkt.Formatter;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -271,4 +273,23 @@ public class DefaultTemporalDatum extend
protected long computeHashCode() {
return super.computeHashCode() + origin;
}
+
+ /**
+ * Formats this datum as a <cite>Well Known Text</cite> {@code TimeDatum[â¦]} element.
+ *
+ * {@note <code>TimeDatum</code> is defined in the WKT 2 specification only.}
+ *
+ * @return {@code "TimeDatum"}.
+ */
+ @Override
+ protected String formatTo(final Formatter formatter) {
+ super.formatTo(formatter);
+ final Convention convention = formatter.getConvention();
+ if (convention == Convention.INTERNAL) {
+ formatter.append(MetadataUtilities.toDate(origin)); // This is an extension compared to ISO 19162.
+ } else if (convention.majorVersion() == 1) {
+ formatter.setInvalidWKT(this, null);
+ }
+ return "TimeDatum";
+ }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -32,7 +32,7 @@ import org.apache.sis.internal.jaxb.Lega
import org.apache.sis.internal.referencing.VerticalDatumTypes;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -247,16 +247,6 @@ public class DefaultVerticalDatum extend
}
/**
- * Returns the legacy code for the datum type, or 0 if none.
- *
- * @see #getVerticalDatumType()
- */
- @Override
- final int getLegacyDatumType() {
- return VerticalDatumTypes.toLegacy(getVerticalDatumType().ordinal());
- }
-
- /**
* Returns the type to be marshalled to XML.
* This element was present in GML 3.0 and 3.1, but has been removed from GML 3.2.
*
@@ -316,14 +306,22 @@ public class DefaultVerticalDatum extend
}
/**
- * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element.
+ * Formats this datum as a <cite>Well Known Text</cite> {@code VerticalDatum[…]} element.
*
- * @param formatter The formatter to use.
- * @return The WKT element name, which is {@code "VERT_DATUM"}.
+ * {@note OGC 01-009 defined numerical codes for various vertical datum types, for example 2005 for geoidal height
+ * and 2002 for ellipsoidal height. Such codes were formatted for all <code>Datum</code> subtypes in WKT 1.
+ * Datum types became provided only for vertical datum in the ISO 19111:2003 specification, then removed
+ * completely in ISO 19111:2007.}
+ *
+ * @return {@code "VerticalDatum"} (WKT 2) or {@code "Vert_Datum"} (WKT 1).
*/
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
- return "VERT_DATUM";
+ if (formatter.getConvention().majorVersion() == 1) {
+ formatter.append(VerticalDatumTypes.toLegacy(type().ordinal()));
+ return "Vert_Datum";
+ }
+ return "VerticalDatum";
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -34,7 +34,6 @@ import static org.apache.sis.internal.re
* by {@link #getTimeReference()}. Those values vary at a rate given by the parameters listed in the
* table below (codes, names and abbreviations are from the EPSG database):
*
- * <table class="compact"><tr><td>
* <table class="sis">
* <tr><th>Code</th> <th>Name</th> <th>Abbr.</th></tr>
* <tr><td>1040</td> <td>Rate of change of X-axis translation</td> <td>{@link #dtX}</td></tr>
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -28,7 +28,7 @@ import org.junit.Test;
import static java.lang.Double.NaN;
import static org.opengis.test.Validators.*;
-import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -23,7 +23,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.opengis.test.Validators.*;
-import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
@@ -90,7 +90,6 @@ public final strictfp class Envelope2DTe
*/
@Test
@DependsOnMethod("testToRectanglesOnSimpleEnvelope")
- @org.junit.Ignore("The tested envelope needs to be associated to CRS:84")
public void testToRectanglesOverAntiMeridian() {
final Envelope2D envelope = new Envelope2D(WGS84, 155, 0, -150 - 155, 50);
final Rectangle2D[] rectangles = envelope.toRectangles();
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -26,7 +26,7 @@ import org.junit.Test;
import static java.lang.Double.NaN;
import static org.opengis.test.Validators.*;
-import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -21,7 +21,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.opengis.test.Validators.*;
-import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -129,7 +129,21 @@ public final strictfp class AxisDirectio
}
/**
- * Tests {@link AxisDirections#isSpatialOrCustom(AxisDirection, boolean)} and
+ * Tests {@link AxisDirections#isGeocentric(AxisDirection)}.
+ */
+ @Test
+ public void testIsGeocentric() {
+ assertTrue (AxisDirections.isGeocentric(GEOCENTRIC_X));
+ assertTrue (AxisDirections.isGeocentric(GEOCENTRIC_Y));
+ assertTrue (AxisDirections.isGeocentric(GEOCENTRIC_Z));
+ assertFalse(AxisDirections.isGeocentric(NORTH));
+ assertFalse(AxisDirections.isGeocentric(UP));
+ assertFalse(AxisDirections.isGeocentric(DOWN));
+ assertFalse(AxisDirections.isGeocentric(FUTURE));
+ }
+
+ /**
+ * Tests {@link AxisDirections#isSpatialOrUserDefined(AxisDirection, boolean)} and
* {@link AxisDirections#isGrid(AxisDirection)}.
*/
@Test
@@ -161,7 +175,7 @@ public final strictfp class AxisDirectio
/**
* Asserts that
- * {@link AxisDirections#isSpatialOrCustom(AxisDirection)},
+ * {@link AxisDirections#isSpatialOrUserDefined(AxisDirection, boolean)},
* {@link AxisDirections#isCartesianOrCustom(AxisDirection)} and
* {@link AxisDirections#isGrid(AxisDirection)}
* returns the expected value for all the given axis directions.
@@ -172,8 +186,8 @@ public final strictfp class AxisDirectio
for (final AxisDirection dir : directions) {
final String name = dir.name();
assertEquals(name, isGrid, AxisDirections.isGrid(dir));
- assertEquals(name, isSpatial, AxisDirections.isSpatialOrCustom(dir, false));
- assertEquals(name, isSpatial | isGrid | isDisplay, AxisDirections.isSpatialOrCustom(dir, true));
+ assertEquals(name, isSpatial, AxisDirections.isSpatialOrUserDefined(dir, false));
+ assertEquals(name, isSpatial | isGrid | isDisplay, AxisDirections.isSpatialOrUserDefined(dir, true));
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1569926&r1=1569916&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -50,7 +50,7 @@ public final strictfp class DefaultParam
private static Map<String,Object> properties(final String name,
final Object minimumValue, final Object maximumValue)
{
- final Map<String,Object> properties = new HashMap<>(8);
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, name));
assertNull(properties.put(DefaultParameterDescriptor.MINIMUM_VALUE_KEY, minimumValue));
assertNull(properties.put(DefaultParameterDescriptor.MAXIMUM_VALUE_KEY, maximumValue));
@@ -66,7 +66,7 @@ public final strictfp class DefaultParam
* @return The parameter descriptor.
*/
static <T> DefaultParameterDescriptor<T> createSimpleOptional(final String name, final Class<T> type) {
- return new DefaultParameterDescriptor<>(properties(name, null, null), type, null, null, false);
+ return new DefaultParameterDescriptor<T>(properties(name, null, null), type, null, null, false);
}
/**
@@ -81,7 +81,7 @@ public final strictfp class DefaultParam
static DefaultParameterDescriptor<Integer> create(final String name,
final int defaultValue, final int minimumValue, final int maximumValue)
{
- return new DefaultParameterDescriptor<>(properties(name, minimumValue, maximumValue),
+ return new DefaultParameterDescriptor<Integer>(properties(name, minimumValue, maximumValue),
Integer.class, Integer.valueOf(defaultValue), null, true);
}
@@ -98,7 +98,7 @@ public final strictfp class DefaultParam
static DefaultParameterDescriptor<Double> create(final String name,
final double defaultValue, final double minimumValue, final double maximumValue, final Unit<?> unit)
{
- return new DefaultParameterDescriptor<>(properties(name,
+ return new DefaultParameterDescriptor<Double>(properties(name,
minimumValue == Double.NEGATIVE_INFINITY ? null : Double.valueOf(minimumValue),
maximumValue == Double.POSITIVE_INFINITY ? null : Double.valueOf(maximumValue)),
Double.class, Double.isNaN(defaultValue) ? null : Double.valueOf(defaultValue), unit, true);
@@ -119,7 +119,7 @@ public final strictfp class DefaultParam
{
final Map<String,Object> properties = properties(name, null, null);
assertNull(properties.put(DefaultParameterDescriptor.VALID_VALUES_KEY, validValues));
- return new DefaultParameterDescriptor<>(properties, type, defaultValue, null, true);
+ return new DefaultParameterDescriptor<T>(properties, type, defaultValue, null, true);
}
/**
@@ -198,7 +198,7 @@ public final strictfp class DefaultParam
*/
@Test
public void testStringType() {
- final ParameterDescriptor<String> descriptor = new DefaultParameterDescriptor<>(
+ final ParameterDescriptor<String> descriptor = new DefaultParameterDescriptor<String>(
properties("String param", "AAA", "BBB"), String.class, "ABC", null, false);
assertEquals("name", "String param", descriptor.getName().getCode());
assertEquals("valueClass", String.class, descriptor.getValueClass());
@@ -213,7 +213,7 @@ public final strictfp class DefaultParam
* This operation shall be invalid for non-numerical types.
*/
try {
- new DefaultParameterDescriptor<>(properties("Invalid param", "AAA", "BBB"),
+ new DefaultParameterDescriptor<String>(properties("Invalid param", "AAA", "BBB"),
String.class, "ABC", SI.METRE, false);
} catch (IllegalArgumentException e) {
assertEquals("Unit of measurement “m” is not valid for “Invalid param” values.", e.getMessage());
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1569926&r1=1569916&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -67,7 +67,7 @@ public final strictfp class DefaultParam
* @return A new parameter instance for the given name and value.
*/
private static DefaultParameterValue<Integer> createOptional(final String name, final int value) {
- final DefaultParameterValue<Integer> parameter = new DefaultParameterValue<>(
+ final DefaultParameterValue<Integer> parameter = new DefaultParameterValue<Integer>(
DefaultParameterDescriptorTest.createSimpleOptional(name, Integer.class));
parameter.setValue(value, null);
return parameter;
@@ -84,7 +84,7 @@ public final strictfp class DefaultParam
private static DefaultParameterValue<Double> create(final String name, final double value, final Unit<?> unit) {
final ParameterDescriptor<Double> descriptor = DefaultParameterDescriptorTest.create(
name, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, unit);
- final DefaultParameterValue<Double> parameter = new DefaultParameterValue<>(descriptor);
+ final DefaultParameterValue<Double> parameter = new DefaultParameterValue<Double>(descriptor);
parameter.setValue(value, unit);
return parameter;
}
@@ -153,7 +153,7 @@ public final strictfp class DefaultParam
@Test
@DependsOnMethod("testInteger")
public void testBoundedInteger() {
- final DefaultParameterValue<Integer> parameter = new DefaultParameterValue<>(
+ final DefaultParameterValue<Integer> parameter = new DefaultParameterValue<Integer>(
DefaultParameterDescriptorTest.create("Bounded param", 15, -30, +40));
assertEquals(Integer.class, parameter.getDescriptor().getValueClass());
assertEquals( "value", Integer.valueOf(15), parameter.getValue());
@@ -272,7 +272,7 @@ public final strictfp class DefaultParam
@Test
@DependsOnMethod("testMeasure")
public void testBoundedDouble() {
- final DefaultParameterValue<Double> parameter = new DefaultParameterValue<>(
+ final DefaultParameterValue<Double> parameter = new DefaultParameterValue<Double>(
DefaultParameterDescriptorTest.create("Bounded param", 15.0, -30.0, +40.0, null));
assertEquals(Double.class, parameter.getDescriptor().getValueClass());
assertEquals( "value", Double.valueOf(15), parameter.getValue());
@@ -316,7 +316,7 @@ public final strictfp class DefaultParam
@Test
@DependsOnMethod({"testMeasure", "testBoundedDouble"})
public void testBoundedMeasure() {
- final DefaultParameterValue<Double> parameter = new DefaultParameterValue<>(
+ final DefaultParameterValue<Double> parameter = new DefaultParameterValue<Double>(
DefaultParameterDescriptorTest.create("Length measure", 12, 4, 20, SI.METRE));
assertEquals("value", Double.valueOf(12), parameter.getValue());
assertEquals("intValue", 12, parameter.intValue());
@@ -363,7 +363,7 @@ public final strictfp class DefaultParam
};
final ParameterDescriptor<AxisDirection> descriptor = DefaultParameterDescriptorTest.create(
"Direction", AxisDirection.class, directions, AxisDirection.NORTH);
- final DefaultParameterValue<AxisDirection> parameter = new DefaultParameterValue<>(descriptor);
+ final DefaultParameterValue<AxisDirection> parameter = new DefaultParameterValue<AxisDirection>(descriptor);
validate(parameter);
assertEquals ("name", "Direction", descriptor.getName().getCode());
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -38,7 +38,7 @@ import static org.apache.sis.metadata.is
/**
- * Tests {@link AbstractIdentifiedObject}.
+ * Tests the {@link AbstractIdentifiedObject} class.
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-2.2)
@@ -95,6 +95,36 @@ public final strictfp class AbstractIden
}
/**
+ * Tests the {@link AbstractIdentifiedObject#AbstractIdentifiedObject(Map)} constructor without name.
+ * This is invalid and should thrown an exception.
+ */
+ @Test
+ public void testMissingName() {
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
+ assertNull(properties.put(AbstractIdentifiedObject.REMARKS_KEY, "Not a name."));
+ try {
+ new AbstractIdentifiedObject(properties);
+ fail("Should not allow unnamed object.");
+ } catch (IllegalArgumentException e) {
+ // The message may be in any language, but shall
+ // contain at least the missing property name.
+ final String message = e.getMessage();
+ assertTrue(message, message.contains("code"));
+ }
+ // Try again, with error messages forced to English.
+ assertNull(properties.put(AbstractIdentifiedObject.LOCALE_KEY, Locale.US));
+ try {
+ new AbstractIdentifiedObject(properties);
+ fail("Should not allow unnamed object.");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Missing value for “code” property.", e.getMessage());
+ }
+ // "code" with String value is accepted as well.
+ assertNull(properties.put("code", "Test"));
+ assertEquals("Test", new AbstractIdentifiedObject(properties).getName().getCode());
+ }
+
+ /**
* Tests the {@link AbstractIdentifiedObject#AbstractIdentifiedObject(Map)} constructor without identifier.
* This method compares the property values against the expected values.
*/
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -19,17 +19,28 @@ package org.apache.sis.referencing;
import java.util.Map;
import java.util.HashMap;
import java.util.Locale;
+import org.opengis.referencing.IdentifiedObject;
import org.opengis.test.Validators;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.metadata.iso.extent.DefaultExtent;
+import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.test.mock.VerticalCRSMock;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import static org.opengis.referencing.ReferenceSystem.*;
import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.assertWktEquals;
/**
- * Tests {@link AbstractReferenceSystem}.
+ * Tests the {@link AbstractReferenceSystem} class.
*
* @author Martin Desruisseaux (IRD)
* @since 0.4 (derived from geotk-2.2)
@@ -78,4 +89,49 @@ public final strictfp class AbstractRefe
assertNotSame(object, assertSerializedEquals(object));
}
+
+ /**
+ * Tests WKT formatting with a name that contains the quote character and optional information.
+ * We test that the closing quote character is doubled and the optional information properly formatted.
+ */
+ @Test
+ @DependsOnMethod("testCreateFromMap")
+ public void testWKT() {
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
+ assertNull(properties.put(NAME_KEY, "My “object”."));
+ assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
+ assertNull(properties.put(REMARKS_KEY, "注です。"));
+ assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(
+ HardCodedCitations.OGP, "EPSG", "4326", "8.2", null)));
+ assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.",
+ new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77),
+ new DefaultVerticalExtent(10, 1000, VerticalCRSMock.DEPTH),
+ new DefaultTemporalExtent()))); // TODO: needs sis-temporal module for testing that one.
+ final IdentifiedObject object = new AbstractReferenceSystem(properties);
+
+ assertWktEquals(Convention.WKT1,
+ // Closing quote conservatively omitted for WKT 1.
+ "ReferenceSystem[“My “object.”, AUTHORITY[“EPSG”, “4326”]]",
+ object);
+
+ assertWktEquals(Convention.WKT2,
+ "ReferenceSystem[“My “object””.”,\n" +
+ " Scope[“Large scale topographic mapping and cadastre.”],\n" +
+ " Area[“Netherlands offshore.”],\n" +
+ " BBox[51.43, 2.54, 55.77, 6.40],\n" +
+ " VerticalExtent[-1000, -10, LengthUnit[“metre”, 1]],\n" +
+ " Id[“EPSG”, 4326, “8.2”, Citation[“OGP”], URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" +
+ " Remarks[“注です。”]]",
+ object);
+
+ assertWktEquals(Convention.WKT2_SIMPLIFIED,
+ "ReferenceSystem[“My “object””.”,\n" +
+ " Scope[“Large scale topographic mapping and cadastre.”],\n" +
+ " Area[“Netherlands offshore.”],\n" +
+ " BBox[51.43, 2.54, 55.77, 6.40],\n" +
+ " VerticalExtent[-1000, -10],\n" +
+ " Id[“EPSG”, 4326, “8.2”, Citation[“OGP”], URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" +
+ " Remarks[“注です。”]]",
+ object);
+ }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java?rev=1569926&r1=1569925&r2=1569926&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java [UTF-8] Wed Feb 19 21:31:56 2014
@@ -28,7 +28,7 @@ import static org.apache.sis.referencing
/**
- * Tests {@link IdentifiedObjects}.
+ * Tests the {@link IdentifiedObjects} static methods.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4