Author: desruisseaux
Date: Sun Feb 22 23:38:34 2015
New Revision: 1661582
URL: http://svn.apache.org/r1661582
Log:
Merge from the JDK6 branch: first complete provider for "Affine general
parametric transformation" (EPSG:9624).
This is our first OperationMethod provider in Apache SIS (the framework by
which we will get our map projections).
Added:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
- copied, changed from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/EPSGName.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/EPSGName.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/package-info.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/package-info.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/
- copied from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
- copied, changed from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransformProvider.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransformProvider.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/
- copied from r1661579,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersAlphaNumTest.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersAlphaNumTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/OperationMethodSetTest.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/OperationMethodSetTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
- copied unchanged from r1661579,
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
Removed:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
Modified:
sis/trunk/ (props changed)
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LogarithmicTransform1D.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/package-info.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/LocalizedStaticObject.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/simple/SimpleIdentifierTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/VersionTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypeNamesTest.java
sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 22 23:38:34 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK6:1394364-1657935
-/sis/branches/JDK7:1394913-1657931
-/sis/branches/JDK8:1584960-1657929
+/sis/branches/JDK6:1394364-1661579
+/sis/branches/JDK7:1394913-1661574
+/sis/branches/JDK8:1584960-1661572
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
[UTF-8] Sun Feb 22 23:38:34 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/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Sun Feb 22 23:38:34 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.ReferenceIdentifier;
import org.opengis.referencing.ReferenceSystem;
@@ -66,6 +67,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;
@@ -620,6 +622,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);
@@ -867,7 +871,7 @@ public class Formatter implements Locali
final Matrix matrix =
ReferencingServices.getInstance().getMatrix(transform);
if (matrix != null) {
openElement(true, "Param_MT");
-
buffer.appendCodePoint(symbols.getOpeningQuote(0)).append("Affine")
+
buffer.appendCodePoint(symbols.getOpeningQuote(0)).append(Constants.AFFINE)
.appendCodePoint(symbols.getClosingQuote(0));
indent(+1);
append(matrix);
@@ -899,7 +903,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/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -1231,6 +1231,6 @@ class PropertyAccessor {
if (type != implementation) {
buffer.append(':').append(Classes.getShortName(type));
}
- return buffer.append(" from
“").append(Citations.getIdentifier(standard)).append("”]").toString();
+ return buffer.append(" from
“").append(Citations.getIdentifier(standard, false)).append("”]").toString();
}
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -22,7 +22,7 @@ import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.citation.Citation;
-import org.opengis.parameter.InvalidParameterValueException;
+import org.opengis.parameter.ParameterValue;
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.util.InternationalString;
import org.apache.sis.util.Deprecable;
@@ -123,7 +123,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*
* @see DefaultIdentifier
@@ -338,8 +338,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);
@@ -366,7 +365,7 @@ public class ImmutableIdentifier extends
*/
value = properties.get(CODESPACE_KEY);
if (value == null && !properties.containsKey(CODESPACE_KEY)) {
- codeSpace = getCodeSpace(authority);
+ codeSpace =
org.apache.sis.internal.util.Citations.getUnicodeIdentifier(authority);
} else if (value instanceof String) {
codeSpace = trimWhitespaces((String) value);
} else {
@@ -451,37 +450,6 @@ public class ImmutableIdentifier extends
}
/**
- * Infers a code space from the given authority. First, this method takes
a short identifier or title with
- * preference for Unicode identifier - see {@link
Citations#getIdentifier(Citation)} for more information.
- * Next this method applies additional restrictions in order to reduce the
risk of undesired code space.
- * Those restrictions are arbitrary and may change in any future SIS
version. Currently, the restriction
- * is to accept only letters or digits.
- *
- * @param authority The authority for which to get a code space.
- * @return The code space, or {@code null} if none.
- *
- * @see Citations#getIdentifier(Citation)
- */
- private static String getCodeSpace(final Citation authority) {
- final String codeSpace = Citations.getIdentifier(authority); //
Whitespaces trimed by Citations.
- if (codeSpace != null) {
- final int length = codeSpace.length();
- if (length != 0) {
- int i = 0;
- do {
- final int c = codeSpace.charAt(i);
- if (!Character.isLetterOrDigit(c)) {
- return null;
- }
- i += Character.charCount(c);
- } while (i < length);
- return codeSpace;
- }
- }
- return null;
- }
-
- /**
* Organization or party responsible for definition and maintenance of the
* {@linkplain #getCode() code}.
*
@@ -598,12 +566,8 @@ public class ImmutableIdentifier extends
protected String formatTo(final Formatter formatter) {
String keyword = null;
if (code != null) {
- String citation = Citations.getIdentifier(authority);
- String cs = codeSpace;
- if (cs == null) {
- cs = citation;
- citation = null;
- }
+ final String cs = (codeSpace != null) ? codeSpace :
+
org.apache.sis.internal.util.Citations.getIdentifier(authority, true);
if (cs != null) {
final Convention convention = formatter.getConvention();
if (convention.majorVersion() == 1) {
@@ -617,18 +581,35 @@ public class ImmutableIdentifier extends
if (version != null) {
appendCode(formatter, version);
}
- 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/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -17,11 +17,13 @@
package org.apache.sis.metadata.iso.citation;
import org.opengis.metadata.citation.Citation;
+import org.opengis.referencing.IdentifiedObject; // For javadoc
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
+import org.apache.sis.metadata.iso.DefaultIdentifier; // For javadoc
/**
@@ -38,7 +40,7 @@ import org.apache.sis.metadata.iso.Defau
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class Citations extends Static {
@@ -59,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.
@@ -77,7 +79,7 @@ public final class Citations extends Sta
*
* @since 0.4
*/
- public static final Citation SIS = new SimpleCitation("SIS");
+ public static final Citation SIS = new SimpleCitation(Constants.SIS);
/**
* The <a href="http://www.esri.com">ESRI</a> organization.
@@ -145,9 +147,7 @@ public final class Citations extends Sta
*
* @since 0.4
*/
- public static final IdentifierSpace<Integer> EPSG = new Authority<Integer>(
- org.apache.sis.internal.util.Citations.EPSG,
- org.apache.sis.internal.util.Citations.EPSG);
+ public static final IdentifierSpace<Integer> EPSG = new
Authority<Integer>(Constants.EPSG, Constants.EPSG);
/**
* <cite>International Standard Book Number</cite> (ISBN) defined by
ISO-2108.
@@ -219,8 +219,7 @@ public final class Citations extends Sta
*
* @param c1 The first citation to compare, or {@code null}.
* @param c2 the second citation to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and at least one
title or
- * alternate title matches.
+ * @return {@code true} if both arguments are non-null, and at least one
title or alternate title matches.
*/
public static boolean titleMatches(final Citation c1, final Citation c2) {
return org.apache.sis.internal.util.Citations.titleMatches(c1, c2);
@@ -234,10 +233,10 @@ public final class Citations extends Sta
*
* @param citation The citation to check for, or {@code null}.
* @param title The title or alternate title to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and the title or
alternate
+ * @return {@code true} if both arguments are non-null, and the title or
an alternate
* title matches the given string.
*/
- public static boolean titleMatches(final Citation citation, String title) {
+ public static boolean titleMatches(final Citation citation, final String
title) {
return org.apache.sis.internal.util.Citations.titleMatches(citation,
title);
}
@@ -256,10 +255,7 @@ public final class Citations extends Sta
*
* @param c1 The first citation to compare, or {@code null}.
* @param c2 the second citation to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and at least one
identifier,
- * title or alternate title matches.
- *
- * @see org.apache.sis.referencing.IdentifierMatching
+ * @return {@code true} if both arguments are non-null, and at least one
identifier matches.
*/
public static boolean identifierMatches(final Citation c1, final Citation
c2) {
return org.apache.sis.internal.util.Citations.identifierMatches(c1,
c2);
@@ -278,10 +274,7 @@ public final class Citations extends Sta
*
* @param citation The citation to check for, or {@code null}.
* @param identifier The identifier to compare, or {@code null}.
- * @return {@code true} if both arguments are non-null, and the title or
alternate title
- * matches the given string.
- *
- * @see org.apache.sis.referencing.IdentifierMatching
+ * @return {@code true} if both arguments are non-null, and an identifier
matches the given string.
*/
public static boolean identifierMatches(final Citation citation, final
String identifier) {
return
org.apache.sis.internal.util.Citations.identifierMatches(citation, null,
identifier);
@@ -289,8 +282,8 @@ public final class Citations extends Sta
/**
* Infers an identifier from the given citation, or returns {@code null}
if no identifier has been found.
- * This method is useful for extracting the namespace from an authority,
for example {@code "EPSG"}.
- * The implementation performs the following choices:
+ * This method is useful for extracting the namespace from an authority
(e.g. {@code "EPSG"})
+ * for display purpose. This method performs the following choices:
*
* <ul>
* <li>If the given citation is {@code null}, then this method returns
{@code null}.</li>
@@ -312,16 +305,57 @@ public final class Citations extends Sta
*
* <div class="note"><b>Note:</b>
* This method searches in alternate titles as a fallback because ISO
specification said
- * that those titles are often used for abbreviations.</div>
+ * that those titles are often used for abbreviations. However titles are
never searched
+ * if the given citation contains at least one identifier.</div>
*
- * This method ignores leading and trailing whitespaces of every character
sequences.
- * Null references, empty character sequences and sequences of whitespaces
only are ignored.
+ * This method ignores leading and trailing {@linkplain
Character#isWhitespace(int) whitespaces}
+ * in every character sequences. Null or empty trimmed character sequences
are ignored.
+ * This method does <em>not</em> remove {@linkplain
Character#isIdentifierIgnorable(int) ignorable characters}.
+ * The result is a string which is <em>likely</em>, but not guaranteed, to
be a valid XML or Unicode identifier.
+ * The returned string is useful when an "identifier-like" string is
desired for display or information purpose,
+ * but does not need to be a strictly valid identifier.
*
* @param citation The citation for which to get the identifier, or
{@code null}.
* @return A non-empty identifier for the given citation without leading
or trailing whitespaces,
* or {@code null} if the given citation is null or does not
declare any identifier or title.
*/
public static String getIdentifier(final Citation citation) {
- return org.apache.sis.internal.util.Citations.getIdentifier(citation);
+ return org.apache.sis.internal.util.Citations.getIdentifier(citation,
false);
+ }
+
+ /**
+ * Infers a valid Unicode identifier from the given citation, or returns
{@code null} if none.
+ * This method is useful for extracting the namespace from an authority
(e.g. {@code "EPSG"})
+ * for processing purpose. This method performs the following actions:
+ *
+ * <ul>
+ * <li>First, invoke {@link #getIdentifier(Citation)}.</li>
+ * <li>If the result of above method call is {@code null} or is not a
+ * {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier
valid Unicode identifier},
+ * then return {@code null}.</li>
+ * <li>Otherwise remove the {@linkplain
Character#isIdentifierIgnorable(int) ignorable characters},
+ * if any, and returns the result.</li>
+ * </ul>
+ *
+ * <div class="note"><b>Note:</b>
+ * examples of ignorable identifier characters are <cite>zero width
space</cite> or <cite>word joiner</cite>.
+ * Those characters are illegal in XML identifiers, and should therfore be
removed if the Unicode identifier
+ * may also be used as XML identifier.</div>
+ *
+ * If non-null, the result is suitable for use as a XML identifier except
for a few uncommon characters
+ * ({@code µ}, {@code ª} (feminine ordinal indicator), {@code º}
(masculine ordinal indicator) and {@code ⁔}).
+ *
+ * @param citation The citation for which to get the Unicode identifier,
or {@code null}.
+ * @return A non-empty Unicode identifier for the given citation without
leading or trailing whitespaces,
+ * or {@code null} if the given citation is null or does not have
any Unicode identifier or title.
+ *
+ * @see org.apache.sis.metadata.iso.ImmutableIdentifier
+ * @see
org.apache.sis.referencing.IdentifiedObjects#getUnicodeIdentifier(IdentifiedObject)
+ * @see org.apache.sis.util.CharSequences#isUnicodeIdentifier(CharSequence)
+ *
+ * @since 0.6
+ */
+ public static String getUnicodeIdentifier(final Citation citation) {
+ return
org.apache.sis.internal.util.Citations.getUnicodeIdentifier(citation);
}
}
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -23,6 +23,7 @@ import org.opengis.metadata.citation.OnL
import org.opengis.metadata.citation.PresentationForm;
import org.apache.sis.metadata.iso.DefaultIdentifier;
import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.util.Static;
import static java.util.Collections.singleton;
@@ -52,7 +53,7 @@ public final strictfp class HardCodedCit
final DefaultCitation c = new DefaultCitation("Open Geospatial
consortium");
c.setAlternateTitles(singleton(new SimpleInternationalString("OGC")));
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
- c.setIdentifiers(singleton(new DefaultIdentifier("OGC")));
+ c.setIdentifiers(singleton(new DefaultIdentifier(Constants.OGC)));
c.freeze();
OGC = c;
}
@@ -134,7 +135,7 @@ public final strictfp class HardCodedCit
final DefaultCitation c = new DefaultCitation("European Petroleum
Survey Group");
c.setAlternateTitles(singleton(new SimpleInternationalString("EPSG")));
c.setPresentationForms(singleton(PresentationForm.TABLE_DIGITAL));
- c.setIdentifiers(singleton(new DefaultIdentifier("EPSG")));
+ c.setIdentifiers(singleton(new DefaultIdentifier(Constants.EPSG)));
c.setCitedResponsibleParties(singleton(p));
c.freeze();
EPSG = c;
@@ -156,7 +157,7 @@ public final strictfp class HardCodedCit
*/
public static final DefaultCitation SIS;
static {
- final DefaultCitation c = new DefaultCitation("SIS");
+ final DefaultCitation c = new DefaultCitation(Constants.SIS);
c.freeze();
SIS = c;
}
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -23,7 +23,9 @@ import org.opengis.referencing.Reference
import org.apache.sis.io.wkt.Symbols;
import org.apache.sis.io.wkt.WKTFormat;
import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.internal.util.Citations;
+import org.apache.sis.metadata.iso.citation.Citations;
+
+import static org.apache.sis.internal.util.Constants.EPSG;
/**
@@ -66,8 +68,8 @@ public strictfp class MetadataAssert ext
public static void assertEpsgIdentifierEquals(final String expected, final
Identifier identifier) {
assertNotNull(identifier);
assertEquals("code", expected, identifier.getCode());
- assertEquals("codeSpace", Citations.EPSG, (identifier instanceof
ReferenceIdentifier) ? ((ReferenceIdentifier) identifier).getCodeSpace() :
null);
- assertEquals("authority", "OGP",
Citations.getIdentifier(identifier.getAuthority()));
+ assertEquals("codeSpace", EPSG, (identifier instanceof
ReferenceIdentifier) ? ((ReferenceIdentifier) identifier).getCodeSpace() :
null);
+ assertEquals("authority", "OGP",
Citations.getIdentifier(identifier.getAuthority()));
}
/**
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
[UTF-8] Sun Feb 22 23:38:34 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/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
[UTF-8] Sun Feb 22 23:38:34 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/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -26,6 +26,8 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.metadata.iso.citation.Citations;
+import static org.apache.sis.internal.util.Citations.getUnicodeIdentifier;
+
/**
* The {@code gml:CodeType}, which is made of a code space and a code value.
@@ -156,7 +158,7 @@ public final class Code {
final String urn =
DefinitionURI.format(NameMeaning.toObjectType(type), fallback);
if (urn != null) {
final Code code = new Code();
- code.codeSpace =
Citations.getIdentifier(fallback.getAuthority());
+ code.codeSpace =
getUnicodeIdentifier(fallback.getAuthority());
code.code = urn;
return code;
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -31,7 +31,7 @@ import static org.apache.sis.internal.me
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class Formulas extends Static {
@@ -43,7 +43,7 @@ public final class Formulas extends Stat
* @see #ANGULAR_TOLERANCE
* @see org.apache.sis.internal.util.Numerics#COMPARISON_THRESHOLD
*/
- public static final double LINEAR_TOLERANCE = 1.0;
+ public static final double LINEAR_TOLERANCE = 0.01;
/**
* Default tolerance threshold for comparing ordinate values in a
geographic CRS,
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -24,6 +24,7 @@ import org.opengis.annotation.UML;
import org.opengis.annotation.Specification;
import org.opengis.referencing.cs.*;
import org.opengis.referencing.crs.*;
+import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.PrimeMeridian;
import org.apache.sis.util.Static;
import org.apache.sis.util.Utilities;
@@ -49,7 +50,7 @@ import static org.apache.sis.internal.ut
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class ReferencingUtilities extends Static {
@@ -167,6 +168,27 @@ public final class ReferencingUtilities
}
/**
+ * Returns the ellipsoid used by the specified coordinate reference
system, providing that
+ * the two first dimensions use an instance of {@link GeographicCRS}.
Otherwise (i.e. if the
+ * two first dimensions are not geographic), returns {@code null}.
+ *
+ * @param crs The coordinate reference system for which to get the
ellipsoid.
+ * @return The ellipsoid in the given CRS, or {@code null} if none.
+ *
+ * @since 0.6
+ */
+ public static Ellipsoid
getEllipsoidOfGeographicCRS(CoordinateReferenceSystem crs) {
+ while (!(crs instanceof GeographicCRS)) {
+ if (crs instanceof CompoundCRS) {
+ crs = ((CompoundCRS) crs).getComponents().get(0);
+ } else {
+ return null;
+ }
+ }
+ return ((GeographicCRS) crs).getDatum().getEllipsoid();
+ }
+
+ /**
* Derives a geographic CRS with (<var>longitude</var>,
<var>latitude</var>) axis order in decimal degrees.
* If no such CRS can be obtained or created, returns {@code null}.
*
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -27,7 +27,6 @@ import org.opengis.referencing.operation
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.parameter.Parameterized;
-import org.apache.sis.parameter.TensorParameters;
import org.apache.sis.referencing.operation.matrix.Matrix2;
import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
import org.apache.sis.referencing.operation.transform.LinearTransform;
@@ -192,7 +191,7 @@ public class AffineTransform2D extends I
*/
@Override
public ParameterDescriptorGroup getParameterDescriptors() {
- return Affine.PARAMETERS;
+ return Affine.getProvider(2, 2, true).getParameters();
}
/**
@@ -202,7 +201,7 @@ public class AffineTransform2D extends I
*/
@Override
public ParameterValueGroup getParameterValues() {
- return TensorParameters.WKT1.createValueGroup(Affine.IDENTIFICATION,
getMatrix());
+ return Affine.parameters(matrix);
}
/**
@@ -411,6 +410,10 @@ public class AffineTransform2D extends I
return true;
}
+ /*
+ * Intentionally no hashCode() method. See equals(Object) for explanation.
+ */
+
/**
* Returns a new affine transform which is a modifiable copy of this
transform. This implementation always
* returns an instance of {@link AffineTransform}, <strong>not</strong>
{@code AffineTransform2D}, because
Copied:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
(from r1661579,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java)
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java?p2=sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java&p1=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java&r1=1661579&r2=1661582&rev=1661582&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -20,9 +20,9 @@ import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import org.opengis.util.GenericName;
-import org.opengis.metadata.Identifier;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.ReferenceIdentifier;
import org.apache.sis.referencing.operation.DefaultOperationMethod;
import org.apache.sis.referencing.operation.transform.MathTransformProvider;
import org.apache.sis.util.ArgumentChecks;
@@ -81,10 +81,10 @@ abstract class AbstractProvider extends
ArgumentChecks.ensureNonNull("parameters", parameters);
final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(NAME_KEY, parameters.getName());
- final Collection<Identifier> identifiers = parameters.getIdentifiers();
+ final Collection<ReferenceIdentifier> identifiers =
parameters.getIdentifiers();
int size = identifiers.size();
if (size != 0) {
- properties.put(IDENTIFIERS_KEY, identifiers.toArray(new
Identifier[size]));
+ properties.put(IDENTIFIERS_KEY, identifiers.toArray(new
ReferenceIdentifier[size]));
}
final Collection<GenericName> aliases = parameters.getAlias();
size = aliases.size();
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -17,11 +17,277 @@
package org.apache.sis.internal.referencing.provider;
import java.util.Map;
+import java.util.Arrays;
import java.util.Collections;
-import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterNotFoundException;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.Conversion;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+import org.apache.sis.parameter.TensorParameters;
+import org.apache.sis.referencing.NamedIdentifier;
+import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
-public abstract class Affine implements
org.opengis.referencing.operation.OperationMethod {
- public static Map<String,Object> IDENTIFICATION =
Collections.<String,Object>singletonMap(NAME_KEY, "Affine");
- public static ParameterDescriptorGroup PARAMETERS; // TODO
+/**
+ * The provider for "<cite>Affine general parametric transformation</cite>"
(EPSG:9624).
+ * The set of available parameters depends on the matrix size, which is 3×3 by
default.
+ *
+ * <table class="sis">
+ * <caption>{@code Affine} parameters</caption>
+ * <tr><th>EPSG code</th><th>EPSG name</th><th>OGC name</th><th>Default
value</th></tr>
+ * <tr><td> </td> <td> </td> <td>{@code num_row}</td>
<td>3</td></tr>
+ * <tr><td> </td> <td> </td> <td>{@code num_col}</td>
<td>3</td></tr>
+ * <tr><td>8623</td> <td>{@code A0}</td> <td>{@code elt_0_0}</td>
<td>1</td></tr>
+ * <tr><td>8624</td> <td>{@code A1}</td> <td>{@code elt_0_1}</td>
<td>0</td></tr>
+ * <tr><td>8625</td> <td>{@code A2}</td> <td>{@code elt_0_2}</td>
<td>0</td></tr>
+ * <tr><td>8639</td> <td>{@code B0}</td> <td>{@code elt_1_0}</td>
<td>0</td></tr>
+ * <tr><td>8640</td> <td>{@code B1}</td> <td>{@code elt_1_1}</td>
<td>1</td></tr>
+ * <tr><td>8641</td> <td>{@code B2}</td> <td>{@code elt_1_2}</td>
<td>0</td></tr>
+ * <tr><td> </td> <td> </td> <td>{@code elt_2_0}</td>
<td>0</td></tr>
+ * <tr><td> </td> <td> </td> <td>{@code elt_2_1}</td>
<td>0</td></tr>
+ * <tr><td> </td> <td> </td> <td>{@code elt_2_2}</td>
<td>1</td></tr>
+ * </table>
+ *
+ * @author Martin Desruisseaux (IRD, Geomatys)
+ * @since 0.5
+ * @version 0.6
+ * @module
+ */
+public final class Affine extends AbstractProvider {
+ /**
+ * Serial number for inter-operability with different versions.
+ */
+ private static final long serialVersionUID = 649555815622129472L;
+
+ /**
+ * The operation method name as defined in the EPSG database.
+ * Must matches exactly the EPSG name (this will be verified by JUnit
tests).
+ *
+ * <p>Note: in contrast, the name used by OGC is just "Affine".</p>
+ *
+ * @see org.apache.sis.internal.util.Constants#AFFINE
+ */
+ public static final String NAME = "Affine general parametric
transformation";
+
+ /**
+ * The EPSG:9624 compliant instance, created when first needed.
+ */
+ private static volatile Affine EPSG_METHOD;
+
+ /**
+ * The number of dimensions used by the EPSG:9624 definition. This will be
used as the
+ * default number of dimensions. Operation methods of other dimensions,
where we have
+ * no EPSG definition, shall use the Well Known Text (WKT) parameter names.
+ */
+ public static final int EPSG_DIMENSION = 2;
+
+ /**
+ * The maximal number of dimensions to be cached. Descriptors having more
than
+ * this amount of dimensions will be recreated every time they are
requested.
+ */
+ private static final int MAX_CACHED_DIMENSION = 6;
+
+ /**
+ * Cached providers for methods of dimension 1×1 to {@link
#MAX_CACHED_DIMENSION}.
+ * The index of each element is computed by {@link #cacheIndex(int, int)}.
+ * All usages of this array shall be synchronized on {@code cached}.
+ */
+ private static final Affine[] cached = new Affine[MAX_CACHED_DIMENSION *
MAX_CACHED_DIMENSION];
+
+ /**
+ * A map containing identification properties for creating {@code
OperationMethod} or
+ * {@code ParameterDescriptorGroup} instances.
+ */
+ private static final Map<String,?> IDENTIFICATION_EPSG, IDENTIFICATION_OGC;
+ static {
+ final NamedIdentifier nameOGC = new NamedIdentifier(Citations.OGC,
Constants.OGC, Constants.AFFINE, null, null);
+ IDENTIFICATION_OGC = Collections.singletonMap(NAME_KEY, nameOGC);
+ IDENTIFICATION_EPSG = EPSGName.properties(9624, NAME, nameOGC);
+ }
+
+ /**
+ * Creates a provider for affine transform with a default matrix size
(standard EPSG:9624 instance).
+ * This constructor is public for the needs of {@link
java.util.ServiceLoader} — do not invoke explicitely.
+ * If an instance of {@code Affine()} is desired, invoke {@code
getProvider(EPSG_DIMENSION, EPSG_DIMENSION)}
+ * instead.
+ *
+ * @see
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory
+ */
+ public Affine() {
+ super(IDENTIFICATION_EPSG, EPSG_DIMENSION, EPSG_DIMENSION, new
Descriptor(IDENTIFICATION_EPSG,
+ Arrays.copyOfRange( // Discards param 0 and 1, take only the
ones in index range [2…7].
+
TensorParameters.ALPHANUM.getAllDescriptors(EPSG_DIMENSION, EPSG_DIMENSION +
1), 2, 8)));
+ /*
+ * Do caching ourselves because this constructor is usually not
invoked by getProvider(int, int).
+ * It is usually invoked when DefaultMathTransformFactory scans the
classpath with a ServiceLoader.
+ * This normally happen only once, so this instance is probably the
unique instance to keep in the JVM.
+ */
+ EPSG_METHOD = this;
+ }
+
+ /**
+ * Creates a provider for affine transform with the specified dimensions.
+ * This is created when first needed by {@link #getProvider(int, int)}.
+ *
+ * @see #getProvider(int, int)
+ */
+ private Affine(final int sourceDimensions, final int targetDimensions) {
+ super(IDENTIFICATION_OGC, sourceDimensions, targetDimensions, new
Descriptor(IDENTIFICATION_OGC,
+ TensorParameters.WKT1.getAllDescriptors(targetDimensions + 1,
sourceDimensions + 1)));
+ }
+
+ /**
+ * The parameter descriptor to be returned by {@link
Affine#getParameters()}.
+ * The only purpose of this class is to override the {@link
#createValue()} method.
+ */
+ private static final class Descriptor extends
DefaultParameterDescriptorGroup {
+ /** For cross-version compatibility. */
+ private static final long serialVersionUID = 8320799650519834830L;
+
+ /** Creates a new descriptor for the given parameters. */
+ Descriptor(final Map<String,?> properties, final
ParameterDescriptor<?>[] parameters) {
+ super(properties, 1, 1, parameters);
+ }
+
+ /**
+ * Returns default parameter values for the "Affine" operation.
Unconditionally use the WKT1 parameter names,
+ * regardless of whether this descriptor is for the EPSG:9624 case,
because the caller is free to change the
+ * matrix size, in which case (strictly speaking) the parameters would
no longer be for EPSG:9624 operation.
+ */
+ @Override
+ public ParameterValueGroup createValue() {
+ return TensorParameters.WKT1.createValueGroup(IDENTIFICATION_OGC);
+ }
+ }
+
+ /**
+ * Returns the type of operations created by this provider.
+ *
+ * @return Always {@code Conversion.class} for this provider.
+ */
+ @Override
+ public Class<Conversion> getOperationType() {
+ return Conversion.class;
+ }
+
+ /**
+ * Creates a projective transform from the specified group of parameter
values.
+ *
+ * @param values The group of parameter values.
+ * @return The created math transform.
+ * @throws ParameterNotFoundException if a required parameter was not
found.
+ */
+ @Override
+ public MathTransform createMathTransform(final ParameterValueGroup values)
throws ParameterNotFoundException {
+ /*
+ * The TensorParameters constant used below (WKT1 or EPSG) does not
matter,
+ * since both of them understand the names of the other
TensorParameters.
+ */
+ return MathTransforms.linear(TensorParameters.WKT1.toMatrix(values));
+ }
+
+ /**
+ * Returns the same operation method, but for different dimensions.
+ *
+ * @param sourceDimensions The desired number of input dimensions.
+ * @param targetDimensions The desired number of output dimensions.
+ * @return The redimensioned operation method, or {@code this} if no
change is needed.
+ */
+ @Override
+ public OperationMethod redimension(final int sourceDimensions, final int
targetDimensions) {
+ return getProvider(sourceDimensions, targetDimensions, false);
+ }
+
+ /**
+ * Returns the index where to store a method of the given dimensions in
the {@link #cached} array,
+ * or -1 if it should not be cached.
+ */
+ private static int cacheIndex(int sourceDimensions, int targetDimensions) {
+ if (--sourceDimensions >= 0 && sourceDimensions < MAX_CACHED_DIMENSION
&&
+ --targetDimensions >= 0 && targetDimensions < MAX_CACHED_DIMENSION)
+ {
+ return sourceDimensions * MAX_CACHED_DIMENSION + targetDimensions;
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the operation method for the specified source and target
dimensions.
+ * This method provides different {@code Affine} instances for different
dimensions.
+ *
+ * @param sourceDimensions The number of source dimensions.
+ * @param targetDimensions The number of target dimensions.
+ * @param isAffine {@code true} if the transform is affine.
+ * @return The provider for transforms of the given source and target
dimensions.
+ */
+ public static Affine getProvider(final int sourceDimensions, final int
targetDimensions, final boolean isAffine) {
+ Affine method;
+ if (isAffine && sourceDimensions == EPSG_DIMENSION && targetDimensions
== EPSG_DIMENSION) {
+ /*
+ * Matrix complies with EPSG:9624 definition. This is the most
common case. We do perform synchronization
+ * for this field since it is okay if the same object is created
twice (they should be identical).
+ */
+ method = EPSG_METHOD;
+ if (method == null) {
+ method = new Affine();
+ }
+ } else {
+ /*
+ * All other cases. We will use the WKT1 parameter names instead
than the EPSG ones.
+ */
+ final int index = cacheIndex(sourceDimensions, targetDimensions);
+ if (index >= 0) {
+ synchronized (cached) {
+ method = cached[index];
+ }
+ if (method != null) {
+ return method;
+ }
+ }
+ /*
+ * At this point, no existing instance has been found in the cache.
+ * Create a new instance and cache it if its dimension is not too
large.
+ */
+ method = new Affine(sourceDimensions, targetDimensions);
+ if (index >= 0) {
+ synchronized (cached) {
+ final Affine other = cached[index]; // May have been
created in another thread.
+ if (other != null) {
+ return other;
+ }
+ cached[index] = method;
+ }
+ }
+ }
+ return method;
+ }
+
+ /**
+ * Returns the parameter values for the given matrix. This method is
invoked by implementations of
+ * {@link
org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterValues()}.
+ *
+ * @param matrix The matrix for which to get parameter values.
+ * @return The parameters of the given matrix.
+ */
+ public static ParameterValueGroup parameters(final Matrix matrix) {
+ final int sourceDimensions = matrix.getNumCol() - 1;
+ final int targetDimensions = matrix.getNumRow() - 1;
+ final TensorParameters<Double> parameters;
+ final Map<String,?> properties;
+ if (sourceDimensions == EPSG_DIMENSION && targetDimensions ==
EPSG_DIMENSION && Matrices.isAffine(matrix)) {
+ parameters = TensorParameters.ALPHANUM;
+ properties = IDENTIFICATION_EPSG;
+ } else {
+ parameters = TensorParameters.WKT1;
+ properties = IDENTIFICATION_OGC;
+ }
+ return parameters.createValueGroup(properties, matrix);
+ }
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -332,7 +332,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/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1661582&r1=1661581&r2=1661582&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] Sun Feb 22 23:38:34 2015
@@ -376,7 +376,8 @@ public class DefaultParameterValue<T> ex
*/
@Override
public double doubleValue(final Unit<?> unit) throws
IllegalArgumentException, IllegalStateException {
- return getConverterTo(unit).convert(doubleValue());
+ final double value = doubleValue(); // Invoke first in case it throws
an exception.
+ return getConverterTo(unit).convert(value);
}
/**
@@ -777,6 +778,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 {
@@ -791,8 +797,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";
}