Author: desruisseaux
Date: Thu Jan 9 15:40:10 2014
New Revision: 1556843
URL: http://svn.apache.org/r1556843
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java
- copied unchanged from r1556838,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardObjects.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1555663-1556838
Modified:
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -282,7 +282,7 @@ public abstract class ModifiableMetadata
List<E> target, final Class<E> elementType)
throws UnmodifiableMetadataException
{
- // See the comments in writeCollection(...) for implementation notes.
+ // See the comments in writeCollection(…) for implementation notes.
if (source != target) {
if (unmodifiable == FREEZING) {
return (List<E>) source;
@@ -330,7 +330,7 @@ public abstract class ModifiableMetadata
Set<E> target, final Class<E> elementType)
throws UnmodifiableMetadataException
{
- // See the comments in writeCollection(...) for implementation notes.
+ // See the comments in writeCollection(…) for implementation notes.
if (source != target) {
if (unmodifiable == FREEZING) {
return (Set<E>) source;
@@ -387,7 +387,8 @@ public abstract class ModifiableMetadata
/*
* It is not worth to copy the content if the current and the new
instance are the
* same. This is safe only using the != operator, not the
!equals(Object) method.
- * This optimization is required for efficient working of
PropertyAccessor.set(...).
+ * This optimization is required for efficient working of
PropertyAccessor.set(…)
+ * and JAXB unmarshalling.
*/
if (source != target) {
if (unmodifiable == FREEZING) {
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -22,7 +22,7 @@ import javax.xml.bind.annotation.XmlAttr
import org.opengis.metadata.citation.Citation;
import org.opengis.referencing.ReferenceIdentifier;
import org.apache.sis.internal.util.DefinitionURI;
-import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.metadata.iso.citation.Citations;
import static
org.apache.sis.internal.referencing.ReferencingUtilities.toURNType;
@@ -114,7 +114,7 @@ public final class Code {
}
authority = Citations.fromName(cs);
}
- return new ImmutableIdentifier(authority, cs, c, version, null);
+ return new NamedIdentifier(authority, cs, c, version, null);
}
/**
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -18,8 +18,11 @@ package org.apache.sis.referencing;
import java.util.Map;
import java.util.Set;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.AbstractCollection;
+import java.util.Iterator;
import java.util.Locale;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlID;
@@ -113,7 +116,7 @@ import org.apache.sis.internal.jdk7.Obje
*/
@XmlType(name="IdentifiedObjectType", propOrder={
"identifier",
- "name", // This is 'names' on the JDK7 branch.
+ "names",
"remarks"
})
@XmlSeeAlso({
@@ -134,25 +137,23 @@ public class AbstractIdentifiedObject ex
/**
* The name for this object or code. Shall never be {@code null}.
*
- * <p><b>Difference between JDK6 and JDK7 branches:</b> in the JDK6
branch, this field is annotated directly.
- * In the JDK7 branch, a {@code getNames()} method is annotated instead in
order to marshal name and aliases
- * in a single list, because GML does that way. We couldn't keep the
getter/setter methods pair in the JDK6
- * branch because JAXB 2.1.10 does not invoke the setter, while JAXB
2.2.4-2 does as expected. The price is
- * that aliases are lost on the JDK6 branch, while they are present on the
JDK7 branch.</p>
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link
Names#add(ReferenceIdentifier)}.</p>
*
* @see #getName()
+ * @see #getNames()
*/
- @XmlElement(name = "name")
- private final ReferenceIdentifier name;
+ private ReferenceIdentifier name;
/**
* An alternative name by which this object is identified, or {@code null}
if none.
* We must be prepared to handle either null or an empty set for "no
alias" because
* we may get both on unmarshalling.
*
- * <p><b>Difference between JDK6 and JDK7 branches:</b> See comment for
{@link #name}.</p>
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link
Names#add(ReferenceIdentifier)}.</p>
*/
- private final Collection<GenericName> alias;
+ private Collection<GenericName> alias;
/**
* An identifier which references elsewhere the object's defining
information.
@@ -186,10 +187,7 @@ public class AbstractIdentifiedObject ex
* reserved to JAXB, which will assign values to the fields using
reflexion.
*/
AbstractIdentifiedObject() {
- name = null;
- alias = null;
- identifiers = null;
- remarks = null;
+ remarks = null;
}
/**
@@ -457,22 +455,102 @@ public class AbstractIdentifiedObject ex
}
}
- /* -----------------------------------------------------------------------
- * DIFFERENCE BETWEEN THE JDK6 AND JDK7 BRANCHES
- * -----------------------------------------------------------------------
- * The JDK7 branch provides two private methods here:
- *
- * - Collection<ReferenceIdentifier> getNames();
- * - void setNames(Collection<ReferenceIdentifier> names);
- *
- * The getter is annotated with @XmlElement(name = "name"), which replace
- * the annotation on this.name field. The intend is to merge the primary
- * name and aliases in a single list, because GML is specified that way.
- * However JAXB 2.1.10 in JDK 1.6.0_65 does not invoke the setter method
- * while JAXB 2.2.4-2 in 1.7.0_25 does. Because of this bug, we annotate
- * the field instead in the JDK6 branch. The consequence is that aliases
- * are lost.
+ /**
+ * A writable view over the {@linkplain AbstractIdentifiedObject#getName()
name} of the enclosing object followed by
+ * all {@linkplain AbstractIdentifiedObject#getAlias() aliases} which are
instance of {@link ReferenceIdentifier}.
+ * Used by JAXB only at (un)marshalling time because GML merges the name
and aliases in a single {@code <gml:name>}
+ * property.
+ */
+ private final class Names extends AbstractCollection<ReferenceIdentifier> {
+ /**
+ * Invoked by JAXB before to write in the collection at unmarshalling
time.
+ * Do nothing since our object is already empty.
+ */
+ @Override
+ public void clear() {
+ }
+
+ /**
+ * Returns the number of name and aliases that are instance of {@link
ReferenceIdentifier}.
+ */
+ @Override
+ public int size() {
+ return NameIterator.count(AbstractIdentifiedObject.this);
+ }
+
+ /**
+ * Returns an iterator over the name and aliases that are instance of
{@link ReferenceIdentifier}.
+ */
+ @Override
+ public Iterator<ReferenceIdentifier> iterator() {
+ return new NameIterator(AbstractIdentifiedObject.this);
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time for each identifier. The
first identifier will be taken
+ * as the name and all other identifiers (if any) as aliases.
+ *
+ * <p>Some JAXB implementations never invoke {@link
AbstractIdentifiedObject#setNames(Collection)}.
+ * Instead they invoke {@link AbstractIdentifiedObject#getNames()} and
add directly the identifiers
+ * in the returned collection. Consequently this method must writes
directly in the enclosing object.
+ * See <a href="https://java.net/jira/browse/JAXB-488">JAXB-488</a>
for more information.</p>
+ */
+ @Override
+ public boolean add(final ReferenceIdentifier id) {
+ if (name == null) {
+ name = id;
+ return true;
+ }
+ if (alias == null) {
+ alias = new ArrayList<GenericName>(4);
+ }
+ /*
+ * Our Code and RS_Identifier implementations should always create
NamedIdentifier instance,
+ * so the 'instanceof' check should not be necessary. But do a
paranoiac check anyway.
+ */
+ return alias.add(id instanceof GenericName ? (GenericName) id :
new NamedIdentifier(id));
+ }
+ }
+
+ /**
+ * Returns the {@link #name} and all aliases which are also instance of
{@lik ReferenceIdentifier}.
+ * The later happen often in SIS implementation since many aliases are
instance of {@link NamedIdentifier}.
+ */
+ @XmlElement(name = "name", required = true)
+ final Collection<ReferenceIdentifier> getNames() {
+ return new Names();
+ }
+
+ /**
+ * Sets the first element as the {@link #name} and all remaining elements
as {@link #alias}.
+ * This method is invoked by some implementations of JAXB (not all of
them) at unmarshalling time.
+ * It should not be invoked anymore after the object has been made
available to the user.
+ *
+ * <p>Some JAXB implementations never invoke this setter method. Instead
they invoke {@link #getNames()}
+ * and add directly the identifiers in the returned collection. Whether
JAXB will perform a final call to
+ * {@code setNames(…)} is JAXB-implementation dependent (JDK7 does but
JDK6 and JDK8 early access do not).
+ * Consequently we can not rely on this method to be invoked. It is better
if this method is invoked, but
+ * we will not lost data if it is not.</p>
+ *
+ * @see <a href="https://java.net/jira/browse/JAXB-488">JAXB-488</a>
*/
+ private void setNames(final Collection<ReferenceIdentifier> names) {
+ /*
+ * If the collection is an instance of Names, then assume that the
collection is the instance obtained
+ * by getNames(), in which case this IdentifiedObject already contains
the content of that collection.
+ * This behavior is necessary for working around the JAXB-488 issue.
+ */
+ if (!(names instanceof Names)) {
+ getNames().addAll(names);
+ }
+ /*
+ * Froze aliases in an unmodifiable set. In JAXB implementations that
do not invoke the setter method,
+ * the aliases list is left modifiable. This is a hole in our object
immutability.
+ */
+ if (alias != null) {
+ alias = immutableSet(true, alias.toArray(new
GenericName[alias.size()]));
+ }
+ }
/**
* Returns the primary name by which this object is identified.
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -28,6 +28,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.EllipsoidalCS;
+import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.datum.PrimeMeridian;
@@ -35,6 +37,7 @@ import org.opengis.referencing.datum.Ver
import org.opengis.referencing.datum.VerticalDatumType;
import org.opengis.referencing.datum.TemporalDatum;
import org.opengis.referencing.datum.DatumAuthorityFactory;
+import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.apache.sis.referencing.datum.DefaultVerticalDatum;
import org.apache.sis.referencing.datum.DefaultTemporalDatum;
import org.apache.sis.util.resources.Vocabulary;
@@ -57,7 +60,7 @@ import static org.opengis.referencing.Id
* (<var>longitude</var>, <var>latitude</var>) axis order on the {@link
#WGS84} geodetic datum:</p>
*
* {@preformat java
- * GeographicCRS crs = GeodeticObjects.WGS84.crs(true);
+ * GeographicCRS crs = GeodeticObjects.WGS84.geographic();
* }
*
* For each enumeration value, the name of the CRS, datum and ellipsoid
objects may or may not be the same.
@@ -104,7 +107,7 @@ public enum GeodeticObjects {
* <tr><th>Ellipsoid axes unit:</th> <td>{@link SI#METRE}</td></tr>
* </table></blockquote>
*/
- WGS84((short) 7030, (short) 6326),
+ WGS84((short) 4326, (short) 6326, (short) 7030),
/**
* World Geodetic System 1972.
@@ -120,7 +123,7 @@ public enum GeodeticObjects {
* <tr><th>Ellipsoid axes unit:</th> <td>{@link SI#METRE}</td></tr>
* </table></blockquote>
*/
- WGS72((short) 7043, (short) 6322),
+ WGS72((short) 4322, (short) 6322, (short) 7043),
/**
* European Terrestrial Reference System 1989.
@@ -142,7 +145,7 @@ public enum GeodeticObjects {
* The <cite>Web Map Server</cite> <code>"CRS:83"</code> authority
code uses the NAD83 datum,
* while the <code>"IGNF:MILLER"</code> authority code uses the
GRS80 datum.}
*/
- ETRS89((short) 7019, (short) 6258),
+ ETRS89((short) 4258, (short) 6258, (short) 7019),
/**
* North American Datum 1983.
@@ -165,7 +168,7 @@ public enum GeodeticObjects {
* The <cite>Web Map Server</cite> <code>"CRS:83"</code> authority
code uses the NAD83 datum,
* while the <code>"IGNF:MILLER"</code> authority code uses the
GRS80 datum.}
*/
- NAD83((short) 7019, (short) 6269),
+ NAD83((short) 4269, (short) 6269, (short) 7019),
/**
* North American Datum 1927.
@@ -181,7 +184,7 @@ public enum GeodeticObjects {
* <tr><th>Ellipsoid axes unit:</th> <td>{@link SI#METRE}</td></tr>
* </table></blockquote>
*/
- NAD27((short) 7008, (short) 6267),
+ NAD27((short) 4267, (short) 6267, (short) 7008),
/**
* European Datum 1950.
@@ -197,7 +200,7 @@ public enum GeodeticObjects {
* <tr><th>Ellipsoid axes unit:</th> <td>{@link SI#METRE}</td></tr>
* </table></blockquote>
*/
- ED50((short) 7022, (short) 6230),
+ ED50((short) 4230, (short) 6230, (short) 7022),
/**
* Unspecified datum based upon the GRS 1980 Authalic Sphere. Spheres use
a simpler algorithm for
@@ -215,19 +218,25 @@ public enum GeodeticObjects {
*
* @see
org.apache.sis.referencing.datum.DefaultEllipsoid#getAuthalicRadius()
*/
- SPHERE((short) 7048, (short) 6047);
+ SPHERE((short) 4047, (short) 6047, (short) 7048);
/**
- * The EPSG code of the ellipsoid.
+ * The EPSG code of the geographic CRS.
*/
- final short ellipsoid;
+ final short crs;
/**
- * The EPSG code of the datum.
+ * The EPSG code of the datum. The value is often {@link #crs} + 2000,
+ * but it doesn't have to be always the case.
*/
final short datum;
/**
+ * The EPSG code of the ellipsoid.
+ */
+ final short ellipsoid;
+
+ /**
* 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.
@@ -237,12 +246,14 @@ public enum GeodeticObjects {
/**
* Creates a new constant for the given EPSG or SIS codes.
*
- * @param ellipsoid The EPSG code for the ellipsoid.
+ * @param crs The EPSG code for the geographic CRS.
* @param datum The EPSG code for the datum.
+ * @param ellipsoid The EPSG code for the ellipsoid.
*/
- private GeodeticObjects(final short ellipsoid, final short datum) {
- this.ellipsoid = ellipsoid;
+ private GeodeticObjects(final short crs, final short datum, final short
ellipsoid) {
+ this.crs = crs;
this.datum = datum;
+ this.ellipsoid = ellipsoid;
}
/**
@@ -261,6 +272,61 @@ public enum GeodeticObjects {
}
/**
+ * Returns the two-dimensional geographic CRS associated to this geodetic
object.
+ * The coordinate system axes will be in (<var>latitude</var>,
<var>longitude</var>) order
+ * oriented toward {@linkplain AxisDirection#NORTH North} and {@linkplain
AxisDirection#EAST East}
+ * respectively, with units in degrees.
+ * The following table summarizes the coordinate reference systems 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>ED50</td> <td>{@link #ED50}</td>
<td>4230</td></tr>
+ * <tr><td>ETRS89</td> <td>{@link #ETRS89}</td>
<td>4258</td></tr>
+ * <tr><td>NAD27</td> <td>{@link #NAD27}</td>
<td>4267</td></tr>
+ * <tr><td>NAD83</td> <td>{@link #NAD83}</td>
<td>4269</td></tr>
+ * <tr><td>GRS 1980 Authalic Sphere</td> <td>{@link #SPHERE}</td>
<td>4047</td></tr>
+ * <tr><td>WGS 72</td> <td>{@link #WGS72}</td>
<td>4322</td></tr>
+ * <tr><td>WGS 84</td> <td>{@link #WGS84}</td>
<td>4326</td></tr>
+ * </table></blockquote>
+ *
+ * @return The geographic CRS associated to this constant.
+ *
+ * @see org.apache.sis.referencing.crs.DefaultGeographicCRS
+ * @see CRSAuthorityFactory#createGeographicCRS(String)
+ */
+ public GeographicCRS geographic() {
+ GeographicCRS object = geographic(cached);
+ if (object == null) {
+ synchronized (this) {
+ object = geographic(cached);
+ if (object == null) {
+ final CRSAuthorityFactory factory =
StandardObjects.crsFactory();
+ if (factory != null) try {
+ cached = object =
factory.createGeographicCRS(String.valueOf(crs));
+ return object;
+ } catch (FactoryException e) {
+ StandardObjects.failure(this, "geographic", e);
+ }
+ /*
+ * All constants defined in this enumeration use the same
coordinate system, EPSG:6422.
+ * We will arbitrarily create this CS only for WGS84 (the
most frequently created CRS),
+ * and share that CS instance for all other constants.
+ */
+ final EllipsoidalCS cs;
+ if (this == WGS84) {
+ cs = (EllipsoidalCS)
StandardDefinitions.createCoordinateSystem((short) 6422);
+ } else {
+ cs = WGS84.geographic().getCoordinateSystem();
+ }
+ object = StandardDefinitions.createGeographicCRS(crs,
datum(), cs);
+ }
+ }
+ }
+ return object;
+ }
+
+ /**
* Returns the geodetic datum associated to this geodetic object.
* The following table summarizes the datums known to this class,
* together with an enumeration value that can be used for fetching that
datum:
@@ -388,6 +454,13 @@ public enum GeodeticObjects {
}
/**
+ * Returns the geographic CRS associated to the given object, or {@code
null} if none.
+ */
+ private static GeographicCRS geographic(final IdentifiedObject object) {
+ return (object instanceof GeographicCRS) ? (GeographicCRS) object :
null;
+ }
+
+ /**
* Returns the datum associated to the given object, or {@code null} if
none.
*/
private static GeodeticDatum datum(final IdentifiedObject object) {
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -138,8 +138,6 @@ public class NamedIdentifier extends Imm
/**
* Constructs an identifier from an authority and localizable code.
* This is a convenience constructor for commonly-used parameters.
- * If more control are wanted (for example adding remarks), use the
- * {@linkplain #NamedIdentifier(Map) constructor with a properties map}.
*
* @param authority The authority (e.g. {@link Citations#OGC} or {@link
Citations#EPSG}),
* or {@code null} if not available.
@@ -156,30 +154,38 @@ public class NamedIdentifier extends Imm
/**
* Constructs an identifier from an authority and code.
* This is a convenience constructor for commonly-used parameters.
- * If more control are wanted (for example adding remarks), use the
- * {@linkplain #NamedIdentifier(Map) constructor with a properties map}.
*
* @param authority The authority (e.g. {@link Citations#OGC} or {@link
Citations#EPSG}),
* or {@code null} if not available.
* @param code The code. This parameter is mandatory.
*/
public NamedIdentifier(final Citation authority, final String code) {
- this(authority, code, null);
+ super(authority, Citations.getIdentifier(authority), code);
}
/**
- * Constructs an identifier from an authority, code and version.
- * This is a convenience constructor for commonly-used parameters.
- * If more control are wanted (for example adding remarks), use the
- * {@linkplain #NamedIdentifier(Map) constructor with a properties map}.
+ * Creates an identifier from the specified code and authority,
+ * with an optional version number and remarks.
*
- * @param authority The authority (e.g. {@link Citations#OGC} or {@link
Citations#EPSG}),
- * or {@code null} if not available.
- * @param code The code. This parameter is mandatory.
- * @param version The version, or {@code null} if none.
- */
- public NamedIdentifier(final Citation authority, final String code, final
String version) {
- super(authority, Citations.getIdentifier(authority), code, version,
null);
+ * @param authority
+ * Organization or party responsible for definition and
maintenance of the code
+ * space or code, or {@code null} if not available.
+ * @param codeSpace
+ * Name or identifier of the person or organization responsible
for namespace, or
+ * {@code null} if not available. This is often an abbreviation
of the authority name.
+ * @param code
+ * Identifier code or name, optionally from a controlled list or
pattern defined by
+ * a code space. The code can not be null.
+ * @param version
+ * The version of the associated code space or code as specified
by the code authority,
+ * or {@code null} if none.
+ * @param remarks
+ * Comments on or information about this identifier, or {@code
null} if none.
+ */
+ public NamedIdentifier(final Citation authority, final String codeSpace,
+ final String code, final String version, final InternationalString
remarks)
+ {
+ super(authority, codeSpace, code, version, remarks);
}
/**
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -25,10 +25,21 @@ 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.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.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.cs.DefaultEllipsoidalCS;
+import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
+import org.apache.sis.referencing.crs.DefaultGeographicCRS;
+import org.apache.sis.measure.Longitude;
+import org.apache.sis.measure.Latitude;
import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
import static org.opengis.referencing.IdentifiedObject.ALIAS_KEY;
@@ -74,6 +85,30 @@ final class StandardDefinitions {
}
/**
+ * Creates a geodetic CRS from hard-coded values for the given code.
+ *
+ * @param code The EPSG code.
+ * @param datum The geodetic datum.
+ * @param cs The coordinate system.
+ * @return The geographic CRS for the given code.
+ */
+ static GeographicCRS createGeographicCRS(final short code, final
GeodeticDatum datum, final EllipsoidalCS cs) {
+ final String name;
+ String alias = null;
+ switch (code) {
+ case 4326: name = "WGS 84"; break;
+ case 4322: name = "WGS 72"; break;
+ case 4258: name = "ETRS89"; alias = "ETRS89-GRS80"; break;
+ case 4269: name = "NAD83"; break;
+ case 4267: name = "NAD27"; break;
+ case 4230: name = "ED50"; break;
+ case 4047: name = "Unspecified datum based upon the GRS 1980
Authalic Sphere"; break;
+ default: throw new AssertionError(code);
+ }
+ return new DefaultGeographicCRS(properties(code, name, alias), datum,
cs);
+ }
+
+ /**
* Creates a geodetic datum from hard-coded values for the given code.
*
* @param code The EPSG code.
@@ -137,4 +172,74 @@ final class StandardDefinitions {
properties.put(IDENTIFIERS_KEY, new NamedIdentifier(Citations.EPSG,
GREENWICH));
return new DefaultPrimeMeridian(properties, 0, NonSI.DEGREE_ANGLE);
}
+
+ /**
+ * 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.
+ *
+ * @param code The EPSG code.
+ * @return The coordinate system for the given code.
+ */
+ static CoordinateSystem createCoordinateSystem(final short code) {
+ final String name;
+ short xc, yc, zc = 0; // Not necessarily (long, lat) order.
+ switch (code) {
+ case 6422: name = "Ellipsoidal 2D"; xc = 106; yc = 107;
break;
+ case 6423: name = "Ellipsoidal 3D"; xc = 108; yc = 109; zc = 110;
break;
+ default: throw new AssertionError(code);
+ }
+ final Map<String,?> properties = properties(code, name, null);
+ final CoordinateSystemAxis xAxis = createAxis(xc);
+ final CoordinateSystemAxis yAxis = createAxis(yc);
+ if (zc != 0) {
+ final CoordinateSystemAxis zAxis = createAxis(zc);
+ return new DefaultEllipsoidalCS(properties, xAxis, yAxis, zAxis);
+ }
+ return new DefaultEllipsoidalCS(properties, xAxis, yAxis);
+ }
+
+ /**
+ * Creates an axis from hard-coded values for the given code.
+ *
+ * @param code The EPSG code.
+ * @return The coordinate system axis for the given code.
+ */
+ private static CoordinateSystemAxis createAxis(final short code) {
+ final String name, abrv;
+ final Unit<?> unit;
+ final double min, max;
+ final RangeMeaning rm;
+ final AxisDirection dir;
+ switch (code) {
+ case 106:
+ case 108: name = "Geodetic latitude";
+ abrv = "φ";
+ unit = NonSI.DEGREE_ANGLE;
+ dir = AxisDirection.NORTH;
+ min = Latitude.MIN_VALUE;
+ max = Latitude.MAX_VALUE;
+ rm = RangeMeaning.EXACT;
+ break;
+ case 107:
+ case 109: name = "Geodetic longitude";
+ abrv = "λ";
+ unit = NonSI.DEGREE_ANGLE;
+ dir = AxisDirection.EAST;
+ min = Longitude.MIN_VALUE;
+ max = Longitude.MAX_VALUE;
+ rm = RangeMeaning.WRAPAROUND;
+ break;
+ case 110: name = "llipsoidal height ";
+ abrv = "h";
+ unit = SI.METRE;
+ dir = AxisDirection.UP;
+ min = Double.NEGATIVE_INFINITY;
+ max = Double.POSITIVE_INFINITY;
+ rm = null;
+ break;
+ default: throw new AssertionError(code);
+ }
+ return new DefaultCoordinateSystemAxis(properties(code, name, null),
abrv, dir, unit, min, max, rm);
+ }
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardObjects.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardObjects.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardObjects.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardObjects.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -18,6 +18,7 @@ package org.apache.sis.referencing;
import java.lang.reflect.Method;
import org.opengis.util.FactoryException;
+import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.opengis.referencing.datum.DatumAuthorityFactory;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.SystemListener;
@@ -64,6 +65,14 @@ final class StandardObjects extends Syst
}
/**
+ * 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.
+ */
+ static CRSAuthorityFactory crsFactory() {
+ return null; // TODO
+ }
+
+ /**
* Returns the EPSG factory to use for creating datum, ellipsoids and
prime meridians, or {@code null} if none.
* If this method returns {@code null}, then the caller will silently
fallback on hard-coded values.
*/
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -55,6 +55,11 @@ import static org.apache.sis.util.Argume
* {@linkplain org.apache.sis.referencing.cs.DefaultLinearCS Linear}.
* </p>
*
+ * {@section Immutability and thread safety}
+ * This class is immutable and thus thread-safe if the property
<em>values</em> (not necessarily the map itself),
+ * the coordinate system and the datum instances given to the constructor are
also immutable. Unless otherwise noted
+ * in the javadoc, this condition holds if all components were created using
only SIS factories and static constants.
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
* @version 0.4
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -38,6 +38,11 @@ import org.apache.sis.referencing.Abstra
* {@linkplain org.apache.sis.referencing.cs.DefaultSphericalCS Spherical}.
* </p>
*
+ * {@section Immutability and thread safety}
+ * This class is immutable and thus thread-safe if the property
<em>values</em> (not necessarily the map itself),
+ * the coordinate system and the datum instances given to the constructor are
also immutable. Unless otherwise noted
+ * in the javadoc, this condition holds if all components were created using
only SIS factories and static constants.
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
* @version 0.4
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -42,6 +42,11 @@ import org.apache.sis.measure.Units;
* {@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS
Ellipsoidal}.
* </p>
*
+ * {@section Immutability and thread safety}
+ * This class is immutable and thus thread-safe if the property
<em>values</em> (not necessarily the map itself),
+ * the coordinate system and the datum instances given to the constructor are
also immutable. Unless otherwise noted
+ * in the javadoc, this condition holds if all components were created using
only SIS factories and static constants.
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
* @version 0.4
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -39,6 +39,11 @@ import static org.apache.sis.util.Argume
* {@linkplain org.apache.sis.referencing.cs.DefaultAffineCS Affine}.
* </p>
*
+ * {@section Immutability and thread safety}
+ * This class is immutable and thus thread-safe if the property
<em>values</em> (not necessarily the map itself),
+ * the coordinate system and the datum instances given to the constructor are
also immutable. Unless otherwise noted
+ * in the javadoc, this condition holds if all components were created using
only SIS factories and static constants.
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
* @version 0.4
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -45,6 +45,11 @@ import static org.apache.sis.util.Argume
* {@linkplain org.apache.sis.referencing.cs.DefaultTimeCS Time}.
* </p>
*
+ * {@section Immutability and thread safety}
+ * This class is immutable and thus thread-safe if the property
<em>values</em> (not necessarily the map itself),
+ * the coordinate system and the datum instances given to the constructor are
also immutable. Unless otherwise noted
+ * in the javadoc, this condition holds if all components were created using
only SIS factories and static constants.
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
* @version 0.4
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -38,6 +38,11 @@ import static org.apache.sis.util.Argume
* {@linkplain org.apache.sis.referencing.cs.DefaultVerticalCS Vertical}.
* </p>
*
+ * {@section Immutability and thread safety}
+ * This class is immutable and thus thread-safe if the property
<em>values</em> (not necessarily the map itself),
+ * the coordinate system and the datum instances given to the constructor are
also immutable. Unless otherwise noted
+ * in the javadoc, this condition holds if all components were created using
only SIS factories and static constants.
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
* @version 0.4
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=1556843&r1=1556842&r2=1556843&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] Thu Jan 9 15:40:10 2014
@@ -85,7 +85,7 @@ public final strictfp class AbstractIden
assertEquals("codespace", "EPSG",
name.getCodeSpace());
assertEquals("version", "8.3",
name.getVersion());
assertEquals("aliases", "International 1979",
getSingleton(object.getAlias()).toString());
-// assertEquals("names", Collections.singletonList(name),
object.getNames());
+ assertEquals("names", name,
getSingleton(object.getNames()));
assertEquals("identifiers", identifiers,
object.getIdentifiers());
assertEquals("ID", gmlID,
object.getID());
assertEquals("remarks", "Adopted by IUGG 1979 Canberra",
object.getRemarks().toString(Locale.ENGLISH));
Modified:
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java?rev=1556843&r1=1556842&r2=1556843&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
[UTF-8] Thu Jan 9 15:40:10 2014
@@ -17,6 +17,7 @@
package org.apache.sis.referencing;
import java.util.Date;
+import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.datum.TemporalDatum;
import org.opengis.referencing.datum.VerticalDatum;
import org.opengis.referencing.datum.VerticalDatumType;
@@ -50,6 +51,16 @@ public final strictfp class GeodeticObje
private static final double DAY_LENGTH = 24 * 60 * 60 * 1000;
/**
+ * Tests the {@link GeodeticObjects#WGS84} constant.
+ */
+ @Test
+ public void testWGS84() {
+ final GeographicCRS crs = GeodeticObjects.WGS84.geographic();
+ Validators.validate(crs);
+ GeodeticObjectVerifier.assertIsWGS84(crs, false, true);
+ }
+
+ /**
* Verifies the vertical datum enumeration.
*/
@Test