Author: desruisseaux
Date: Mon Apr 27 22:18:15 2015
New Revision: 1676390
URL: http://svn.apache.org/r1676390
Log:
Omit PrimeMeridian element in WKT2_SIMPLIFIED mode if the meridian is Greenwich.
Added test for WKT 1 formatting of ProjectedCRS.
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
(with props)
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -71,6 +71,7 @@ public enum Convention {
* to the {@link #WKT2} convention except for the following aspects:
*
* <ul>
+ * <li>{@code PrimeMeridian} element omitted if the meridian is Greenwich.</li>
* <li>{@code Axis} element omits the {@code Order} sub-element.</li>
* <li>{@code VerticalExtent} element omits the {@code LengthUnit} sub-element
* if the unit is {@link javax.measure.unit.SI#METRE}.</li>
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.crs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.measure.unit.NonSI;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -27,9 +28,12 @@ import org.opengis.referencing.cs.Ellips
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.datum.GeodeticDatum;
+import org.opengis.referencing.datum.PrimeMeridian;
import org.apache.sis.internal.referencing.Legacy;
import org.apache.sis.internal.referencing.WKTUtilities;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.Formatter;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -174,14 +178,7 @@ class DefaultGeodeticCRS extends Abstrac
final boolean isWKT1 = formatter.getConvention().majorVersion() == 1;
final Unit<?> unit = getUnit();
final Unit<?> oldUnit = formatter.addContextualUnit(unit);
- final GeodeticDatum datum = getDatum(); // Gives to users a chance to override
this property.
- formatter.newLine();
- formatter.append(toFormattable(datum));
- formatter.newLine();
- formatter.indent(isWKT1 ? 0 : +1);
- formatter.append(toFormattable(datum.getPrimeMeridian()));
- formatter.indent(isWKT1 ? 0 : -1);
- formatter.newLine();
+ formatTo(isWKT1, getDatum(), formatter);
CoordinateSystem cs = getCoordinateSystem();
if (isWKT1) { // WKT 1 writes unit before axes, while WKT 2 writes them after axes.
formatter.append(unit);
@@ -202,7 +199,7 @@ class DefaultGeodeticCRS extends Abstrac
}
}
} else {
- formatter.append(toFormattable(cs)); // The concept of CoordinateSystem was not
explicit in WKT 1.
+ formatter.append(toFormattable(cs)); // WKT2 only, since the concept of CoordinateSystem
was not explicit in WKT 1.
formatter.indent(+1);
}
final int dimension = cs.getDimension();
@@ -230,4 +227,27 @@ class DefaultGeodeticCRS extends Abstrac
*/
return (cs instanceof EllipsoidalCS) ? "GeogCS" : "GeocCS";
}
+
+ /**
+ * Formats the given geodetic datum to the given formatter. This is part of the WKT formatting
+ * for a geodetic CRS, either standalone or as part of a projected CRS.
+ *
+ * @param isWKT1 {@code true} if formatting WKT 1, or {@code false} for WKT 2.
+ * @param datum The datum to format.
+ * @param formatter Where to format the datum.
+ */
+ static void formatTo(final boolean isWKT1, final GeodeticDatum datum, final Formatter
formatter) {
+ formatter.newLine();
+ formatter.append(toFormattable(datum));
+ formatter.newLine();
+ formatter.indent(isWKT1 ? 0 : +1);
+ final PrimeMeridian pm = datum.getPrimeMeridian();
+ if (formatter.getConvention() != Convention.WKT2_SIMPLIFIED ||
+ ReferencingUtilities.getGreenwichLongitude(pm, NonSI.DEGREE_ANGLE) != 0)
+ {
+ formatter.append(toFormattable(pm));
+ }
+ formatter.indent(isWKT1 ? 0 : -1);
+ formatter.newLine();
+ }
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -39,7 +39,9 @@ import org.apache.sis.referencing.operat
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.internal.util.Constants;
+import org.apache.sis.io.wkt.FormattableObject;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
@@ -202,7 +204,7 @@ public class DefaultProjectedCRS extends
* Used by JAXB only (invoked by reflection).
*/
private void setDatum(final GeodeticDatum datum) {
- // TODO
+ throw new UnsupportedOperationException(); // TODO
}
/**
@@ -244,23 +246,39 @@ public class DefaultProjectedCRS extends
/**
* Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation
of this CRS.
*
- * @return {@code "ProjCS"} (WKT 1).
+ * @return {@code "ProjectedCRS"} (WKT 2) or {@code "ProjCS"} (WKT 1).
*/
@Override
protected String formatTo(final Formatter formatter) {
WKTUtilities.appendName(this, formatter, null);
- final Conversion conversion = getConversionFromBase();
- final GeographicCRS baseCRS = getBaseCRS();
- final Ellipsoid ellipsoid = getDatum().getEllipsoid();
- final Unit<?> unit = ReferencingUtilities.getUnit(getCoordinateSystem());
- final Unit<Angle> geoUnit = ReferencingUtilities.getAngularUnit(baseCRS.getCoordinateSystem());
- final Unit<?> linearUnit = formatter.addContextualUnit(unit);
- final Unit<Angle> angularUnit = formatter.addContextualUnit(geoUnit);
- final Unit<Length> axisUnit = ellipsoid.getAxisUnit();
+ final Convention convention = formatter.getConvention();
+ final boolean isWKT1 = (convention.majorVersion() == 1);
+ final Conversion conversion = getConversionFromBase();
+ final GeographicCRS baseCRS = getBaseCRS();
+ final Ellipsoid ellipsoid = getDatum().getEllipsoid();
+ final CartesianCS cs = getCoordinateSystem();
+ final Unit<?> linearUnit = ReferencingUtilities.getUnit(cs);
+ final Unit<Angle> angularUnit = ReferencingUtilities.getAngularUnit(baseCRS.getCoordinateSystem());
+ final Unit<?> oldLinearUnit = formatter.addContextualUnit(linearUnit);
+ final Unit<Angle> oldAngularUnit = formatter.addContextualUnit(angularUnit);
+ final Unit<Length> axisUnit = ellipsoid.getAxisUnit();
formatter.newLine();
- formatter.append(toFormattable(baseCRS));
+ if (isWKT1) {
+ formatter.append(toFormattable(baseCRS));
+ } else {
+ /*
+ * WKT 1 (above case) formatted a full GeographicCRS while WKT 2 (this case)
formats
+ * only the datum and the prime meridian. It does not format the coordinate
system,
+ * and uses a different keyword ("BaseGeodCRS" instead of "GeogCS").
+ *
+ * Note that we format the unit in "simplified" mode, not in verbose mode. This
looks
+ * like the opposite of what we would expect, but this is because formatting
the unit
+ * here allow us to avoid repeating the unit in many projection parameters.
+ */
+ formatter.append(new BaseCRS(baseCRS, isWKT1, convention.isSimplified() ? angularUnit
: null));
+ }
formatter.newLine();
- formatter.append(DefaultOperationMethod.castOrCopy(conversion));
+ formatter.append(DefaultOperationMethod.castOrCopy(conversion.getMethod()));
formatter.newLine();
for (final GeneralParameterValue param : conversion.getParameterValues().values())
{
final GeneralParameterDescriptor desc = param.getDescriptor();
@@ -284,21 +302,50 @@ public class DefaultProjectedCRS extends
}
WKTUtilities.append(param, formatter);
}
- formatter.append(unit);
- final CartesianCS cs = getCoordinateSystem();
+ formatter.append(linearUnit);
final int dimension = cs.getDimension();
for (int i=0; i<dimension; i++) {
formatter.newLine();
formatter.append(toFormattable(cs.getAxis(i)));
}
- if (unit == null) {
+ if (linearUnit == null) {
formatter.setInvalidWKT(this, null);
}
- formatter.removeContextualUnit(unit);
- formatter.removeContextualUnit(geoUnit);
- formatter.addContextualUnit(angularUnit);
- formatter.addContextualUnit(linearUnit);
+ formatter.removeContextualUnit(linearUnit);
+ formatter.removeContextualUnit(angularUnit);
+ formatter.addContextualUnit(oldAngularUnit);
+ formatter.addContextualUnit(oldLinearUnit);
formatter.newLine(); // For writing the ID[…] element on its own line.
- return "ProjCS";
+ return isWKT1 ? "ProjCS" : "ProjectedCRS";
+ }
+
+ /**
+ * Temporary object use for formatting the {@code BaseGeodCRS} element inside a {@code
ProjectedCRS} element.
+ */
+ private static final class BaseCRS extends FormattableObject {
+ /** The base CRS. */
+ private final GeographicCRS baseCRS;
+
+ /** {@code true} for WKT 1 formatting, or {@code false} for WKT 2. */
+ private final boolean isWKT1;
+
+ /** Coordinate axis units. */
+ private final Unit<Angle> angularUnit;
+
+ /** Creates a new temporary {@code BaseGeodCRS} element. */
+ BaseCRS(final GeographicCRS baseCRS, final boolean isWKT1, final Unit<Angle>
angularUnit) {
+ this.baseCRS = baseCRS;
+ this.isWKT1 = isWKT1;
+ this.angularUnit = angularUnit;
+ }
+
+ /** Formats this {@code BaseGeodCRS} element. */
+ @Override protected String formatTo(final Formatter formatter) {
+ WKTUtilities.appendName(baseCRS, formatter, null);
+ DefaultGeodeticCRS.formatTo(isWKT1, baseCRS.getDatum(), formatter);
+ formatter.append(angularUnit); // May be null.
+ formatter.newLine();
+ return "BaseGeodCRS";
+ }
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -872,7 +872,14 @@ public class DefaultCoordinateSystemAxis
/**
* Creates a new {@code ORDER[…]} element for the given axis in the given coordinate
system.
* If this method does not found exactly one instance of the given axis in the given
coordinate system,
- * then returns {@code null}. It will be caller's responsibility to declare the WKT
as invalid.
+ * then returns {@code null}. In the later case, it is caller's responsibility to
declare the WKT as invalid.
+ *
+ * <p>This method is a little bit inefficient since the enclosing {@link AbstractCS#formatTo(Formatter)}
+ * method already know this axis index. But there is currently no API in {@link Formatter}
for carrying
+ * this information, and we are a little bit reluctant to introduce such API since
it would force us to
+ * introduce lists in a model which is, for everything else, purely based on trees.</p>
+ *
+ * @se <a href="https://issues.apache.org/jira/browse/SIS-163">SIS-163</a>
*/
static Order create(final CoordinateSystem cs, final DefaultCoordinateSystemAxis
axis) {
Order order = null;
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -530,6 +530,9 @@ public class DefaultGeodeticDatum extend
* }
* </div>
*
+ * Note that the {@linkplain #getPrimeMeridian() prime meridian} shall be formatted by
the caller
+ * as a separated element after the geodetic datum (for compatibility with WKT 1).
+ *
* @return {@code "Datum"}.
*/
@Override
@@ -552,6 +555,7 @@ public class DefaultGeodeticDatum extend
}
}
}
+ // For the WKT 2 case, the ANCHOR[…] element is added by Formatter itself.
formatter.newLine(); // For writing the ID[…] element on its own line.
return "Datum";
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -77,4 +77,42 @@ public final strictfp class DefaultGeoce
" LengthUnit[“metre”, 1]]",
HardCodedCRS.GEOCENTRIC);
}
+
+ /**
+ * Tests WKT 2 simplified formatting.
+ */
+ @Test
+ @DependsOnMethod("testWKT2")
+ public void testWKT2_Simplified() {
+ assertWktEquals(Convention.WKT2_SIMPLIFIED,
+ "GeodeticCRS[“Geocentric”,\n" +
+ " Datum[“World Geodetic System 1984”,\n" +
+ " Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
+ " CS[“Cartesian”, 3],\n" +
+ " Axis[“(X)”, geocentricX],\n" +
+ " Axis[“(Y)”, geocentricY],\n" +
+ " Axis[“(Z)”, geocentricZ],\n" +
+ " Unit[“metre”, 1]]",
+ HardCodedCRS.GEOCENTRIC);
+ }
+
+ /**
+ * Tests WKT 2 internal formatting.
+ */
+ @Test
+ @DependsOnMethod("testWKT2")
+ public void testWKT2_Internal() {
+ assertWktEquals(Convention.INTERNAL,
+ "GeodeticCRS[“Geocentric”,\n" +
+ " Datum[“World Geodetic System 1984”,\n" +
+ " Ellipsoid[“WGS84”, 6378137.0, 298.257223563],\n" +
+ " Id[“EPSG”, 6326]],\n" +
+ " PrimeMeridian[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
+ " CS[“Cartesian”, 3],\n" +
+ " Axis[“Geocentric X (X)”, geocentricX],\n" +
+ " Axis[“Geocentric Y (Y)”, geocentricY],\n" +
+ " Axis[“Geocentric Z (Z)”, geocentricZ],\n" +
+ " Unit[“metre”, 1]]",
+ HardCodedCRS.GEOCENTRIC);
+ }
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -168,12 +168,18 @@ public final strictfp class DefaultGeogr
" Area[“World”],\n" +
" BBox[-90.00, -180.00, 90.00, 180.00]]",
HardCodedCRS.WGS84);
+ }
+ /**
+ * Tests WKT 2 simplified formatting.
+ */
+ @Test
+ @DependsOnMethod("testWKT2")
+ public void testWKT2_Simplified() {
assertWktEquals(Convention.WKT2_SIMPLIFIED,
"GeodeticCRS[“WGS 84”,\n" +
" Datum[“World Geodetic System 1984”,\n" +
" Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
- " PrimeMeridian[“Greenwich”, 0.0],\n" +
" CS[“ellipsoidal”, 2],\n" +
" Axis[“Longitude (L)”, east],\n" +
" Axis[“Latitude (B)”, north],\n" +
@@ -181,7 +187,14 @@ public final strictfp class DefaultGeogr
" Area[“World”],\n" +
" BBox[-90.00, -180.00, 90.00, 180.00]]",
HardCodedCRS.WGS84);
+ }
+ /**
+ * Tests WKT 2 internal formatting.
+ */
+ @Test
+ @DependsOnMethod("testWKT2")
+ public void testWKT2_Internal() {
assertWktEquals(Convention.INTERNAL,
"GeodeticCRS[“WGS 84”,\n" +
" Datum[“World Geodetic System 1984”,\n" +
Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1676390&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -0,0 +1,98 @@
+/*
+ * 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.crs;
+
+import java.util.Collections;
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
+import org.opengis.util.FactoryException;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.apache.sis.referencing.cs.HardCodedCS;
+import org.apache.sis.referencing.operation.DefaultConversion;
+import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.MetadataAssert.*;
+
+
+/**
+ * Tests the {@link DefaultProjectedCRS} class.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+@DependsOn({
+ DefaultGeographicCRSTest.class
+})
+public final strictfp class DefaultProjectedCRSTest extends TestCase {
+ /**
+ * Creates the "NTF (Paris) / Lambert zone II" CRS.
+ *
+ * @see HardCodedCRS#NTF
+ *
+ * @todo Move this kind of code in a helper class.
+ * @todo Accuracy problem in formatting of scale factor in DefaultParameterValueGroup.toString().
+ */
+ private static DefaultProjectedCRS create() throws FactoryException {
+ final MathTransformFactory mtFactory = DefaultFactories.forBuildin(MathTransformFactory.class);
+ final ParameterValueGroup p = mtFactory.getDefaultParameters("Lambert Conic Conformal
(1SP)");
+ p.parameter("Latitude of natural origin").setValue(52, NonSI.GRADE);
+ p.parameter("Scale factor at natural origin").setValue(0.99987742);
+ p.parameter("False easting").setValue(600000, SI.METRE);
+ p.parameter("False northing").setValue(2200000, SI.METRE);
+ final MathTransform mt = mtFactory.createBaseToDerived(HardCodedCRS.NTF, p, HardCodedCS.PROJECTED);
+ final DefaultConversion conversion = new DefaultConversion(Collections.singletonMap(
+ DefaultConversion.NAME_KEY, "Lambert zone II"), mtFactory.getLastMethodUsed(),
mt);
+ return new DefaultProjectedCRS(Collections.singletonMap(DefaultConversion.NAME_KEY,
+ "NTF (Paris) / Lambert zone II"), conversion, HardCodedCRS.NTF, HardCodedCS.PROJECTED);
+ }
+
+ /**
+ * Tests WKT 1 formatting.
+ *
+ * @throws FactoryException if the CRS creation failed.
+ */
+ @Test
+ public void testWKT1() throws FactoryException {
+ final DefaultProjectedCRS crs = create();
+ assertWktEquals(Convention.WKT1,
+ "PROJCS[“NTF (Paris) / Lambert zone II”,\n" +
+ " GEOGCS[“NTF (Paris)”,\n" +
+ " DATUM[“Nouvelle Triangulation Francaise”,\n" +
+ " SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" +
+ " PRIMEM[“Paris”, 2.33722917],\n" +
+ " UNIT[“degree”, 0.017453292519943295],\n" +
+ " AXIS[“Longitude”, EAST],\n" +
+ " AXIS[“Latitude”, NORTH]],\n" +
+ " PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n"
+
+ " PARAMETER[“latitude_of_origin”, 46.8],\n" +
+ " PARAMETER[“scale_factor”, 0.99987742],\n" +
+ " PARAMETER[“false_easting”, 600000.0],\n" +
+ " PARAMETER[“false_northing”, 2200000.0],\n" +
+ " UNIT[“metre”, 1],\n" +
+ " AXIS[“Easting”, EAST],\n" +
+ " AXIS[“Northing”, NORTH]]",
+ crs);
+ }
+}
Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -84,6 +84,8 @@ public final strictfp class HardCodedCRS
* this CRS is to test operations between CRS having different prime meridian.</p>
*
* @since 0.5
+ *
+ * @see DefaultProjectedCRSTest#NTF_ZONE_II
*/
public static final DefaultGeographicCRS NTF = new DefaultGeographicCRS(
properties("NTF (Paris)"), HardCodedDatum.NTF, HardCodedCS.GEODETIC_2D);
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1676390&r1=1676389&r2=1676390&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Mon Apr 27 22:18:15 2015
@@ -126,6 +126,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultProjectedCRSTest.class,
org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
org.apache.sis.referencing.crs.SubTypesTest.class,
|