Author: desruisseaux Date: Fri Nov 4 21:16:09 2016 New Revision: 1768102 URL: http://svn.apache.org/viewvc?rev=1768102&view=rev Log: Merge from JDK7 branch the addition of new units and the fix for performance problem in CRS.findOperation(...).
Modified: sis/trunk/ (props changed) sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultTransformation.java sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleAttributeType.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCharacterIterator.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleExtent.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/measure/LinearConverter.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitRegistry.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/measure/package-info.java sis/trunk/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitAliases.properties sis/trunk/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties sis/trunk/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java sis/trunk/pom.xml Propchange: sis/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Nov 4 21:16:09 2016 @@ -1,4 +1,4 @@ /sis/branches/Android:1430670-1480699 /sis/branches/JDK6:1394364-1758914 -/sis/branches/JDK7:1394913-1767562 -/sis/branches/JDK8:1584960-1767556 +/sis/branches/JDK7:1394913-1768097 +/sis/branches/JDK8:1584960-1768094 Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java [UTF-8] (original) +++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -62,13 +62,6 @@ final class OperationWrapper extends Pro */ @Override public PropertyTypeBuilder setMinimumOccurs(int occurs) {if (occurs == 1) return this; throw readOnly();} @Override public PropertyTypeBuilder setMaximumOccurs(int occurs) {if (occurs == 1) return this; throw readOnly();} - @Override @Deprecated - public PropertyTypeBuilder setCardinality(final int minimumOccurs, final int maximumOccurs) { - if (minimumOccurs != 1 || maximumOccurs != 1) { - throw readOnly(); - } - return this; - } /** * Do not allow modifications. Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java [UTF-8] (original) +++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -176,33 +176,6 @@ public abstract class PropertyTypeBuilde } /** - * Sets the minimum and maximum number of property values. Those numbers must be equal or greater than zero. - * - * <p>If this method is not invoked, then the default values are the cardinality specified by the last call - * to {@link FeatureTypeBuilder#setDefaultCardinality(int, int)} at the time this instance has been created. - * If the later method has not been invoked, then the default cardinality is [1 … 1].</p> - * - * @param minimumOccurs new minimum number of property values. - * @param maximumOccurs new maximum number of property values. - * @return {@code this} for allowing method calls chaining. - * - * @deprecated Replaced by {@link #setMinimumOccurs(int)} and {@link #setMaximumOccurs(int)}. - */ - @Deprecated - @SuppressWarnings("unchecked") - public PropertyTypeBuilder setCardinality(final int minimumOccurs, final int maximumOccurs) { - if (this.minimumOccurs != minimumOccurs || this.maximumOccurs != maximumOccurs) { - if (minimumOccurs < 0 || maximumOccurs < minimumOccurs) { - throw new IllegalArgumentException(errors().getString(Errors.Keys.IllegalRange_2, minimumOccurs, maximumOccurs)); - } - this.minimumOccurs = minimumOccurs; - this.maximumOccurs = maximumOccurs; - clearCache(); - } - return this; - } - - /** * Returns {@code true} if {@link AttributeRole#IDENTIFIER_COMPONENT} has been associated to this property. */ boolean isIdentifier() { Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java [UTF-8] (original) +++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/AttributeTypeBuilderTest.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -79,7 +79,7 @@ public final strictfp class AttributeTyp assertSame(builder, builder.setDesignation ("test designation")); assertSame(builder, builder.setDescription ("test description")); assertSame(builder, builder.setDefaultValue("test default value.")); - assertSame(builder, builder.setCardinality(10, 60)); + assertSame(builder, builder.setMinimumOccurs(10).setMaximumOccurs(60)); assertSame(builder, builder.setMaximalLength(80)); final DefaultAttributeType<?> att = builder.build(); Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java [UTF-8] (original) +++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/builder/FeatureTypeBuilderTest.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -84,7 +84,7 @@ public final strictfp class FeatureTypeB builder.addAttribute(String .class).setName("name"); builder.addAttribute(Integer.class).setName("age"); builder.addAttribute(Point .class).setName("location").setCRS(HardCodedCRS.WGS84); - builder.addAttribute(Double .class).setName("score").setDefaultValue(10.0).setCardinality(5, 50); + builder.addAttribute(Double .class).setName("score").setDefaultValue(10.0).setMinimumOccurs(5).setMaximumOccurs(50); final DefaultFeatureType type = builder.build(); assertEquals("name", "myScope:myName", type.getName().toString()); Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -119,14 +119,14 @@ public final class Envelopes extends Sta * A buckle method for calculating derivative and coordinate transformation in a single step, * if the given {@code derivative} argument is {@code true}. * - * @param transform The transform to use. - * @param srcPts The array containing the source coordinate at offset 0. - * @param dstPts the array into which the transformed coordinate is returned. - * @param dstOff The offset to the location of the transformed point that is stored in the destination array. - * @param derivate {@code true} for computing the derivative, or {@code false} if not needed. - * @return The matrix of the transform derivative at the given source position, + * @param transform the transform to use. + * @param srcPts the array containing the source coordinate at offset 0. + * @param dstPts the array into which the transformed coordinate is returned. + * @param dstOff the offset to the location of the transformed point that is stored in the destination array. + * @param derivate {@code true} for computing the derivative, or {@code false} if not needed. + * @return the matrix of the transform derivative at the given source position, * or {@code null} if the {@code derivate} argument is {@code false}. - * @throws TransformException If the point can not be transformed + * @throws TransformException if the point can not be transformed * or if a problem occurred while calculating the derivative. */ static Matrix derivativeAndTransform(final MathTransform transform, final double[] srcPts, @@ -152,10 +152,10 @@ public final class Envelopes extends Sta * to get the {@link CoordinateOperation} or {@link MathTransform} instance once and invoke one of the * others {@code transform(…)} methods. * - * @param envelope The envelope to transform (may be {@code null}). - * @param targetCRS The target CRS (may be {@code null}). - * @return A new transformed envelope, or directly {@code envelope} if no change was required. - * @throws TransformException If a transformation was required and failed. + * @param envelope the envelope to transform (may be {@code null}). + * @param targetCRS the target CRS (may be {@code null}). + * @return a new transformed envelope, or directly {@code envelope} if no change was required. + * @throws TransformException if a transformation was required and failed. * * @since 0.5 */ @@ -194,9 +194,9 @@ public final class Envelopes extends Sta * or when it crosses the ±180° longitude, because {@link MathTransform} does not carry sufficient information. * For a more robust envelope transformation, use {@link #transform(CoordinateOperation, Envelope)} instead. * - * @param transform The transform to use. - * @param envelope Envelope to transform, or {@code null}. This envelope will not be modified. - * @return The transformed envelope, or {@code null} if {@code envelope} was null. + * @param transform the transform to use. + * @param envelope envelope to transform, or {@code null}. This envelope will not be modified. + * @return the transformed envelope, or {@code null} if {@code envelope} was null. * @throws TransformException if a transform failed. * * @see #transform(CoordinateOperation, Envelope) @@ -214,9 +214,9 @@ public final class Envelopes extends Sta * Implementation of {@link #transform(MathTransform, Envelope)} with the opportunity to * save the projected center coordinate. * - * @param targetPt After this method call, the center of the source envelope projected to - * the target CRS. The length of this array must be the number of target dimensions. - * May be {@code null} if this information is not needed. + * @param targetPt after this method call, the center of the source envelope projected to the target CRS. + * The length of this array must be the number of target dimensions. + * May be {@code null} if this information is not needed. */ @SuppressWarnings("null") private static GeneralEnvelope transform(final MathTransform transform, @@ -426,9 +426,9 @@ public final class Envelopes extends Sta * of accuracy. In order to prevent this method from performing such pre-transformation (if not desired), * callers can ensure that the envelope CRS is {@code null} before to call this method.</div> * - * @param operation The operation to use. - * @param envelope Envelope to transform, or {@code null}. This envelope will not be modified. - * @return The transformed envelope, or {@code null} if {@code envelope} was null. + * @param operation the operation to use. + * @param envelope envelope to transform, or {@code null}. This envelope will not be modified. + * @return the transformed envelope, or {@code null} if {@code envelope} was null. * @throws TransformException if a transform failed. * * @see #transform(MathTransform, Envelope) @@ -742,9 +742,9 @@ public final class Envelopes extends Sta * See {@link GeneralEnvelope#GeneralEnvelope(CharSequence)} for more information about the * parsing rules. * - * @param wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse. - * @return The envelope of the given geometry. - * @throws FactoryException If the given WKT can not be parsed. + * @param wkt the {@code BOX}, {@code POLYGON} or other kind of element to parse. + * @return the envelope of the given geometry. + * @throws FactoryException if the given WKT can not be parsed. * * @see #toString(Envelope) * @see CRS#fromWKT(String) @@ -775,8 +775,8 @@ public final class Envelopes extends Sta * The string returned by this method can be {@linkplain GeneralEnvelope#GeneralEnvelope(CharSequence) * parsed} by the {@code GeneralEnvelope} constructor. * - * @param envelope The envelope to format. - * @return This envelope as a {@code BOX} or {@code BOX3D} (most typical dimensions) element. + * @param envelope the envelope to format. + * @return this envelope as a {@code BOX} or {@code BOX3D} (most typical dimensions) element. * * @see #fromWKT(CharSequence) * @see org.apache.sis.io.wkt @@ -793,8 +793,8 @@ public final class Envelopes extends Sta * <p>The string returned by this method can be {@linkplain GeneralEnvelope#GeneralEnvelope(CharSequence) * parsed} by the {@code GeneralEnvelope} constructor.</p> * - * @param envelope The envelope to format. - * @return The envelope as a {@code POLYGON} in WKT format. + * @param envelope the envelope to format. + * @return the envelope as a {@code POLYGON} in WKT format. * @throws IllegalArgumentException if the given envelope can not be formatted. * * @see org.apache.sis.io.wkt Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -73,13 +73,13 @@ import static org.apache.sis.util.Argume * // Constructs the list of parameters. * ParameterDescriptor<?>[] parameters = { * builder.addName("Latitude of natural origin") // Name in the default namespace ("EPSG" in this example). - * .createBounded( -80, +84, 0, Units.DEGREE), // Latitude of Mercator projection can not go to the poles. + * .createBounded( -80, +84, 0, Units.DEGREE), // Latitude of Mercator projection can not go to the poles. * * builder.addIdentifier("8802") // Primary key in default namespace ("EPSG" in this example). * .addName("Longitude of natural origin") // Primary name in default namespace ("EPSG" in this example). * .addName(Citations.OGC, "central_meridian") // First alias in "OGC" namespace. * .addName(Citations.GEOTIFF, "NatOriginLong") // Second alias in "GeoTIFF" namespace. - * .createBounded(-180, +180, 0, Units.DEGREE), // Projection is valid on all the longitude range (±180°). + * .createBounded(-180, +180, 0, Units.DEGREE), // Projection is valid on all the longitude range (±180°). * * builder.addName("Scale factor at natural origin") * .createStrictlyPositive(1, Units.UNITY), Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -19,6 +19,8 @@ package org.apache.sis.referencing.facto import java.util.Set; import java.util.Collections; import java.util.LinkedHashSet; +import java.util.logging.Level; +import java.util.logging.LogRecord; import org.opengis.util.GenericName; import org.opengis.util.FactoryException; import org.opengis.metadata.Identifier; @@ -165,7 +167,7 @@ public class IdentifiedObjectFinder { * this constructor is protected because instances of this class should not be created directly. * Use {@link GeodeticAuthorityFactory#newIdentifiedObjectFinder()} instead.</div> * - * @param factory The factory to scan for the identified objects. + * @param factory the factory to scan for the identified objects. * * @see GeodeticAuthorityFactory#newIdentifiedObjectFinder() */ @@ -182,7 +184,7 @@ public class IdentifiedObjectFinder { * <p>This method also copies the configuration of the given finder, thus providing a central place * where to add calls to setters methods if such methods are added in a future SIS version.</p> * - * @param other The cache or the adapter wrapping this finder. + * @param other the cache or the adapter wrapping this finder. */ final void setWrapper(final IdentifiedObjectFinder other) { wrapper = other; @@ -197,7 +199,7 @@ public class IdentifiedObjectFinder { * * <p>The default value is {@link Domain#VALID_DATASET}.</p> * - * @return The domain of the search. + * @return the domain of the search. */ public Domain getSearchDomain() { return domain; @@ -207,7 +209,7 @@ public class IdentifiedObjectFinder { * Sets the domain of the search (for example whether to include deprecated objects in the search). * If this method is never invoked, then the default value is {@link Domain#VALID_DATASET}. * - * @param domain The domain of the search. + * @param domain the domain of the search. */ public void setSearchDomain(final Domain domain) { ArgumentChecks.ensureNonNull("domain", domain); @@ -231,7 +233,7 @@ public class IdentifiedObjectFinder { * method may return a Coordinate Reference System object with (<var>latitude</var>, <var>longitude</var>) * axes even if the given object had (<var>longitude</var>, <var>latitude</var>) axes. * - * @param ignore {@code true} if the search should ignore coordinate system axes. + * @param ignore {@code true} if the search should ignore coordinate system axes. */ public void setIgnoringAxes(final boolean ignore) { ignoreAxes = ignore; @@ -259,7 +261,7 @@ public class IdentifiedObjectFinder { * This method will be invoked by {@link #find(IdentifiedObject)} * only if {@link #getSearchDomain()} is not {@link Domain#DECLARATION}. * - * @return The given {@code result}, or another set equal to the result if it has been computed + * @return the given {@code result}, or another set equal to the result if it has been computed * concurrently in another thread. */ Set<IdentifiedObject> cache(final IdentifiedObject object, Set<IdentifiedObject> result) { @@ -288,8 +290,8 @@ public class IdentifiedObjectFinder { * The created objects which are equal to the specified object in the * the sense of {@link ComparisonMode#APPROXIMATIVE} are returned. * - * @param object The object looked up. - * @return The identified objects, or an empty set if not found. + * @param object the object looked up. + * @return the identified objects, or an empty set if not found. * @throws FactoryException if an error occurred while creating an object. */ public Set<IdentifiedObject> find(final IdentifiedObject object) throws FactoryException { @@ -348,8 +350,8 @@ public class IdentifiedObjectFinder { * <li>Otherwise this method considers that there is ambiguity and returns {@code null}.</li> * </ul> * - * @param object The object looked up. - * @return The identified object, or {@code null} if none or ambiguous. + * @param object the object looked up. + * @return the identified object, or {@code null} if none or ambiguous. * @throws FactoryException if an error occurred while creating an object. */ public IdentifiedObject findSingleton(final IdentifiedObject object) throws FactoryException { @@ -385,8 +387,8 @@ public class IdentifiedObjectFinder { * * <p>This method may be used in order to get a fully identified object from a partially identified one.</p> * - * @param object The object looked up. - * @return The identified object, or {@code null} if not found. + * @param object the object looked up. + * @return the identified object, or {@code null} if not found. * @throws FactoryException if an error occurred while creating an object. * * @see #createFromCodes(IdentifiedObject) @@ -427,8 +429,8 @@ public class IdentifiedObjectFinder { * implementations like the one backed by the EPSG database, which are capable to find an object * from its name when the identifier is unknown.</p> * - * @param object The object looked up. - * @return The identified object, or {@code null} if not found. + * @param object the object looked up. + * @return the identified object, or {@code null} if not found. * @throws FactoryException if an error occurred while creating an object. * * @see #createFromCodes(IdentifiedObject) @@ -482,8 +484,8 @@ public class IdentifiedObjectFinder { * <code>{@linkplain #createFromNames createFromNames}(object)</code> before to fallback * on this method.</p> * - * @param object The object looked up. - * @return The identified object, or {@code null} if not found. + * @param object the object looked up. + * @return the identified object, or {@code null} if not found. * @throws FactoryException if an error occurred while scanning through authority codes. * * @see #createFromIdentifiers(IdentifiedObject) @@ -511,8 +513,8 @@ public class IdentifiedObjectFinder { * method implementation of for each code returned by the {@link #getCodeCandidates(IdentifiedObject)} method, * in iteration order. * - * @param code The authority code for which to create an object. - * @return The identified object for the given code, or {@code null} to stop attempts. + * @param code the authority code for which to create an object. + * @return the identified object for the given code, or {@code null} to stop attempts. * @throws FactoryException if an error occurred while creating the object. */ private IdentifiedObject create(final String code) throws FactoryException { @@ -537,8 +539,8 @@ public class IdentifiedObjectFinder { * where {@code type} is the interface specified at construction type. * Subclasses should override this method in order to return a smaller set, if they can. * - * @param object The object looked up. - * @return A set of code candidates. + * @param object the object looked up. + * @return a set of code candidates. * @throws FactoryException if an error occurred while fetching the set of code candidates. */ protected Set<String> getCodeCandidates(final IdentifiedObject object) throws FactoryException { @@ -549,6 +551,8 @@ public class IdentifiedObjectFinder { * Invoked when an exception occurred during the creation of a candidate from a code. */ private static void exceptionOccurred(final FactoryException exception) { - Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), IdentifiedObjectFinder.class, "find", exception); + final LogRecord record = new LogRecord(Level.FINER, exception.getLocalizedMessage()); + record.setLoggerName(Loggers.CRS_FACTORY); + Logging.log(IdentifiedObjectFinder.class, "find", record); } } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -48,7 +48,7 @@ import org.apache.sis.util.Debug; * * @author Martin Desruisseaux (IRD, Geomatys) * @since 0.7 - * @version 0.7 + * @version 0.8 * @module */ final class AuthorityCodes extends AbstractMap<String,String> implements Serializable { @@ -124,10 +124,10 @@ final class AuthorityCodes extends Abstr /** * Creates a new map of authority codes for the specified type. * - * @param connection The connection to the EPSG database. - * @param table The table to query. - * @param type The type to query. - * @param factory The factory originator. + * @param connection the connection to the EPSG database. + * @param table the table to query. + * @param type the type to query. + * @param factory the factory originator. */ AuthorityCodes(final Connection connection, final TableInfo table, final Class<?> type, final EPSGDataAccess factory) throws SQLException @@ -142,21 +142,7 @@ final class AuthorityCodes extends Abstr final int columnNameStart = buffer.append("SELECT ").length(); final int columnNameEnd = buffer.append(table.codeColumn).length(); buffer.append(" FROM ").append(table.table); - boolean hasWhere = false; - Class<?> tableType = table.type; - if (table.typeColumn != null) { - for (int i=0; i<table.subTypes.length; i++) { - final Class<?> candidate = table.subTypes[i]; - if (candidate.isAssignableFrom(type)) { - buffer.append(" WHERE (CAST(").append(table.typeColumn).append(" AS ").append(TableInfo.ENUM_REPLACEMENT) - .append(") LIKE '").append(table.typeNames[i]).append("%')"); - hasWhere = true; - tableType = candidate; - break; - } - } - } - buffer.append(hasWhere ? " AND " : " WHERE "); + final Class<?> tableType = table.where(type, buffer); final int conditionStart = buffer.length(); if (table.showColumn != null) { buffer.append(table.showColumn).append("<>0 AND "); @@ -204,8 +190,8 @@ final class AuthorityCodes extends Abstr /** * Returns the code at the given index, or -1 if the index is out of bounds. * - * @param index index of the code to fetch. - * @return The code at the given index, or -1 if out of bounds. + * @param index index of the code to fetch. + * @return the code at the given index, or -1 if out of bounds. * @throws SQLException if an error occurred while querying the database. */ private int getCodeAt(final int index) throws SQLException { @@ -273,8 +259,8 @@ final class AuthorityCodes extends Abstr * If there is no name for the {@linkplain #type} of object being queried, then this method * returns the code itself. * - * @param code The code for which to get the description. May be a string or an integer. - * @return The description for the given code, or {@code null} if none. + * @param code the code for which to get the description. May be a string or an integer. + * @return the description for the given code, or {@code null} if none. */ @Override public String get(final Object code) { Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -3082,11 +3082,13 @@ next: while (r.next()) { String from = "Coordinate Reference System"; final String where; final Set<Number> codes; + final TableInfo table; boolean isFloat = false; if (object instanceof Ellipsoid) { select = "ELLIPSOID_CODE"; from = "Ellipsoid"; where = "SEMI_MAJOR_AXIS"; + table = TableInfo.ELLIPSOID; codes = Collections.<Number>singleton(((Ellipsoid) object).getSemiMajorAxis()); isFloat = true; } else { @@ -3094,14 +3096,17 @@ next: while (r.next()) { if (object instanceof GeneralDerivedCRS) { dependency = ((GeneralDerivedCRS) object).getBaseCRS(); where = "SOURCE_GEOGCRS_CODE"; + table = TableInfo.CRS; } else if (object instanceof SingleCRS) { dependency = ((SingleCRS) object).getDatum(); where = "DATUM_CODE"; + table = TableInfo.CRS; } else if (object instanceof GeodeticDatum) { dependency = ((GeodeticDatum) object).getEllipsoid(); select = "DATUM_CODE"; from = "Datum"; where = "ELLIPSOID_CODE"; + table = TableInfo.DATUM; } else { // Not a supported type. Returns all codes. return super.getCodeCandidates(object); @@ -3131,7 +3136,6 @@ next: while (r.next()) { Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), Finder.class, "getCodeCandidates", e); } } - codes.remove(null); // Paranoiac safety. if (codes.isEmpty()) { // Dependency not found. return Collections.emptySet(); @@ -3144,8 +3148,10 @@ next: while (r.next()) { * - If EPSG code, there is only one parameter which is the code to search. * - If numeric, there is 3 parameters: lower value, upper value, exact value to search. */ - final StringBuilder buffer = new StringBuilder(60); - buffer.append("SELECT ").append(select).append(" FROM [").append(from).append("] WHERE ").append(where); + final StringBuilder buffer = new StringBuilder(200); + buffer.append("SELECT ").append(select).append(" FROM [").append(from).append(']'); + table.where(object.getClass(), buffer); + buffer.append(where); if (isFloat) { buffer.append(">=? AND ").append(where).append("<=?"); } else { Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -24,18 +24,38 @@ import org.opengis.referencing.operation import org.opengis.parameter.ParameterDescriptor; import org.apache.sis.internal.metadata.WKTKeywords; +// Branch-dependent imports +import org.apache.sis.referencing.crs.DefaultParametricCRS; +import org.apache.sis.referencing.cs.DefaultParametricCS; +import org.apache.sis.referencing.datum.DefaultParametricDatum; + /** * Information about a specific table. The MS-Access dialect of SQL is assumed; * it will be translated into ANSI SQL later by {@link SQLTranslator#apply(String)} if needed. * - * @author Martin Desruisseaux (IRD) + * @author Martin Desruisseaux (IRD, Geomatys) * @since 0.7 - * @version 0.7 + * @version 0.8 * @module */ final class TableInfo { /** + * The {@link EPSG} item used for coordinate reference systems. + */ + static final TableInfo CRS; + + /** + * The {@link EPSG} item used for datums. + */ + static final TableInfo DATUM; + + /** + * The {@link EPSG} item used for ellipsoids. + */ + static final TableInfo ELLIPSOID; + + /** * List of tables and columns to test for codes values. * Those tables are used by the {@link EPSGDataAccess#createObject(String)} method * in order to detect which of the following methods should be invoked for a given code: @@ -49,23 +69,23 @@ final class TableInfo { * The order is significant: it is the key for a {@code switch} statement. */ static final TableInfo[] EPSG = { - new TableInfo(CoordinateReferenceSystem.class, + CRS = new TableInfo(CoordinateReferenceSystem.class, "[Coordinate Reference System]", "COORD_REF_SYS_CODE", "COORD_REF_SYS_NAME", "COORD_REF_SYS_KIND", new Class<?>[] { ProjectedCRS.class, GeographicCRS.class, GeocentricCRS.class, - VerticalCRS.class, CompoundCRS.class, EngineeringCRS.class}, - // TemporalCRS.class, ParametricCRS.class (See comment below) + VerticalCRS.class, CompoundCRS.class, EngineeringCRS.class, + DerivedCRS.class, TemporalCRS.class, DefaultParametricCRS.class}, // See comment below new String[] {"projected", "geographic", "geocentric", - "vertical", "compound", "engineering"}, - // "temporal", "parametric" + "vertical", "compound", "engineering", + "derived", "temporal", "parametric"}, // See comment below "SHOW_CRS"), /* - * Above declaration omitted Temporal and Parametric cases because they are not defined - * by the EPSG registry (at least as of version 8.9). In particular, we are not sure if - * EPSG would chose to use "time" or "temporal". Omitting those types for now does not - * prevent SIS to find CRS of those types; the operation will only be more costly. + * Above declaration could omit Derived, Temporal and Parametric cases since they are not defined + * by the EPSG registry (at least as of version 8.9). In particular we are not sure if EPSG would + * chose to use "time" or "temporal". However omitting those types slow down a lot the search for + * CRS matching an existing one (even if it still work). */ new TableInfo(CoordinateSystem.class, @@ -74,11 +94,11 @@ final class TableInfo { "COORD_SYS_NAME", "COORD_SYS_TYPE", new Class<?>[] {CartesianCS.class, EllipsoidalCS.class, VerticalCS.class, LinearCS.class, - SphericalCS.class, PolarCS.class, CylindricalCS.class}, - // TimeCS.class, ParametricCS.class, AffineCS.class (see above comment) + SphericalCS.class, PolarCS.class, CylindricalCS.class, + TimeCS.class, DefaultParametricCS.class, AffineCS.class}, new String[] {WKTKeywords.Cartesian, WKTKeywords.ellipsoidal, WKTKeywords.vertical, WKTKeywords.linear, - WKTKeywords.spherical, WKTKeywords.polar, WKTKeywords.cylindrical}, - // WKTKeywords.temporal, WKTKeywords.parametric, WKTKeywords.affine + WKTKeywords.spherical, WKTKeywords.polar, WKTKeywords.cylindrical, + WKTKeywords.temporal, WKTKeywords.parametric, WKTKeywords.affine}, // Same comment than in the CRS case above. null), new TableInfo(CoordinateSystemAxis.class, @@ -88,18 +108,18 @@ final class TableInfo { "COORD_AXIS_NAME", null, null, null, null), - new TableInfo(Datum.class, + DATUM = new TableInfo(Datum.class, "[Datum]", "DATUM_CODE", "DATUM_NAME", "DATUM_TYPE", - new Class<?>[] { GeodeticDatum.class, VerticalDatum.class, EngineeringDatum.class}, - // TemporalDatum.class, ParametricDatum.class (see above comment), - new String[] {"geodetic", "vertical", "engineering"}, - // "temporal", "parametric", + new Class<?>[] { GeodeticDatum.class, VerticalDatum.class, EngineeringDatum.class, + TemporalDatum.class, DefaultParametricDatum.class}, + new String[] {"geodetic", "vertical", "engineering", + "temporal", "parametric"}, // Same comment than in the CRS case above. null), - new TableInfo(Ellipsoid.class, + ELLIPSOID = new TableInfo(Ellipsoid.class, "[Ellipsoid]", "ELLIPSOID_CODE", "ELLIPSOID_NAME", @@ -165,7 +185,7 @@ final class TableInfo { * {@link EPSGDataAccess} and {@link AuthorityCodes} assumes that values in this column * have the maximal length described in the {@value #ENUM_REPLACEMENT} statement. */ - final String typeColumn; + private final String typeColumn; /** * The SQL type to use as a replacement for enumerated values on databases that do not support enumerations. @@ -175,12 +195,12 @@ final class TableInfo { /** * Sub-interfaces of {@link #type} to handle, or {@code null} if none. */ - final Class<?>[] subTypes; + private final Class<?>[] subTypes; /** * Names of {@link #subTypes} in the database, or {@code null} if none. */ - final String[] typeNames; + private final String[] typeNames; /** * The column that specify if the object should be shown, or {@code null} if none. @@ -204,4 +224,38 @@ final class TableInfo { this.typeNames = typeNames; this.showColumn = showColumn; } + + /** + * Appends a {@code WHERE} clause together with a condition for searching the most specific subtype, + * if such condition can be added. The clause appended by this method looks like the following example + * (details may vary because of enumeration values): + * + * {@preformat sql + * WHERE COORD_REF_SYS_KIND LIKE 'geographic%' AND + * } + * + * In any case, the caller shall add at least one condition after this method call. + * + * @param userType the type specified by the user. + * @param buffer where to append the {@code WHERE} clause. + * @return the subtype, or {@link #type} if no subtype was found. + */ + final Class<?> where(final Class<?> userType, final StringBuilder buffer) { + buffer.append(" WHERE "); + if (typeColumn != null) { + for (int i=0; i<subTypes.length; i++) { + final Class<?> candidate = subTypes[i]; + if (candidate.isAssignableFrom(userType)) { + if (ENUM_REPLACEMENT != null) { + buffer.append("CAST(").append(typeColumn).append(" AS ").append(ENUM_REPLACEMENT).append(')'); + } else { + buffer.append(typeColumn); + } + buffer.append(" LIKE '").append(typeNames[i]).append("%' AND "); + return candidate; + } + } + } + return type; + } } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -17,6 +17,7 @@ package org.apache.sis.referencing.operation; import java.util.Map; +import java.util.Objects; import java.util.Collection; import java.util.Collections; import javax.xml.bind.Unmarshaller; @@ -66,9 +67,6 @@ import org.apache.sis.internal.system.Lo import static org.apache.sis.util.Utilities.deepEquals; -// Branch-dependent imports -import java.util.Objects; - /** * Describes the operation for transforming coordinates in the source CRS to coordinates in the target CRS. @@ -318,12 +316,12 @@ public class AbstractCoordinateOperation * The math transform shall let the interpolation coordinates {@linkplain DefaultPassThroughOperation pass through * the operation}. * - * @param properties The properties to be given to the identified object. - * @param sourceCRS The source CRS, or {@code null} if unspecified. - * @param targetCRS The target CRS, or {@code null} if unspecified. - * @param interpolationCRS The CRS of additional coordinates needed for the operation, or {@code null} if none. - * @param transform Transform from positions in the source CRS to positions in the target CRS, - * or {@code null} if unspecified. + * @param properties the properties to be given to the identified object. + * @param sourceCRS the source CRS, or {@code null} if unspecified. + * @param targetCRS the target CRS, or {@code null} if unspecified. + * @param interpolationCRS the CRS of additional coordinates needed for the operation, or {@code null} if none. + * @param transform transform from positions in the source CRS to positions in the target CRS, + * or {@code null} if unspecified. */ public AbstractCoordinateOperation(final Map<String,?> properties, final CoordinateReferenceSystem sourceCRS, @@ -344,7 +342,7 @@ public class AbstractCoordinateOperation * are consistent with {@link #transform} input and output dimensions. */ final void checkDimensions(final Map<String,?> properties) { - final MathTransform transform = this.transform; // Protect from changes. + final MathTransform transform = this.transform; // Protect from changes. if (transform != null) { final int interpDim = ReferencingUtilities.getDimension(interpolationCRS); check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1 == target check. @@ -380,7 +378,7 @@ check: for (int isTarget=0; ; isTar * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * - * @param operation The coordinate operation to copy. + * @param operation the coordinate operation to copy. * * @see #castOrCopy(CoordinateOperation) */ @@ -422,8 +420,8 @@ check: for (int isTarget=0; ; isTar * properties contained in the given object are not recursively copied.</li> * </ul> * - * @param object The object to get as a SIS implementation, or {@code null} if none. - * @return A SIS implementation containing the values of the given object (may be the + * @param object the object to get as a SIS implementation, or {@code null} if none. + * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static AbstractCoordinateOperation castOrCopy(final CoordinateOperation object) { @@ -435,7 +433,7 @@ check: for (int isTarget=0; ; isTar * The default implementation returns {@code CoordinateOperation.class}. * Subclasses implementing a more specific GeoAPI interface shall override this method. * - * @return The coordinate operation interface implemented by this class. + * @return the coordinate operation interface implemented by this class. */ @Override public Class<? extends CoordinateOperation> getInterface() { @@ -478,7 +476,7 @@ check: for (int isTarget=0; ; isTar * This information is optional for {@linkplain DefaultConversion conversions} according * the ISO 19111 standard, but Apache SIS tries to provide that CRS in most cases anyway. * - * @return The source CRS, or {@code null} if not available. + * @return the source CRS, or {@code null} if not available. */ @Override public CoordinateReferenceSystem getSourceCRS() { @@ -491,7 +489,7 @@ check: for (int isTarget=0; ; isTar * This information is optional for {@linkplain DefaultConversion conversions} according * the ISO 19111 standard, but Apache SIS tries to provide that CRS in most cases anyway. * - * @return The target CRS, or {@code null} if not available. + * @return the target CRS, or {@code null} if not available. */ @Override public CoordinateReferenceSystem getTargetCRS() { @@ -507,7 +505,7 @@ check: for (int isTarget=0; ; isTar * in order to interpolate in a grid. This method returns the CRS of the grid where such interpolations * are performed.</div> * - * @return The CRS (neither source or target CRS) required for interpolating the values, or {@code null} if none. + * @return the CRS (neither source or target CRS) required for interpolating the values, or {@code null} if none. */ public CoordinateReferenceSystem getInterpolationCRS() { return interpolationCRS; @@ -527,7 +525,7 @@ check: for (int isTarget=0; ; isTar * nature of the parameters. In principle this property is irrelevant to coordinate * {@linkplain DefaultConversion conversions}, but Apache SIS accepts it anyway. * - * @return The coordinate operation version, or {@code null} in none. + * @return the coordinate operation version, or {@code null} in none. */ @Override @XmlElement(name = "operationVersion") @@ -540,7 +538,7 @@ check: for (int isTarget=0; ; isTar * The positional accuracy gives position error estimates for target coordinates * of this coordinate operation, assuming no errors in source coordinates. * - * @return The position error estimations, or an empty collection if not available. + * @return the position error estimations, or an empty collection if not available. * * @see #getLinearAccuracy() */ @@ -584,7 +582,7 @@ check: for (int isTarget=0; ; isTar * if the math transforms are highly non-linear.</div></li> * </ul> * - * @return The accuracy estimation (always in meters), or NaN if unknown. + * @return the accuracy estimation (always in meters), or NaN if unknown. * * @see org.apache.sis.referencing.CRS#getLinearAccuracy(CoordinateOperation) */ @@ -595,7 +593,7 @@ check: for (int isTarget=0; ; isTar /** * Returns the area or region or timeframe in which this coordinate operation is valid. * - * @return The coordinate operation valid domain, or {@code null} if not available. + * @return the coordinate operation valid domain, or {@code null} if not available. */ @Override @XmlElement(name = "domainOfValidity") @@ -606,7 +604,7 @@ check: for (int isTarget=0; ; isTar /** * Returns a description of domain of usage, or limitations of usage, for which this operation is valid. * - * @return A description of domain of usage, or {@code null} if none. + * @return a description of domain of usage, or {@code null} if none. */ @Override @XmlElement(name = "scope", required = true) @@ -633,7 +631,7 @@ check: for (int isTarget=0; ; isTar * The interpolation coordinates will {@linkplain DefaultPassThroughOperation pass through the operation} * and appear in the math transform outputs, in the same order than inputs. * - * @return The transform from source to target CRS, or {@code null} if not applicable. + * @return the transform from source to target CRS, or {@code null} if not applicable. */ @Override public MathTransform getMathTransform() { @@ -644,7 +642,7 @@ check: for (int isTarget=0; ; isTar * Returns the operation method. This apply only to {@link AbstractSingleOperation} subclasses, * which will make this method public. * - * @return The operation method, or {@code null} if none. + * @return the operation method, or {@code null} if none. */ OperationMethod getMethod() { return null; @@ -698,7 +696,7 @@ check: for (int isTarget=0; ; isTar * Returns the parameter values. The default implementation infers the * parameter values from the {@linkplain #transform}, if possible. * - * @return The parameter values (never {@code null}). + * @return the parameter values (never {@code null}). * @throws UnsupportedOperationException if the parameter values can not * be determined for the current math transform implementation. */ @@ -734,10 +732,10 @@ check: for (int isTarget=0; ; isTar * properties are compared including the {@linkplain #getDomainOfValidity() domain of validity} and the * {@linkplain #getScope() scope}. * - * @param object The object to compare to {@code this}. - * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or - * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for ignoring properties - * that do not make a difference in the numerical results of coordinate operations. + * @param object the object to compare to {@code this}. + * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or + * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for ignoring properties + * that do not make a difference in the numerical results of coordinate operations. * @return {@code true} if both objects are equal for the given comparison mode. */ @Override @@ -837,7 +835,7 @@ check: for (int isTarget=0; ; isTar * Invoked by {@code hashCode()} for computing the hash code when first needed. * See {@link AbstractIdentifiedObject#computeHashCode()} for more information. * - * @return The hash code value. This value may change in any future Apache SIS version. + * @return the hash code value. This value may change in any future Apache SIS version. */ @Override protected long computeHashCode() { @@ -852,7 +850,7 @@ check: for (int isTarget=0; ; isTar /** * Formats this coordinate operation in Well Known Text (WKT) version 2 format. * - * @param formatter The formatter to use. + * @param formatter the formatter to use. * @return {@code "CoordinateOperation"}. * * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#113">WKT 2 specification §17</a> @@ -921,9 +919,9 @@ check: for (int isTarget=0; ; isTar /** * Appends the given CRS (if non-null) wrapped in an element of the given name. * - * @param formatter The formatter where to append the object name. - * @param crs The object to append, or {@code null} if none. - * @param type The keyword to write before the object. + * @param formatter the formatter where to append the object name. + * @param crs the object to append, or {@code null} if none. + * @param type the keyword to write before the object. */ private static void append(final Formatter formatter, final CoordinateReferenceSystem crs, final String type) { if (crs != null) { Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -160,7 +160,7 @@ class AbstractSingleOperation extends Ab * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * - * @param operation The coordinate operation to copy. + * @param operation the coordinate operation to copy. */ protected AbstractSingleOperation(final SingleOperation operation) { super(operation); @@ -189,10 +189,10 @@ class AbstractSingleOperation extends Ab * is taken. Only one non-ignorable step may exist, otherwise we do not try to select any of them.</li> * </ul> * - * @param method The operation method to compare to the math transform. - * @param interpDim The number of interpolation dimension, or 0 if none. - * @param transform The math transform to compare to the operation method. - * @param properties Properties of the caller object being constructed, used only for formatting error message. + * @param method the operation method to compare to the math transform. + * @param interpDim the number of interpolation dimension, or 0 if none. + * @param transform the math transform to compare to the operation method. + * @param properties properties of the caller object being constructed, used only for formatting error message. * @throws IllegalArgumentException if the number of dimensions are incompatible. */ static void checkDimensions(final OperationMethod method, final int interpDim, MathTransform transform, @@ -277,7 +277,7 @@ class AbstractSingleOperation extends Ab * Returns a description of the operation method, including a list of expected parameter names. * The returned object does not contains any parameter value. * - * @return A description of the operation method. + * @return a description of the operation method. */ @Override @XmlElement(name = "method", required = true) @@ -301,7 +301,7 @@ class AbstractSingleOperation extends Ab * should be very similar. If they differ, it should be only in minor details like remarks, default * values or units of measurement.</div> * - * @return A description of the parameters. + * @return a description of the parameters. * * @see DefaultOperationMethod#getParameters() * @see org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterDescriptors() @@ -322,7 +322,7 @@ class AbstractSingleOperation extends Ab * <li>Otherwise throw {@link org.apache.sis.util.UnsupportedImplementationException}.</li> * </ul> * - * @return The parameter values. + * @return the parameter values. * @throws UnsupportedOperationException if the parameter values can not be determined * for the current math transform implementation. * @@ -344,7 +344,7 @@ class AbstractSingleOperation extends Ab @Override public boolean equals(final Object object, final ComparisonMode mode) { if (object == this) { - return true; // Slight optimization. + return true; // Slight optimization. } if (!super.equals(object, mode)) { return false; Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -287,8 +287,8 @@ class CoordinateOperationRegistry { * * @param sourceCRS input coordinate reference system. * @param targetCRS output coordinate reference system. - * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}, or {@code null} - * if no such operation is explicitly defined in the underlying database. + * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}, + * or {@code null} if no such operation is explicitly defined in the underlying database. * @throws OperationNotFoundException if no operation path was found from {@code sourceCRS} to {@code targetCRS}. * @throws FactoryException if the operation creation failed for some other reason. */ @@ -354,9 +354,7 @@ class CoordinateOperationRegistry { * * @param sourceCRS source coordinate reference system. * @param targetCRS target coordinate reference system. - * @return A coordinate operation from {@code sourceCRS} to {@code targetCRS}, - * or {@code null} if no such operation is explicitly defined in the underlying database. - * @return A coordinate operation from {@code sourceCRS} to {@code targetCRS}, or {@code null} + * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}, or {@code null} * if no such operation is explicitly defined in the underlying database. * @throws IllegalArgumentException if the coordinate systems are not of the same type or axes do not match. * @throws IncommensurableException if the units are not compatible or a unit conversion is non-linear. @@ -540,8 +538,8 @@ class CoordinateOperationRegistry { * a new query of EPSG database may be necessary, and if no explicit definition is found there is too many arbitrary * values to set in a default inverse operation for making that API public.</p> * - * @param operation The operation to invert, or {@code null}. - * @return The inverse of {@code operation}, or {@code null} if none. + * @param operation the operation to invert, or {@code null}. + * @return the inverse of {@code operation}, or {@code null} if none. * @throws NoninvertibleTransformException if the operation is not invertible. * @throws FactoryException if the operation creation failed for an other reason. */ @@ -957,7 +955,7 @@ class CoordinateOperationRegistry { * Consequently, the Apache SIS implementation relaxes the rule requiring an operation * version and we do not try to provide this information here for now.</div> * - * @param name The name to put in a map. + * @param name the name to put in a map. * @return a modifiable map containing the given name. Callers can put other entries in this map. */ static Map<String,Object> properties(final Identifier name) { @@ -997,14 +995,14 @@ class CoordinateOperationRegistry { * DefaultCoordinateOperationFactory.createSingleOperation(…)}.</li> * </ul> * - * @param properties The properties to give to the operation, as a modifiable map. - * @param sourceCRS The source coordinate reference system. - * @param targetCRS The destination coordinate reference system. - * @param transform The math transform. - * @param method The operation method, or {@code null} if unknown. - * @param parameters The operations parameters, or {@code null} for automatic detection (not always reliable). - * @param type {@code Conversion.class}, {@code Transformation.class}, or {@code null} if unknown. - * @return A coordinate operation using the specified math transform. + * @param properties the properties to give to the operation, as a modifiable map. + * @param sourceCRS the source coordinate reference system. + * @param targetCRS the destination coordinate reference system. + * @param transform the math transform. + * @param method the operation method, or {@code null} if unknown. + * @param parameters the operations parameters, or {@code null} for automatic detection (not always reliable). + * @param type {@code Conversion.class}, {@code Transformation.class}, or {@code null} if unknown. + * @return a coordinate operation using the specified math transform. * @throws FactoryException if the operation can not be created. */ final CoordinateOperation createFromMathTransform(final Map<String,Object> properties, Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultTransformation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultTransformation.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultTransformation.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultTransformation.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -97,12 +97,12 @@ public class DefaultTransformation exten * </tr> * </table> * - * @param properties The properties to be given to the identified object. - * @param sourceCRS The source CRS. - * @param targetCRS The target CRS. - * @param interpolationCRS The CRS of additional coordinates needed for the operation, or {@code null} if none. - * @param method The coordinate operation method (mandatory in all cases). - * @param transform Transform from positions in the source CRS to positions in the target CRS. + * @param properties the properties to be given to the identified object. + * @param sourceCRS the source CRS. + * @param targetCRS the target CRS. + * @param interpolationCRS the CRS of additional coordinates needed for the operation, or {@code null} if none. + * @param method the coordinate operation method (mandatory in all cases). + * @param transform transform from positions in the source CRS to positions in the target CRS. */ public DefaultTransformation(final Map<String,?> properties, final CoordinateReferenceSystem sourceCRS, @@ -123,7 +123,7 @@ public class DefaultTransformation exten * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * - * @param operation The coordinate operation to copy. + * @param operation the coordinate operation to copy. * * @see #castOrCopy(Transformation) */ @@ -139,8 +139,8 @@ public class DefaultTransformation exten * Note that this is a <cite>shallow</cite> copy operation, since the other properties contained in the given * object are not recursively copied. * - * @param object The object to get as a SIS implementation, or {@code null} if none. - * @return A SIS implementation containing the values of the given object (may be the + * @param object the object to get as a SIS implementation, or {@code null} if none. + * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultTransformation castOrCopy(final Transformation object) { Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -143,7 +143,6 @@ final class InverseOperationMethod exten * parameter values, copies those parameters in a "parameters" entry in the properties map. * Otherwise does nothing. */ - final boolean isInvertible = isInvertible(source.getMethod()); final ParameterValueGroup parameters = source.getParameterValues(); final ParameterValueGroup copy = parameters.getDescriptor().createValue(); for (final GeneralParameterValue gp : parameters.values()) { @@ -154,30 +153,36 @@ final class InverseOperationMethod exten final ParameterDescriptor<?> descriptor = src.getDescriptor(); final InternationalString remarks = descriptor.getRemarks(); if (remarks != SignReversalComment.SAME) { - boolean isOpposite = (remarks == SignReversalComment.OPPOSITE); - if (!isOpposite) { + if (remarks != SignReversalComment.OPPOSITE) { /* - * If the parameter descriptor does not contain an information about whether the - * inverse operation uses values of opposite sign or not, use heuristic rules. + * The parameter descriptor does not specify whether the values for the inverse operation + * have the same sign or opposite sign. We could heuristically presume that we can invert + * the sign if the minimum value has the opposite sign than the maximum value (as in the + * [-10 … 10] range), but such assumption is dangerous. For example the values in a matrix + * could be bounded to a range like [-1 … 1], which would mislead above heuristic rule. + * + * Note that abandoning here does not mean that we will never know the parameter values. + * As a fallback, AbstractCoordinateOperation will try to get the parameter values from + * the MathTransform. This is the appropriate thing to do at least for Affine operation. */ - if (!isInvertible) { - return; // Can not create inverse parameter values - abandon. - } - final Comparable<?> minimum = descriptor.getMinimumValue(); - isOpposite = (minimum == null || (minimum instanceof Number && ((Number) minimum).doubleValue() < 0)); + return; } - if (isOpposite) { - final ParameterValue<?> tgt = copy.parameter(descriptor.getName().getCode()); - final Unit<?> unit = src.getUnit(); - if (unit != null) { - tgt.setValue(-src.doubleValue(), unit); - } else if (value instanceof Integer || value instanceof Short || value instanceof Byte) { - tgt.setValue(-src.intValue()); - } else { - tgt.setValue(-src.doubleValue()); - } - continue; + /* + * The parameter value of the inverse operation is (or is presumed to be) the negative of + * the parameter value of the source operation. We need to preserve units of measurement + * if they were specified. + */ + final ParameterValue<?> tgt = copy.parameter(descriptor.getName().getCode()); + final Unit<?> unit = src.getUnit(); + if (unit != null) { + tgt.setValue(-src.doubleValue(), unit); + } else if (value instanceof Integer || value instanceof Short || value instanceof Byte) { + tgt.setValue(-src.intValue()); + } else { + tgt.setValue(-src.doubleValue()); } + // No need to add 'tgt' to 'copy' since it was done by the call to copy.parameter(…). + continue; } } } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -53,21 +53,21 @@ public final strictfp class ParameterBui assertEquals("defaultValue", 0.0, p.getDefaultValue(), 0); assertNull ("minimumValue", p.getMinimumValue()); assertNull ("maximumValue", p.getMaximumValue()); - assertEquals("unit", Units.METRE, p.getUnit()); + assertEquals("unit", Units.METRE, p.getUnit()); p = builder.addName("Test 2").create(Double.NaN, Units.METRE); assertEquals("name", "Test 2", p.getName().getCode()); assertNull ("defaultValue", p.getDefaultValue()); assertNull ("minimumValue", p.getMinimumValue()); assertNull ("maximumValue", p.getMaximumValue()); - assertEquals("unit", Units.METRE, p.getUnit()); + assertEquals("unit", Units.METRE, p.getUnit()); p = builder.addName("Test 3").createBounded(1, 4, 3, Units.METRE); assertEquals("name", "Test 3", p.getName().getCode()); assertEquals("defaultValue", 3.0, p.getDefaultValue(), 0); assertEquals("minimumValue", 1.0, p.getMinimumValue()); assertEquals("maximumValue", 4.0, p.getMaximumValue()); - assertEquals("unit", Units.METRE, p.getUnit()); + assertEquals("unit", Units.METRE, p.getUnit()); } /** @@ -94,7 +94,7 @@ public final strictfp class ParameterBui assertEquals("False easting", parameters[3].getName().getCode()); assertEquals("Some remarks.", parameters[0].getRemarks().toString()); assertEquals(Double.valueOf(84), parameters[1].getMaximumValue()); - assertEquals(Units.METRE, parameters[4].getUnit()); + assertEquals(Units.METRE, parameters[4].getUnit()); assertTrue ( parameters[1].getAlias().isEmpty()); final GenericName alias = parameters[0].getAlias().iterator().next(); Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -252,8 +252,8 @@ public final strictfp class EPSGFactoryT /** * Verifies the parameter values of the given Universal Transverse Mercator projection. * - * @param parameters The parameter value to verify. - * @param cm The expected central meridian value. + * @param parameters the parameter value to verify. + * @param cm the expected central meridian value. */ private static void verifyTransverseMercatorParmeters(final ParameterValueGroup parameters, final double cm) { assertEquals("Transverse Mercator", parameters.getDescriptor().getName().getCode()); @@ -666,6 +666,7 @@ public final strictfp class EPSGFactoryT final Set<String> geographicCRS = factory.getAuthorityCodes(GeographicCRS.class); assertFalse("GeographicCRS not found.", geographicCRS.isEmpty()); assertTrue ("Shall contain WGS84.", geographicCRS.contains("4326")); + assertFalse("Shall not contain geocentric CRS.", geographicCRS.contains("4978")); assertFalse("Shall not contain projected CRS.", geographicCRS.contains("3395")); if (RUN_EXTENSIVE_TESTS) { assertTrue ("Check size() consistency.", geographicCRS.size() >= 468); Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -55,7 +55,7 @@ public class CitationConstant extends Si * The most typical example is the "EPSG" authority which manage the codes identifying Coordinate Reference * System (CRS) objects in the EPSG namespace. * - * @param <T> The type of object used as identifier values. + * @param <T> the type of object used as identifier values. */ public static class Authority<T> extends CitationConstant implements IdentifierSpace<T> { /** @@ -66,7 +66,7 @@ public class CitationConstant extends Si /** * Creates a new citation for an authority managing codes in the given namespace. * - * @param namespace The namespace of codes managed by this authority (e.g. "EPSG"). + * @param namespace the namespace of codes managed by this authority (e.g. "EPSG"). */ public Authority(final String namespace) { super(namespace); @@ -103,7 +103,7 @@ public class CitationConstant extends Si * Creates a new proxy for the given primary key. * The key should be readable enough for being usable as a fallback if the database is not available. * - * @param name A human-understandable primary key for fetching more information. + * @param name a human-understandable primary key for fetching more information. */ public CitationConstant(final String name) { super(name); @@ -148,7 +148,7 @@ public class CitationConstant extends Si /** * Redirects the call to the delegate citation (the instance which actually contain the data). * - * @return The value returned by the delegate. + * @return the value returned by the delegate. */ @Override public InternationalString getTitle() {return delegate().getTitle();} @Override public Collection<? extends InternationalString> getAlternateTitles() {return delegate().getAlternateTitles();} @@ -167,7 +167,7 @@ public class CitationConstant extends Si * Invoked at deserialization time in order to replace the deserialized instance by the existing * instance defined in the {@link org.apache.sis.metadata.iso.citation.Citations} class. * - * @return The instance to use, as an unique instance if possible. + * @return the instance to use, as an unique instance if possible. */ protected Object readResolve() { CitationConstant c = MetadataServices.getInstance().getCitationConstant(title); Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleAttributeType.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleAttributeType.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleAttributeType.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleAttributeType.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -28,7 +28,7 @@ import org.opengis.util.TypeName; * Such simple type are suitable for use in ISO 19103 {@link org.opengis.util.RecordType} * in addition to ISO 19109 {@link org.opengis.feature.FeatureType}. * - * @param <V> The type of attribute value. + * @param <V> the type of attribute value. * * @author Martin Desruisseaux (Geomatys) * @since 0.5 @@ -54,8 +54,8 @@ public final class SimpleAttributeType<V /** * Creates a new attribute type for the given name and class of values. * - * @param name The name for this attribute type (shall not be null). - * @param valueClass The class of value for attributes of this type (shall not be null). + * @param name the name for this attribute type (shall not be null). + * @param valueClass the class of value for attributes of this type (shall not be null). */ public SimpleAttributeType(final TypeName name, final Class<V> valueClass) { this.name = name; @@ -65,7 +65,7 @@ public final class SimpleAttributeType<V /** * Returns the name of this attribute type (ISO 19109). * - * @return The name of this attribute type. + * @return the name of this attribute type. */ public GenericName getName() { return name; @@ -74,7 +74,7 @@ public final class SimpleAttributeType<V /** * Returns the name of this attribute type (ISO 19103). * - * @return The name of this attribute type. + * @return the name of this attribute type. */ @Override public TypeName getTypeName() { @@ -84,7 +84,7 @@ public final class SimpleAttributeType<V /** * Returns the class of value for attributes of this type. * - * @return The class of value for attributes of this type. + * @return the class of value for attributes of this type. */ public Class<V> getValueClass() { return valueClass; @@ -93,7 +93,7 @@ public final class SimpleAttributeType<V /** * Returns 1 as of simple feature definition. * - * @return Always 1. + * @return always 1. */ public int getMinimumOccurs() { return 1; @@ -102,7 +102,7 @@ public final class SimpleAttributeType<V /** * Returns 1 as of simple feature definition. * - * @return Always 1. + * @return always 1. */ public int getMaximumOccurs() { return 1; @@ -111,7 +111,7 @@ public final class SimpleAttributeType<V /** * Not used for this simple attribute type. * - * @return Always {@code null}. + * @return always {@code null}. */ public V getDefaultValue() { return null; @@ -120,7 +120,7 @@ public final class SimpleAttributeType<V /** * Not used for this simple attribute type. * - * @return Always {@code null}. + * @return always {@code null}. */ public InternationalString getDefinition() { return null; @@ -129,7 +129,7 @@ public final class SimpleAttributeType<V /** * Not used for this simple attribute type. * - * @return Always {@code null}. + * @return always {@code null}. */ public InternationalString getDesignation() { return null; @@ -147,7 +147,7 @@ public final class SimpleAttributeType<V /** * Returns a hash code value for this type. * - * @return A hash code value. + * @return a hash code value. */ @Override public int hashCode() { @@ -157,7 +157,7 @@ public final class SimpleAttributeType<V /** * Compares this attribute type with the given object for equality. * - * @param object The object to compare with this attribute type. + * @param object the object to compare with this attribute type. * @return {@code true} if both objects are equal. */ @Override @@ -175,7 +175,7 @@ public final class SimpleAttributeType<V /** * Returns the type name. * - * @return The type name. + * @return the type name. */ @Override public String toString() { Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCharacterIterator.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCharacterIterator.java?rev=1768102&r1=1768101&r2=1768102&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCharacterIterator.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCharacterIterator.java [UTF-8] Fri Nov 4 21:16:09 2016 @@ -62,7 +62,7 @@ public class SimpleCharacterIterator imp /** * Creates a new character iterator for the given character sequence. * - * @param text The character sequence to wrap. + * @param text the character sequence to wrap. */ public SimpleCharacterIterator(final CharSequence text) { ArgumentChecks.ensureNonNull("text", text);