Author: desruisseaux
Date: Thu Jan 16 19:41:06 2014
New Revision: 1558895
URL: http://svn.apache.org/r1558895
Log:
Added crs() implementation for vertical and temporal enums.
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Thu Jan 16 19:41:06 2014
@@ -330,6 +330,9 @@ public class AbstractIdentifiedObject ex
* <ul>
* <li>If the given object is {@code null}, then this method returns
{@code null}.</li>
* <li>Otherwise if the given object is is an instance of
+ * {@link org.opengis.referencing.cs.CoordinateReferenceSystem},
+ * {@link org.opengis.referencing.cs.CoordinateSystem},
+ * {@link org.opengis.referencing.cs.CoordinateSystemAxis},
* {@link org.opengis.referencing.datum.Datum},
* {@link org.opengis.referencing.datum.Ellipsoid} or
* {@link org.opengis.referencing.datum.PrimeMeridian},
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
[UTF-8] Thu Jan 16 19:41:06 2014
@@ -17,10 +17,11 @@
package org.apache.sis.referencing;
import java.util.Map;
-import java.util.HashMap;
import java.util.Date;
-import java.util.Locale;
import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
+import javax.measure.unit.Unit;
+import javax.measure.quantity.Duration;
import org.opengis.util.FactoryException;
import org.opengis.util.InternationalString;
import org.opengis.referencing.IdentifiedObject;
@@ -28,6 +29,8 @@ import org.opengis.referencing.crs.Geode
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.cs.TimeCS;
+import org.opengis.referencing.cs.VerticalCS;
import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.datum.Ellipsoid;
@@ -42,13 +45,19 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.referencing.datum.DefaultVerticalDatum;
import org.apache.sis.referencing.datum.DefaultTemporalDatum;
import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.DefaultTimeCS;
+import org.apache.sis.referencing.cs.DefaultVerticalCS;
+import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
+import org.apache.sis.referencing.crs.DefaultTemporalCRS;
+import org.apache.sis.referencing.crs.DefaultVerticalCRS;
import org.apache.sis.internal.system.SystemListener;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.logging.Logging;
+import org.apache.sis.measure.Units;
+import static java.util.Collections.singletonMap;
import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
-import static org.opengis.referencing.IdentifiedObject.ALIAS_KEY;
/**
@@ -59,7 +68,7 @@ import static org.opengis.referencing.Id
*
* <p>Referencing objects are cached after creation. Invoking the same method
on the same {@code GeodeticObjects}
* instance twice will return the same {@link IdentifiedObject} instance,
unless the internal cache has been cleared
- * (e.g. the application is running in a container environment, and some
modules have been installed or uninstalled).</p>
+ * (e.g. the application is running in a container environment and some
modules have been installed or uninstalled).</p>
*
* <p><b>Example:</b> the following code fetches a geographic Coordinate
Reference System using
* (<var>longitude</var>, <var>latitude</var>) axis order on the {@link
#WGS84} geodetic datum:</p>
@@ -561,24 +570,31 @@ public enum GeodeticObjects {
*
* <p>Referencing objects are cached after creation. Invoking the same
method on the same {@code Vertical}
* instance twice will return the same {@link IdentifiedObject} instance,
unless the internal cache has been cleared
- * (e.g. the application is running in a container environment, and some
modules have been installed or uninstalled).</p>
+ * (e.g. the application is running in a container environment and some
modules have been installed or uninstalled).</p>
*
- * <p><b>Example:</b> the following code fetches a vertical Coordinate
Reference System for height above the geoid:</p>
+ * <p><b>Example:</b> the following code fetches a vertical Coordinate
Reference System for heights
+ * above the Mean Sea Level (MSL):</p>
*
* {@preformat java
- * VerticalCRS crs = GeodeticObjects.Vertical.GEOIDAL.crs();
+ * VerticalCRS crs = GeodeticObjects.Vertical.MSL_HEIGHT.crs();
* }
*
* Below is an alphabetical list of object names available in this
enumeration:
*
* <blockquote><table class="sis">
- * <tr><th>Name or alias</th> <th>Object type</th> <th>Enumeration
value</th></tr>
- * <tr><td>Barometric altitude</td> <td>CRS, Datum</td> <td>{@link
#BAROMETRIC}</td></tr>
- * <tr><td>Geoidal height</td> <td>CRS, Datum</td> <td>{@link
#GEOIDAL}</td></tr>
- * <tr><td>Ellipsoidal height</td> <td>CRS, Datum</td> <td>{@link
#ELLIPSOIDAL}</td></tr>
- * <tr><td>Other surface</td> <td>CRS, Datum</td> <td>{@link
#OTHER_SURFACE}</td></tr>
+ * <tr><th>Name or alias</th> <th>Object type</th>
<th>Enumeration value</th></tr>
+ * <tr><td>Barometric altitude</td> <td>CRS, Datum</td>
<td>{@link #BAROMETRIC}</td></tr>
+ * <tr><td><s>Ellipsoidal height</s></td> <td>CRS, Datum</td>
<td><s>{@link #ELLIPSOIDAL}</s></td></tr>
+ * <tr><td>Mean Sea Level</td> <td>Datum</td>
<td>{@link #MSL_HEIGHT}</td></tr>
+ * <tr><td>Mean Sea Level height</td> <td>CRS</td>
<td>{@link #MSL_HEIGHT}</td></tr>
+ * <tr><td>Mean Sea Level depth</td> <td>CRS</td>
<td>{@link #MSL_DEPTH}</td></tr>
+ * <tr><td>Other surface</td> <td>CRS, Datum</td>
<td>{@link #OTHER_SURFACE}</td></tr>
* </table></blockquote>
*
+ * {@note We do not provide a <code>GEOIDAL</code> value because its
definition depends on the realization epoch.
+ * For example EGM84, EGM96 and EGM2008 are applications of three
different geoid models on the WGS 84
+ * ellipsoid. The <code>MSL_HEIGHT</code> value can be used instead
as an approximation of geoidal heights.}
+ *
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
* @version 0.4
@@ -586,21 +602,47 @@ public enum GeodeticObjects {
*/
public static enum Vertical {
/**
- * Height measured by atmospheric pressure.
+ * Height measured by atmospheric pressure in hectopascals (hPa).
+ * The datum is not specific to any location or epoch.
*
* @see VerticalDatumType#BAROMETRIC
*/
- BAROMETRIC(Vocabulary.Keys.BarometricAltitude),
+ BAROMETRIC(Vocabulary.Keys.BarometricAltitude, (short) 0, (short) 0),
/**
- * Height measured above an equipotential surface.
+ * Height measured above the Mean Sea Level (MSL) in metres. Can be
used as an approximation of geoidal heights
+ * (height measured above an equipotential surface), except that MSL
are not specific to any location or epoch.
+ *
+ * <blockquote><table class="compact" style="text-align:left">
+ * <tr><th>EPSG identifiers:</th> <td>5714
(<i>datum:</i> 5100)</td></tr>
+ * <tr><th>Primary names:</th> <td>"MSL height"
(<i>datum:</i> "Mean Sea Level")</td></tr>
+ * <tr><th>Abbreviations or aliases:</th> <td>"mean sea level
height" &nbp;(<i>datum:</i> "MSL")</td></tr>
+ * <tr><th>Direction:</th> <td>{@link
AxisDirection#UP}</td></tr>
+ * <tr><th>Unit:</th> <td>{@link
SI#METRE}</td></tr>
+ * </table></blockquote>
*
* @see VerticalDatumType#GEOIDAL
*/
- GEOIDAL(Vocabulary.Keys.Geoidal),
+ MSL_HEIGHT(Vocabulary.Keys.Geoidal, (short) 5714, (short) 5100),
+
+ /**
+ * Depth measured below the Mean Sea Level (MSL) in metres.
+ *
+ * <blockquote><table class="compact" style="text-align:left">
+ * <tr><th>EPSG identifiers:</th> <td>5715
(<i>datum:</i> 5100)</td></tr>
+ * <tr><th>Primary names:</th> <td>"MSL depth"
(<i>datum:</i> "Mean Sea Level")</td></tr>
+ * <tr><th>Abbreviations or aliases:</th> <td>"mean sea level depth"
&nbp;(<i>datum:</i> "MSL")</td></tr>
+ * <tr><th>Direction:</th> <td>{@link
AxisDirection#DOWN}</td></tr>
+ * <tr><th>Unit:</th> <td>{@link
SI#METRE}</td></tr>
+ * </table></blockquote>
+ *
+ * @see VerticalDatumType#GEOIDAL
+ */
+ MSL_DEPTH(Vocabulary.Keys.Geoidal, (short) 5715, (short) 5100),
/**
* Height measured along the normal to the ellipsoid used in the
definition of horizontal datum.
+ * The unit of measurement is metres.
*
* <p><b>This datum is not part of ISO 19111 international
standard.</b>
* Usage of this datum is generally not recommended since ellipsoidal
heights make little sense without
@@ -609,14 +651,15 @@ public enum GeodeticObjects {
* because it is sometime useful to temporarily express ellipsoidal
heights independently from other
* ordinate values.</p>
*/
- ELLIPSOIDAL(Vocabulary.Keys.Ellipsoidal),
+ ELLIPSOIDAL(Vocabulary.Keys.Ellipsoidal, (short) 0, (short) 0),
/**
* Height measured above other kind of surface, for example a
geological feature.
+ * The unit of measurement is metres.
*
* @see VerticalDatumType#OTHER_SURFACE
*/
- OTHER_SURFACE(Vocabulary.Keys.OtherSurface);
+ OTHER_SURFACE(Vocabulary.Keys.OtherSurface, (short) 0, (short) 0);
/**
* The resource keys for the name as one of the {@code
Vocabulary.Keys} constants.
@@ -624,6 +667,16 @@ public enum GeodeticObjects {
private final short key;
/**
+ * The EPSG code for the CRS, or 0 if none.
+ */
+ final short crs;
+
+ /**
+ * The EPSG code for the datum, or 0 if none.
+ */
+ final short datum;
+
+ /**
* The cached object. This is initially {@code null}, then set to
various kind of objects depending
* on which method has been invoked. The kind of object stored in this
field may change during the
* application execution.
@@ -637,8 +690,10 @@ public enum GeodeticObjects {
* early class initialization. In particular, we do not want
early dependency to the SIS-specific
* <code>VerticalDatumTypes.ELLIPSOIDAL</code> constant.}
*/
- private Vertical(final short name) {
- this.key = name;
+ private Vertical(final short name, final short crs, final short datum)
{
+ this.key = name;
+ this.crs = crs;
+ this.datum = datum;
}
/**
@@ -663,16 +718,91 @@ public enum GeodeticObjects {
}
/**
+ * Returns the coordinate reference system associated to this vertical
object.
+ * The following table summarizes the CRS known to this class,
+ * together with an enumeration value that can be used for fetching
that CRS:
+ *
+ * <blockquote><table class="sis">
+ * <tr><th>Name or alias</th> <th>Enum</th>
<th>EPSG</th></tr>
+ * <tr><td>Barometric altitude</td> <td>{@link
#BAROMETRIC}</td> <td></td></tr>
+ * <tr><td><s>Ellipsoidal height</s></td> <td><s>{@link
#ELLIPSOIDAL}</s></td> <td></td></tr>
+ * <tr><td>Mean Sea Level height</td> <td>{@link
#MSL_HEIGHT}</td> <td>5714</td></tr>
+ * <tr><td>Mean Sea Level depth</td> <td>{@link
#MSL_DEPTH}</td> <td>5715</td></tr>
+ * <tr><td>Other surface</td> <td>{@link
#OTHER_SURFACE}</td> <td></td></tr>
+ * </table></blockquote>
+ *
+ * @return The CRS associated to this constant.
+ *
+ * @see DefaultVerticalCRS
+ */
+ public VerticalCRS crs() {
+ VerticalCRS object = crs(cached);
+ if (object == null) {
+ synchronized (this) {
+ object = crs(cached);
+ if (object == null) {
+ if (crs != 0) {
+ final CRSAuthorityFactory factory = crsFactory();
+ if (factory != null) try {
+ cached = object =
factory.createVerticalCRS(String.valueOf(crs));
+ return object;
+ } catch (FactoryException e) {
+ failure(this, "crs", e);
+ }
+ object =
StandardDefinitions.createVerticalCRS(crs, datum());
+ } else {
+ final VerticalDatum datum = datum();
+ object = new
DefaultVerticalCRS(IdentifiedObjects.getProperties(datum), datum, cs());
+ }
+ cached = object;
+ }
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Creates the coordinate system associated to this vertical object.
+ * This method does not cache the coordinate system.
+ */
+ private VerticalCS cs() {
+ final Map<String,?> cs, axis;
+ final Unit<?> unit;
+ switch (this) {
+ default: {
+ // Share the coordinate system created for ellipsoidal
height.
+ return ELLIPSOIDAL.crs().getCoordinateSystem();
+ }
+ case ELLIPSOIDAL: {
+ // Create all properties for a new coordinate system.
+ cs = properties(Vocabulary.Keys.Vertical);
+ axis = properties(Vocabulary.Keys.Height);
+ unit = SI.METRE;
+ break;
+ }
+ case BAROMETRIC: {
+ // Share the NamedIdentifier created for ellipsoidal
height.
+ final VerticalCS share =
ELLIPSOIDAL.crs().getCoordinateSystem();
+ cs = IdentifiedObjects.getProperties(share);
+ axis = IdentifiedObjects.getProperties(share.getAxis(0));
+ unit = SI.MetricPrefix.HECTO(SI.PASCAL);
+ break;
+ }
+ }
+ return new DefaultVerticalCS(cs, new
DefaultCoordinateSystemAxis(axis, "h", AxisDirection.UP, unit));
+ }
+
+ /**
* Returns the datum associated to this vertical object.
* The following table summarizes the datum known to this class,
* together with an enumeration value that can be used for fetching
that datum:
*
* <blockquote><table class="sis">
- * <tr><th>Name or alias</th> <th>Enum</th></tr>
- * <tr><td>Barometric altitude</td> <td>{@link #BAROMETRIC}</td></tr>
- * <tr><td>Geoidal height</td> <td>{@link #GEOIDAL}</td></tr>
- * <tr><td>Ellipsoidal height</td> <td>{@link
#ELLIPSOIDAL}</td></tr>
- * <tr><td>Other surface</td> <td>{@link
#OTHER_SURFACE}</td></tr>
+ * <tr><th>Name or alias</th> <th>Enum</th>
<th>EPSG</th></tr>
+ * <tr><td>Barometric altitude</td> <td>{@link
#BAROMETRIC}</td> <td></td></tr>
+ * <tr><td><s>Ellipsoidal height</s></td> <td><s>{@link
#ELLIPSOIDAL}</s></td> <td></td></tr>
+ * <tr><td>Mean Sea Level</td> <td>{@link
#MSL_HEIGHT}</td> <td>5100</td></tr>
+ * <tr><td>Other surface</td> <td>{@link
#OTHER_SURFACE}</td> <td></td></tr>
* </table></blockquote>
*
* @return The datum associated to this constant.
@@ -685,11 +815,18 @@ public enum GeodeticObjects {
synchronized (this) {
object = datum(cached);
if (object == null) {
- final Map<String,Object> properties = new HashMap<>(4);
- final InternationalString name =
Vocabulary.formatInternational(key);
- properties.put(NAME_KEY, name.toString(Locale.ROOT));
- properties.put(ALIAS_KEY, name);
- object = new DefaultVerticalDatum(properties,
VerticalDatumType.valueOf(name()));
+ if (datum != 0) {
+ final DatumAuthorityFactory factory =
datumFactory();
+ if (factory != null) try {
+ cached = object =
factory.createVerticalDatum(String.valueOf(datum));
+ return object;
+ } catch (FactoryException e) {
+ failure(this, "datum", e);
+ }
+ object =
StandardDefinitions.createVerticalDatum(datum);
+ } else {
+ object = new DefaultVerticalDatum(properties(key),
VerticalDatumType.valueOf(name()));
+ }
cached = object;
}
}
@@ -698,6 +835,13 @@ public enum GeodeticObjects {
}
/**
+ * Returns the vertical CRS associated to the given object, or {@code
null} if none.
+ */
+ private static VerticalCRS crs(final IdentifiedObject object) {
+ return (object instanceof VerticalCRS) ? (VerticalCRS) object :
null;
+ }
+
+ /**
* Returns the datum associated to the given object, or {@code null}
if none.
*/
private static VerticalDatum datum(final IdentifiedObject object) {
@@ -719,7 +863,7 @@ public enum GeodeticObjects {
*
* <p>Referencing objects are cached after creation. Invoking the same
method on the same {@code Temporal}
* instance twice will return the same {@link IdentifiedObject} instance,
unless the internal cache has been cleared
- * (e.g. the application is running in a container environment, and some
modules have been installed or uninstalled).</p>
+ * (e.g. the application is running in a container environment and some
modules have been installed or uninstalled).</p>
*
* <p><b>Example:</b> the following code fetches a temporal Coordinate
Reference System using the Julian calendar:</p>
*
@@ -829,6 +973,74 @@ public enum GeodeticObjects {
}
/**
+ * Returns the coordinate reference system associated to this temporal
object.
+ * The following table summarizes the CRS known to this class,
+ * together with an enumeration value that can be used for fetching
that CRS:
+ *
+ * <blockquote><table class="sis">
+ * <tr><th>Name or alias</th> <th>Enum</th></tr>
+ * <tr><td>Dublin Julian</td> <td>{@link
#DUBLIN_JULIAN}</td></tr>
+ * <tr><td>Julian</td> <td>{@link #JULIAN}</td></tr>
+ * <tr><td>Modified Julian</td> <td>{@link
#MODIFIED_JULIAN}</td></tr>
+ * <tr><td>Truncated Julian</td> <td>{@link
#TRUNCATED_JULIAN}</td></tr>
+ * <tr><td>Unix/POSIX or Java</td> <td>{@link #UNIX}</td></tr>
+ * </table></blockquote>
+ *
+ * @return The CRS associated to this constant.
+ *
+ * @see DefaultTemporalCRS
+ */
+ public TemporalCRS crs() {
+ TemporalCRS object = crs(cached);
+ if (object == null) {
+ synchronized (this) {
+ object = crs(cached);
+ if (object == null) {
+ final TemporalDatum datum = datum();
+ object = new
DefaultTemporalCRS(IdentifiedObjects.getProperties(datum), datum, cs());
+ cached = object;
+ }
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Creates the coordinate system associated to this temporal object.
+ * This method does not cache the coordinate system.
+ */
+ @SuppressWarnings("fallthrough")
+ private TimeCS cs() {
+ final Map<String,?> cs, axis;
+ Unit<Duration> unit = SI.SECOND;
+ switch (this) {
+ default: {
+ // Share the coordinate system created for truncated
Julian.
+ return TRUNCATED_JULIAN.crs().getCoordinateSystem();
+ }
+ case TRUNCATED_JULIAN: {
+ unit = NonSI.DAY;
+ // Fall through
+ }
+ case UNIX: {
+ // Share the NamedIdentifier created for Java time.
+ final TimeCS share = JAVA.crs().getCoordinateSystem();
+ cs = IdentifiedObjects.getProperties(share);
+ axis = IdentifiedObjects.getProperties(share.getAxis(0));
+ break;
+ }
+ case JAVA: {
+ // Create all properties for a new coordinate system.
+ cs = properties(Vocabulary.Keys.Temporal);
+ axis = properties(Vocabulary.Keys.Time);
+ unit = Units.MILLISECOND;
+ break;
+ }
+ }
+ return new DefaultTimeCS(cs, new DefaultCoordinateSystemAxis(axis,
"t", AxisDirection.FUTURE, unit));
+ }
+
+ /**
* Returns the datum associated to this temporal object.
* The following table summarizes the datum known to this class,
* together with an enumeration value that can be used for fetching
that datum:
@@ -855,16 +1067,13 @@ public enum GeodeticObjects {
if (this == UNIX) {
object = JAVA.datum(); // Share the same instance
for UNIX and JAVA.
} else {
- final Map<String,Object> properties;
- properties = new HashMap<>(4);
- final InternationalString name;
+ final Map<String,?> properties;
if (key == Vocabulary.Keys.Time_1) {
- name = Vocabulary.formatInternational(key,
this == JAVA ? "Java" : "Unix/POSIX");
+ properties =
properties(Vocabulary.formatInternational(
+ key, (this == JAVA) ? "Java" :
"Unix/POSIX"));
} else {
- name = Vocabulary.formatInternational(key);
+ properties = properties(key);
}
- properties.put(NAME_KEY,
name.toString(Locale.ROOT));
- properties.put(ALIAS_KEY, name);
object = new DefaultTemporalDatum(properties, new
Date(epoch));
}
cached = object;
@@ -875,6 +1084,13 @@ public enum GeodeticObjects {
}
/**
+ * Returns the temporal CRS associated to the given object, or {@code
null} if none.
+ */
+ private static TemporalCRS crs(final IdentifiedObject object) {
+ return (object instanceof TemporalCRS) ? (TemporalCRS) object :
null;
+ }
+
+ /**
* Returns the datum associated to the given object, or {@code null}
if none.
*/
private static TemporalDatum datum(final IdentifiedObject object) {
@@ -889,6 +1105,23 @@ public enum GeodeticObjects {
}
/**
+ * Puts the name for the given key in a map of properties to be given to
object constructors.
+ *
+ * @param key A constant from {@link
org.apache.sis.util.resources.Vocabulary.Keys}.
+ * @return The properties to give to the object constructor.
+ */
+ static Map<String,?> properties(final short key) {
+ return properties(Vocabulary.formatInternational(key));
+ }
+
+ /**
+ * Puts the given name in a map of properties to be given to object
constructors.
+ */
+ static Map<String,?> properties(final InternationalString name) {
+ return singletonMap(NAME_KEY, new NamedIdentifier(null, name));
+ }
+
+ /**
* Returns the EPSG factory to use for creating CRS, or {@code null} if
none.
* If this method returns {@code null}, then the caller will silently
fallback on hard-coded values.
*/
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
[UTF-8] Thu Jan 16 19:41:06 2014
@@ -25,19 +25,25 @@ import javax.measure.quantity.Length;
import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.PrimeMeridian;
import org.opengis.referencing.datum.GeodeticDatum;
+import org.opengis.referencing.datum.VerticalDatum;
+import org.opengis.referencing.datum.VerticalDatumType;
import org.opengis.referencing.cs.RangeMeaning;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.VerticalCRS;
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.referencing.datum.DefaultEllipsoid;
import org.apache.sis.referencing.datum.DefaultPrimeMeridian;
import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
+import org.apache.sis.referencing.datum.DefaultVerticalDatum;
+import org.apache.sis.referencing.cs.DefaultVerticalCS;
import org.apache.sis.referencing.cs.DefaultEllipsoidalCS;
import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
+import org.apache.sis.referencing.crs.DefaultVerticalCRS;
import org.apache.sis.measure.Longitude;
import org.apache.sis.measure.Latitude;
@@ -174,6 +180,41 @@ final class StandardDefinitions {
}
/**
+ * Creates a vertical CRS from hard-coded values for the given code.
+ *
+ * @param code The EPSG code.
+ * @param datum The vertical datum.
+ * @return The vertical CRS for the given code.
+ */
+ static VerticalCRS createVerticalCRS(final short code, final VerticalDatum
datum) {
+ final String name, alias, cs;
+ final short c, axis;
+ switch (code) {
+ case 5714: name = "MSL height"; alias = "mean sea level height";
cs = "Vertical CS. Axis: height (H)."; c = 6499; axis = 114; break;
+ case 5715: name = "MSL depth"; alias = "mean sea level depth";
cs = "Vertical CS. Axis: depth (D)."; c = 6498; axis = 113; break;
+ default: throw new AssertionError(code);
+ }
+ return new DefaultVerticalCRS(properties(code, name, alias), datum,
+ new DefaultVerticalCS(properties(c, cs, null),
createAxis(axis)));
+ }
+
+ /**
+ * Creates a vertical datum from hard-coded values for the given code.
+ *
+ * @param code The EPSG code.
+ * @return The vertical datum for the given code.
+ */
+ static VerticalDatum createVerticalDatum(final short code) {
+ final String name;
+ final String alias;
+ switch (code) {
+ case 5100: name = "Mean Sea Level"; alias = "MSL"; break;
+ default: throw new AssertionError(code);
+ }
+ return new DefaultVerticalDatum(properties(code, name, alias),
VerticalDatumType.GEOIDAL);
+ }
+
+ /**
* Creates a coordinate system from hard-coded values for the given code.
* The coordinate system names used by this method contains only the first
* part of the names declared in the EPSG database.
@@ -208,12 +249,12 @@ final class StandardDefinitions {
private static CoordinateSystemAxis createAxis(final short code) {
final String name, abrv;
final Unit<?> unit;
- final double min, max;
- final RangeMeaning rm;
+ double min = Double.NEGATIVE_INFINITY;
+ double max = Double.POSITIVE_INFINITY;
+ RangeMeaning rm = null;
final AxisDirection dir;
switch (code) {
- case 106:
- case 108: name = "Geodetic latitude";
+ case 106: name = "Geodetic latitude";
abrv = "φ";
unit = NonSI.DEGREE_ANGLE;
dir = AxisDirection.NORTH;
@@ -221,8 +262,7 @@ final class StandardDefinitions {
max = Latitude.MAX_VALUE;
rm = RangeMeaning.EXACT;
break;
- case 107:
- case 109: name = "Geodetic longitude";
+ case 107: name = "Geodetic longitude";
abrv = "λ";
unit = NonSI.DEGREE_ANGLE;
dir = AxisDirection.EAST;
@@ -230,13 +270,20 @@ final class StandardDefinitions {
max = Longitude.MAX_VALUE;
rm = RangeMeaning.WRAPAROUND;
break;
- case 110: name = "llipsoidal height ";
+ case 110: name = "Ellipsoidal height";
abrv = "h";
unit = SI.METRE;
dir = AxisDirection.UP;
- min = Double.NEGATIVE_INFINITY;
- max = Double.POSITIVE_INFINITY;
- rm = null;
+ break;
+ case 114: name = "Gravity-related height";
+ abrv = "H";
+ unit = SI.METRE;
+ dir = AxisDirection.UP;
+ break;
+ case 113: name = "Depth";
+ abrv = "D";
+ unit = SI.METRE;
+ dir = AxisDirection.DOWN;
break;
default: throw new AssertionError(code);
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java
[UTF-8] Thu Jan 16 19:41:06 2014
@@ -17,9 +17,15 @@
package org.apache.sis.referencing;
import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.Datum;
import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.PrimeMeridian;
+import org.apache.sis.referencing.crs.AbstractCRS;
+import org.apache.sis.referencing.cs.AbstractCS;
+import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
import org.apache.sis.referencing.datum.AbstractDatum;
import org.apache.sis.referencing.datum.DefaultEllipsoid;
import org.apache.sis.referencing.datum.DefaultPrimeMeridian;
@@ -53,6 +59,15 @@ final class SubTypes {
* @see AbstractIdentifiedObject#castOrCopy(IdentifiedObject)
*/
static AbstractIdentifiedObject castOrCopy(final IdentifiedObject object) {
+ if (object instanceof CoordinateReferenceSystem) {
+ return AbstractCRS.castOrCopy((CoordinateReferenceSystem) object);
+ }
+ if (object instanceof CoordinateSystem) {
+ return AbstractCS.castOrCopy((CoordinateSystem) object);
+ }
+ if (object instanceof CoordinateSystemAxis) {
+ return
DefaultCoordinateSystemAxis.castOrCopy((CoordinateSystemAxis) object);
+ }
if (object instanceof Datum) {
return AbstractDatum.castOrCopy((Datum) object);
}
@@ -62,6 +77,14 @@ final class SubTypes {
if (object instanceof PrimeMeridian) {
return DefaultPrimeMeridian.castOrCopy((PrimeMeridian) object);
}
+ /*
+ * Intentionally check for AbstractIdentifiedObject after the
interfaces because user may have defined his own
+ * subclass implementing the interface. If we were checking for
AbstractIdentifiedObject before the interfaces,
+ * the returned instance could have been a user subclass without the
JAXB annotations required for XML marshalling.
+ */
+ if (object == null || object instanceof AbstractIdentifiedObject) {
+ return (AbstractIdentifiedObject) object;
+ }
return new AbstractIdentifiedObject(object);
}
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
[UTF-8] Thu Jan 16 19:41:06 2014
@@ -79,7 +79,8 @@ public final strictfp class GeodeticObje
@Test
public void testVertical() {
assertEquals(VerticalDatumType. BAROMETRIC,
type(GeodeticObjects.Vertical.BAROMETRIC));
- assertEquals(VerticalDatumType. GEOIDAL,
type(GeodeticObjects.Vertical.GEOIDAL));
+ assertEquals(VerticalDatumType. GEOIDAL,
type(GeodeticObjects.Vertical.MSL_HEIGHT));
+ assertEquals(VerticalDatumType. GEOIDAL,
type(GeodeticObjects.Vertical.MSL_DEPTH));
assertEquals(VerticalDatumTypes.ELLIPSOIDAL,
type(GeodeticObjects.Vertical.ELLIPSOIDAL));
assertEquals(VerticalDatumType. OTHER_SURFACE,
type(GeodeticObjects.Vertical.OTHER_SURFACE));
}
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Thu Jan 16 19:41:06 2014
@@ -155,6 +155,11 @@ public final class Vocabulary extends In
public static final short Geoidal = 19;
/**
+ * Height
+ */
+ public static final short Height = 69;
+
+ /**
* Identifier
*/
public static final short Identifier = 20;
@@ -315,11 +320,21 @@ public final class Vocabulary extends In
public static final short StandardDeviation = 51;
/**
+ * Temporal
+ */
+ public static final short Temporal = 66;
+
+ /**
* Temporary files
*/
public static final short TemporaryFiles = 52;
/**
+ * Time
+ */
+ public static final short Time = 67;
+
+ /**
* {0} time
*/
public static final short Time_1 = 53;
@@ -380,6 +395,11 @@ public final class Vocabulary extends In
public static final short Versions = 63;
/**
+ * Vertical
+ */
+ public static final short Vertical = 68;
+
+ /**
* World
*/
public static final short World = 64;
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Thu Jan 16 19:41:06 2014
@@ -34,6 +34,7 @@ Directory = Directory
DublinJulian = Dublin Julian
Ellipsoidal = Ellipsoidal
Geoidal = Geoidal
+Height = Height
Identifier = Identifier
Implementation = Implementation
Index = Index
@@ -67,6 +68,8 @@ Scale = Scale
Source = Source
StandardDeviation = Standard deviation
TemporaryFiles = Temporary files
+Temporal = Temporal
+Time = Time
Time_1 = {0} time
Timezone = Timezone
TruncatedJulian = Truncated Julian
@@ -79,4 +82,5 @@ Value = Value
Variables = Variables
Version_2 = {0} version {1}
Versions = Versions
+Vertical = Vertical
World = World
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Thu Jan 16 19:41:06 2014
@@ -34,6 +34,7 @@ Directory = R\u00e9pertoire
DublinJulian = Julien Dublin
Ellipsoidal = Ellipso\u00efdal
Geoidal = Geo\u00efdal
+Height = Hauteur
Identifier = Identifiant
Implementation = Impl\u00e9mentation
Index = Index
@@ -67,6 +68,8 @@ Scale = \u00c9chelle
Source = Source
StandardDeviation = \u00c9cart type
TemporaryFiles = Fichiers temporaires
+Temporal = Temporel
+Time = Temps
Time_1 = Heure {0}
Timezone = Fuseau horaire
TruncatedJulian = Julien tronqu\u00e9
@@ -79,4 +82,5 @@ Value = Valeur
Variables = Variables
Version_2 = {0} version {1}
Versions = Versions
+Vertical = Vertical
World = Monde
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml?rev=1558895&r1=1558894&r2=1558895&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml Thu Jan 16
19:41:06 2014
@@ -56,6 +56,7 @@
<word>deserialized</word>
<word>endianness</word>
<word>geoidal</word>
+ <word>hectopascals</word>
<word>initially</word>
<word>javadoc</word>
<word>loggings</word>