Author: desruisseaux
Date: Mon Feb 16 23:28:06 2015
New Revision: 1660249
URL: http://svn.apache.org/r1660249
Log:
Ported the "Affine" operation method.
This is our first provider ported to SIS - we are comming closer to a working
MathTransform factory providing real coordinate operations support.
Added:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
(with props)
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
(with props)
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
Added:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java?rev=1660249&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
(added)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] Mon Feb 16 23:28:06 2015
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing.provider;
+
+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.apache.sis.referencing.operation.DefaultOperationMethod;
+import org.apache.sis.referencing.operation.transform.MathTransformProvider;
+import org.apache.sis.util.ArgumentChecks;
+
+
+/**
+ * Base class for all providers defined in this package.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+abstract class AbstractProvider extends DefaultOperationMethod implements
MathTransformProvider {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 2239172887926695217L;
+
+ /**
+ * Constructs a math transform provider from a set of parameters. The
provider name and
+ * {@linkplain #getIdentifiers() identifiers} will be the same than the
parameter ones.
+ *
+ * @param sourceDimension Number of dimensions in the source CRS of this
operation method.
+ * @param targetDimension Number of dimensions in the target CRS of this
operation method.
+ * @param parameters The set of parameters (never {@code null}).
+ */
+ AbstractProvider(final int sourceDimension,
+ final int targetDimension,
+ final ParameterDescriptorGroup parameters)
+ {
+ super(toMap(parameters), sourceDimension, targetDimension, parameters);
+ }
+
+ /**
+ * Work around for RFE #4093999 in Sun's bug database
+ * ("Relax constraint on placement of this()/super() call in
constructors").
+ */
+ private static Map<String,Object> toMap(final IdentifiedObject parameters)
{
+ ArgumentChecks.ensureNonNull("parameters", parameters);
+ final Map<String,Object> properties = new HashMap<>(4);
+ properties.put(NAME_KEY, parameters.getName());
+ final Collection<Identifier> identifiers = parameters.getIdentifiers();
+ int size = identifiers.size();
+ if (size != 0) {
+ properties.put(IDENTIFIERS_KEY, identifiers.toArray(new
Identifier[size]));
+ }
+ final Collection<GenericName> aliases = parameters.getAlias();
+ size = aliases.size();
+ if (size != 0) {
+ properties.put(ALIAS_KEY, aliases.toArray(new GenericName[size]));
+ }
+ return properties;
+ }
+}
Propchange:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java?rev=1660249&r1=1660248&r2=1660249&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] Mon Feb 16 23:28:06 2015
@@ -18,10 +18,162 @@ package org.apache.sis.internal.referenc
import java.util.Map;
import java.util.Collections;
+import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.ParameterNotFoundException;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.operation.Conversion;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.OperationMethod;
+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.transform.MathTransforms;
-public abstract class Affine implements
org.opengis.referencing.operation.OperationMethod {
- public static Map<String,Object> IDENTIFICATION =
Collections.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
+ * {@value
org.geotoolkit.parameter.MatrixParameterDescriptors#DEFAULT_MATRIX_SIZE}×{@value
+ * org.geotoolkit.parameter.MatrixParameterDescriptors#DEFAULT_MATRIX_SIZE} by
default.
+ *
+ * <table class="sis">
+ * <caption>{@code Affine} parameters</caption>
+ * <tr><th>Parameter name</th><th>Default value</th></tr>
+ * <tr><td>{@code num_row}</td><td>3</td></tr>
+ * <tr><td>{@code num_col}</td><td>3</td></tr>
+ * <tr><td>{@code elt_0_0}</td><td>1</td></tr>
+ * <tr><td>{@code elt_0_1}</td><td>0</td></tr>
+ * <tr><td>{@code elt_0_2}</td><td>0</td></tr>
+ * <tr><td>{@code elt_1_0}</td><td>0</td></tr>
+ * <tr><td>{@code elt_1_1}</td><td>1</td></tr>
+ * <tr><td>{@code elt_1_2}</td><td>0</td></tr>
+ * <tr><td>{@code elt_2_0}</td><td>0</td></tr>
+ * <tr><td>{@code elt_2_1}</td><td>0</td></tr>
+ * <tr><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 default matrix size.
+ */
+ private static final int DEFAULT_MATRIX_SIZE = 3;
+
+ /**
+ * The set of predefined providers.
+ */
+ private static final Affine[] methods = new Affine[8];
+
+ /**
+ * The name, aliases and identifiers of the "Affine" method.
+ */
+ public static final Map<String,?> IDENTIFICATION =
+ Collections.singletonMap(NAME_KEY, new
NamedIdentifier(Citations.OGC, "Affine"));
+
+ /**
+ * The group of all parameters expected by this coordinate operation.
+ */
+ public static final ParameterDescriptorGroup PARAMETERS;
+ static {
+ final int[] indices = new int[2]; // The length of this array is the
number of tensor dimensions.
+ @SuppressWarnings("rawtypes")
+ final ParameterDescriptor<?>[] parameters =
+ new ParameterDescriptor[indices.length + (DEFAULT_MATRIX_SIZE
* DEFAULT_MATRIX_SIZE)];
+ int k = 0;
+ do {
+ parameters[k] = TensorParameters.WKT1.getDimensionDescriptor(k);
+ } while (++k < indices.length);
+ for (int j=0; j<DEFAULT_MATRIX_SIZE; j++) {
+ for (int i=0; i<DEFAULT_MATRIX_SIZE; i++) {
+ indices[0] = j;
+ indices[1] = i;
+ parameters[k++] =
TensorParameters.WKT1.getElementDescriptor(indices);
+ }
+ }
+ PARAMETERS = new DefaultParameterDescriptorGroup(IDENTIFICATION, 1, 1,
parameters);
+ }
+
+ /**
+ * Creates a provider for affine transform with a default matrix size.
+ */
+ public Affine() {
+ this(DEFAULT_MATRIX_SIZE - 1, DEFAULT_MATRIX_SIZE - 1);
+ methods[DEFAULT_MATRIX_SIZE - 2] = this;
+ }
+
+ /**
+ * Creates a provider for affine transform with the specified dimensions.
+ */
+ private Affine(final int sourceDimension, final int targetDimension) {
+ super(sourceDimension, targetDimension, PARAMETERS);
+ }
+
+ /**
+ * 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 {
+ 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);
+ }
+
+ /**
+ * Returns the operation method for the specified source and target
dimensions.
+ * This method provides different sourceDimensions for different matrix
sizes.
+ *
+ * @param sourceDimensions The number of source dimensions.
+ * @param targetDimensions The number of target dimensions.
+ * @return The provider for transforms of the given source and target
dimensions.
+ */
+ public static Affine getProvider(final int sourceDimensions, final int
targetDimensions) {
+ if (sourceDimensions == targetDimensions) {
+ final int i = sourceDimensions - 1;
+ if (i >= 0 && i < methods.length) {
+ synchronized (Affine.class) {
+ Affine method = methods[i];
+ if (method == null) {
+ methods[i] = method = new Affine(sourceDimensions,
targetDimensions);
+ }
+ return method;
+ }
+ }
+ }
+ return new Affine(sourceDimensions, targetDimensions);
+ }
}
Added:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java?rev=1660249&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
(added)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
[UTF-8] Mon Feb 16 23:28:06 2015
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing.provider;
+
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.citation.Citation;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.util.resources.Vocabulary;
+
+
+/**
+ * A reference identifier for EPSG or GeoTiff codes.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+final class IdentifierCode extends ImmutableIdentifier {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 357222258307746767L;
+
+ /**
+ * If this identifier is deprecated, the identifier that supersede this
one.
+ * Otherwise {@code 0}.
+ */
+ final int supersededBy;
+
+ /**
+ * Creates a new identifier for the given authority.
+ *
+ * @param authority Organization for definition and maintenance of the
code space or code.
+ * @param code Identifier code from the authority.
+ */
+ IdentifierCode(final Citation authority, final int code) {
+ this(authority, code, 0);
+ }
+
+ /**
+ * Creates a deprecated identifier for the given authority.
+ *
+ * @param authority Organization for definition and maintenance of the
code space or code.
+ * @param code Identifier code from the authority.
+ * @param supersededBy The code that replace this one.
+ */
+ IdentifierCode(final Citation authority, final int code, final int
supersededBy) {
+ super(authority, codespace(authority), Integer.toString(code), null,
remarks(supersededBy));
+ this.supersededBy = supersededBy;
+ }
+
+ /**
+ * Returns the code space for the given authority.
+ */
+ private static String codespace(final Citation authority) {
+ return authority.getIdentifiers().iterator().next().getCode();
+ }
+
+ /**
+ * formats a "Superseded by" international string.
+ */
+ private static InternationalString remarks(final int supersededBy) {
+ if (supersededBy == 0) {
+ return null;
+ }
+ return Vocabulary.formatInternational(Vocabulary.Keys.SupersededBy_1,
supersededBy);
+ }
+
+ /**
+ * Returns {@code true} if this code is deprecated.
+ */
+ @Override
+ public boolean isDeprecated() {
+ return supersededBy != 0;
+ }
+}
Propchange:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1660249&r1=1660248&r2=1660249&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Mon Feb 16 23:28:06 2015
@@ -371,6 +371,11 @@ public final class Vocabulary extends In
public static final short StandardDeviation = 51;
/**
+ * Superseded by {0}.
+ */
+ public static final short SupersededBy_1 = 84;
+
+ /**
* Temporal
*/
public static final short Temporal = 66;
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1660249&r1=1660248&r2=1660249&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Mon Feb 16 23:28:06 2015
@@ -77,6 +77,7 @@ RootMeanSquare = Root Mean Squa
Scale = Scale
Source = Source
StandardDeviation = Standard deviation
+SupersededBy_1 = Superseded by {0}.
TemporaryFiles = Temporary files
Temporal = Temporal
Time = Time
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1660249&r1=1660248&r2=1660249&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Mon Feb 16 23:28:06 2015
@@ -77,6 +77,7 @@ RootMeanSquare = Moyenne quadra
Scale = \u00c9chelle
Source = Source
StandardDeviation = \u00c9cart type
+SupersededBy_1 = Remplac\u00e9 par {0}.
TemporaryFiles = Fichiers temporaires
Temporal = Temporel
Time = Temps