Author: desruisseaux
Date: Tue Mar 17 21:32:34 2015
New Revision: 1667413
URL: http://svn.apache.org/r1667413
Log:
Merge from the JDK6 branch. This is work toward an initial Mercator projection
parameter descriptor.
Added:
sis/trunk/application/sis-console/src/main/artifact/conf/
- copied from r1667400,
sis/branches/JDK6/application/sis-console/src/main/artifact/conf/
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionDescriptor.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionDescriptor.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/DeprecatedCode.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/DeprecatedCode.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/DeprecatedName.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/DeprecatedName.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
sis/trunk/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/LongitudeRotationTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/MapProjectionParametersTest.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/MapProjectionParametersTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/LazySetTest.java
- copied unchanged from r1667400,
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/LazySetTest.java
Removed:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/IdentifierCode.java
Modified:
sis/trunk/ (props changed)
sis/trunk/application/sis-console/src/main/artifact/bin/sis
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.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/parameter/ParameterTableRow.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/UninitializedParameter.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/package-info.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AffineTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.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/parameter/ParametersTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Static.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/trunk/ide-project/NetBeans/build.xml
sis/trunk/src/main/javadoc/stylesheet.css
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 17 21:32:34 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK6:1394364-1661579
-/sis/branches/JDK7:1394913-1661574
-/sis/branches/JDK8:1584960-1661572
+/sis/branches/JDK6:1394364-1667400
+/sis/branches/JDK7:1394913-1667398
+/sis/branches/JDK8:1584960-1667393
Modified: sis/trunk/application/sis-console/src/main/artifact/bin/sis
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/artifact/bin/sis?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/artifact/bin/sis [UTF-8]
(original)
+++ sis/trunk/application/sis-console/src/main/artifact/bin/sis [UTF-8] Tue Mar
17 21:32:34 2015
@@ -29,4 +29,6 @@ then
fi
# Execute SIS with any optional JAR that the user may put in the 'lib'
directory.
-java -classpath "$BASE_DIR/lib/*" org.apache.sis.console.Command $SIS_OPTS "$@"
+java -classpath "$BASE_DIR/lib/*" \
+ -Djava.util.logging.config.file="$BASE_DIR/conf/logging.properties" \
+ org.apache.sis.console.Command $SIS_OPTS "$@"
Modified:
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
[UTF-8] (original)
+++
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -17,6 +17,8 @@
package org.apache.sis.console;
import java.util.Locale;
+import java.util.logging.LogManager;
+import java.util.logging.ConsoleHandler;
import java.io.Console;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -62,7 +64,7 @@ import org.apache.sis.util.logging.Monol
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.4
+ * @version 0.6
* @module
*/
public final class Command {
@@ -227,7 +229,24 @@ public final class Command {
* @param args Command-line options.
*/
public static void main(final String[] args) {
- MonolineFormatter.install();
+ /*
+ * The logging configuration is given by the "conf/logging.properties"
file in the Apache SIS
+ * installation directory. By default, that configuration file
contains the following line:
+ *
+ * java.util.logging.ConsoleHandler.formatter =
org.apache.sis.util.logging.MonolineFormatter
+ *
+ * However this configuration is silently ignored by LogManager at JVM
startup time, probably
+ * because the Apache SIS class is not on the system classpath. So we
check again for this
+ * configuration line here, and manually install our log formatter
only if the above-cited
+ * line is present.
+ */
+ final LogManager manager = LogManager.getLogManager();
+ if
(MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName()
+ ".formatter"))) {
+ MonolineFormatter.install();
+ }
+ /*
+ * Now run the command.
+ */
final Command c;
try {
c = new Command(args);
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -92,7 +92,7 @@ import org.apache.sis.metadata.iso.exten
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*/
public class Formatter implements Localized {
@@ -1244,12 +1244,15 @@ public class Formatter implements Locali
append((FormattableObject) value);
} else if (value instanceof IdentifiedObject) {
append(ReferencingServices.getInstance().toFormattableObject((IdentifiedObject)
value));
- }
- else if (value instanceof MathTransform)
append((MathTransform) value);
- else if (value instanceof Matrix) append((Matrix)
value);
- else if (value instanceof Unit<?>) append((Unit<?>)
value);
- else if (value instanceof GeographicBoundingBox)
append((GeographicBoundingBox) value, BBOX_ACCURACY);
- else if (value instanceof VerticalExtent) {
+ } else if (value instanceof MathTransform) {
+ append((MathTransform) value);
+ } else if (value instanceof Matrix) {
+ append((Matrix) value);
+ } else if (value instanceof Unit<?>) {
+ append((Unit<?>) value);
+ } else if (value instanceof GeographicBoundingBox) {
+ append((GeographicBoundingBox) value, BBOX_ACCURACY);
+ } else if (value instanceof VerticalExtent) {
appendVerticalExtent(Extents.getVerticalRange(new
SimpleExtent(null, (VerticalExtent) value, null)));
} else if (value instanceof TemporalExtent) {
appendTemporalExtent(Extents.getTimeRange(new SimpleExtent(null,
null, (TemporalExtent) value)));
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -436,6 +436,7 @@ public class ImmutableIdentifier extends
/**
* Name or identifier of the person or organization responsible for
namespace.
+ * This is often the {@linkplain #getAuthority() authority}'s
abbreviation, but not necessarily.
*
* <div class="note"><b>Example:</b> {@code "EPSG"}.</div>
*
@@ -450,8 +451,9 @@ public class ImmutableIdentifier extends
}
/**
- * Organization or party responsible for definition and maintenance of the
- * {@linkplain #getCode() code}.
+ * Organization or party responsible for definition and maintenance of the
{@linkplain #getCode() code}.
+ * The organization's abbreviation is often the same than this identifier
{@linkplain #getCodeSpace()
+ * code space}, but not necessarily.
*
* <div class="note"><b>Example:</b> Coordinate Reference System (CRS)
identified by an EPSG code will return
* {@link Citations#OGP}, since OGP is the organization maintaining the
EPSG geodetic database.</div>
@@ -464,10 +466,9 @@ public class ImmutableIdentifier extends
}
/**
- * Identifier of the version of the associated code space or code, as
specified by the
- * code authority. This version is included only when the {@linkplain
#getCode() code}
- * uses versions. When appropriate, the edition is identified by the
effective date,
- * coded using ISO 8601 date format.
+ * Identifier of the version of the associated code space or code, as
specified by the code authority.
+ * This version is included only when the {@linkplain #getCode() code}
uses versions. When appropriate,
+ * the edition is identified by the effective date, coded using ISO 8601
date format.
*
* <div class="note"><b>Example:</b> the version of the underlying EPSG
database.</div>
*
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -75,6 +75,28 @@ public final class Citations extends Sta
public static final Citation OGP = new SimpleCitation("OGP");
/**
+ * The <a href="http://www.epsg.org">EPSG</a> dataset. This citation is
used as an authority for
+ * {@linkplain org.opengis.referencing.crs.CoordinateReferenceSystem
coordinate reference system}
+ * identifiers.
+ *
+ * <div class="note"><b>Historical note:</b>
+ * The EPSG acronym meaning was <cite>European Petroleum Survey
Group</cite>.
+ * But this meaning does not apply anymore since the European and American
associations merged
+ * into the <cite>International Association of Oil & Gas
producers</cite> (IOGP).
+ * The legacy acronym now applies only to the database Coordinate
Reference System definitions,
+ * known as <cite>EPSG dataset</cite>.</div>
+ *
+ * @see #OGP
+ * @see #AUTO
+ * @see #AUTO2
+ * @see #CRS
+ * @category Code space
+ *
+ * @since 0.4
+ */
+ public static final IdentifierSpace<Integer> EPSG = new
Authority<Integer>(Constants.EPSG, Constants.EPSG);
+
+ /**
* The <a href="http://sis.apache.org">Apache SIS</a> project.
*
* @since 0.4
@@ -111,12 +133,13 @@ public final class Citations extends Sta
/**
* The <a
href="http://www.remotesensing.org/geotiff/geotiff.html">GeoTIFF</a>
specification.
+ * This specification identifies some map projections by their own
numerical codes.
*
- * @category Specification
+ * @category Code space
*
* @since 0.4
*/
- public static final Citation GEOTIFF = new SimpleCitation("GeoTIFF");
+ public static final IdentifierSpace<Integer> GEOTIFF = new
Authority<Integer>("GeoTIFF", "GeoTIFF");
/**
* The <a href="http://trac.osgeo.org/proj/">Proj.4</a> project.
@@ -125,29 +148,16 @@ public final class Citations extends Sta
*
* @since 0.4
*/
- public static final IdentifierSpace<String> PROJ4 = new
Authority<String>("Proj.4", "PROJ4");
+ public static final IdentifierSpace<String> PROJ4 = new
Authority<String>("Proj.4", "Proj4");
/**
- * The <a href="http://www.epsg.org">EPSG</a> dataset. This citation is
used as an authority for
- * {@linkplain org.opengis.referencing.crs.CoordinateReferenceSystem
coordinate reference system}
- * identifiers.
- *
- * <div class="note"><b>Historical note:</b>
- * The EPSG acronym meaning was <cite>European Petroleum Survey
Group</cite>.
- * But this meaning does not apply anymore since the European and American
associations merged
- * into the <cite>International Association of Oil & Gas
producers</cite> (IOGP).
- * The legacy acronym now applies only to the database Coordinate
Reference System definitions,
- * known as <cite>EPSG dataset</cite>.</div>
+ * The MapInfo software. This software defines its own projection codes.
*
- * @see #OGP
- * @see #AUTO
- * @see #AUTO2
- * @see #CRS
* @category Code space
*
- * @since 0.4
+ * @since 0.6
*/
- public static final IdentifierSpace<Integer> EPSG = new
Authority<Integer>(Constants.EPSG, Constants.EPSG);
+ public static final IdentifierSpace<Integer> MAP_INFO = new
Authority<Integer>("MapInfo", "MapInfo");
/**
* <cite>International Standard Book Number</cite> (ISBN) defined by
ISO-2108.
@@ -175,7 +185,7 @@ public final class Citations extends Sta
* List of citations declared in this class.
*/
private static final Citation[] CITATIONS = {
- ISO, OGC, OGP, SIS, ESRI, ORACLE, NETCDF, GEOTIFF, PROJ4, EPSG, ISBN,
ISSN
+ ISO, OGC, OGP, EPSG, SIS, ESRI, ORACLE, NETCDF, GEOTIFF, PROJ4,
MAP_INFO, ISBN, ISSN
};
/**
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -35,6 +35,7 @@ import org.apache.sis.xml.IdentifierSpac
import org.apache.sis.xml.IdentifiedObject;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.Emptiable;
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -62,14 +63,14 @@ import static org.apache.sis.internal.me
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*
* @see DefaultResolution#getEquivalentScale()
*/
@XmlType(name = "MD_RepresentativeFraction_Type")
@XmlRootElement(name = "MD_RepresentativeFraction")
-public class DefaultRepresentativeFraction extends Number implements
RepresentativeFraction, IdentifiedObject {
+public class DefaultRepresentativeFraction extends Number implements
RepresentativeFraction, IdentifiedObject, Emptiable {
/**
* Serial number for compatibility with different versions.
*/
@@ -239,6 +240,26 @@ public class DefaultRepresentativeFracti
}
/**
+ * Returns {@code true} if no scale is defined.
+ * The following relationship shall hold:
+ *
+ * {@preformat java
+ * assert isEmpty() == Double.isNaN(doubleValue());
+ * }
+ *
+ * @return {@code true} if no scale is defined.
+ *
+ * @see #doubleValue()
+ * @see #floatValue()
+ *
+ * @since 0.6
+ */
+ @Override
+ public boolean isEmpty() {
+ return (denominator == 0);
+ }
+
+ /**
* Compares this object with the specified value for equality.
*
* @param object The object to compare with.
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -60,7 +60,7 @@ import static org.opengis.annotation.Spe
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*
* @see AbstractIdentification#getSpatialResolutions()
@@ -126,7 +126,10 @@ public class DefaultResolution extends I
* @since 0.4
*/
public DefaultResolution(final RepresentativeFraction scale) {
- value = scale;
+ if (scale != null) {
+ value = scale;
+ property = SCALE;
+ }
}
// Note: there is not yet DefaultResolution(double) method because
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -20,7 +20,9 @@ import org.apache.sis.metadata.iso.Defau
import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.metadata.iso.extent.DefaultExtent;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.metadata.iso.identification.DefaultResolution;
import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
+import
org.apache.sis.metadata.iso.identification.DefaultRepresentativeFraction;
import org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation;
import org.apache.sis.internal.simple.SimpleIdentifier;
import org.apache.sis.test.DependsOnMethod;
@@ -38,7 +40,7 @@ import static org.apache.sis.metadata.Va
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
@DependsOn(ValueMapTest.class)
@@ -54,6 +56,15 @@ public final strictfp class PrunerTest e
private final DefaultDataIdentification identification;
/**
+ * A child of an other child metadata object being tested.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-194">SIS-194</a>
+ *
+ * @since 0.6
+ */
+ private final DefaultRepresentativeFraction scale;
+
+ /**
* A child of the metadata object being tested.
*/
private final DefaultExtent extent;
@@ -69,10 +80,12 @@ public final strictfp class PrunerTest e
public PrunerTest() {
metadata = new DefaultMetadata();
identification = new DefaultDataIdentification();
+ scale = new DefaultRepresentativeFraction();
extent = new DefaultExtent();
bbox = new DefaultGeographicBoundingBox();
extent.setGeographicElements(singleton(bbox));
identification.setExtents(singleton(extent));
+ identification.setSpatialResolutions(singleton(new
DefaultResolution(scale)));
metadata.setIdentificationInfo(singleton(identification));
}
@@ -86,6 +99,7 @@ public final strictfp class PrunerTest e
*/
assertTrue("GeographicBoundingBox", bbox.isEmpty());
assertTrue("Extent", extent.isEmpty());
+ assertTrue("Scale", scale.isEmpty());
assertTrue("DataIdentification", identification.isEmpty());
assertTrue("Metadata", metadata.isEmpty());
/*
@@ -94,6 +108,7 @@ public final strictfp class PrunerTest e
identification.setCitation(new DefaultCitation("A citation title"));
assertTrue ("GeographicBoundingBox", bbox.isEmpty());
assertTrue ("Extent", extent.isEmpty());
+ assertTrue ("Scale", scale.isEmpty());
assertFalse("DataIdentification", identification.isEmpty());
assertFalse("Metadata", metadata.isEmpty());
/*
@@ -102,6 +117,7 @@ public final strictfp class PrunerTest e
metadata.setMetadataIdentifier(new SimpleIdentifier(null, "A file
identifiers"));
assertTrue ("GeographicBoundingBox", bbox.isEmpty());
assertTrue ("Extent", extent.isEmpty());
+ assertTrue ("Scale", scale.isEmpty());
assertFalse("DataIdentification", identification.isEmpty());
assertFalse("Metadata", metadata.isEmpty());
/*
@@ -110,13 +126,26 @@ public final strictfp class PrunerTest e
identification.setCitation(new DefaultCitation(" "));
assertTrue ("GeographicBoundingBox", bbox.isEmpty());
assertTrue ("Extent", extent.isEmpty());
+ assertTrue ("Scale", scale.isEmpty());
assertTrue ("DataIdentification", identification.isEmpty());
assertFalse("Metadata", metadata.isEmpty());
/*
+ * Set a representative fraction.
+ */
+ scale.setDenominator(1000);
+ assertTrue ("GeographicBoundingBox", bbox.isEmpty());
+ assertTrue ("Extent", extent.isEmpty());
+ assertFalse("Scale", scale.isEmpty());
+ assertFalse("DataIdentification", identification.isEmpty());
+ assertFalse("Metadata", metadata.isEmpty());
+ /*
* Set an empty string in an element.
*/
+ scale.setScale(Double.NaN);
metadata.setMetadataIdentifier(new SimpleIdentifier(null, " "));
- assertTrue("Metadata", metadata.isEmpty());
+ assertTrue("Scale", scale.isEmpty());
+ assertTrue("DataIdentification", identification.isEmpty());
+ assertTrue("Metadata", metadata.isEmpty());
}
/**
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -17,6 +17,7 @@
package org.apache.sis.metadata.iso.identification;
import javax.xml.bind.JAXBException;
+import org.opengis.metadata.identification.RepresentativeFraction;
import org.apache.sis.xml.XML;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.metadata.iso.LoggingWatcher;
@@ -34,7 +35,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.6
* @module
*/
@DependsOn(DefaultRepresentativeFractionTest.class)
@@ -57,6 +58,21 @@ public final strictfp class DefaultResol
};
/**
+ * Tests the {@link
DefaultResolution#DefaultResolution(RepresentativeFraction)} constructor.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-195">SIS-195</a>
+ *
+ * @since 0.6
+ */
+ @Test
+ public void testConstructor() {
+ final DefaultRepresentativeFraction scale = new
DefaultRepresentativeFraction();
+ scale.setDenominator(100);
+ final DefaultResolution metadata = new DefaultResolution(scale);
+ assertSame(scale, metadata.getEquivalentScale());
+ }
+
+ /**
* Tests the various setter methods. Since they are exclusive properties,
* we expect any new property to replace the old one.
*/
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -19,13 +19,9 @@ package org.apache.sis.test;
import java.util.Collection;
import org.opengis.metadata.Identifier;
import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.ReferenceIdentifier;
import org.apache.sis.io.wkt.Symbols;
import org.apache.sis.io.wkt.WKTFormat;
import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.metadata.iso.citation.Citations;
-
-import static org.apache.sis.internal.util.Constants.EPSG;
/**
@@ -57,22 +53,6 @@ public strictfp class MetadataAssert ext
}
/**
- * Asserts that the given identifier has the expected code and the {@code
"EPSG"} code space.
- * The authority is expected to have the {@code "OGP"} title or alternate
title.
- *
- * @param expected The expected identifier code.
- * @param identifier The identifier to verify.
- *
- * @since 0.5
- */
- public static void assertEpsgIdentifierEquals(final String expected, final
Identifier identifier) {
- assertNotNull(identifier);
- assertEquals("code", expected, identifier.getCode());
- assertEquals("codeSpace", EPSG, (identifier instanceof
ReferenceIdentifier) ? ((ReferenceIdentifier) identifier).getCodeSpace() :
null);
- assertEquals("authority", "OGP",
Citations.getIdentifier(identifier.getAuthority()));
- }
-
- /**
* Asserts that the given collection contains exactly one identifier with
the given
* {@linkplain Identifier#getCode() code}. The {@linkplain
Identifier#getCodeSpace()
* code space} and authority are ignored.
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -122,6 +122,7 @@ public class AffineTransform2D extends I
pz(elements[1]), pz(elements[4]),
pz(elements[2]), pz(elements[5]));
matrix = new AffineMatrix(this, elements);
+ // Do not call freeze(), as it was implied by above line.
}
/**
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -19,13 +19,24 @@ package org.apache.sis.internal.referenc
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
+import javax.measure.unit.Unit;
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
import org.opengis.util.GenericName;
+import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.ReferenceIdentifier;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.measure.Latitude;
+import org.apache.sis.measure.Longitude;
+import org.apache.sis.measure.MeasurementRange;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.parameter.ParameterBuilder;
import org.apache.sis.referencing.operation.DefaultOperationMethod;
import org.apache.sis.referencing.operation.transform.MathTransformProvider;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.Workaround;
/**
@@ -77,6 +88,7 @@ abstract class AbstractProvider extends
* Work around for RFE #4093999 in Sun's bug database
* ("Relax constraint on placement of this()/super() call in
constructors").
*/
+ @Workaround(library="JDK", version="1.7")
private static Map<String,Object> toMap(final IdentifiedObject parameters)
{
ArgumentChecks.ensureNonNull("parameters", parameters);
final Map<String,Object> properties = new HashMap<String,Object>(4);
@@ -93,4 +105,45 @@ abstract class AbstractProvider extends
}
return properties;
}
+
+ /**
+ * Creates the parameter builder with the default namespace set to EPSG.
+ */
+ static ParameterBuilder builder() {
+ return new ParameterBuilder().setCodeSpace(Citations.OGP,
Constants.EPSG).setRequired(true);
+ }
+
+ /**
+ * Creates a descriptor for a latitude parameter in degrees.
+ */
+ static ParameterDescriptor<Double> createLatitude(final ParameterBuilder
builder, final boolean includePoles) {
+ return builder.createBounded(MeasurementRange.create(
+ Latitude.MIN_VALUE, includePoles,
+ Latitude.MAX_VALUE, includePoles,
+ NonSI.DEGREE_ANGLE), 0.0);
+ }
+
+ /**
+ * Creates a descriptor for a longitude parameter in degrees.
+ */
+ static ParameterDescriptor<Double> createLongitude(final ParameterBuilder
builder) {
+ return builder.createBounded(MeasurementRange.create(
+ Longitude.MIN_VALUE, true,
+ Longitude.MAX_VALUE, true,
+ NonSI.DEGREE_ANGLE), 0.0);
+ }
+
+ /**
+ * Creates a descriptor for a scale parameter with a default value of 1.
+ */
+ static ParameterDescriptor<Double> createScale(final ParameterBuilder
builder) {
+ return builder.createStrictlyPositive(1.0, Unit.ONE);
+ }
+
+ /**
+ * Creates a false easting or northing parameter in metre with a default
value of 0.
+ */
+ static ParameterDescriptor<Double> createShift(final ParameterBuilder
builder) {
+ return builder.create(0.0, SI.METRE);
+ }
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -36,7 +36,7 @@ import org.apache.sis.referencing.operat
/**
- * The provider for "<cite>Affine general parametric transformation</cite>"
(EPSG:9624).
+ * The provider for "<cite>Affine parametric transformation</cite>"
(EPSG:9624).
* The set of available parameters depends on the matrix size, which is 3×3 by
default.
*
* <table class="sis">
@@ -74,7 +74,7 @@ public final class Affine extends Abstra
*
* @see org.apache.sis.internal.util.Constants#AFFINE
*/
- public static final String NAME = "Affine general parametric
transformation";
+ public static final String NAME = "Affine parametric transformation";
/**
* The EPSG:9624 compliant instance, created when first needed.
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -153,7 +153,24 @@ public class DefaultParameterDescriptorG
{
super(properties, minimumOccurs, maximumOccurs);
ArgumentChecks.ensureNonNull("parameters", parameters);
- parameters = parameters.clone();
+ verifyNames(properties, parameters = parameters.clone());
+ descriptors = asList(parameters);
+ }
+
+ /**
+ * Creates a mandatory parameter group without cloning the given array.
This constructor shall
+ * be used only when we know that the given array is already a copy of the
user-provided array.
+ */
+ DefaultParameterDescriptorGroup(final Map<String,?> properties, final
GeneralParameterDescriptor[] parameters) {
+ super(properties, 1, 1);
+ verifyNames(properties, parameters.clone());
+ descriptors = asList(parameters);
+ }
+
+ /**
+ * Ensures that the given name array does not contain duplicate values.
+ */
+ private static void verifyNames(final Map<String,?> properties, final
GeneralParameterDescriptor[] parameters) {
for (int i=0; i<parameters.length; i++) {
ArgumentChecks.ensureNonNullElement("parameters", i, parameters);
final String name = parameters[i].getName().getCode();
@@ -165,7 +182,6 @@ public class DefaultParameterDescriptorG
}
}
}
- descriptors = asList(parameters);
}
/**
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -209,6 +209,7 @@ public class DefaultParameterValue<T> ex
* and there is no default value.
*
* @see #setValue(Object)
+ * @see Parameters#getValue(ParameterDescriptor)
*/
@Override
public T getValue() {
@@ -227,6 +228,7 @@ public class DefaultParameterValue<T> ex
* @throws IllegalStateException if the value is not defined and there is
no default value.
*
* @see #setValue(boolean)
+ * @see Parameters#booleanValue(ParameterDescriptor)
*/
@Override
public boolean booleanValue() throws IllegalStateException {
@@ -250,6 +252,7 @@ public class DefaultParameterValue<T> ex
*
* @see #setValue(int)
* @see #intValueList()
+ * @see Parameters#intValue(ParameterDescriptor)
*/
@Override
public int intValue() throws IllegalStateException {
@@ -276,6 +279,7 @@ public class DefaultParameterValue<T> ex
*
* @see #setValue(Object)
* @see #intValue()
+ * @see Parameters#intValueList(ParameterDescriptor)
*/
@Override
public int[] intValueList() throws IllegalStateException {
@@ -301,6 +305,7 @@ public class DefaultParameterValue<T> ex
* @see #getUnit()
* @see #setValue(double)
* @see #doubleValueList()
+ * @see Parameters#doubleValue(ParameterDescriptor)
*/
@Override
public double doubleValue() throws IllegalStateException {
@@ -373,6 +378,7 @@ public class DefaultParameterValue<T> ex
* @see #getUnit()
* @see #setValue(double,Unit)
* @see #doubleValueList(Unit)
+ * @see Parameters#doubleValue(ParameterDescriptor)
*/
@Override
public double doubleValue(final Unit<?> unit) throws
IllegalArgumentException, IllegalStateException {
@@ -397,6 +403,7 @@ public class DefaultParameterValue<T> ex
* @see #getUnit()
* @see #setValue(double[],Unit)
* @see #doubleValue(Unit)
+ * @see Parameters#doubleValueList(ParameterDescriptor)
*/
@Override
public double[] doubleValueList(final Unit<?> unit) throws
IllegalArgumentException, IllegalStateException {
@@ -418,6 +425,7 @@ public class DefaultParameterValue<T> ex
*
* @see #getValue()
* @see #setValue(Object)
+ * @see Parameters#stringValue(ParameterDescriptor)
*/
@Override
public String stringValue() throws IllegalStateException {
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -97,15 +97,13 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*
* @see DefaultParameterDescriptorGroup
* @see DefaultParameterValue
*/
-public class DefaultParameterValueGroup implements ParameterValueGroup,
- LenientComparable, Serializable, Cloneable
-{
+public class DefaultParameterValueGroup extends Parameters implements
LenientComparable, Serializable {
/**
* Serial number for inter-operability with different versions.
*/
@@ -157,6 +155,8 @@ public class DefaultParameterValueGroup
* The list will verify those conditions and throws {@link
org.opengis.parameter.InvalidParameterNameException},
* {@link org.opengis.parameter.InvalidParameterCardinalityException} or
other runtime exceptions if a condition
* is not meet.
+ *
+ * @return The values in this group.
*/
@Override
public List<GeneralParameterValue> values() {
@@ -197,13 +197,49 @@ public class DefaultParameterValueGroup
* @param name The name of the parameter to search for.
* @return The parameter value for the given name.
* @throws ParameterNotFoundException if there is no parameter value for
the given name.
+ *
+ * @see #getValue(ParameterDescriptor)
*/
@Override
public ParameterValue<?> parameter(final String name) throws
ParameterNotFoundException {
+ ParameterValue<?> value = parameterIfExist(name);
+ if (value == null) {
+ /*
+ * No existing parameter found. Maybe the parameter is optional
and not yet created.
+ * Get the descriptor of that parameter. If the descriptor is not
found, or is not
+ * a descriptor for a single parameter (not a group), or the
parameter is disabled
+ * (maximum occurrence = 0), behaves as if the parameter was not
found.
+ */
+ final GeneralParameterDescriptor descriptor =
values.descriptor.descriptor(name);
+ if (!(descriptor instanceof ParameterDescriptor<?>) ||
descriptor.getMaximumOccurs() == 0) {
+ throw new
ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,
+ values.descriptor.getName(), name), name);
+ }
+ /*
+ * Create the optional parameter and add it to our internal list.
Note that this is
+ * not the only place were a ParameterValue may be created, so do
not extract just
+ * this call to 'createValue()' in a user-overrideable method.
+ */
+ value = ((ParameterDescriptor<?>) descriptor).createValue();
+ values.addUnchecked(value);
+ }
+ return value;
+ }
+
+ /**
+ * Returns the value in this group for the specified name if it exists, or
{@code null} if none.
+ * This method does not create any new {@code ParameterValue} instance.
+ */
+ @Override
+ final ParameterValue<?> parameterIfExist(final String name) throws
ParameterNotFoundException {
ArgumentChecks.ensureNonNull("name", name);
final ParameterValueList values = this.values; // Protect against
accidental changes.
-
- // Quick search for an exact match.
+ /*
+ * Quick search for an exact match. By invoking 'descriptor(i)'
instead of 'get(i)',
+ * we avoid the creation of mandatory ParameterValue which was
deferred. If we find
+ * a matching name, the ParameterValue will be lazily created (if not
already done)
+ * by the call to 'get(i)'.
+ */
final int size = values.size();
for (int i=0; i<size; i++) {
final GeneralParameterDescriptor descriptor = values.descriptor(i);
@@ -213,8 +249,11 @@ public class DefaultParameterValueGroup
}
}
}
- // More costly search before to give up.
- int fallback = -1, ambiguity = -1;
+ /*
+ * More costly search, including aliases, before to give up.
+ */
+ int fallback = -1;
+ int ambiguity = -1;
for (int i=0; i<size; i++) {
final GeneralParameterDescriptor descriptor = values.descriptor(i);
if (descriptor instanceof ParameterDescriptor<?>) {
@@ -229,23 +268,12 @@ public class DefaultParameterValueGroup
}
if (fallback >= 0) {
if (ambiguity < 0) {
- return (ParameterValue<?>) values.get(fallback);
+ return (ParameterValue<?>) values.get(fallback); // May
lazily create a ParameterValue.
}
throw new
ParameterNotFoundException(Errors.format(Errors.Keys.AmbiguousName_3,
values.descriptor(fallback).getName(),
values.descriptor(ambiguity).getName(), name), name);
}
- /*
- * No existing parameter found. The parameter may be optional. Check
if a descriptor exists.
- * If such a descriptor is found, create the parameter, add it to the
values list and returns it.
- */
- final GeneralParameterDescriptor descriptor =
values.descriptor.descriptor(name);
- if (descriptor instanceof ParameterDescriptor<?> &&
descriptor.getMaximumOccurs() != 0) {
- final ParameterValue<?> value = ((ParameterDescriptor<?>)
descriptor).createValue();
- values.addUnchecked(value);
- return value;
- }
- throw new
ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,
- values.descriptor.getName(), name), name);
+ return null;
}
/**
@@ -385,16 +413,12 @@ public class DefaultParameterValueGroup
* Included parameter values and subgroups are cloned recursively.
*
* @return A copy of this group of parameter values.
+ *
+ * @see #copy(ParameterValueGroup, ParameterValueGroup)
*/
@Override
- @SuppressWarnings("unchecked")
public DefaultParameterValueGroup clone() {
- final DefaultParameterValueGroup copy;
- try {
- copy = (DefaultParameterValueGroup) super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(e);
- }
+ final DefaultParameterValueGroup copy = (DefaultParameterValueGroup)
super.clone();
copy.values = new ParameterValueList(copy.values);
return copy;
}
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=1667413&r1=1667412&r2=1667413&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] Tue Mar 17 21:32:34 2015
@@ -20,6 +20,9 @@ import javax.measure.unit.Unit;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.GeneralParameterDescriptor;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.cs.CoordinateSystem; // For javadoc
+import org.opengis.referencing.crs.CoordinateReferenceSystem; // For javadoc
import org.apache.sis.measure.MeasurementRange;
import org.apache.sis.measure.NumberRange;
import org.apache.sis.measure.Range;
@@ -35,55 +38,77 @@ import static org.apache.sis.util.Argume
* {@link ParameterDescriptor#createValue()} on the descriptor provided by the
implementor.
*
* {@section Identification properties}
- * Each parameter must have a name, which can be specified by any of the
{@code addName(…)} methods.
- * Parameters can optionally have an arbitrary amount of aliases, which are
also specified by the
- * {@code addName(…)} methods — each call after the first one adds an alias.
+ * The following properties are cleared after a call to any {@code
createXXX(…)} method,
+ * since those properties are specific to the each parameter. Other properties
like codespace,
+ * version and cardinality are left unchanged because they may be shared by
many parameters.
*
- * <p>Parameters can also have an arbitrary amount of identifiers, which are
specified by the
- * {@code addIdentifier(…)} methods. Like names, more than one identifier can
be added by invoking
- * the method many time.</p>
+ * <ul>
+ * <li><p><b>{@linkplain DefaultParameterDescriptor#getName() Names}:</b>
+ * each parameter must have a name, which can be specified by any of the
{@link #addName(CharSequence)
+ * addName(…)} methods. Parameters can optionally have an arbitrary amount
of aliases, which are also specified
+ * by the {@code addName(…)} methods. Each call after the first one adds an
alias.</p></li>
*
- * <p>Parameters can have at most one remark, which is specified by the {@code
setRemarks(…)} method.</p>
+ * <li><p><b>{@linkplain DefaultParameterDescriptor#getIdentifiers()
Identifiers}:</b>
+ * parameters can also have an arbitrary amount of identifiers, which are
specified by any of the
+ * {@link #addIdentifier(String) addIdentifier(…)} methods. Like names, more
than one identifier can be
+ * added by invoking the method many time.</p></li>
+ *
+ * <li><p><b>{@linkplain DefaultParameterDescriptor#getRemarks()
Remarks}:</b>
+ * parameters can have at most one remark, which is specified by the {@code
setRemarks(…)} method.</p></li>
+ * </ul>
*
- * <p>All the above-cited properties are cleared after a call to any {@code
createXXX(…)} method,
- * since those properties are specific to the each parameter. Other properties
like codespace,
- * version and cardinality are left unchanged because they may be shared by
many parameters.</p>
*
* {@section Usage example}
* Parameter descriptors are typically grouped in a {@link
ParameterDescriptorGroup}.
* All parameters usually have the same namespace, which can be declared only
once.
- * The following example creates parameters for "<cite>Mercator (variant
A)</cite>" projection method (EPSG:9804)
- * with all parameter names in the "EPSG" namespace. The default values define
a projection centered on (0°,0°),
- * with no scale factor and no false easting/northing. The projection is valid
from 80°S to 84°N and on all the
- * longitude range (±180°).
+ * The following example creates parameters for <cite>"Mercator (variant
A)"</cite>
+ * projection method (EPSG:9804), previously known as <cite>"Mercator
(1SP)"</cite>,
+ * centered by default on (0°,0°) with no scale factor and no false
easting/northing.
+ * The projection is valid from 80°S to 84°N and on all the longitude range
(±180°).
+ * In this example, the <cite>"Longitude of natural origin"</cite> parameter
is giving different aliases
+ * for illustrating the case of different softwares or standards using
different conventions.
*
* {@preformat java
* ParameterBuilder builder = new ParameterBuilder();
- * builder.setCodeSpace(Citations.OGP, "EPSG").setRequired(true);
+ * builder.setCodeSpace(Citations.OGP, "EPSG") // The
default namespace to be used below.
+ * .setRequired(true); // All
parameters will be considered mandatory.
+ *
+ * // Constructs the list of parameters.
* ParameterDescriptor<?>[] parameters = {
- * builder.addName("Latitude of natural origin") .createBounded( -80,
+84, 0, NonSI.DEGREE_ANGLE),
- * builder.addName("Longitude of natural origin") .createBounded(-180,
+180, 0, NonSI.DEGREE_ANGLE),
- * builder.addName("Scale factor at natural
origin").createStrictlyPositive(1, Unit.ONE),
- * builder.addName("False easting") .create(0, SI.METRE),
- * builder.addName("False northing") .create(0, SI.METRE)
- * };
- * }
+ * builder.addName("Latitude of natural origin") // Name in
the default namespace ("EPSG" in this example).
+ * .createBounded( -80, +84, 0, NonSI.DEGREE_ANGLE), //
Latitude of Mercator projection can not go to the poles.
*
- * Parameters often have more than one name, because different softwares or
standards use different conventions.
- * In the above example, the line creating the <cite>Longitude of natural
origin</cite> parameter could be replaced
- * by the following code in order to declare its aliases:
+ * 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, NonSI.DEGREE_ANGLE), //
Projection is valid on all the longitude range (±180°).
*
- * {@preformat java
- * builder.addIdentifier("8802") // Primary key in
builder default namespace (EPSG in this example).
- * .addName("Longitude of natural origin") // Primary name in
builder 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(-80, +84, 0, NonSI.DEGREE_ANGLE);
+ * builder.addName("Scale factor at natural origin")
+ * .createStrictlyPositive(1, Unit.ONE),
+ *
+ * builder.addName("False easting")
+ * .create(0, SI.METRE),
+ *
+ * builder.addName("False northing")
+ * .create(0, SI.METRE)
+ * };
+ *
+ * // Put all above parameters in a group.
+ * ParameterDescriptorGroup group = builder
+ * .addIdentifier("9804") // Defined
in implicit "EPSG" namespace.
+ * .addName ("Mercator (variant A)") // Defined
in implicit "EPSG" namespace.
+ * .addName ("Mercator (1SP)") // Defined
in implicit "EPSG" namespace.
+ * .addName (Citations.OGC, "Mercator_1SP") // "OGC"
namespace explicitly shown by toString().
+ * .addName (Citations.GEOTIFF, "CT_Mercator") //
"GeoTIFF" namespace explicitly shown by toString().
+ * .addIdentifier(Citations.GEOTIFF, "7")
+ * .setRemarks ("The “Mercator (1SP)” method name was used prior
to October 2010.")
+ * .createGroupForMapProjection(parameters);
* }
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
public class ParameterBuilder extends Builder<ParameterBuilder> {
@@ -120,6 +145,13 @@ public class ParameterBuilder extends Bu
}
/**
+ * Boxes the given value if non-NaN, or returns {@code null} if the value
is {@code NaN}.
+ */
+ private static Double valueOf(final double value) {
+ return Double.isNaN(value) ? null : Double.valueOf(value);
+ }
+
+ /**
* Creates a descriptor for floating point values without domain
restriction.
* All {@code double} values are considered valid.
*
@@ -134,7 +166,7 @@ public class ParameterBuilder extends Bu
} else {
valueDomain = null;
}
- return create(Double.class, valueDomain, null,
Double.valueOf(defaultValue));
+ return create(Double.class, valueDomain, null, valueOf(defaultValue));
}
/**
@@ -160,11 +192,11 @@ public class ParameterBuilder extends Bu
public ParameterDescriptor<Double> createStrictlyPositive(final double
defaultValue, final Unit<?> unit) {
final Range<Double> valueDomain;
if (unit != null) {
- valueDomain = MeasurementRange.create(0.0, false,
Double.POSITIVE_INFINITY, false, unit);
+ valueDomain = MeasurementRange.createGreaterThan(0.0, unit);
} else {
valueDomain = NumberRange.create(0.0, false,
Double.POSITIVE_INFINITY, false);
}
- return create(Double.class, valueDomain, null,
Double.valueOf(defaultValue));
+ return create(Double.class, valueDomain, null, valueOf(defaultValue));
}
/**
@@ -187,7 +219,7 @@ public class ParameterBuilder extends Bu
} else {
valueDomain = null;
}
- return create(Double.class, valueDomain, null,
Double.valueOf(defaultValue));
+ return create(Double.class, valueDomain, null, valueOf(defaultValue));
}
/**
@@ -285,6 +317,30 @@ public class ParameterBuilder extends Bu
}
/**
+ * Creates a descriptor group for the given cardinality and parameters.
+ *
+ * @param minimumOccurs The {@linkplain
DefaultParameterDescriptorGroup#getMinimumOccurs() minimum}
+ * number of times that values for this parameter
group are required.
+ * @param maximumOccurs The {@linkplain
DefaultParameterDescriptorGroup#getMaximumOccurs() maximum}
+ * number of times that values for this parameter
group are required.
+ * @param parameters The {@linkplain
DefaultParameterDescriptorGroup#descriptors() parameter descriptors}
+ * for the group to create.
+ * @return The parameter descriptor group.
+ */
+ public ParameterDescriptorGroup createGroup(final int minimumOccurs, final
int maximumOccurs,
+ final GeneralParameterDescriptor... parameters)
+ {
+ final ParameterDescriptorGroup group;
+ onCreate(false);
+ try {
+ group = new DefaultParameterDescriptorGroup(properties,
minimumOccurs, maximumOccurs, parameters);
+ } finally {
+ onCreate(true);
+ }
+ return group;
+ }
+
+ /**
* Creates a descriptor group for the given parameters. This is a
convenience method for
* {@link #createGroup(int, int, GeneralParameterDescriptor[])} with a
cardinality of [0 … 1]
* or [1 … 1] depending on the value given to the last call to {@link
#setRequired(boolean)}.
@@ -298,23 +354,50 @@ public class ParameterBuilder extends Bu
}
/**
- * Creates a descriptor group for the given cardinality and parameters.
+ * Creates a descriptor group for a map projection. This method
automatically adds mandatory parameters
+ * for the <cite>semi-major</cite> and <cite>semi-minor axis
length</cite>. Those parameters are usually
+ * not explicitely included in parameter definitions since the axis
lengths can be inferred from the
+ * {@linkplain org.apache.sis.referencing.datum.DefaultEllipsoid
ellipsoid}.
+ * However {@link
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory}
needs them.
+ *
+ * <p>In addition, this method adds hidden parameters for alternative ways
to express some standard parameters.
+ * Those hidden parameters never appear in the {@linkplain
DefaultParameterDescriptorGroup#descriptors() list
+ * of parameters}. However when one of those parameters is read or
written, the work will be delegated to the
+ * standard parameters.</p>
+ *
+ * <table class="sis">
+ * <caption>Parameters automatically added by this method</caption>
+ * <tr><th>Name</th> <th>Visibility</th>
<th>Comment</th></tr>
+ * <tr><td>{@code "semi_major"}</td> <td>Always</td>
<td>Standard parameter defined by WKT 1.</td></tr>
+ * <tr><td>{@code "semi_minor"}</td> <td>Always</td>
<td>Standard parameter defined by WKT 1.</td></tr>
+ * <tr><td>{@code "earth_radius"}</td> <td>Hidden</td>
<td>Mapped to {@code "semi_major"} and {@code "semi_minor"}
parameters.</td></tr>
+ * <tr><td>{@code "inverse_flattening"}</td> <td>Hidden</td>
<td>Mapped to {@code "semi_major"} and {@code "semi_minor"}
parameters.</td></tr>
+ * <tr><td>{@code "standard_parallel"}</td> <td>Hidden</td>
+ * <td>Array of 1 or 2 elements mapped to {@code
"standard_parallel_1"} and {@code "standard_parallel_2"}.</td></tr>
+ * </table>
+ *
+ * <div class="note"><b>Note:</b>
+ * When the {@code "earth_radius"} parameter is read, its value is the
+ * {@linkplain
org.apache.sis.referencing.datum.DefaultEllipsoid#getAuthalicRadius() authalic
radius}
+ * computed from the semi-major and semi-minor axis lengths.</div>
+ *
+ * Map projection parameter groups always have a {@linkplain
DefaultParameterDescriptorGroup#getMinimumOccurs()
+ * minimum} and {@linkplain
DefaultParameterDescriptorGroup#getMaximumOccurs() maximum occurrence} of 1,
+ * regardless the value given to {@link #setRequired(boolean)}.
*
- * @param minimumOccurs The {@linkplain
DefaultParameterDescriptorGroup#getMinimumOccurs() minimum}
- * number of times that values for this parameter
group are required.
- * @param maximumOccurs The {@linkplain
DefaultParameterDescriptorGroup#getMaximumOccurs() maximum}
- * number of times that values for this parameter
group are required.
- * @param parameters The {@linkplain
DefaultParameterDescriptorGroup#descriptors() parameter descriptors}
- * for the group to create.
- * @return The parameter descriptor group.
+ * @param parameters The {@linkplain
DefaultParameterDescriptorGroup#descriptors() parameter descriptors}
+ * for the group to create.
+ * @return The parameter descriptor group for a map projection.
+ *
+ * @see
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#createBaseToDerived(CoordinateReferenceSystem,
ParameterValueGroup, CoordinateSystem)
+ *
+ * @since 0.6
*/
- public ParameterDescriptorGroup createGroup(final int minimumOccurs, final
int maximumOccurs,
- final GeneralParameterDescriptor... parameters)
- {
+ public ParameterDescriptorGroup createGroupForMapProjection(final
ParameterDescriptor<?>... parameters) {
final ParameterDescriptorGroup group;
onCreate(false);
try {
- group = new DefaultParameterDescriptorGroup(properties,
minimumOccurs, maximumOccurs, parameters);
+ group = new MapProjectionDescriptor(properties, parameters);
} finally {
onCreate(true);
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -44,6 +44,7 @@ import org.apache.sis.internal.util.X364
import static org.apache.sis.internal.util.X364.*;
import static org.apache.sis.util.CharSequences.spaces;
+import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
/**
@@ -309,7 +310,7 @@ final class ParameterTableRow {
final Colors colors, final boolean colorsForRows, final String
lineSeparator) throws IOException
{
if (codespaceWidth != 0) {
- codespaceWidth++; // Add a space between codespace and code in
e.g. "OGC: Mercator".
+ codespaceWidth += 2; // Add a colon and space between codespace
and code in e.g. "OGC: Mercator".
}
boolean isNewLine = false;
for (final Map.Entry<String,Set<Object>> entry :
identifiers.entrySet()) {
@@ -330,9 +331,9 @@ final class ParameterTableRow {
int pad = codespaceWidth;
if (codespace != null) {
writeColor(out, FAINT, colorsForRows);
- out.append(codespace).append(':');
+ out.append(codespace).append(DEFAULT_SEPARATOR);
writeColor(out, NORMAL, colorsForRows);
- pad -= codespace.length();
+ pad -= (codespace.length() + 1);
}
out.append(spaces(pad));
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java?rev=1667413&r1=1667412&r2=1667413&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] Tue Mar 17 21:32:34 2015
@@ -70,6 +70,7 @@ final class ParameterValueList extends A
/**
* The parameter values in the group. The length of this array is the list
capacity.
+ * This array will growth as needed.
*/
private GeneralParameterValue[] values;