sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1516631 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ sis-referencing/ sis-referencing/src/main/java/org/apache/sis/io/wkt/
Date Thu, 22 Aug 2013 21:50:12 GMT
Author: desruisseaux
Date: Thu Aug 22 21:50:11 2013
New Revision: 1516631

URL: http://svn.apache.org/r1516631
Log:
Ported the Convention enumeration.

Added:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
    sis/branches/JDK7/core/sis-referencing/pom.xml
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Colors.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java?rev=1516631&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java
[UTF-8] Thu Aug 22 21:50:11 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.metadata.iso.citation;
+
+import org.apache.sis.internal.simple.SimpleCitation;
+import org.apache.sis.xml.IdentifierSpace;
+
+
+/**
+ * A citation constant also used as a namespace for identifiers.
+ *
+ * @param <T> The identifier type.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4 (derived from geotk-3.19)
+ * @version 0.4
+ * @module
+ *
+ * @see Citations#EPSG
+ */
+final class Authority<T> extends SimpleCitation implements IdentifierSpace<T>
{
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = 9049409961960288134L;
+
+    /**
+     * The identifier namespace.
+     */
+    private final String namespace;
+
+    /**
+     * Creates a new citation of the given title.
+     *
+     * @param title The title to be returned by {@link #getTitle()}.
+     */
+    Authority(final String title, final String namespace) {
+        super(title);
+        this.namespace = namespace;
+    }
+
+    /**
+     * Returns the name of this identifier space.
+     */
+    @Override
+    public String getName() {
+        return namespace;
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Authority.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1516631&r1=1516630&r2=1516631&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Thu Aug 22 21:50:11 2013
@@ -37,7 +37,7 @@ import org.apache.sis.util.CharSequences
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.2)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class Citations extends Static {
@@ -58,6 +58,84 @@ public final class Citations extends Sta
     public static final Citation OGC = new SimpleCitation("OGC");
 
     /**
+     * The <a href="http://sis.apache.org">Apache SIS</a> project.
+     *
+     * @since 0.4
+     */
+    public static final Citation SIS = new SimpleCitation("SIS");
+
+    /**
+     * The <a href="http://www.esri.com">ESRI</a> organization.
+     * This company defines many Coordinate Reference Systems in addition to the {@linkplain
#EPSG} ones.
+     *
+     * @see org.apache.sis.io.wkt.Convention#ESRI
+     * @category Organization
+     *
+     * @since 0.4
+     */
+    public static final Citation ESRI = new SimpleCitation("ESRI");
+
+    /**
+     * The <a href="http://www.oracle.com">Oracle</a> organization.
+     *
+     * @see org.apache.sis.io.wkt.Convention#ORACLE
+     * @category Organization
+     *
+     * @since 0.4
+     */
+    public static final Citation ORACLE = new SimpleCitation("Oracle");
+
+    /**
+     * The <a href="http://www.unidata.ucar.edu/software/netcdf-java">NetCDF</a>
specification.
+     *
+     * @see org.apache.sis.io.wkt.Convention#NETCDF
+     * @category Specification
+     *
+     * @since 0.4
+     */
+    public static final Citation NETCDF = new SimpleCitation("NetCDF");
+
+    /**
+     * The <a href="http://www.remotesensing.org/geotiff/geotiff.html">GeoTIFF</a>
specification.
+     *
+     * @see org.apache.sis.io.wkt.Convention#GEOTIFF
+     * @category Specification
+     *
+     * @since 0.4
+     */
+    public static final Citation GEOTIFF = new SimpleCitation("GeoTIFF");
+
+    /**
+     * The <a href="http://trac.osgeo.org/proj/">Proj.4</a> project.
+     *
+     * @see org.apache.sis.io.wkt.Convention#PROJ4
+     * @category Code space
+     *
+     * @since 0.4
+     */
+    public static final IdentifierSpace<String> PROJ4 = new Authority<>("Proj.4",
"PROJ4");
+
+    /**
+     * The <a href="http://www.epsg.org">European Petroleum Survey Group</a>
authority.
+     * This citation is used as an authority for
+     * {@linkplain org.opengis.referencing.crs.CoordinateReferenceSystem coordinate reference
system}
+     * identifiers. When searching an {@linkplain org.opengis.referencing.crs.CRSAuthorityFactory
CRS
+     * authority factory} on EPSG data, SIS compares the {@code "EPSG"} string against the
+     * {@linkplain Citation#getIdentifiers identifiers} (or against the {@linkplain Citation#getTitle
+     * title} and {@linkplain Citation#getAlternateTitles alternate titles} if there is no
identifier)
+     * using the {@link #identifierMatches(Citation,String) identifierMatches} method.
+     *
+     * @see #AUTO
+     * @see #AUTO2
+     * @see #CRS
+     * @see org.apache.sis.io.wkt.Convention#EPSG
+     * @category Code space
+     *
+     * @since 0.4
+     */
+    public static final IdentifierSpace<Integer> EPSG = new Authority<>("EPSG",
"EPSG");
+
+    /**
      * <cite>International Standard Book Number</cite> (ISBN) defined by ISO-2108.
      * The ISO-19115 metadata standard defines a specific attribute for this information,
      * but the SIS library handles it like any other identifier.
@@ -83,7 +161,7 @@ public final class Citations extends Sta
      * List of citations declared in this class.
      */
     private static final Citation[] AUTHORITIES = {
-        ISO, OGC, ISBN, ISSN
+        ISO, OGC, SIS, ESRI, ORACLE, NETCDF, GEOTIFF, PROJ4, EPSG, ISBN, ISSN
     };
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/pom.xml?rev=1516631&r1=1516630&r2=1516631&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/pom.xml (original)
+++ sis/branches/JDK7/core/sis-referencing/pom.xml Thu Aug 22 21:50:11 2013
@@ -117,6 +117,11 @@ Implementations of Coordinate Reference 
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.sis.core</groupId>
+      <artifactId>sis-metadata</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.opengis</groupId>
       <artifactId>geoapi-pending</artifactId>
     </dependency>

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Colors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Colors.java?rev=1516631&r1=1516630&r2=1516631&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Colors.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Colors.java
[UTF-8] Thu Aug 22 21:50:11 2013
@@ -110,6 +110,14 @@ public class Colors implements Serializa
     }
 
     /**
+     * Returns the ANSI sequence for the given syntactic element, or {@code null} if none.
+     */
+    final String getAnsiSequence(final ElementKind key) {
+        final X364 color = map.get(key);
+        return (color != null) ? color.sequence() : null;
+    }
+
+    /**
      * An immutable subclass of {@link Colors} for the {@link Colors#DEFAULT} constant
      * or for the object to be used by {@link WKTFormat}.
      */

Added: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1516631&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Thu Aug 22 21:50:11 2013
@@ -0,0 +1,331 @@
+/*
+ * 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.io.wkt;
+
+import javax.measure.unit.SI;
+import javax.measure.unit.Unit;
+import javax.measure.quantity.Angle;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.referencing.cs.CartesianCS;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.GeocentricCRS;
+import org.opengis.referencing.operation.OperationMethod;
+import org.opengis.referencing.operation.CoordinateOperation;
+import org.apache.sis.util.Debug;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.referencing.cs.DefaultCartesianCS;
+import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
+
+import static javax.measure.unit.NonSI.DEGREE_ANGLE;
+
+
+/**
+ * The convention to use for WKT formatting.
+ * This enumeration exists as an attempt to address some of the problems documented in the
Frank Warmerdam's
+ * <a href="http://home.gdal.org/projects/opengis/wktproblems.html">OGC WKT Coordinate
System Issues</a> page.
+ *
+ * <p>The various conventions differ mostly in parameter names, and sometime in WKT
syntax.
+ * For example the {@linkplain org.apache.sis.referencing.operation.projection.Mercator projection}
+ * has a parameter named "<cite>Longitude of natural origin</cite>" by {@linkplain
#EPSG},
+ * "{@code central_meridian}" by {@linkplain #OGC} and "{@code NatOriginLong}" by {@linkplain
#GEOTIFF}.
+ * In addition the unit of the prime meridian shall be the angular unit of the enclosing
+ * {@linkplain GeographicCRS geographic CRS} according the {@linkplain #OGC} standard,
+ * but is restricted to decimal degrees by {@linkplain #ESRI}.
+ * Other differences are documented in the javadoc of each enumeration value.</p>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4 (derived from geotk-3.20)
+ * @version 0.4
+ * @module
+ *
+ * @see WKTFormat#getConvention()
+ * @see WKTFormat#setConvention(Convention)
+ */
+public enum Convention {
+    /**
+     * The <a href="http://www.opengeospatial.org">Open Geospatial consortium</a>
convention.
+     * This is the default convention for all WKT formatting in the Apache SIS library.
+     *
+     * {@section Spacial case}
+     * For {@link GeocentricCRS}, this convention uses the legacy set of Cartesian axes.
+     * Those axes were defined in OGC 01-009 as <var>Other</var>,
+     * <var>{@linkplain DefaultCoordinateSystemAxis#EASTING Easting}</var> and
+     * <var>{@linkplain DefaultCoordinateSystemAxis#NORTHING Northing}</var>
+     * in metres, where the "<var>Other</var>" axis is toward prime meridian.
+     *
+     * @see Citations#OGC
+     * @see #toConformCS(CoordinateSystem)
+     */
+    OGC(Citations.OGC, null, false),
+
+    /**
+     * The <a href="http://www.epsg.org">European Petroleum Survey Group</a>
convention.
+     * This convention uses the most descriptive parameter and projection names.
+     *
+     * {@section Spacial case}
+     * For {@link GeocentricCRS}, this convention uses the new set of Cartesian axes.
+     * Those axes are defined in ISO 19111 as
+     * <var>{@linkplain DefaultCoordinateSystemAxis#GEOCENTRIC_X Geocentric X}</var>,
+     * <var>{@linkplain DefaultCoordinateSystemAxis#GEOCENTRIC_Y Geocentric Y}</var>
and
+     * <var>{@linkplain DefaultCoordinateSystemAxis#GEOCENTRIC_Z Geocentric Z}</var>
in metres.
+     *
+     * @see Citations#EPSG
+     * @see #toConformCS(CoordinateSystem)
+     */
+    EPSG(Citations.EPSG, null, false) {
+        @Override
+        public CoordinateSystem toConformCS(CoordinateSystem cs) {
+            if (cs instanceof CartesianCS) {
+                cs = replace((CartesianCS) cs, false);
+            }
+            return cs;
+        }
+    },
+
+    /**
+     * The <a href="http://www.esri.com">ESRI</a> convention.
+     * This convention is similar to the {@link #OGC} convention except in the following
aspects:
+     *
+     * <ul>
+     *   <li>The angular units of {@code PRIMEM} and {@code PARAMETER} elements are
always degrees,
+     *       no matter the units of the enclosing {@code GEOGCS} element.</li>
+     *   <li>The {@code AXIS} elements are ignored at parsing time.</li>
+     *   <li>Unit names use American spelling instead than the international ones
+     *       (e.g. "<cite>meter</cite>" instead than "<cite>metre</cite>").</li>
+     *   <li>At parsing time, the {@code AXIS} elements are ignored.</li>
+     * </ul>
+     *
+     * @see Citations#ESRI
+     */
+    ESRI(Citations.ESRI, DEGREE_ANGLE, true),
+
+    /**
+     * The <a href="http://www.oracle.com">Oracle</a> convention.
+     * This convention is similar to the {@link #OGC} convention except in the following
aspects:
+     *
+     * <ul>
+     *   <li>The Bursa-Wolf parameters are inserted straight into the {@code DATUM}
element,
+     *       without enclosing them in a {@code TOWGS84} element.</li>
+     *   <li>The {@code PROJECTION} names are {@linkplain CoordinateOperation Coordinate
Operation}
+     *       names instead than {@linkplain OperationMethod Operation Method} names.</li>
+     *   <li>Unit names use American spelling instead than the international ones
+     *       (e.g. "<cite>meter</cite>" instead than "<cite>metre</cite>").</li>
+     * </ul>
+     *
+     * @see Citations#ORACLE
+     */
+    ORACLE(Citations.ORACLE, null, true),
+
+    /**
+     * The <a href="http://www.unidata.ucar.edu/software/netcdf-java">NetCDF</a>
convention.
+     * This convention is similar to the {@link #OGC} convention except for parameter and
projection names.
+     *
+     * @see Citations#NETCDF
+     */
+    NETCDF(Citations.NETCDF, null, false),
+
+    /**
+     * The <a href="http://www.remotesensing.org/geotiff/geotiff.html">GeoTIFF</a>
convention.
+     * This convention is similar to the {@link #OGC} convention except for parameter and
projection names.
+     *
+     * @see Citations#GEOTIFF
+     */
+    GEOTIFF(Citations.GEOTIFF, null, false),
+
+    /**
+     * The <a href="http://trac.osgeo.org/proj/">Proj.4</a> convention.
+     * This convention uses very short parameter and projection names.
+     * Other differences are:
+     *
+     * <ul>
+     *   <li>The angular units of {@code PRIMEM} and {@code PARAMETER} elements are
always degrees,
+     *       no matter the units of the enclosing {@code GEOGCS} element.</li>
+     * </ul>
+     *
+     * @see Citations#PROJ4
+     */
+    PROJ4(Citations.PROJ4, DEGREE_ANGLE, false),
+
+    /**
+     * A special convention for formatting objects as stored internally by Apache SIS.
+     * In the majority of cases, the result will be identical to the one we would get using
the {@link #OGC} convention.
+     * However in the particular case of map projections, the result may be quite different
because of the way
+     * SIS separates the linear from the non-linear parameters.
+     *
+     * <p>This convention is used only for debugging purpose.</p>
+     *
+     * @see Formatter#isInternalWKT()
+     */
+    @Debug
+    INTERNAL(Citations.SIS, null, false) {
+        @Override
+        public CoordinateSystem toConformCS(final CoordinateSystem cs) {
+            return cs; // Prevent any modification on the internal CS.
+        }
+    };
+
+    /**
+     * A three-dimensional Cartesian CS with the legacy set of geocentric axes.
+     * Those axes were defined in the OGC 01-009 specification as <var>Other</var>,
+     * <var>{@linkplain DefaultCoordinateSystemAxis#EASTING Easting}</var>,
+     * <var>{@linkplain DefaultCoordinateSystemAxis#NORTHING Northing}</var>
+     * in metres, where the "Other" axis is toward prime meridian.
+     */
+    private static final DefaultCartesianCS LEGACY = new DefaultCartesianCS("Legacy",
+            new DefaultCoordinateSystemAxis("X", AxisDirection.OTHER, SI.METRE),
+            new DefaultCoordinateSystemAxis("Y", AxisDirection.EAST,  SI.METRE),
+            new DefaultCoordinateSystemAxis("Z", AxisDirection.NORTH, SI.METRE));
+
+    /**
+     * If non-null, forces {@code PRIMEM} and {@code PARAMETER} angular units to this field
+     * value instead than inferring it from the context. The standard value is {@code null},
+     * which means that the angular units are inferred from the context as required by the
+     * <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html#PRIMEM">WKT
specification</a>.
+     *
+     * @see ReferencingParser#getForcedAngularUnit()
+     */
+    final Unit<Angle> forcedAngularUnit;
+
+    /**
+     * {@code true} if the convention uses US unit names instead of the international names.
+     * For example Americans said [@code "meter"} instead of {@code "metre"}.
+     */
+    final boolean unitUS;
+
+    /**
+     * The citation for this enumeration.
+     */
+    private final Citation citation;
+
+    /**
+     * Creates a new enumeration value.
+     */
+    private Convention(final Citation citation, final Unit<Angle> angularUnit, final
boolean unitUS) {
+        this.citation = citation;
+        this.forcedAngularUnit = angularUnit;
+        this.unitUS = unitUS;
+    }
+
+    /**
+     * Returns the citation for this enumeration.
+     * This is one of the constants defined in the {@link Citations} class.
+     *
+     * @return The citation for this enum.
+     *
+     * @see WKTFormat#getAuthority()
+     */
+    public Citation getCitation() {
+        return citation;
+    }
+
+    /**
+     * Returns the convention for the given citation.
+     *
+     * @param  citation The citation for which to get the convention, or {@code null}.
+     * @param  defaultConvention The default convention to return if none where found for
+     *         the given citation. May be {@code null}.
+     * @return The convention, or {@code null} if no matching convention were found and the
+     *         {@code defaultConvention} argument is {@code null}.
+     */
+    public static Convention forCitation(final Citation citation, final Convention defaultConvention)
{
+        if (citation != null) {
+            for (final Convention candidate : values()) {
+                if (Citations.identifierMatches(candidate.getCitation(), citation)) {
+                    return candidate;
+                }
+            }
+        }
+        return defaultConvention;
+    }
+
+    /**
+     * Returns the convention for the given identifier.
+     *
+     * @param  identifier The identifier for which to get the convention, or {@code null}.
+     * @param  defaultConvention The default convention to return if none where found for
+     *         the given identifier. May be {@code null}.
+     * @return The convention, or {@code null} if no matching convention were found and the
+     *         {@code defaultConvention} argument is {@code null}.
+     */
+    public static Convention forIdentifier(final String identifier, final Convention defaultConvention)
{
+        if (identifier != null) {
+            for (final Convention candidate : values()) {
+                if (Citations.identifierMatches(candidate.getCitation(), identifier)) {
+                    return candidate;
+                }
+            }
+        }
+        return defaultConvention;
+    }
+
+    /**
+     * Makes the given coordinate system conform to this convention. This method is used
mostly
+     * for converting between the legacy (OGC 01-009) {@link GeocentricCRS} axis directions,
+     * and the new (ISO 19111) directions. Those directions are:
+     *
+     * <ul>
+     *   <li>OGC 01-009: Other,
+     *     {@linkplain DefaultCoordinateSystemAxis#EASTING Easting},
+     *     {@linkplain DefaultCoordinateSystemAxis#NORTHING Northing}.
+     *   </li>
+     *   <li>ISO 19111:
+     *     {@linkplain DefaultCoordinateSystemAxis#GEOCENTRIC_X Geocentric X},
+     *     {@linkplain DefaultCoordinateSystemAxis#GEOCENTRIC_Y Geocentric Y},
+     *     {@linkplain DefaultCoordinateSystemAxis#GEOCENTRIC_Z Geocentric Z}.
+     *   </li>
+     * </ul>
+     *
+     * @param  cs The coordinate system.
+     * @return A coordinate system equivalent to the given one but with conform axis names,
+     *         or the given {@code cs} if no change apply to the given coordinate system.
+     *
+     * @see #OGC
+     * @see #EPSG
+     */
+    public CoordinateSystem toConformCS(CoordinateSystem cs) {
+        if (cs instanceof CartesianCS) {
+            cs = replace((CartesianCS) cs, true);
+        }
+        return cs;
+    }
+
+    /**
+     * Returns the axes to use instead of the ones in the given coordinate system.
+     * If the coordinate system axes should be used as-is, returns {@code cs}.
+     *
+     * @param  cs The coordinate system for which to compare the axis directions.
+     * @param  legacy {@code true} for replacing ISO directions by the legacy ones,
+     *         or {@code false} for the other way around.
+     * @return The axes to use instead of the ones in the given CS,
+     *         or {@code cs} if the CS axes should be used as-is.
+     */
+    static CartesianCS replace(final CartesianCS cs, final boolean legacy) {
+        final CartesianCS check = legacy ? DefaultCartesianCS.GEOCENTRIC : LEGACY;
+        final int dimension = check.getDimension();
+        if (cs.getDimension() != dimension) {
+            return cs;
+        }
+        for (int i=0; i<dimension; i++) {
+            if (!cs.getAxis(i).getDirection().equals(check.getAxis(i).getDirection())) {
+                return cs;
+            }
+        }
+        return legacy ? LEGACY : DefaultCartesianCS.GEOCENTRIC;
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java?rev=1516631&r1=1516630&r2=1516631&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
[UTF-8] Thu Aug 22 21:50:11 2013
@@ -191,7 +191,7 @@ public class Symbols implements Localize
      * @return The symbols locale.
      */
     @Override
-    public Locale getLocale() {
+    public final Locale getLocale() {
         return locale;
     }
 



Mime
View raw message