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 2013/11/27 00:04:20 UTC
svn commit: r1545879 - in
/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs:
AbstractCS.java DefaultCylindricalCS.java DefaultEllipsoidalCS.java
Author: desruisseaux
Date: Tue Nov 26 23:04:20 2013
New Revision: 1545879
URL: http://svn.apache.org/r1545879
Log:
Ported DefaultEllipsoidalCS.
Added:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java (with props)
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1545879&r1=1545878&r2=1545879&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Tue Nov 26 23:04:20 2013
@@ -210,12 +210,12 @@ public class AbstractCS extends Abstract
/**
* Returns the number of dimensions of this coordinate system.
- * This is the number of axes.
+ * This is the number of axes given at construction time.
*
* @return The number of dimensions of this coordinate system.
*/
@Override
- public int getDimension() {
+ public final int getDimension() {
return axes.length;
}
@@ -227,7 +227,7 @@ public class AbstractCS extends Abstract
* @throws IndexOutOfBoundsException if {@code dimension} is out of bounds.
*/
@Override
- public CoordinateSystemAxis getAxis(final int dimension) throws IndexOutOfBoundsException {
+ public final CoordinateSystemAxis getAxis(final int dimension) throws IndexOutOfBoundsException {
return axes[dimension];
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java?rev=1545879&r1=1545878&r2=1545879&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] Tue Nov 26 23:04:20 2013
@@ -85,7 +85,7 @@ public class DefaultCylindricalCS extend
* </tr>
* </table>
*
- * @param properties Set of properties. Should contains at least {@code "name"}.
+ * @param properties The properties to be given to the identified object.
* @param axis0 The first axis.
* @param axis1 The second axis.
* @param axis2 The third axis.
Added: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1545879&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] Tue Nov 26 23:04:20 2013
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.cs;
+
+import java.util.Map;
+import javax.measure.unit.Unit;
+import org.opengis.referencing.cs.EllipsoidalCS;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.measure.Units;
+import org.apache.sis.util.Immutable;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.internal.referencing.AxisDirections;
+
+
+/**
+ * A 2- or 3-dimensional coordinate system in which position is specified by geodetic latitude and longitude,
+ * and optionally by ellipsoidal height.
+ *
+ * <table class="sis"><tr>
+ * <th>Used with</th>
+ * <th>Permitted axis names</th>
+ * </tr><tr>
+ * <td>{@linkplain org.geotoolkit.referencing.crs.DefaultGeocentricCRS Geographic CRS}</td>
+ * <td>“Geodetic latitude”, “Geodetic longitude”, “Ellipsoidal height” (if 3D)</td>
+ * </tr><tr>
+ * <td>{@linkplain org.geotoolkit.referencing.crs.DefaultEngineeringCRS Engineering CRS}</td>
+ * <td>unspecified</td>
+ * </tr></table>
+ *
+ * @author Martin Desruisseaux (IRD, Geomatys)
+ * @since 0.4 (derived from geotk-2.0)
+ * @version 0.4
+ * @module
+ */
+@Immutable
+public class DefaultEllipsoidalCS extends AbstractCS implements EllipsoidalCS {
+ /**
+ * Serial number for inter-operability with different versions.
+ */
+ private static final long serialVersionUID = -1452492488902329211L;
+
+ /**
+ * Constructs a two-dimensional coordinate system from a set of properties.
+ * The properties map is given unchanged to the
+ * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
+ * The following table is a reminder of main (not all) properties:
+ *
+ * <table class="sis">
+ * <tr>
+ * <th>Property name</th>
+ * <th>Value type</th>
+ * <th>Returned by</th>
+ * </tr>
+ * <tr>
+ * <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} or {@link String}</td>
+ * <td>{@link #getName()}</td>
+ * </tr>
+ * <tr>
+ * <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
+ * <td>{@link org.opengis.util.GenericName} or {@link CharSequence} (optionally as array)</td>
+ * <td>{@link #getAlias()}</td>
+ * </tr>
+ * <tr>
+ * <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
+ * <td>{@link org.opengis.referencing.ReferenceIdentifier} (optionally as array)</td>
+ * <td>{@link #getIdentifiers()}</td>
+ * </tr>
+ * <tr>
+ * <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
+ * <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+ * <td>{@link #getRemarks()}</td>
+ * </tr>
+ * </table>
+ *
+ * @param properties The properties to be given to the identified object.
+ * @param axis0 The first axis.
+ * @param axis1 The second axis.
+ */
+ public DefaultEllipsoidalCS(final Map<String,?> properties,
+ final CoordinateSystemAxis axis0,
+ final CoordinateSystemAxis axis1)
+ {
+ super(properties, axis0, axis1);
+ }
+
+ /**
+ * Constructs a three-dimensional coordinate system from a set of properties.
+ * The properties map is given unchanged to the
+ * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
+ *
+ * @param properties The properties to be given to the identified object.
+ * @param axis0 The first axis.
+ * @param axis1 The second axis.
+ * @param axis2 The third axis.
+ */
+ public DefaultEllipsoidalCS(final Map<String,?> properties,
+ final CoordinateSystemAxis axis0,
+ final CoordinateSystemAxis axis1,
+ final CoordinateSystemAxis axis2)
+ {
+ super(properties, axis0, axis1, axis2);
+ }
+
+ /**
+ * Creates a new coordinate system with the same values than the specified one.
+ * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
+ * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
+ *
+ * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
+ *
+ * @param cs The coordinate system to copy.
+ *
+ * @see #castOrCopy(EllipsoidalCS)
+ */
+ protected DefaultEllipsoidalCS(final EllipsoidalCS cs) {
+ super(cs);
+ }
+
+ /**
+ * Returns a SIS coordinate system implementation with the same values than the given arbitrary implementation.
+ * If the given object is {@code null}, then this method returns {@code null}.
+ * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged.
+ * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
+ *
+ * @param object The object to get as a SIS implementation, or {@code null} if none.
+ * @return A SIS implementation containing the values of the given object (may be the
+ * given object itself), or {@code null} if the argument was null.
+ */
+ public static DefaultEllipsoidalCS castOrCopy(final EllipsoidalCS object) {
+ return (object == null) || (object instanceof DefaultEllipsoidalCS)
+ ? (DefaultEllipsoidalCS) object : new DefaultEllipsoidalCS(object);
+ }
+
+ /**
+ * Returns {@code true} if the specified axis direction is allowed for this coordinate system.
+ * The current implementation accepts only the following directions:
+ * {@link AxisDirection#NORTH NORTH}, {@link AxisDirection#SOUTH SOUTH},
+ * {@link AxisDirection#EAST EAST}, {@link AxisDirection#WEST WEST},
+ * {@link AxisDirection#UP UP} and {@link AxisDirection#DOWN DOWN}.
+ */
+ @Override
+ final boolean isCompatibleDirection(AxisDirection direction) {
+ direction = AxisDirections.absolute(direction);
+ return AxisDirection.NORTH.equals(direction) ||
+ AxisDirection.EAST .equals(direction) ||
+ AxisDirection.UP .equals(direction);
+ }
+
+ /**
+ * Returns {@code true} if the specified unit is an angular units, or a linear one in the
+ * special case of height. This method is invoked at construction time for checking units
+ * compatibility.
+ */
+ @Override
+ final boolean isCompatibleUnit(AxisDirection direction, final Unit<?> unit) {
+ direction = AxisDirections.absolute(direction);
+ if (AxisDirection.UP.equals(direction)) {
+ return Units.isLinear(unit);
+ }
+ return Units.isAngular(unit);
+ }
+
+ /**
+ * Compares this coordinate system with the specified object for equality.
+ *
+ * @param object The object to compare to {@code this}.
+ * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
+ * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
+ * relevant to coordinate transformations.
+ * @return {@code true} if both objects are equal.
+ */
+ @Override
+ public boolean equals(final Object object, final ComparisonMode mode) {
+ if (object == this) {
+ return true; // Slight optimization.
+ }
+ return (object instanceof EllipsoidalCS) && super.equals(object, mode);
+ }
+}
Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8