Author: desruisseaux
Date: Thu Feb 19 22:54:05 2015
New Revision: 1661029
URL: http://svn.apache.org/r1661029
Log:
Better formatting of "Affine parametric transformation" parameters in Well
Known Text (WKT) format:
- As a side effect of this work, moved "HardCoded" internal class as
"Constants" internal class in sis-utility module.
This allow us to leverage the constant values (in particular the newly added
"num_row" and "num_col") in WKT classes.
- ImmutableIdentifier shall format the parameter identifier (e.g.
Parameter["A0", Id["EPSG", 8623]]). This require
synchronization with the Formatter class because Parameter identifiers are
handled in a special way in ISO 19162.
- MatrixParameters shall omit the "num_row" and "num_col" parameters, together
with the last row of the affine matrix,
when the matrix size is 3x3. This is for matching the definition of EPSG:9624
operation method.
Added:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
- copied, changed from r1660664,
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
Removed:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -23,7 +23,7 @@ import org.opengis.referencing.crs.*;
import org.opengis.referencing.datum.*;
import org.opengis.referencing.operation.*;
import org.apache.sis.util.Static;
-import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.util.Constants;
/**
@@ -91,7 +91,7 @@ public final class NameMeaning extends S
* @return {@code true} if the given code space is known to use the URN
syntax.
*/
public static boolean usesURN(final String codeSpace) {
- return (codeSpace != null) &&
codeSpace.equalsIgnoreCase(Citations.EPSG);
+ return (codeSpace != null) &&
codeSpace.equalsIgnoreCase(Constants.EPSG);
}
/**
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -45,6 +45,7 @@ import org.opengis.metadata.extent.Verti
import org.opengis.metadata.extent.TemporalExtent;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.parameter.GeneralParameterDescriptor;
+import org.opengis.parameter.GeneralParameterValue;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.datum.Datum;
@@ -65,6 +66,7 @@ import org.apache.sis.util.CharSequences
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.simple.SimpleExtent;
import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.measure.Range;
@@ -619,6 +621,8 @@ public class Formatter implements Locali
*/
if (info != null) {
appendComplement(info, stackDepth == 0);
+ } else if (convention.majorVersion() != 1 && object instanceof
GeneralParameterValue) {
+ appendComplement(((GeneralParameterValue) object).getDescriptor(),
false);
}
buffer.appendCodePoint(symbols.getClosingBracket(0));
indent(-1);
@@ -898,7 +902,9 @@ public class Formatter implements Locali
boolean columns = false;
do {
openElement(true, "Parameter");
- buffer.appendCodePoint(openQuote).append(columns ? "num_col" :
"num_row").appendCodePoint(closeQuote);
+ buffer.appendCodePoint(openQuote)
+ .append(columns ? Constants.NUM_COL : Constants.NUM_ROW)
+ .appendCodePoint(closeQuote);
append(columns ? numCol : numRow);
closeElement(false);
} while ((columns = !columns) == true);
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -23,7 +23,7 @@ import javax.xml.bind.annotation.XmlElem
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
-import org.opengis.parameter.InvalidParameterValueException;
+import org.opengis.parameter.ParameterValue;
import org.opengis.util.InternationalString;
import org.apache.sis.util.Deprecable;
import org.apache.sis.util.resources.Errors;
@@ -123,7 +123,7 @@ import java.util.Objects;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*
* @see DefaultIdentifier
@@ -328,8 +328,7 @@ public class ImmutableIdentifier extends
* since localizations are deferred to the {@link
InternationalString#toString(Locale)} method.</p>
*
* @param properties The properties to be given to this identifier.
- * @throws InvalidParameterValueException if a property has an invalid
value.
- * @throws IllegalArgumentException if a property is invalid for some
other reason.
+ * @throws IllegalArgumentException if a property has an illegal value.
*/
public ImmutableIdentifier(final Map<String,?> properties) throws
IllegalArgumentException {
ensureNonNull("properties", properties);
@@ -573,19 +572,35 @@ public class ImmutableIdentifier extends
if (version != null) {
appendCode(formatter, version);
}
- final String citation =
org.apache.sis.internal.util.Citations.getIdentifier(authority, false);
- if (citation != null && !citation.equals(cs)) {
- formatter.append(new Cite(citation));
+ /*
+ * In order to simplify the WKT, format the citation only
if it is different than the code space.
+ * We will also omit the citation if this identifier is
for a parameter value, because parameter
+ * values are handled in a special way by the
international standard:
+ *
+ * - ISO 19162 explicitely said that we shall format the
identifier for the root element only,
+ * and omit the identifier for all inner elements
EXCEPT parameter values and operation method.
+ * - Exclusion of identifier for inner elements is
performed by the Formatter class, so it does
+ * not need to be checked here.
+ * - Parameter values are numerous, while operation
methods typically appear only once in a WKT
+ * document. So we will simplify the parameter values
only (not the operation methods) except
+ * if the parameter value is the root element (in
which case we will format full identifier).
+ */
+ final FormattableObject enclosing =
formatter.getEnclosingElement(1);
+ final boolean isRoot =
formatter.getEnclosingElement(2) == null;
+ if (isRoot || !(enclosing instanceof ParameterValue<?>)) {
+ final String citation =
org.apache.sis.internal.util.Citations.getIdentifier(authority, false);
+ if (citation != null && !citation.equals(cs)) {
+ formatter.append(new Cite(citation));
+ }
}
/*
* Do not format the optional URI element for internal
convention,
* because this property is currently computed rather than
stored.
* Other conventions format only for the ID[…] of root
element.
*/
- if (convention != Convention.INTERNAL &&
formatter.getEnclosingElement(2) == null) {
- final FormattableObject parent =
formatter.getEnclosingElement(1);
- if (parent != null && NameMeaning.usesURN(cs)) {
- final String type =
NameMeaning.toObjectType(parent.getClass());
+ if (isRoot && enclosing != null && convention !=
Convention.INTERNAL) {
+ if (NameMeaning.usesURN(cs)) {
+ final String type =
NameMeaning.toObjectType(enclosing.getClass());
if (type != null) {
formatter.append(new URI(type, cs, version,
code));
}
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -21,6 +21,7 @@ import org.opengis.referencing.Identifie
import org.apache.sis.util.Static;
import org.apache.sis.util.CharSequences;
import org.apache.sis.xml.IdentifierSpace;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.simple.SimpleCitation;
import org.apache.sis.metadata.iso.DefaultIdentifier; // For javadoc
@@ -60,7 +61,7 @@ public final class Citations extends Sta
*
* @category Organization
*/
- public static final Citation OGC = new SimpleCitation("OGC");
+ public static final Citation OGC = new SimpleCitation(Constants.OGC);
/**
* The <a href="http://www.ogp.org.uk">International Association of Oil
& Gas Producers</a> organization.
@@ -146,9 +147,7 @@ public final class Citations extends Sta
*
* @since 0.4
*/
- public static final IdentifierSpace<Integer> EPSG = new Authority<>(
- org.apache.sis.internal.util.Citations.EPSG,
- org.apache.sis.internal.util.Citations.EPSG);
+ public static final IdentifierSpace<Integer> EPSG = new
Authority<>(Constants.EPSG, Constants.EPSG);
/**
* <cite>International Standard Book Number</cite> (ISBN) defined by
ISO-2108.
Modified:
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -24,7 +24,7 @@ import org.apache.sis.io.wkt.WKTFormat;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.metadata.iso.citation.Citations;
-import static org.apache.sis.internal.util.Citations.EPSG;
+import static org.apache.sis.internal.util.Constants.EPSG;
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -19,7 +19,7 @@ package org.apache.sis.internal.jaxb.ref
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.internal.jaxb.gml.CodeListAdapter;
-import static org.apache.sis.internal.referencing.HardCoded.EPSG;
+import static org.apache.sis.internal.util.Constants.EPSG;
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -19,7 +19,7 @@ package org.apache.sis.internal.jaxb.ref
import org.opengis.referencing.cs.RangeMeaning;
import org.apache.sis.internal.jaxb.gml.CodeListAdapter;
-import static org.apache.sis.internal.referencing.HardCoded.EPSG;
+import static org.apache.sis.internal.util.Constants.EPSG;
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -339,7 +339,10 @@ public abstract class AbstractParameterD
}
return "ParameterGroup";
} else if (this instanceof ParameterDescriptor<?>) {
- formatter.appendAny(((ParameterDescriptor<?>)
this).getDefaultValue());
+ final Object defaultValue = ((ParameterDescriptor<?>)
this).getDefaultValue();
+ if (defaultValue != null) {
+ formatter.appendAny(defaultValue);
+ }
final Unit<?> unit = ((ParameterDescriptor<?>) this).getUnit();
if (unit != null) {
if (!formatter.getConvention().isSimplified() ||
!unit.equals(formatter.toContextualUnit(unit))) {
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -782,6 +782,11 @@ public class DefaultParameterValue<T> ex
final Unit<?> targetUnit =
formatter.toContextualUnit(descriptor.getUnit());
final Convention convention = formatter.getConvention();
final boolean isWKT1 = convention.majorVersion() == 1;
+ /*
+ * In the WKT 1 specification, the unit of measurement is given by the
context.
+ * If this parameter value does not use the same unit, then we must
convert it.
+ * Otherwise we can write the value as-is.
+ */
if (isWKT1 && targetUnit != null) {
double convertedValue;
try {
@@ -796,8 +801,15 @@ public class DefaultParameterValue<T> ex
} else {
formatter.appendAny(value);
}
+ /*
+ * In the WKT 2 specification, the unit and the identifier are
optional but recommended.
+ * We follow that recommendation in strict WKT2 mode, but omit them in
non-strict modes.
+ * The only exception is when the parameter unit is not the same than
the contextual unit,
+ * in which case we have no choice: we must format that unit.
+ */
if (unit != null && !isWKT1 && (!convention.isSimplified() ||
!unit.equals(targetUnit))) {
formatter.append(unit);
+ // ID will be added by the Formatter itself.
}
return "Parameter";
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -22,7 +22,8 @@ import java.io.ObjectStreamException;
import org.opengis.metadata.citation.Citation;
import org.opengis.parameter.ParameterDescriptor;
import org.apache.sis.referencing.NamedIdentifier;
-import org.apache.sis.internal.referencing.HardCoded;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.internal.referencing.provider.Affine;
import org.apache.sis.metadata.iso.ImmutableIdentifier;
import org.apache.sis.metadata.iso.citation.Citations;
@@ -95,7 +96,41 @@ final class MatrixParameters extends Ten
* are {@code "A0"}, {@code "A1"}, {@code "A2"}, {@code "B0"}, {@code
"B1"} and {@code "B2"}.
*/
private static boolean isEPSG(final int[] indices) {
- return indices[0] < 2 && indices[1] < 3;
+ return indices[0] < Affine.EPSG_DIMENSION &&
+ indices[1] <= Affine.EPSG_DIMENSION; // Include translation
column.
+ }
+
+ /**
+ * Returns 0 if the dimension parameters ({@code "num_row"} and {@code
"num_col"}) shall be hidden.
+ * Those parameters need to be hidden for the EPSG:9624 operation method,
since the EPSG database
+ * does not define those parameters.
+ */
+ @Override
+ final int numDimensions(final int[] actualSize) {
+ if (isEPSG() && actualSize[0] == Affine.EPSG_DIMENSION + 1
+ && actualSize[1] == Affine.EPSG_DIMENSION + 1)
+ {
+ return 0;
+ }
+ return super.numDimensions(actualSize);
+ }
+
+ /**
+ * Returns the number of elements (e.g. {@code "elt_0_0"}) when formatting
the parameter descriptors for a tensor
+ * of the given size. This is the total number of elements in the tensor,
except for matrices which are intended
+ * to be affine (like {@link #EPSG}) where the last row is omitted.
+ */
+ @Override
+ final int numElements(final int[] actualSize) {
+ int numRow = actualSize[0];
+ int numCol = actualSize[1];
+ assert super.numElements(actualSize) == (numRow * numCol);
+ if (isEPSG() && numRow == Affine.EPSG_DIMENSION + 1
+ && numCol == Affine.EPSG_DIMENSION + 1)
+ {
+ numRow--; // Ommit last row of an affine matrix.
+ }
+ return numRow * numCol;
}
/**
@@ -204,17 +239,17 @@ final class MatrixParameters extends Ten
* For the WKT1 convention, create an alias matching the EPSG
pattern ("A0", "A1", etc.) for all
* indices but declare the EPSG authority and identifier only for
A0, A1, A2, B0, B1 and B2.
*/
- name = new NamedIdentifier(Citations.OGC, HardCoded.OGC,
super.indicesToName(indices), null, null);
+ name = new NamedIdentifier(Citations.OGC, Constants.OGC,
super.indicesToName(indices), null, null);
final Citation authority;
final String codeSpace;
if (isEPSG(indices)) {
authority = Citations.OGP;
- codeSpace = HardCoded.EPSG;
- final int code = (indices[0] == 0 ? HardCoded.A0 :
HardCoded.B0) + indices[1];
+ codeSpace = Constants.EPSG;
+ final int code = (indices[0] == 0 ? Constants.A0 :
Constants.B0) + indices[1];
identifier = new ImmutableIdentifier(authority, codeSpace,
String.valueOf(code));
} else {
authority = Citations.SIS;
- codeSpace = HardCoded.SIS;
+ codeSpace = Constants.SIS;
identifier = null;
}
final String c = indicesToAlias(indices);
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -40,6 +40,7 @@ import org.apache.sis.referencing.NamedI
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.operation.matrix.Matrices;
import org.apache.sis.internal.referencing.provider.Affine;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.util.UnmodifiableArrayList;
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.measure.NumberRange;
@@ -126,7 +127,7 @@ import java.util.Objects;
* one can use the following code:
*
* {@preformat java
- * Map<String,?> properties = Collections.singletonMap("name", "My
operation");
+ * Map<String,?> properties =
Collections.singletonMap(ParameterValueGroup.NAME_KEY, "Affine");
* ParameterValueGroup p =
TensorParameters.WKT1.createValueGroup(properties);
* }
*
@@ -136,6 +137,8 @@ import java.util.Objects;
* @since 0.4
* @version 0.6
* @module
+ *
+ * @see MatrixSIS
*/
public class TensorParameters<E> implements Serializable {
/**
@@ -156,7 +159,7 @@ public class TensorParameters<E> impleme
* This implementation accepts also parameters for matrix of different
size (for example {@code "C4"} for row 3
* and column 4), but such extensions are not official EPSG parameter
names.
*
- * <p>If addition, each parameter accepts also the {@link WKT1} name (e.g.
{@code "elt_1_2"})
+ * <p>In addition, each parameter accepts also the {@link WKT1} name (e.g.
{@code "elt_1_2"})
* as an {@linkplain ParameterDescriptor#getAlias() alias}.</p>
*
* @since 0.6
@@ -195,10 +198,10 @@ public class TensorParameters<E> impleme
*/
final Map<String,Object> properties = new HashMap<>(4);
properties.put(Identifier.AUTHORITY_KEY, Citations.OGC);
- properties.put(Identifier.CODE_KEY, "num_row");
+ properties.put(Identifier.CODE_KEY, Constants.NUM_ROW);
ParameterDescriptor<Integer> numRow = new DefaultParameterDescriptor<>(
properties, 1, 1, Integer.class, valueDomain, null,
defaultSize);
- properties.put(Identifier.CODE_KEY, "num_col");
+ properties.put(Identifier.CODE_KEY, Constants.NUM_COL);
ParameterDescriptor<Integer> numCol = new DefaultParameterDescriptor<>(
properties, 1, 1, Integer.class, valueDomain, null,
defaultSize);
WKT1 = new MatrixParameters("elt_", "_", numRow, numCol);
@@ -312,7 +315,7 @@ public class TensorParameters<E> impleme
// Ignore - zero and one will be left to null.
}
int length = 1;
- for (int i = Math.min(dimensions.length, CACHE_RANK); --i >= 0;) {
+ for (int i = Math.min(rank(), CACHE_RANK); --i >= 0;) {
length *= CACHE_SIZE;
}
return new ParameterDescriptor[length];
@@ -463,9 +466,9 @@ public class TensorParameters<E> impleme
* @throws IllegalArgumentException If the given array does not have the
expected length or have illegal value.
*/
protected String indicesToName(final int[] indices) throws
IllegalArgumentException {
- if (indices.length != dimensions.length) {
+ if (indices.length != rank()) {
throw new IllegalArgumentException(Errors.format(
- Errors.Keys.UnexpectedArrayLength_2, dimensions.length,
indices.length));
+ Errors.Keys.UnexpectedArrayLength_2, rank(),
indices.length));
}
final StringBuilder name = new StringBuilder();
String s = prefix;
@@ -495,7 +498,7 @@ public class TensorParameters<E> impleme
if (!name.regionMatches(true, 0, prefix, 0, s)) {
return null;
}
- final int[] indices = new int[dimensions.length];
+ final int[] indices = new int[rank()];
final int last = indices.length - 1;
for (int i=0; i<last; i++) {
final int split = name.indexOf(separator, s);
@@ -581,6 +584,28 @@ public class TensorParameters<E> impleme
}
/**
+ * Returns the number of dimensions (e.g. {@code "num_row"} and {@code
"num_col"}) when formatting the parameter
+ * descriptors for a tensor of the given size. This is the {@linkplain
#rank() rank}, except in the special case
+ * of {@link #EPSG} with a matrix size matching the expectation of the
standard EPSG:9624 operation method.
+ */
+ int numDimensions(final int[] actualSize) {
+ return actualSize.length;
+ }
+
+ /**
+ * Returns the number of elements (e.g. {@code "elt_0_0"}) when formatting
the parameter descriptors for a tensor
+ * of the given size. This is the total number of elements in the tensor,
except for matrices which are intended
+ * to be affine (like {@link #EPSG}) where the last row is omitted.
+ */
+ int numElements(final int[] actualSize) {
+ int n = actualSize[0];
+ for (int i=1; i<actualSize.length; i++) {
+ n *= actualSize[i];
+ }
+ return n;
+ }
+
+ /**
* Returns all parameters in this group for a tensor of the specified
dimensions.
*
* @param actualSize The current values of parameters that define the
matrix (or tensor) dimensions.
@@ -588,21 +613,19 @@ public class TensorParameters<E> impleme
* @return The matrix parameters, including all elements.
*/
final List<GeneralParameterDescriptor> descriptors(final int[] actualSize)
{
- final int rank = dimensions.length; // 2 for a matrix, may be higher
for a tensor.
- int length = actualSize[0];
- for (int i=1; i<rank; i++) {
- length *= actualSize[i];
- }
- final GeneralParameterDescriptor[] parameters = new
GeneralParameterDescriptor[rank + length];
- System.arraycopy(dimensions, 0, parameters, 0, rank);
- final int[] indices = new int[rank];
+ assert actualSize.length == rank();
+ final int numDimensions = numDimensions(actualSize);
+ final int numElements = numElements(actualSize);
+ final GeneralParameterDescriptor[] parameters = new
GeneralParameterDescriptor[numDimensions + numElements];
+ System.arraycopy(dimensions, 0, parameters, 0, numDimensions);
+ final int[] indices = new int[rank()];
/*
* Iterates on all possible index values. Indes on the right side
(usually the column index)
* will vary faster, and index on the left side (usually the row
index) will vary slowest.
*/
- for (int i=0; i<length; i++) {
- parameters[rank + i] = getElementDescriptor(indices);
- for (int j=rank; --j >= 0;) {
+ for (int i=0; i<numElements; i++) {
+ parameters[numDimensions + i] = getElementDescriptor(indices);
+ for (int j=indices.length; --j >= 0;) {
if (++indices[j] < actualSize[j]) {
break;
}
@@ -666,7 +689,7 @@ public class TensorParameters<E> impleme
* @return A new parameter group initialized to the given matrix.
*/
public ParameterValueGroup createValueGroup(final Map<String,?>
properties, final Matrix matrix) {
- if (dimensions.length != 2) {
+ if (rank() != 2) {
throw new IllegalStateException();
}
ArgumentChecks.ensureNonNull("matrix", matrix);
@@ -684,7 +707,7 @@ public class TensorParameters<E> impleme
* @throws InvalidParameterNameException if a parameter name was not
recognized.
*/
public Matrix toMatrix(final ParameterValueGroup parameters) throws
InvalidParameterNameException {
- if (dimensions.length != 2) {
+ if (rank() != 2) {
throw new IllegalStateException();
}
ArgumentChecks.ensureNonNull("parameters", parameters);
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -54,7 +54,7 @@ import org.apache.sis.util.resources.Err
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*/
final class TensorValues<E> extends AbstractParameterDescriptor
@@ -166,13 +166,13 @@ final class TensorValues<E> extends Abst
*/
@Override
public List<GeneralParameterDescriptor> descriptors() {
- return descriptors.descriptors(dimensions());
+ return descriptors.descriptors(size());
}
/**
- * Returns the current tensor dimensions.
+ * Returns the current tensor size for each dimensions.
*/
- private int[] dimensions() {
+ private int[] size() {
final int[] indices = new int[dimensions.length];
for (int i=0; i<indices.length; i++) {
indices[i] = dimensions[i].intValue();
@@ -191,7 +191,7 @@ final class TensorValues<E> extends Abst
public GeneralParameterDescriptor descriptor(String name) throws
ParameterNotFoundException {
name = CharSequences.trimWhitespaces(name);
ArgumentChecks.ensureNonEmpty("name", name);
- return descriptors.descriptor(this, name, dimensions());
+ return descriptors.descriptor(this, name, size());
}
/**
@@ -213,7 +213,7 @@ final class TensorValues<E> extends Abst
cause = exception;
}
if (indices != null) {
- final int[] actualSize = dimensions();
+ final int[] actualSize = size();
if (TensorParameters.isInBounds(indices, actualSize)) {
return parameter(indices, actualSize);
}
@@ -298,9 +298,13 @@ final class TensorValues<E> extends Abst
*/
@Override
public List<GeneralParameterValue> values() {
- final List<GeneralParameterValue> addTo = new ArrayList<>(16);
- addTo.addAll(Arrays.asList(dimensions));
- addValues(values, dimensions(), 0, addTo);
+ final List<GeneralParameterValue> addTo = new ArrayList<>();
+ for (final ParameterValue<Integer> dimension : dimensions) {
+ if (!isOmitted(dimension)) {
+ addTo.add(dimension);
+ }
+ }
+ addValues(values, size(), 0, addTo);
return Collections.unmodifiableList(addTo);
}
@@ -319,9 +323,9 @@ final class TensorValues<E> extends Abst
}
} else {
for (int i=0; i<length; i++) {
- final Object value = values[i];
- if (value != null) {
- addTo.add((ParameterValue<?>) value);
+ final ParameterValue<?> parameter = (ParameterValue<?>)
values[i];
+ if (parameter != null && !isOmitted(parameter)) {
+ addTo.add(parameter);
}
}
}
@@ -329,6 +333,19 @@ final class TensorValues<E> extends Abst
}
/**
+ * Returns {@code true} if the given parameter can be omitted. A parameter
can be omitted
+ * if it is not mandatory and has a value equals to the default value.
+ */
+ private static boolean isOmitted(final ParameterValue<?> parameter) {
+ final Object value = parameter.getValue();
+ if (value == null) { // Implies that the default value is also null.
+ return true;
+ }
+ final ParameterDescriptor<?> descriptor = parameter.getDescriptor();
+ return descriptor.getMinimumOccurs() == 0 &&
value.equals(descriptor.getDefaultValue());
+ }
+
+ /**
* Always throws an exception since this group does not contain subgroups.
*/
@Override
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -65,11 +65,11 @@ import org.apache.sis.measure.Units;
import static java.util.Collections.singletonMap;
import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
-import static org.apache.sis.internal.referencing.HardCoded.CRS;
-import static org.apache.sis.internal.referencing.HardCoded.EPSG;
-import static org.apache.sis.internal.referencing.HardCoded.CRS27;
-import static org.apache.sis.internal.referencing.HardCoded.CRS83;
-import static org.apache.sis.internal.referencing.HardCoded.CRS84;
+import static org.apache.sis.internal.util.Constants.CRS;
+import static org.apache.sis.internal.util.Constants.EPSG;
+import static org.apache.sis.internal.util.Constants.CRS27;
+import static org.apache.sis.internal.util.Constants.CRS83;
+import static org.apache.sis.internal.util.Constants.CRS84;
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -33,11 +33,11 @@ import org.apache.sis.referencing.Abstra
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.measure.Longitude;
-import static org.apache.sis.internal.referencing.HardCoded.CRS;
-import static org.apache.sis.internal.referencing.HardCoded.EPSG;
-import static org.apache.sis.internal.referencing.HardCoded.CRS27;
-import static org.apache.sis.internal.referencing.HardCoded.CRS83;
-import static org.apache.sis.internal.referencing.HardCoded.CRS84;
+import static org.apache.sis.internal.util.Constants.CRS;
+import static org.apache.sis.internal.util.Constants.EPSG;
+import static org.apache.sis.internal.util.Constants.CRS27;
+import static org.apache.sis.internal.util.Constants.CRS83;
+import static org.apache.sis.internal.util.Constants.CRS84;
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -44,8 +44,8 @@ import org.opengis.referencing.operation
import org.opengis.util.FactoryException;
import org.opengis.util.NoSuchIdentifierException;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.referencing.Formulas;
-import org.apache.sis.internal.referencing.HardCoded;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.referencing.j2d.ParameterizedAffine;
import org.apache.sis.parameter.Parameters;
@@ -501,8 +501,8 @@ public class DefaultMathTransformFactory
ParameterValue<?> mismatchedParam = null;
double mismatchedValue = 0;
try {
- final ParameterValue<?> semiMajor =
parameters.parameter(HardCoded.SEMI_MAJOR);
- final ParameterValue<?> semiMinor =
parameters.parameter(HardCoded.SEMI_MINOR);
+ final ParameterValue<?> semiMajor =
parameters.parameter(Constants.SEMI_MAJOR);
+ final ParameterValue<?> semiMinor =
parameters.parameter(Constants.SEMI_MINOR);
final Unit<Length> axisUnit = ellipsoid.getAxisUnit();
/*
* The two calls to getOptional(…) shall succeed before we
write anything, in order to have a
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -19,10 +19,13 @@ package org.apache.sis.parameter;
import java.util.Map;
import java.util.List;
import java.util.HashMap;
+import java.util.Collections;
import org.opengis.parameter.ParameterDirection;
import org.opengis.parameter.GeneralParameterDescriptor;
import org.opengis.parameter.ParameterNotFoundException;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -38,7 +41,7 @@ import static org.opengis.referencing.Id
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Johann Sorel (Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*/
@DependsOn(DefaultParameterDescriptorTest.class)
@@ -182,6 +185,33 @@ public final strictfp class DefaultParam
}
/**
+ * Tests WKT formatting of a group with a parameter having an identifier.
+ *
+ * @see DefaultParameterDescriptorTest#testIdentifiedParameterWKT()
+ *
+ * @since 0.6
+ */
+ @Test
+ @DependsOnMethod("testWKT")
+ public void testIdentifiedParameterWKT() {
+ /*
+ * Test below is identical to
DefaultParameterDescriptorTest.testIdentifiedParameterWKT(),
+ * but is reproduced here for easier comparison with the test
following it.
+ */
+ final DefaultParameterDescriptor<Double> descriptor =
DefaultParameterDescriptorTest.createEPSG("A0", Constants.A0);
+ assertWktEquals("Parameter[“A0”, Id[“EPSG”, 8623, Citation[“OGP”],
URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor);
+ /*
+ * When the parameter is part of a larger element, we expect a
simplification.
+ * Here, the URI should be omitted because it is a long value which
does not
+ * bring new information, since it is computed from other values.
+ */
+ final DefaultParameterDescriptorGroup group = new
DefaultParameterDescriptorGroup(
+ Collections.singletonMap(NAME_KEY, "Affine"), 1, 1,
descriptor);
+ assertWktEquals("ParameterGroup[“Affine”,\n" +
+ " Parameter[“A0”, Id[“EPSG”, 8623,
Citation[“OGP”]]]]", group);
+ }
+
+ /**
* Tests {@link DefaultParameterDescriptorGroup} serialization.
*/
@Test
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -25,6 +25,9 @@ import org.opengis.parameter.ParameterDe
import org.apache.sis.measure.Range;
import org.apache.sis.measure.NumberRange;
import org.apache.sis.measure.MeasurementRange;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -39,7 +42,7 @@ import static org.apache.sis.test.Metada
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
@DependsOn(org.apache.sis.referencing.AbstractIdentifiedObjectTest.class)
@@ -135,6 +138,20 @@ public final strictfp class DefaultParam
}
/**
+ * Creates a descriptor with the given EPSG identifier.
+ *
+ * @param name The parameter name.
+ * @param code The parameter identifier.
+ * @return The descriptor with the given EPSG identifier.
+ */
+ static DefaultParameterDescriptor<Double> createEPSG(final String name,
final short code) {
+ final Map<String, Object> properties = properties(name);
+ assertNull(properties.put(DefaultParameterDescriptor.IDENTIFIERS_KEY,
+ new ImmutableIdentifier(HardCodedCitations.OGP,
Constants.EPSG, Short.toString(code))));
+ return new DefaultParameterDescriptor<>(properties, 0, 1,
Double.class, null, null, null);
+ }
+
+ /**
* Tests the creation of a simple descriptor for an optional parameter
without minimum or maximum value.
*/
@Test
@@ -294,4 +311,18 @@ public final strictfp class DefaultParam
assertWktEquals("Parameter[“Real number”, 5.0, LengthUnit[“metre”,
1]]", descriptor);
assertEquals("Parameter[\"Real number\", 5.0, Unit[\"metre\", 1]]",
descriptor.toString());
}
+
+ /**
+ * Tests WKT formatting of a parameter having an identifier.
+ *
+ * @see DefaultParameterDescriptorGroupTest#testIdentifiedParameterWKT()
+ *
+ * @since 0.6
+ */
+ @Test
+ @DependsOnMethod("testWKT")
+ public void testIdentifiedParameterWKT() {
+ final DefaultParameterDescriptor<Double> descriptor = createEPSG("A0",
Constants.A0);
+ assertWktEquals("Parameter[“A0”, Id[“EPSG”, 8623, Citation[“OGP”],
URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor);
+ }
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -24,6 +24,7 @@ import org.opengis.referencing.datum.Ver
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.InvalidParameterTypeException;
import org.opengis.parameter.InvalidParameterValueException;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
@@ -40,7 +41,7 @@ import static org.apache.sis.test.Metada
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
@DependsOn(DefaultParameterDescriptorTest.class)
@@ -600,4 +601,16 @@ public final strictfp class DefaultParam
assertWktEquals(Convention.WKT2, "Parameter[“Count”, 4]", count);
assertWktEquals(Convention.WKT2, "Parameter[“Length”, 30.0,
LengthUnit[“cm”, 0.01]]", length);
}
+
+ /**
+ * Tests WKT formatting of a parameter having an identifier.
+ *
+ * @since 0.6
+ */
+ @Test
+ @DependsOnMethod("testWKT")
+ public void testIdentifiedParameterWKT() {
+ final Watcher<Double> parameter = new
Watcher<>(DefaultParameterDescriptorTest.createEPSG("A0", Constants.A0));
+ assertWktEquals("Parameter[“A0”, null, Id[“EPSG”, 8623,
Citation[“OGP”]]]", parameter);
+ }
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -147,8 +147,8 @@ public final strictfp class MatrixParame
@Test
@DependsOnMethod("testGetElementDescriptor")
public void testDescriptors() {
- TensorParametersTest.testDescriptors(TensorParameters.WKT1,
TensorParametersTest.ELEMENT_NAMES, NAMES, IDENTIFIERS);
- TensorParametersTest.testDescriptors(TensorParameters.EPSG, NAMES,
TensorParametersTest.ELEMENT_NAMES, IDENTIFIERS);
+ TensorParametersTest.testDescriptors(TensorParameters.WKT1, false,
TensorParametersTest.ELEMENT_NAMES, NAMES, IDENTIFIERS);
+ TensorParametersTest.testDescriptors(TensorParameters.EPSG, true,
NAMES, TensorParametersTest.ELEMENT_NAMES, IDENTIFIERS);
}
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -211,11 +211,11 @@ public final strictfp class TensorParame
@Test
@DependsOnMethod("testGetElementDescriptor")
public void testDescriptors() {
- testDescriptors(WKT1, ELEMENT_NAMES, null, null);
+ testDescriptors(WKT1, false, ELEMENT_NAMES, null, null);
}
/** Implementation of {@link #testDescriptors()} with user-supplied
parameters. */
- static void testDescriptors(final TensorParameters<Double> WKT1,
+ static void testDescriptors(final TensorParameters<Double> WKT1, final
boolean isEPSG,
final String[][] names, final String[][] aliases, final short[][]
identifiers)
{
final Double N0 = 0.0;
@@ -239,22 +239,27 @@ public final strictfp class TensorParame
assertEquals("size", 8, descriptors.size());
descriptors = WKT1.descriptors(new int[] {3, 3});
- verifyDescriptor(SIZE_NAMES, null, null, N3, descriptors.get(0),
0, 0);
- verifyDescriptor(SIZE_NAMES, null, null, N3, descriptors.get(1),
1, 0);
- verifyDescriptor(names, aliases, identifiers, N1, descriptors.get( 2),
0, 0);
- verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 3),
0, 1);
- verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 4),
0, 2);
- verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 5),
1, 0);
- verifyDescriptor(names, aliases, identifiers, N1, descriptors.get( 6),
1, 1);
- verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 7),
1, 2);
- verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 8),
2, 0);
- verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 9),
2, 1);
- verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(10),
2, 2);
- assertEquals("size", 11, descriptors.size());
+ int i = 0;
+ if (!isEPSG) {
+ verifyDescriptor(SIZE_NAMES, null, null, N3,
descriptors.get(i++), 0, 0);
+ verifyDescriptor(SIZE_NAMES, null, null, N3,
descriptors.get(i++), 1, 0);
+ }
+ verifyDescriptor(names, aliases, identifiers, N1,
descriptors.get(i++), 0, 0);
+ verifyDescriptor(names, aliases, identifiers, N0,
descriptors.get(i++), 0, 1);
+ verifyDescriptor(names, aliases, identifiers, N0,
descriptors.get(i++), 0, 2);
+ verifyDescriptor(names, aliases, identifiers, N0,
descriptors.get(i++), 1, 0);
+ verifyDescriptor(names, aliases, identifiers, N1,
descriptors.get(i++), 1, 1);
+ verifyDescriptor(names, aliases, identifiers, N0,
descriptors.get(i++), 1, 2);
+ if (!isEPSG) {
+ verifyDescriptor(names, aliases, identifiers, N0,
descriptors.get(i++), 2, 0);
+ verifyDescriptor(names, aliases, identifiers, N0,
descriptors.get(i++), 2, 1);
+ verifyDescriptor(names, aliases, identifiers, N1,
descriptors.get(i++), 2, 2);
+ }
+ assertEquals("size", i, descriptors.size());
descriptors = WKT1.descriptors(new int[] {4, 4});
- verifyDescriptor(SIZE_NAMES, null, null, N3, descriptors.get(0),
0, 0);
- verifyDescriptor(SIZE_NAMES, null, null, N3, descriptors.get(1),
1, 0);
+ verifyDescriptor(SIZE_NAMES, null, null, N3, descriptors.get( 0),
0, 0);
+ verifyDescriptor(SIZE_NAMES, null, null, N3, descriptors.get( 1),
1, 0);
verifyDescriptor(names, aliases, identifiers, N1, descriptors.get( 2),
0, 0);
verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 3),
0, 1);
verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 4),
0, 2);
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -26,6 +26,7 @@ import org.opengis.parameter.GeneralPara
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.referencing.operation.Matrix;
import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.io.wkt.Convention;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -54,11 +55,18 @@ public final strictfp class TensorValues
/**
* Creates an instance for a matrix using the WKT 1 conventions.
*/
- private static ParameterValueGroup create() {
+ private static ParameterValueGroup createWKT1() {
return
TensorParameters.WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY,
GROUP_NAME));
}
/**
+ * Creates an instance for a matrix using the EPSG conventions.
+ */
+ private static ParameterValueGroup createEPSG() {
+ return
TensorParameters.EPSG.createValueGroup(singletonMap(TensorValues.NAME_KEY,
GROUP_NAME));
+ }
+
+ /**
* Asserts that the given descriptor has the given name and default value.
* Aliases and identifiers are ignored - testing them is the purpose of
{@link MatrixParametersTest}.
*
@@ -86,14 +94,14 @@ public final strictfp class TensorValues
}
/**
- * Tests {@link TensorValues#descriptors()}.
+ * Tests {@link TensorValues#descriptors()} using WKT1 contentions.
*/
@Test
- public void testDescriptors() {
+ public void testDescriptorsWKT1() {
final Double N0 = 0.0;
final Double N1 = 1.0;
final Integer N3 = 3;
- final ParameterValueGroup group = create();
+ final ParameterValueGroup group = createWKT1();
group.parameter("num_row").setValue(1);
group.parameter("num_col").setValue(1);
@@ -118,12 +126,48 @@ public final strictfp class TensorValues
}
/**
+ * Tests {@link TensorValues#descriptors()} using EPSG contentions.
+ */
+ @Test
+ public void testDescriptorsEPSG() {
+ final Integer N3 = 3;
+ final ParameterValueGroup group = createEPSG();
+ List<GeneralParameterDescriptor> descriptors =
group.getDescriptor().descriptors();
+ verifyDescriptorsEPSG(descriptors, 0);
+ /*
+ * Use non-standard matrix size. The "num_row" and "num_col"
+ * parameters shall be included in the list of descriptors.
+ */
+ group.parameter("num_row").setValue(2);
+ descriptors = group.getDescriptor().descriptors();
+ assertDescriptorEquals("num_row", N3, descriptors.get(0));
+ assertDescriptorEquals("num_col", N3, descriptors.get(1));
+ verifyDescriptorsEPSG(descriptors, 2);
+ }
+
+ /**
+ * Verifies that all remaining elements in the given descriptors, starting
at index <var>i</var>,
+ * are A0, A1, A2, B0, B1, B1 parameters.
+ */
+ private static void verifyDescriptorsEPSG(final
List<GeneralParameterDescriptor> descriptors, int i) {
+ final Double N0 = 0.0;
+ final Double N1 = 1.0;
+ assertDescriptorEquals("A0", N1, descriptors.get(i++));
+ assertDescriptorEquals("A1", N0, descriptors.get(i++));
+ assertDescriptorEquals("A2", N0, descriptors.get(i++));
+ assertDescriptorEquals("B0", N0, descriptors.get(i++));
+ assertDescriptorEquals("B1", N1, descriptors.get(i++));
+ assertDescriptorEquals("B2", N0, descriptors.get(i++));
+ assertEquals("size", i, descriptors.size());
+ }
+
+ /**
* Tests {@link TensorValues#values()}.
*/
@Test
@DependsOnMethod("testParameter")
public void testValues() {
- final ParameterValueGroup group = create();
+ final ParameterValueGroup group = createWKT1();
group.parameter("num_row").setValue(2);
group.parameter("num_col").setValue(3);
List<GeneralParameterValue> values = group.values();
@@ -155,7 +199,7 @@ public final strictfp class TensorValues
final Double N0 = 0.0;
final Double N1 = 1.0;
final Integer N3 = 3;
- final ParameterValueGroup group = create();
+ final ParameterValueGroup group = createWKT1();
final ParameterDescriptorGroup d = group.getDescriptor();
assertDescriptorEquals("num_row", N3, d.descriptor("num_row"));
assertDescriptorEquals("num_col", N3, d.descriptor("num_col"));
@@ -203,7 +247,7 @@ public final strictfp class TensorValues
final Double N0 = 0.0;
final Double N1 = 1.0;
final Integer N3 = 3;
- final ParameterValueGroup group = create();
+ final ParameterValueGroup group = createWKT1();
assertValueEquals("num_row", N3, group.parameter("num_row"));
assertValueEquals("num_col", N3, group.parameter("num_col"));
assertValueEquals("elt_0_0", N1, group.parameter("elt_0_0"));
@@ -244,7 +288,7 @@ public final strictfp class TensorValues
@Test
@DependsOnMethod("testParameter")
public void testClone() {
- final ParameterValueGroup group = create();
+ final ParameterValueGroup group = createWKT1();
group.parameter("num_row").setValue(2);
group.parameter("elt_0_1").setValue(4);
group.parameter("elt_1_0").setValue(2);
@@ -267,28 +311,40 @@ public final strictfp class TensorValues
}
/**
- * Tests WKT formatting.
+ * Tests WKT 1 formatting.
+ * <ul>
+ * <li>Group name shall be {@code "Affine"}.</li>
+ * <li>Parameters {@code "num_row"} and {@code "num_col"} are
mandatory.</li>
+ * <li>Parameter names shall be of the form {@code "elt_0_0"}.</li>
+ * <li>No identifier.</li>
+ * </ul>
*/
@Test
- public void testWKT() {
+ public void testWKT1() {
final Matrix matrix = Matrices.createIdentity(4);
matrix.setElement(0,2, 4);
matrix.setElement(1,0, -2);
matrix.setElement(2,3, 7);
- final ParameterValueGroup group = TensorParameters.WKT1
- .createValueGroup(singletonMap(TensorValues.NAME_KEY,
"Affine"), matrix);
+ final ParameterValueGroup group =
TensorParameters.WKT1.createValueGroup(
+ singletonMap(TensorValues.NAME_KEY, "Affine"), matrix);
validate(group);
- assertWktEquals(
- "ParameterGroup[“Affine”,\n" +
- " Parameter[“num_row”, 4],\n" +
- " Parameter[“num_col”, 4],\n" +
- " Parameter[“elt_0_2”, 4.0],\n" +
- " Parameter[“elt_1_0”, -2.0],\n" +
- " Parameter[“elt_2_3”, 7.0]]", group);
+ assertWktEquals(Convention.WKT1,
+ "PARAMETERGROUP[“Affine”,\n" +
+ " PARAMETER[“num_row”, 4],\n" +
+ " PARAMETER[“num_col”, 4],\n" +
+ " PARAMETER[“elt_0_2”, 4.0],\n" +
+ " PARAMETER[“elt_1_0”, -2.0],\n" +
+ " PARAMETER[“elt_2_3”, 7.0]]", group);
}
/**
- * Tests WKT formatting using EPSG parameter names.
+ * Tests WKT 2 formatting using EPSG parameter names.
+ * <ul>
+ * <li>Group name shall be {@code "Affine general parametric
transformation"}.</li>
+ * <li>No {@code "num_row"} or {@code "num_col"} parameters.</li>
+ * <li>Parameter names shall be of the form {@code "A0"}.</li>
+ * <li>Identifiers present, but only for A0-A2 and B0-B2.</li>
+ * </ul>
*/
@Test
public void testWKT2() {
@@ -296,15 +352,13 @@ public final strictfp class TensorValues
matrix.setElement(0,2, 4);
matrix.setElement(1,0, -2);
matrix.setElement(2,1, 7);
- final ParameterValueGroup group = TensorParameters.EPSG
- .createValueGroup(singletonMap(TensorValues.NAME_KEY,
"Affine"), matrix);
+ final ParameterValueGroup group =
TensorParameters.EPSG.createValueGroup(
+ singletonMap(TensorValues.NAME_KEY, "Affine general parametric
transformation"), matrix);
validate(group);
assertWktEquals(
- "ParameterGroup[“Affine”,\n" +
- " Parameter[“num_row”, 3],\n" +
- " Parameter[“num_col”, 3],\n" +
- " Parameter[“A2”, 4.0],\n" +
- " Parameter[“B0”, -2.0],\n" +
+ "ParameterGroup[“Affine general parametric transformation”,\n"
+
+ " Parameter[“A2”, 4.0, Id[“EPSG”, 8625]],\n" +
+ " Parameter[“B0”, -2.0, Id[“EPSG”, 8639]],\n" +
" Parameter[“C1”, 7.0]]", group);
}
@@ -313,6 +367,6 @@ public final strictfp class TensorValues
*/
@Test
public void testSerialization() {
- assertSerializedEquals(create());
+ assertSerializedEquals(createWKT1());
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -34,9 +34,9 @@ import org.opengis.referencing.cs.AxisDi
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.RangeMeaning;
import org.opengis.util.GenericName;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.geometry.AbstractEnvelope;
import org.apache.sis.geometry.GeneralDirectPosition;
-import org.apache.sis.internal.referencing.HardCoded;
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.util.iso.DefaultNameSpace;
@@ -77,7 +77,7 @@ public strictfp class ReferencingAssert
if (code == 0) {
assertTrue("identifiers.isEmpty()", identifiers.isEmpty());
} else {
- assertEquals("identifier", HardCoded.EPSG +
DefaultNameSpace.DEFAULT_SEPARATOR + code,
+ assertEquals("identifier", Constants.EPSG +
DefaultNameSpace.DEFAULT_SEPARATOR + code,
IdentifiedObjects.toString(TestUtilities.getSingleton(identifiers)));
}
}
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -45,16 +45,6 @@ import java.util.Objects;
*/
public final class Citations extends Static {
/**
- * The {@value} code space.
- */
- public static final String OGC = "OGC";
-
- /**
- * The {@value} code space.
- */
- public static final String EPSG = "EPSG";
-
- /**
* Do not allows instantiation of this class.
*/
private Citations() {
Copied:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
(from r1660664,
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java?p2=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java&r1=1660664&r2=1661029&rev=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -14,40 +14,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.referencing;
+package org.apache.sis.internal.util;
import org.apache.sis.util.Static;
-import org.apache.sis.internal.util.Citations;
/**
* Hard coded values (typically identifiers).
+ * The set of constants defined in this class may change in any SIS version -
do not rely on them.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
* @version 0.6
* @module
*/
-public final class HardCoded extends Static {
+public final class Constants extends Static {
/**
* The {@value} code space.
*/
- public static final String EPSG = Citations.EPSG;
-
- /**
- * Name of the {@value} projection parameter, which is handled specially
during WKT formatting.
- */
- public static final String SEMI_MAJOR = "semi_major", SEMI_MINOR =
"semi_minor";
+ public static final String EPSG = "EPSG";
/**
* The {@value} code space.
*/
- public static final String SIS = "SIS";
+ public static final String OGC = "OGC";
/**
* The {@value} code space.
*/
- public static final String OGC = Citations.OGC;
+ public static final String SIS = "SIS";
/**
* The {@value} code space.
@@ -70,6 +65,16 @@ public final class HardCoded extends Sta
public static final byte CRS84 = 84;
/**
+ * Name of the {@value} projection parameter, which is handled specially
during WKT formatting.
+ */
+ public static final String SEMI_MAJOR = "semi_major", SEMI_MINOR =
"semi_minor";
+
+ /**
+ * Name of the {@value} matrix parameters.
+ */
+ public static final String NUM_ROW = "num_row", NUM_COL = "num_col";
+
+ /**
* EPSG code of the {@code A0} coefficient used in affine (general
parametric) and polynomial transformations.
* Codes for parameters {@code A1} to {@code A8} inclusive follow, but the
affine coefficients stop at {@code A2}.
*/
@@ -84,6 +89,6 @@ public final class HardCoded extends Sta
/**
* Do not allow instantiation of this class.
*/
- private HardCoded() {
+ private Constants() {
}
}
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -32,7 +32,7 @@ import org.apache.sis.util.Exceptions;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.util.DefinitionURI;
-import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.util.XPaths;
import static java.lang.Math.PI;
@@ -356,7 +356,7 @@ public final class Units extends Static
* we want to try to parse as a xpointer before to give up.
*/
if (isURI(uom)) {
- String code = DefinitionURI.codeOf("uom", Citations.EPSG, uom);
+ String code = DefinitionURI.codeOf("uom", Constants.EPSG, uom);
if (code != null && code != uom) try { // Really identity check,
see above comment.
return valueOfEPSG(Integer.parseInt(code));
} catch (NumberFormatException e) {
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -27,7 +27,7 @@ import org.opengis.util.TypeName;
import org.opengis.util.NameSpace;
import org.opengis.util.NameFactory;
import org.opengis.util.InternationalString;
-import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.Numbers;
@@ -81,7 +81,7 @@ final class TypeNames {
* Creates a new factory of type names.
*/
TypeNames(final NameFactory factory) {
- ogcNS = factory.createNameSpace(factory.createLocalName(null,
Citations.OGC), null);
+ ogcNS = factory.createNameSpace(factory.createLocalName(null,
Constants.OGC), null);
classNS = factory.createNameSpace(factory.createLocalName(null,
"class"), null);
}
@@ -158,7 +158,7 @@ final class TypeNames {
*/
static Class<?> toClass(final String namespace, final String name) throws
ClassNotFoundException {
Class<?> c;
- if (namespace == null || namespace.equalsIgnoreCase(Citations.OGC)) {
+ if (namespace == null || namespace.equalsIgnoreCase(Constants.OGC)) {
c = MAPPING.get(name);
if (c == null) {
c = Types.forStandardName(name);
Modified:
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java?rev=1661029&r1=1661028&r2=1661029&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
[UTF-8] Thu Feb 19 22:54:05 2015
@@ -23,7 +23,7 @@ import org.junit.Test;
import static org.opengis.test.Validators.*;
import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.internal.util.Citations.EPSG;
+import static org.apache.sis.internal.util.Constants.EPSG;
import static
org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR_STRING;