You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/06/16 12:37:55 UTC
svn commit: r1748710 [1/2] - in /sis/trunk: ./
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-console/src/test/java/org/apache/sis/console/
application/sis-console/src/test/java/org/apache/sis/test/suite/
application/sis-...
Author: desruisseaux
Date: Thu Jun 16 12:37:54 2016
New Revision: 1748710
URL: http://svn.apache.org/viewvc?rev=1748710&view=rev
Log:
Merge from the JDK6 branch. Contains first draft of OpenOffice add-ins.
Added:
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/CRSCommandTest.java
- copied unchanged from r1748701, sis/branches/JDK6/application/sis-console/src/test/java/org/apache/sis/console/CRSCommandTest.java
sis/trunk/application/sis-openoffice/
- copied from r1748701, sis/branches/JDK6/application/sis-openoffice/
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/
- copied from r1748701, sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java
- copied unchanged from r1748701, sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java
sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/CodeTypeTest.java
- copied unchanged from r1748701, sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/CodeTypeTest.java
Modified:
sis/trunk/ (props changed)
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataCommandTest.java
sis/trunk/application/sis-console/src/test/java/org/apache/sis/test/suite/ConsoleTestSuite.java
sis/trunk/application/sis-openoffice/pom.xml
sis/trunk/application/sis-openoffice/src/main/unopkg/sis.png (props changed)
sis/trunk/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java
sis/trunk/core/sis-build-helper/pom.xml
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxisFilter.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
sis/trunk/pom.xml
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 16 12:37:54 2016
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK6:1394364-1746056
-/sis/branches/JDK7:1394913-1746055
-/sis/branches/JDK8:1584960-1746054
+/sis/branches/JDK6:1394364-1748701
+/sis/branches/JDK7:1394913-1748694
+/sis/branches/JDK8:1584960-1748692
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -37,7 +37,7 @@ import org.apache.sis.io.wkt.Convention;
*/
final class CRSCommand extends MetadataCommand {
/**
- * Creates the {@code "metadata"}, {@code "crs"} or {@code "identifier"} sub-command.
+ * Creates the {@code "crs"} sub-command.
*/
CRSCommand(final int commandIndex, final String... args) throws InvalidOptionException {
super(commandIndex, args);
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -95,7 +95,7 @@ final class IdentifierCommand extends Me
}
/**
- * Creates the {@code "metadata"}, {@code "crs"} or {@code "identifier"} sub-command.
+ * Creates the {@code "identifier"} sub-command.
*/
IdentifierCommand(final int commandIndex, final String... args) throws InvalidOptionException {
super(commandIndex, args);
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -16,11 +16,8 @@
*/
package org.apache.sis.console;
-import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Set;
import java.io.Console;
import java.io.IOException;
import javax.xml.bind.Marshaller;
@@ -39,6 +36,7 @@ import org.apache.sis.referencing.CRS;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStores;
import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.internal.storage.CodeType;
import org.apache.sis.util.collection.TableColumn;
import org.apache.sis.util.collection.TreeTable;
import org.apache.sis.util.collection.TreeTableFormat;
@@ -58,18 +56,6 @@ import org.apache.sis.xml.XML;
*/
class MetadataCommand extends CommandRunner {
/**
- * The protocol part of the filename to be recognized as a CRS authority.
- * In such case, this class will delegate to {@link CRS#forCode(String)}
- * instead of opening the file.
- */
- static final Set<String> AUTHORITIES = new HashSet<String>(Arrays.asList("URN", "EPSG", "CRS", "AUTO", "AUTO2"));
-
- /**
- * Length of the longest authority name declared in {@link #AUTHORITIES}.
- */
- static final int MAX_AUTHORITY_LENGTH = 5;
-
- /**
* The output format.
*/
static enum Format {
@@ -142,39 +128,7 @@ class MetadataCommand extends CommandRun
}
/**
- * Returns {@code true} if the given argument begins with one of the known authorities
- * ("URN", "EPSG", "CRS", "AUTO", <i>etc.</i>).
- */
- static boolean isAuthorityCode(final String code) {
- final char[] authority = new char[MAX_AUTHORITY_LENGTH];
- final int length = code.length();
- int p = 0, i = 0;
- while (i < length) {
- final int c = code.codePointAt(i);
- if (c == ':') {
- if (!AUTHORITIES.contains(new String(authority, 0, p))) {
- break;
- }
- return true;
- }
- if (!Character.isWhitespace(c)) {
- if (p >= MAX_AUTHORITY_LENGTH || !Character.isLetterOrDigit(c)) {
- break;
- }
- /*
- * Casting to char is okay because AUTHORITIES contains only ASCII values.
- * If 'c' was a supplemental Unicode value, then the result of the cast
- * would not match any AUTHORITIES value anyway.
- */
- authority[p++] = (char) Character.toUpperCase(c);
- }
- i += Character.charCount(c);
- }
- return false;
- }
-
- /**
- * If the given argument begins with one of the known authorities ("URN", "EPSG", "CRS", "AUTO", <i>etc.</i>),
+ * If the given argument seems to be an authority code ("URN", "EPSG", "CRS", "AUTO", <i>etc.</i>),
* delegates to {@link CRS#forCode(String)}. Otherwise reads the metadata using a datastore.
*
* @return A {@link Metadata} or {@link CoordinateReferenceSystem} instance, or {@code null} if none.
@@ -192,7 +146,7 @@ class MetadataCommand extends CommandRun
return null;
} else {
final String file = files.get(0);
- if (isAuthorityCode(file)) {
+ if (CodeType.guess(file).isCRS) {
return CRS.forCode(file);
} else {
final DataStore store = DataStores.open(file);
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -53,6 +53,7 @@ import org.apache.sis.geometry.Immutable
import org.apache.sis.internal.referencing.Formulas;
import org.apache.sis.internal.referencing.DirectPositionView;
import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.storage.CodeType;
import org.apache.sis.internal.util.PatchedUnitFormat;
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.CRS;
@@ -164,7 +165,7 @@ final class TransformCommand extends Met
final String name = option.label();
throw new InvalidOptionException(Errors.format(Errors.Keys.MissingValueForOption_1, name), name);
}
- if (isAuthorityCode(identifier)) try {
+ if (CodeType.guess(identifier).isCRS) try {
return CRS.forCode(identifier);
} catch (NoSuchAuthorityCodeException e) {
final String name = option.label();
Modified: sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataCommandTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataCommandTest.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataCommandTest.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataCommandTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -37,22 +37,9 @@ import static org.junit.Assert.*;
@DependsOn(CommandRunnerTest.class)
public final strictfp class MetadataCommandTest extends TestCase {
/**
- * Verifies the {@link MetadataCommand#MAX_AUTHORITY_LENGTH} value.
- */
- @Test
- public void verifyMaxAuthorityLength() {
- int length = 0;
- for (final String authority : MetadataCommand.AUTHORITIES) {
- final int c = authority.length();
- if (c > length) length = c;
- }
- assertEquals("MAX_AUTHORITY_LENGTH", length, MetadataCommand.MAX_AUTHORITY_LENGTH);
- }
-
- /**
* Tests the sub-command on a NetCDF file.
*
- * @throws Exception Should never happen.
+ * @throws Exception if an error occurred while creating the command.
*/
@Test
@Ignore("Requires GeoAPI 3.1")
@@ -79,7 +66,7 @@ public final strictfp class MetadataComm
/**
* Tests with the same file than {@link #testNetCDF()}, but producing a XML output.
*
- * @throws Exception Should never happen.
+ * @throws Exception if an error occurred while creating the command.
*/
@Test
@Ignore("Requires GeoAPI 3.1")
Modified: sis/trunk/application/sis-console/src/test/java/org/apache/sis/test/suite/ConsoleTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/test/java/org/apache/sis/test/suite/ConsoleTestSuite.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/test/java/org/apache/sis/test/suite/ConsoleTestSuite.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/test/java/org/apache/sis/test/suite/ConsoleTestSuite.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.4
+ * @version 0.8
* @module
*/
@Suite.SuiteClasses({
@@ -34,7 +34,8 @@ import org.junit.BeforeClass;
org.apache.sis.console.HelpCommandTest.class,
org.apache.sis.console.AboutCommandTest.class,
org.apache.sis.console.MimeTypeCommandTest.class,
- org.apache.sis.console.MetadataCommandTest.class
+ org.apache.sis.console.MetadataCommandTest.class,
+ org.apache.sis.console.CRSCommandTest.class
})
public final strictfp class ConsoleTestSuite extends TestSuite {
/**
Modified: sis/trunk/application/sis-openoffice/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-openoffice/pom.xml?rev=1748710&r1=1748701&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-openoffice/pom.xml (original)
+++ sis/trunk/application/sis-openoffice/pom.xml Thu Jun 16 12:37:54 2016
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>application</artifactId>
- <version>0.8-jdk6-SNAPSHOT</version>
+ <version>0.8-SNAPSHOT</version>
</parent>
@@ -88,7 +88,7 @@
<dependencies>
<dependency>
<groupId>org.opengis</groupId>
- <artifactId>geoapi-pending</artifactId>
+ <artifactId>geoapi</artifactId>
</dependency>
<dependency>
<groupId>javax.measure</groupId>
Propchange: sis/trunk/application/sis-openoffice/src/main/unopkg/sis.png
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 16 12:37:54 2016
@@ -1,8 +1,8 @@
/sis/branches/Android/application/sis-openoffice/src/main/unopkg/sis.png:1430670-1480699
/sis/branches/Android/src/site/resources/images/banner.png:1430670-1480699
-/sis/branches/JDK6/application/sis-openoffice/src/main/unopkg/sis.png:1394913-1508480
+/sis/branches/JDK6/application/sis-openoffice/src/main/unopkg/sis.png:1394364-1746056,1748699-1748701
/sis/branches/JDK6/src/site/resources/images/banner.png:1394913-1498321
-/sis/branches/JDK7/application/sis-openoffice/src/main/unopkg/sis.png:1394913-1746055,1748682
-/sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/sis.png:1584960-1748678
+/sis/branches/JDK7/application/sis-openoffice/src/main/unopkg/sis.png:1394913-1748694
+/sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/sis.png:1584960-1748692
/sis/trunk/application/sis-openoffice/src/main/unopkg/sis.png:1394364-1508466,1519089-1519674
/sis/trunk/src/site/resources/images/banner.png:1394364-1498284
Modified: sis/trunk/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java?rev=1748710&r1=1748701&r2=1748710&view=diff
==============================================================================
--- sis/trunk/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java [UTF-8] (original)
+++ sis/trunk/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -26,7 +26,7 @@ import org.junit.AfterClass;
import org.junit.Test;
import static org.junit.Assert.*;
-import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
/**
@@ -102,7 +102,7 @@ public final strictfp class ReferencingF
public void testGetGeographicArea() {
final double[][] bbox = instance.getGeographicArea("EPSG:32620"); // UTM zone 20
assertEquals(2, bbox.length);
- assumeFalse(Double.isNaN(bbox[0][0])); // NaN if EPSG dataset is not installed.
+ assumeTrue(!Double.isNaN(bbox[0][0])); // NaN if EPSG dataset is not installed.
assertArrayEquals("Upper left corner", new double[] {84, -66}, bbox[0], STRICT);
assertArrayEquals("Lower right corner", new double[] { 0, -60}, bbox[1], STRICT);
}
Modified: sis/trunk/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/pom.xml?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/pom.xml (original)
+++ sis/trunk/core/sis-build-helper/pom.xml Thu Jun 16 12:37:54 2016
@@ -45,9 +45,9 @@
<!-- Left alignment because this description will be copied in META-INF/MANIFEST.MF
The leading space after the first line is necessary for proper formatting. -->
Define Maven Mojos and Javadoc taglets for generating resource files
- or formatting the Javadoc. While any project could use it, this module
- is primarily for internal use by Apache SIS and may change in any
- future version.
+ formatting the Javadoc or creating ".oxt" files for OpenOffice.org.
+ While any project could use it, this module is primarily for internal
+ use by Apache SIS and may change in any future version.
</description>
@@ -108,12 +108,12 @@ Define Maven Mojos and Javadoc taglets f
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>3.3.3</version>
+ <version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>3.3.3</version>
+ <version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java [UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -92,7 +92,7 @@ public class Assembler extends AbstractM
* have been zipped. Now generate the Pack200 file and zip it directly (without creating
* a temporary "sis.pack.gz" file).
*/
- final Packer packer = new Packer(project.getName(), project.getUrl(), version, targetDirectory);
+ final Packer packer = new Packer(project.getName(), version, targetDirectory);
final ZipArchiveEntry entry = new ZipArchiveEntry(
artifactBase + '/' + LIB_DIRECTORY + '/' + FATJAR_FILE + PACK_EXTENSION);
entry.setMethod(ZipArchiveEntry.STORED);
Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java [UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -74,7 +74,7 @@ public class BundleCreator extends Abstr
}
final String version = project.getVersion();
try {
- final Packer packer = new Packer(project.getName(), project.getUrl(), version, targetDirectory);
+ final Packer packer = new Packer(project.getName(), version, targetDirectory);
packer.preparePack200(FINALNAME_PREFIX + version + ".jar").pack();
} catch (IOException e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java [UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -118,11 +118,10 @@ final class PackOutput implements Closea
* Opens the given JAR file for writing and creates its manifest.
*
* @param projectName The project name, or {@code null} if none.
- * @param projectURL The project URL, or {@code null} if none.
* @param version The project version, or {@code null} if none.
* @throws IOException if the file can't be open.
*/
- void open(final String projectName, final String projectURL, final String version) throws IOException {
+ void open(final String projectName, final String version) throws IOException {
final Manifest manifest = new Manifest();
Attributes attributes = manifest.getMainAttributes();
attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
@@ -132,9 +131,6 @@ final class PackOutput implements Closea
attributes.put(Attributes.Name.IMPLEMENTATION_TITLE, projectName);
attributes.put(Attributes.Name.IMPLEMENTATION_VENDOR, projectName);
}
- if (projectURL != null) {
- attributes.put(Attributes.Name.IMPLEMENTATION_URL, projectURL);
- }
if (version != null) {
attributes.put(Attributes.Name.SPECIFICATION_VERSION, version);
attributes.put(Attributes.Name.IMPLEMENTATION_VERSION, version);
@@ -182,8 +178,7 @@ final class PackOutput implements Closea
copy(src, attributes, Attributes.Name.SPECIFICATION_VERSION) |
copy(src, attributes, Attributes.Name.IMPLEMENTATION_TITLE) |
copy(src, attributes, Attributes.Name.IMPLEMENTATION_VENDOR) |
- copy(src, attributes, Attributes.Name.IMPLEMENTATION_VERSION) |
- copy(src, attributes, Attributes.Name.IMPLEMENTATION_URL))
+ copy(src, attributes, Attributes.Name.IMPLEMENTATION_VERSION))
{
manifest.getEntries().put(packageName, attributes);
}
@@ -330,11 +325,13 @@ final class PackOutput implements Closea
final File inputFile = outputJAR;
final Pack200.Packer packer = Pack200.newPacker();
final Map<String,String> p = packer.properties();
- p.put(EFFORT, String.valueOf(9)); // Maximum compression level.
- p.put(KEEP_FILE_ORDER, FALSE); // Reorder files for better compression.
- p.put(MODIFICATION_TIME, LATEST); // Smear modification times to a single value.
- p.put(DEFLATE_HINT, TRUE); // Ignore all JAR deflation requests.
- p.put(UNKNOWN_ATTRIBUTE, ERROR); // Throw an error if an attribute is unrecognized
+ p.put(EFFORT, String.valueOf(9)); // Maximum compression level.
+ p.put(SEGMENT_LIMIT, "-1"); // use largest-possible archive segments (>10% better compression).
+ p.put(KEEP_FILE_ORDER, FALSE); // Reorder files for better compression.
+ p.put(MODIFICATION_TIME, LATEST); // Smear modification times to a single value.
+ p.put(DEFLATE_HINT, TRUE); // Ignore all JAR deflation requests.
+ p.put(UNKNOWN_ATTRIBUTE, ERROR); // Throw an error if an attribute is unrecognized
+ p.put(CODE_ATTRIBUTE_PFX+"LocalVariableTable", STRIP); // discard debug attributes.
final JarFile jarFile = new JarFile(inputFile);
try {
final OutputStream deflater = new GZIPOutputStream(out);
Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java [UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -40,9 +40,9 @@ import static org.apache.sis.internal.ma
*/
final class Packer implements FilenameFilter {
/**
- * The project name, URL and version to declare in the manifest file, or {@code null} if none.
+ * The project name and version to declare in the manifest file, or {@code null} if none.
*/
- private final String projectName, projectURL, version;
+ private final String projectName, version;
/**
* The Maven target directory. Shall contain the {@code "binaries"} sub-directory,
@@ -59,16 +59,12 @@ final class Packer implements FilenameFi
* Creates a packer.
*
* @param projectName The project name to declare in the manifest file, or {@code null} if none.
- * @param projectURL The project URL to declare in the manifest file, or {@code null} if none.
* @param version The project version to declare in the manifest file, or {@code null} if none.
* @param targetDirectory The Maven target directory.
* @throws FileNotFoundException if the {@code target/binaries} directory is not found.
*/
- Packer(final String projectName, final String projectURL, final String version,
- final File targetDirectory) throws FileNotFoundException
- {
+ Packer(final String projectName, final String version, final File targetDirectory) throws FileNotFoundException {
this.projectName = projectName;
- this.projectURL = projectURL;
this.version = version;
this.targetDirectory = targetDirectory;
this.binariesDirectory = new File(targetDirectory, BINARIES_DIRECTORY);
@@ -130,7 +126,7 @@ final class Packer implements FilenameFi
final File outDirectory = distributionDirectory(targetDirectory);
final PackOutput output = new PackOutput(getInputJARs(), new File(outDirectory, outputJAR));
try {
- output.open(projectName, projectURL, version);
+ output.open(projectName, version);
output.writeContent();
} finally {
output.close();
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -19,7 +19,6 @@ package org.apache.sis.internal.metadata
import java.util.Locale;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.security.AccessController;
@@ -37,6 +36,7 @@ import javax.naming.event.EventContext;
import javax.naming.event.NamingEvent;
import javax.naming.event.NamingExceptionEvent;
import javax.naming.event.ObjectChangeListener;
+import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.system.DataDirectory;
import org.apache.sis.internal.system.Shutdown;
import org.apache.sis.internal.system.Loggers;
@@ -61,7 +61,7 @@ import org.apache.sis.internal.jdk7.Path
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.7
- * @version 0.7
+ * @version 0.8
* @module
*/
public abstract class Initializer {
@@ -181,7 +181,7 @@ public abstract class Initializer {
*/
Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM), Listener.class, "objectChanged", e);
}
- for (Initializer init : ServiceLoader.load(Initializer.class)) {
+ for (Initializer init : DefaultFactories.createServiceLoader(Initializer.class)) {
init.dataSourceChanged();
}
}
@@ -299,7 +299,7 @@ public abstract class Initializer {
m.invoke(source, "create");
Connection c = source.getConnection();
try {
- for (Initializer init : ServiceLoader.load(Initializer.class)) {
+ for (Initializer init : DefaultFactories.createServiceLoader(Initializer.class)) {
init.createSchema(c);
}
} finally {
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -33,7 +33,7 @@ import org.apache.sis.metadata.Modifiabl
import org.apache.sis.internal.jaxb.IdentifierMapAdapter;
import org.apache.sis.internal.jaxb.ModifiableIdentifierMap;
import org.apache.sis.internal.metadata.MetadataUtilities;
-import org.apache.sis.internal.util.Utilities;
+import org.apache.sis.internal.system.Modules;
import org.apache.sis.util.collection.Containers;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -96,7 +96,7 @@ public class ISOMetadata extends Modifia
* without invoking super.getIdentifiers(), in which case their identifiers will not be copied.
* For safety, we will do this optimization only if the implementation is an Apache SIS one.
*/
- if (Utilities.isSIS(object.getClass())) {
+ if (object.getClass().getName().startsWith(Modules.CLASSNAME_PREFIX)) {
return;
}
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -324,7 +324,7 @@ public class DefaultBand extends Default
/**
* Returns the wavelength at which the response is the highest.
- * The units of measurement is given by {@link #getUnits()}.
+ * The units of measurement is given by {@link #getBoundUnits()}.
*
* @return Wavelength at which the response is the highest, or {@code null} if unspecified.
*/
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -40,7 +40,7 @@
* {@code �����\u2514\u2500} {@linkplain org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent Spatial temporal extent}<br>
* </td><td class="sep" style="width: 50%; white-space: nowrap">
* {@linkplain org.apache.sis.metadata.iso.extent.DefaultExtent Extent}<br>
- * {@code �\u251c\u2500} {@linkplain org.apache.sis.metadata.iso.extent.AbstractGeographicExtent Geographic extent}<br>
+ * {@code �\u251c\u2500} {@linkplain org.apache.sis.metadata.iso.extent.AbstractGeographicExtent Geographic extent} �abstract�<br>
* {@code �\u251c\u2500} {@linkplain org.apache.sis.metadata.iso.extent.DefaultVerticalExtent Vertical extent}<br>
* {@code �\u2514\u2500} {@linkplain org.apache.sis.metadata.iso.extent.DefaultTemporalExtent Temporal extent}<br>
* {@linkplain org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent Spatial temporal extent}<br>
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -22,6 +22,12 @@ import java.util.LinkedHashSet;
import java.util.Locale;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.NoSuchAuthorityCodeException;
+import org.opengis.referencing.datum.DatumAuthorityFactory;
+import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.datum.GeodeticDatum;
+import org.opengis.referencing.datum.VerticalDatum;
import org.opengis.referencing.crs.GeocentricCRS;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.ProjectedCRS;
@@ -49,11 +55,11 @@ import org.apache.sis.util.Debug;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.7
- * @version 0.7
+ * @version 0.8
* @module
*/
@Fallback
-final class EPSGFactoryFallback extends GeodeticAuthorityFactory implements CRSAuthorityFactory {
+final class EPSGFactoryFallback extends GeodeticAuthorityFactory implements CRSAuthorityFactory, DatumAuthorityFactory {
/**
* Whether to disallow {@code CommonCRS} to use {@link org.apache.sis.referencing.factory.sql.EPSGFactory}
* (in which case {@code CommonCRS} will fallback on hard-coded values).
@@ -65,7 +71,12 @@ final class EPSGFactoryFallback extends
/**
* The singleton instance.
*/
- static final CRSAuthorityFactory INSTANCE = new EPSGFactoryFallback();
+ static final EPSGFactoryFallback INSTANCE = new EPSGFactoryFallback();
+
+ /**
+ * Kinds of object created by this factory. Used as bitmask.
+ */
+ private static final int CRS = 1, DATUM = 2, ELLIPSOID = 4, PRIME_MERIDIAN = 8;
/**
* The authority, created when first needed.
@@ -107,18 +118,22 @@ final class EPSGFactoryFallback extends
*/
@Override
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) {
+ final boolean pm = type.isAssignableFrom(PrimeMeridian.class);
+ final boolean ellipsoid = type.isAssignableFrom(Ellipsoid .class);
+ final boolean datum = type.isAssignableFrom(GeodeticDatum.class);
final boolean geographic = type.isAssignableFrom(GeographicCRS.class);
final boolean geocentric = type.isAssignableFrom(GeocentricCRS.class);
final boolean projected = type.isAssignableFrom(ProjectedCRS .class);
final Set<String> codes = new LinkedHashSet<String>();
+ if (pm) codes.add(StandardDefinitions.GREENWICH);
for (final CommonCRS crs : CommonCRS.values()) {
+ if (ellipsoid) add(codes, crs.ellipsoid);
+ if (datum) add(codes, crs.datum);
+ if (geocentric) add(codes, crs.geocentric);
if (geographic) {
add(codes, crs.geographic);
add(codes, crs.geo3D);
}
- if (geocentric) {
- add(codes, crs.geocentric);
- }
if (projected && (crs.northUTM != 0 || crs.southUTM != 0)) {
for (int zone = crs.firstZone; zone <= crs.lastZone; zone++) {
if (crs.northUTM != 0) codes.add(Integer.toString(crs.northUTM + zone));
@@ -126,10 +141,13 @@ final class EPSGFactoryFallback extends
}
}
}
- if (type.isAssignableFrom(VerticalCRS.class)) {
+ final boolean vertical = type.isAssignableFrom(VerticalCRS .class);
+ final boolean vdatum = type.isAssignableFrom(VerticalDatum.class);
+ if (vertical || vdatum) {
for (final CommonCRS.Vertical candidate : CommonCRS.Vertical.values()) {
if (candidate.isEPSG) {
- codes.add(Integer.toString(candidate.crs));
+ if (vertical) codes.add(Integer.toString(candidate.crs));
+ if (vdatum) codes.add(Integer.toString(candidate.datum));
}
}
}
@@ -147,11 +165,55 @@ final class EPSGFactoryFallback extends
}
/**
+ * Returns a prime meridian for the given EPSG code.
+ */
+ @Override
+ public PrimeMeridian createPrimeMeridian(final String code) throws NoSuchAuthorityCodeException {
+ return (PrimeMeridian) predefined(code, PRIME_MERIDIAN);
+ }
+
+ /**
+ * Returns an ellipsoid for the given EPSG code.
+ */
+ @Override
+ public Ellipsoid createEllipsoid(final String code) throws NoSuchAuthorityCodeException {
+ return (Ellipsoid) predefined(code, ELLIPSOID);
+ }
+
+ /**
+ * Returns a datum for the given EPSG code.
+ */
+ @Override
+ public Datum createDatum(final String code) throws NoSuchAuthorityCodeException {
+ return (Datum) predefined(code, DATUM);
+ }
+
+ /**
* Returns a coordinate reference system for the given EPSG code. This method is invoked
* as a fallback when {@link CRS#forCode(String)} can not create a CRS for a given code.
*/
@Override
+ public CoordinateReferenceSystem createCoordinateReferenceSystem(final String code) throws NoSuchAuthorityCodeException {
+ return (CoordinateReferenceSystem) predefined(code, CRS);
+ }
+
+ /**
+ * Returns a coordinate reference system, datum or ellipsoid for the given EPSG code.
+ */
+ @Override
public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException {
+ return predefined(code, -1);
+ }
+
+ /**
+ * Implementation of the {@code createFoo(String)} methods.
+ *
+ * @param code the EPSG code.
+ * @param kind any combination of {@link #CRS}, {@link #DATUM}, {@link #ELLIPSOID} or {@link #PRIME_MERIDIAN} bits.
+ * @return the requested object.
+ * @throws NoSuchAuthorityCodeException if no matching object has been found.
+ */
+ private IdentifiedObject predefined(String code, final int kind) throws NoSuchAuthorityCodeException {
NumberFormatException cause = null;
try {
/*
@@ -161,35 +223,57 @@ final class EPSGFactoryFallback extends
* is used directly (not through MultiAuthoritiesFactory), which should be rare. The main case is
* when using the factory returned by AuthorityFactories.fallback(\u2026).
*/
- final int n = Integer.parseInt(CharSequences.trimWhitespaces(code,
- code.lastIndexOf(DefaultNameSpace.DEFAULT_SEPARATOR) + 1,
- code.length()).toString());
+ code = CharSequences.trimWhitespaces(code, code.lastIndexOf(DefaultNameSpace.DEFAULT_SEPARATOR) + 1, code.length()).toString();
+ final int n = Integer.parseInt(code);
+ if ((kind & PRIME_MERIDIAN) != 0 && n == 8901) {
+ return CommonCRS.WGS84.primeMeridian();
+ }
for (final CommonCRS crs : CommonCRS.values()) {
- if (n == crs.geographic) return crs.geographic();
- if (n == crs.geocentric) return crs.geocentric();
- if (n == crs.geo3D) return crs.geographic3D();
- final double latitude;
- int zone;
- if (crs.northUTM != 0 && (zone = n - crs.northUTM) >= crs.firstZone && zone <= crs.lastZone) {
- latitude = +1;
- } else if (crs.southUTM != 0 && (zone = n - crs.southUTM) >= crs.firstZone && zone <= crs.lastZone) {
- latitude = -1;
- } else {
- continue;
+ /*
+ * In a complete EPSG dataset we could have an ambiguity below because the same code can be used
+ * for datum, ellipsoid and CRS objects. However in the particular case of this EPSG-subset, we
+ * ensured that there is no such collision - see CommonCRSTest.ensureNoCodeCollision().
+ */
+ if ((kind & ELLIPSOID) != 0 && n == crs.ellipsoid) return crs.ellipsoid();
+ if ((kind & DATUM) != 0 && n == crs.datum) return crs.datum();
+ if ((kind & CRS) != 0) {
+ if (n == crs.geographic) return crs.geographic();
+ if (n == crs.geocentric) return crs.geocentric();
+ if (n == crs.geo3D) return crs.geographic3D();
+ final double latitude;
+ int zone;
+ if (crs.northUTM != 0 && (zone = n - crs.northUTM) >= crs.firstZone && zone <= crs.lastZone) {
+ latitude = +1;
+ } else if (crs.southUTM != 0 && (zone = n - crs.southUTM) >= crs.firstZone && zone <= crs.lastZone) {
+ latitude = -1;
+ } else {
+ continue;
+ }
+ return crs.UTM(latitude, TransverseMercator.centralMeridian(zone));
}
- return crs.UTM(latitude, TransverseMercator.centralMeridian(zone));
}
- for (final CommonCRS.Vertical candidate : CommonCRS.Vertical.values()) {
- if (candidate.isEPSG && candidate.crs == n) {
- return candidate.crs();
+ if ((kind & (DATUM | CRS)) != 0) {
+ for (final CommonCRS.Vertical candidate : CommonCRS.Vertical.values()) {
+ if (candidate.isEPSG) {
+ if ((kind & DATUM) != 0 && candidate.datum == n) return candidate.datum();
+ if ((kind & CRS) != 0 && candidate.crs == n) return candidate.crs();
+ }
}
}
} catch (NumberFormatException e) {
cause = e;
}
- final String authority = Constants.EPSG + " subset";
+ final Class<?> type;
+ switch (kind) {
+ case CRS: type = CoordinateReferenceSystem.class; break;
+ case DATUM: type = Datum.class; break;
+ case ELLIPSOID: type = Ellipsoid.class; break;
+ case PRIME_MERIDIAN: type = PrimeMeridian.class; break;
+ default: type = IdentifiedObject.class; break;
+ }
+ final String authority = Constants.EPSG + "-subset";
final NoSuchAuthorityCodeException e = new NoSuchAuthorityCodeException(Errors.format(
- Errors.Keys.NoSuchAuthorityCode_3, authority, CoordinateReferenceSystem.class, code), authority, code);
+ Errors.Keys.NoSuchAuthorityCode_3, authority, type, code), authority, code);
e.initCause(cause);
throw e;
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -153,12 +153,6 @@ public enum AxesConvention implements Ax
}
@Override
- @Deprecated
- public Unit<?> getUnitReplacement(Unit<?> unit) {
- return getUnitReplacement(null, unit);
- }
-
- @Override
public Unit<?> getUnitReplacement(final CoordinateSystemAxis axis, Unit<?> unit) {
if (Units.isLinear(unit)) {
unit = SI.METRE;
@@ -171,12 +165,6 @@ public enum AxesConvention implements Ax
}
@Override
- @Deprecated
- public AxisDirection getDirectionReplacement(final AxisDirection direction) {
- return getDirectionReplacement(null, direction);
- }
-
- @Override
public AxisDirection getDirectionReplacement(final CoordinateSystemAxis axis, final AxisDirection direction) {
/*
* For now we do not touch to inter-cardinal directions (e.g. "North-East")
@@ -250,23 +238,11 @@ public enum AxesConvention implements Ax
}
@Override
- @Deprecated
- public Unit<?> getUnitReplacement(final Unit<?> unit) {
- return unit;
- }
-
- @Override
public Unit<?> getUnitReplacement(final CoordinateSystemAxis axis, final Unit<?> unit) {
return unit;
}
@Override
- @Deprecated
- public AxisDirection getDirectionReplacement(final AxisDirection direction) {
- return getDirectionReplacement(null, direction);
- }
-
- @Override
public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, AxisDirection direction) {
return NORMALIZED.getDirectionReplacement(axis, direction);
}
@@ -306,23 +282,11 @@ public enum AxesConvention implements Ax
}
@Override
- @Deprecated
- public Unit<?> getUnitReplacement(final Unit<?> unit) {
- return unit;
- }
-
- @Override
public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, final Unit<?> unit) {
return unit;
}
@Override
- @Deprecated
- public AxisDirection getDirectionReplacement(final AxisDirection direction) {
- return direction;
- }
-
- @Override
public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) {
return direction;
}
@@ -358,23 +322,11 @@ public enum AxesConvention implements Ax
}
@Override
- @Deprecated
- public Unit<?> getUnitReplacement(final Unit<?> unit) {
- return unit;
- }
-
- @Override
public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, final Unit<?> unit) {
return unit;
}
@Override
- @Deprecated
- public AxisDirection getDirectionReplacement(final AxisDirection direction) {
- return direction;
- }
-
- @Override
public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) {
return direction;
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxisFilter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxisFilter.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxisFilter.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxisFilter.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -83,15 +83,6 @@ public interface AxisFilter {
AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, AxisDirection direction);
/**
- * @deprecated Use {@link #getDirectionReplacement(CoordinateSystemAxis, AxisDirection)} instead.
- *
- * @param direction The original axis direction.
- * @return The new axis direction, or {@code direction} if there is no change.
- */
- @Deprecated
- AxisDirection getDirectionReplacement(AxisDirection direction);
-
- /**
* Returns a replacement for the given axis unit.
*
* <div class="note"><b>Example:</b>
@@ -116,13 +107,4 @@ public interface AxisFilter {
* @since 0.7
*/
Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit);
-
- /**
- * @deprecated Use {@link #getUnitReplacement(CoordinateSystemAxis, Unit)} instead.
- *
- * @param unit The original axis unit.
- * @return The new axis unit, or {@code unit} if there is no change.
- */
- @Deprecated
- Unit<?> getUnitReplacement(Unit<?> unit);
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -446,16 +446,6 @@ public final class CoordinateSystems ext
public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, AxisDirection direction) {
return direction;
}
-
- @Deprecated @Override
- public AxisDirection getDirectionReplacement(AxisDirection direction) {
- return direction;
- }
-
- @Deprecated @Override
- public Unit<?> getUnitReplacement(Unit<?> unit) {
- return getUnitReplacement(null, unit);
- }
});
}
@@ -497,16 +487,6 @@ public final class CoordinateSystems ext
public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, AxisDirection direction) {
return direction;
}
-
- @Deprecated @Override
- public AxisDirection getDirectionReplacement(AxisDirection direction) {
- return direction;
- }
-
- @Deprecated @Override
- public Unit<?> getUnitReplacement(Unit<?> unit) {
- return getUnitReplacement(null, unit);
- }
});
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -182,6 +182,9 @@ abstract class AuthorityFactoryProxy<T>
@Override InternationalString createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
return factory.getDescriptionText(code);
}
+ @Override AuthorityFactoryProxy<InternationalString> specialize(String typeName) {
+ return this;
+ }
};
/**
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -751,7 +751,8 @@ public class MultiAuthoritiesFactory ext
if (code == null) {
message = Errors.format(Errors.Keys.MissingComponentInElement_2, s, "code");
} else {
- message = Errors.format(Errors.Keys.CanNotCreateObjectAsInstanceOf_2, type, uri.type);
+ message = Errors.format(Errors.Keys.CanNotCreateObjectAsInstanceOf_2, type,
+ DefinitionURI.PREFIX + DefinitionURI.SEPARATOR + uri.type);
}
throw new NoSuchAuthorityCodeException(message, authority, code, s);
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -17,7 +17,6 @@
package org.apache.sis.referencing.factory.sql;
import java.util.Locale;
-import java.util.ServiceLoader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -32,6 +31,7 @@ import java.io.BufferedReader;
import org.apache.sis.util.StringBuilders;
import org.apache.sis.internal.metadata.sql.ScriptRunner;
import org.apache.sis.internal.metadata.sql.SQLUtilities;
+import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.Fallback;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Exceptions;
@@ -52,7 +52,7 @@ import org.apache.sis.internal.jdk8.BiFu
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.7
- * @version 0.7
+ * @version 0.8
* @module
*/
final class EPSGInstaller extends ScriptRunner {
@@ -278,7 +278,7 @@ final class EPSGInstaller extends Script
*/
private static InstallationResources lookupProvider(final Locale locale) throws IOException {
InstallationResources fallback = null;
- for (final InstallationResources provider : ServiceLoader.load(InstallationResources.class)) {
+ for (final InstallationResources provider : DefaultFactories.createServiceLoader(InstallationResources.class)) {
if (provider.getAuthorities().contains(EPSG)) {
if (provider.getClass().isAnnotationPresent(Fallback.class)) {
return provider;
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -46,8 +46,8 @@ import org.apache.sis.referencing.operat
import org.apache.sis.internal.referencing.provider.MapProjection;
import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.referencing.Formulas;
+import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.util.Constants;
-import org.apache.sis.internal.util.Utilities;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.util.resources.Errors;
@@ -594,7 +594,7 @@ public abstract class NormalizedProjecti
group = DESCRIPTORS.get(type);
if (group == null) {
final ParameterBuilder builder = new ParameterBuilder().setRequired(true);
- if (Utilities.isSIS(type)) {
+ if (type.getName().startsWith(Modules.CLASSNAME_PREFIX)) {
builder.setCodeSpace(Citations.SIS, Constants.SIS);
}
final String[] names = getInternalParameterNames();
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -424,18 +424,6 @@ public class ContextualParameters extend
}
/**
- * @deprecated Replaced by {@link #getMatrix(MatrixRole)}.
- *
- * @param norm {@code true} for fetching the <cite>normalization</cite> transform to apply before the kernel,
- * or {@code false} for the <cite>denormalization</cite> transform to apply after the kernel.
- * @return The matrix for the requested normalization ({@code true}) or denormalization ({@code false}) affine transform.
- */
- @Deprecated
- public final MatrixSIS getMatrix(final boolean norm) {
- return getMatrix(norm ? MatrixRole.NORMALIZATION : MatrixRole.DENORMALIZATION);
- }
-
- /**
* Prepends a normalization step converting input ordinates in the two first dimensions from degrees to radians.
* The normalization can optionally subtract the given \u03bb\u2080 value (in degrees) from the longitude.
*
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -1189,35 +1189,6 @@ public class DefaultMathTransformFactory
}
/**
- * Creates a transform from a base to a derived CS using an existing parameterized transform.
- * The given {@code parameterized} transform shall expect
- * {@linkplain org.apache.sis.referencing.cs.AxesConvention#NORMALIZED normalized} input coordinates and
- * produce normalized output coordinates.
- *
- * @param baseCS The source coordinate system.
- * @param parameterized A <cite>base to derived</cite> transform for normalized input and output coordinates.
- * @param derivedCS The target coordinate system.
- * @return The transform from {@code baseCS} to {@code derivedCS}, including unit conversions and axis swapping.
- * @throws FactoryException if the object creation failed. This exception is thrown
- * if some required parameter has not been supplied, or has illegal value.
- *
- * @deprecated Replaced by {@link #swapAndScaleAxes(MathTransform, Context)}.
- */
- @Deprecated
- public MathTransform createBaseToDerived(final CoordinateSystem baseCS,
- final MathTransform parameterized, final CoordinateSystem derivedCS)
- throws FactoryException
- {
- ArgumentChecks.ensureNonNull("baseCS", baseCS);
- ArgumentChecks.ensureNonNull("parameterized", parameterized);
- ArgumentChecks.ensureNonNull("derivedCS", derivedCS);
- final Context context = new Context();
- context.setSource(baseCS);
- context.setTarget(derivedCS);
- return swapAndScaleAxes(parameterized, context);
- }
-
- /**
* Creates a math transform that represent a change of coordinate system.
*
* @param source the source coordinate system.
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -46,7 +46,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.7
- * @version 0.7
+ * @version 0.8
* @module
*/
public final strictfp class AuthorityFactoriesTest extends TestCase {
@@ -66,6 +66,20 @@ public final strictfp class AuthorityFac
}
/**
+ * Tests {@link CRSAuthorityFactory#getDescriptionText(String)}.
+ *
+ * @throws FactoryException if the EPSG:4326 name can not be obtained.
+ *
+ * @since 0.8
+ */
+ @Test
+ public void testGetDescriptionText() throws FactoryException {
+ final CRSAuthorityFactory factory = AuthorityFactories.ALL;
+ assertEquals("WGS 84", factory.getDescriptionText("EPSG:4326").toString());
+ assertEquals("WGS 84", factory.getDescriptionText("urn:ogc:def:crs:epsg::4326").toString());
+ }
+
+ /**
* Tests creation of {@code CRS:84} from various codes.
*
* @throws FactoryException if a CRS:84 creation failed.
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -16,10 +16,11 @@
*/
package org.apache.sis.referencing;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.crs.SingleCRS;
-import org.opengis.util.FactoryException;
import org.apache.sis.referencing.crs.DefaultCompoundCRS;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.crs.HardCodedCRS;
@@ -40,7 +41,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.7
+ * @version 0.8
* @module
*/
@DependsOn({
@@ -106,6 +107,21 @@ public final strictfp class CRSTest exte
}
/**
+ * Test {@link CRS#forCode(String)} with values that should be invalid.
+ *
+ * @throws FactoryException if an error other than {@link NoSuchAuthorityCodeException} happened.
+ */
+ @Test
+ public void testForInvalidCode() throws FactoryException {
+ try {
+ CRS.forCode("EPSG:4");
+ fail("Should not find EPSG:4");
+ } catch (NoSuchAuthorityCodeException e) {
+ assertEquals("4", e.getAuthorityCode());
+ }
+ }
+
+ /**
* Tests simple WKT parsing. It is not the purpose of this class to test extensively the WKT parser;
* those tests are rather done by {@link org.apache.sis.io.wkt.GeodeticObjectParserTest}.
* Here we merely test that {@link CRS#fromWKT(String)} is connected to the parser.
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -17,6 +17,8 @@
package org.apache.sis.referencing;
import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.crs.VerticalCRS;
@@ -49,7 +51,7 @@ import static org.apache.sis.test.TestUt
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.7
+ * @version 0.8
* @module
*/
@DependsOn({
@@ -64,6 +66,58 @@ public final strictfp class CommonCRSTes
private static final double DAY_LENGTH = 24 * 60 * 60 * 1000;
/**
+ * Verifies that the same EPSG code is not used for two objects. Collisions are not allowed between
+ * {@code geographic}, {@code geocentric}, {@code geo3D} and all UTM projections. Strictly speaking
+ * all the above-cited codes may collide with {@code datum} and {@code ellipsoid}, but we nevertheless
+ * avoid those collisions in order to simplify {@link EPSGFactoryFallback#createObject(String)} implementation.
+ */
+ @Test
+ public void ensureNoCodeCollision() {
+ final Map<Integer,Enum<?>> codes = new HashMap<Integer,Enum<?>>();
+ final CommonCRS[] values = CommonCRS.values();
+ for (final CommonCRS crs : values) {
+ assertNoCodeCollision(codes, crs, crs.geographic);
+ assertNoCodeCollision(codes, crs, crs.geocentric);
+ assertNoCodeCollision(codes, crs, crs.geo3D);
+ for (int zone = crs.firstZone; zone <= crs.lastZone; zone++) {
+ if (crs.northUTM != 0) assertNoCodeCollision(codes, crs, crs.northUTM + zone);
+ if (crs.southUTM != 0) assertNoCodeCollision(codes, crs, crs.southUTM + zone);
+ }
+ }
+ final CommonCRS.Vertical[] vertical = CommonCRS.Vertical.values();
+ for (final CommonCRS.Vertical crs : vertical) {
+ if (crs.isEPSG) {
+ assertNoCodeCollision(codes, crs, crs.crs);
+ }
+ }
+ /*
+ * Following restrictions are not strictly required, but their enforcement
+ * simplifies the EPSGFactoryFallback.createObject(String) implementation.
+ */
+ assertNull(codes.put(Integer.valueOf(StandardDefinitions.GREENWICH), CommonCRS.WGS84));
+ for (final CommonCRS crs : values) assertNull (crs.name(), codes.get(Integer.valueOf(crs.ellipsoid)));
+ for (final CommonCRS crs : values) assertNotSame(crs.name(), crs, codes.put(Integer.valueOf(crs.ellipsoid), crs));
+ for (final CommonCRS crs : values) assertNull (crs.name(), codes.get(Integer.valueOf(crs.datum)));
+ for (final CommonCRS.Vertical crs : vertical) {
+ if (crs.isEPSG) {
+ assertNull(crs.name(), codes.get(Integer.valueOf(crs.datum)));
+ }
+ }
+ }
+
+ /**
+ * Helper method for {@link #ensureNoCodeCollision()} only.
+ */
+ private static void assertNoCodeCollision(final Map<Integer,Enum<?>> codes, final Enum<?> crs, final int n) {
+ if (n != 0) {
+ final Enum<?> existing = codes.put(n, crs);
+ if (existing != null) {
+ fail(existing + " and " + crs + " both use the same EPSG:" + n + " code.");
+ }
+ }
+ }
+
+ /**
* Tests the {@link CommonCRS#geographic()} method.
*/
@Test
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -26,6 +26,9 @@ import org.opengis.referencing.crs.Geogr
import org.opengis.referencing.crs.GeocentricCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.CRSAuthorityFactory;
+import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.datum.PrimeMeridian;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
@@ -44,7 +47,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.7
- * @version 0.7
+ * @version 0.8
* @module
*/
@DependsOn({
@@ -59,6 +62,12 @@ public final strictfp class EPSGFactoryF
*/
@Test
public void testGetAuthorityCodes() throws FactoryException {
+ assertSetEquals(Arrays.asList(StandardDefinitions.GREENWICH),
+ EPSGFactoryFallback.INSTANCE.getAuthorityCodes(PrimeMeridian.class));
+ assertSetEquals(Arrays.asList("7030", "7043", "7019", "7008", "7022", "7048"),
+ EPSGFactoryFallback.INSTANCE.getAuthorityCodes(Ellipsoid.class));
+ assertSetEquals(Arrays.asList("6326", "6322", "6269", "6267", "6258", "6230", "6047", "5100", "5103"),
+ EPSGFactoryFallback.INSTANCE.getAuthorityCodes(Datum.class));
assertSetEquals(Arrays.asList("4978", "4984", "4936"),
EPSGFactoryFallback.INSTANCE.getAuthorityCodes(GeocentricCRS.class));
assertSetEquals(Arrays.asList("4326", "4322", "4047", "4269", "4267", "4258", "4230", "4979", "4985", "4937"),
@@ -68,6 +77,46 @@ public final strictfp class EPSGFactoryF
}
/**
+ * Tests {@link EPSGFactoryFallback#createPrimeMeridian(String)}.
+ *
+ * @throws FactoryException if a prime meridian can not be constructed.
+ */
+ @Test
+ public void testCreatePrimeMeridian() throws FactoryException {
+ verifyCreatePrimeMeridian(CommonCRS.WGS84.primeMeridian(), StandardDefinitions.GREENWICH);
+ }
+
+ /**
+ * Tests {@link EPSGFactoryFallback#createEllipsoid(String)}.
+ *
+ * @throws FactoryException if an ellipsoid can not be constructed.
+ */
+ @Test
+ public void testCreateEllipsoid() throws FactoryException {
+ verifyCreateEllipsoid(CommonCRS.WGS84 .ellipsoid(), "7030");
+ verifyCreateEllipsoid(CommonCRS.WGS72 .ellipsoid(), "7043");
+ verifyCreateEllipsoid(CommonCRS.NAD83 .ellipsoid(), "7019");
+ verifyCreateEllipsoid(CommonCRS.NAD27 .ellipsoid(), "7008");
+ verifyCreateEllipsoid(CommonCRS.ED50 .ellipsoid(), "7022");
+ verifyCreateEllipsoid(CommonCRS.SPHERE.ellipsoid(), "7048");
+ }
+
+ /**
+ * Tests {@link EPSGFactoryFallback#createEllipsoid(String)}.
+ *
+ * @throws FactoryException if an ellipsoid can not be constructed.
+ */
+ @Test
+ public void testCreateDatum() throws FactoryException {
+ verifyCreateDatum(CommonCRS.WGS84 .datum(), "6326");
+ verifyCreateDatum(CommonCRS.WGS72 .datum(), "6322");
+ verifyCreateDatum(CommonCRS.NAD83 .datum(), "6269");
+ verifyCreateDatum(CommonCRS.NAD27 .datum(), "6267");
+ verifyCreateDatum(CommonCRS.ED50 .datum(), "6230");
+ verifyCreateDatum(CommonCRS.SPHERE.datum(), "6047");
+ }
+
+ /**
* Tests {@link EPSGFactoryFallback#createCoordinateReferenceSystem(String)}.
*
* @throws FactoryException if a CRS can not be constructed.
@@ -77,30 +126,55 @@ public final strictfp class EPSGFactoryF
*/
@Test
public void testCreateCRS() throws FactoryException {
- verifyCreate(CommonCRS.WGS84 .geographic(), "4326");
- verifyCreate(CommonCRS.WGS72 .geographic(), "4322");
- verifyCreate(CommonCRS.SPHERE.geographic(), "4047");
- verifyCreate(CommonCRS.NAD83 .geographic(), "4269");
- verifyCreate(CommonCRS.NAD27 .geographic(), "4267");
- verifyCreate(CommonCRS.ETRS89.geographic(), "4258");
- verifyCreate(CommonCRS.ED50 .geographic(), "4230");
- verifyCreate(CommonCRS.WGS84 .geocentric(), "4978");
- verifyCreate(CommonCRS.WGS72 .geocentric(), "4984");
- verifyCreate(CommonCRS.ETRS89.geocentric(), "4936");
- verifyCreate(CommonCRS.WGS84 .geographic(), "EPSG:4326");
- verifyCreate(CommonCRS.WGS72 .geographic(), "EPSG::4322");
- verifyCreate(CommonCRS.WGS84 .geographic3D(), "4979");
- verifyCreate(CommonCRS.WGS72 .geographic3D(), "4985");
- verifyCreate(CommonCRS.ETRS89.geographic3D(), "4937");
- verifyCreate(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "5714");
- verifyCreate(CommonCRS.Vertical.DEPTH.crs(), "5715");
+ verifyCreateCRS(CommonCRS.WGS84 .geographic(), "4326");
+ verifyCreateCRS(CommonCRS.WGS72 .geographic(), "4322");
+ verifyCreateCRS(CommonCRS.SPHERE.geographic(), "4047");
+ verifyCreateCRS(CommonCRS.NAD83 .geographic(), "4269");
+ verifyCreateCRS(CommonCRS.NAD27 .geographic(), "4267");
+ verifyCreateCRS(CommonCRS.ETRS89.geographic(), "4258");
+ verifyCreateCRS(CommonCRS.ED50 .geographic(), "4230");
+ verifyCreateCRS(CommonCRS.WGS84 .geocentric(), "4978");
+ verifyCreateCRS(CommonCRS.WGS72 .geocentric(), "4984");
+ verifyCreateCRS(CommonCRS.ETRS89.geocentric(), "4936");
+ verifyCreateCRS(CommonCRS.WGS84 .geographic(), "EPSG:4326");
+ verifyCreateCRS(CommonCRS.WGS72 .geographic(), "EPSG::4322");
+ verifyCreateCRS(CommonCRS.WGS84 .geographic3D(), "4979");
+ verifyCreateCRS(CommonCRS.WGS72 .geographic3D(), "4985");
+ verifyCreateCRS(CommonCRS.ETRS89.geographic3D(), "4937");
+ verifyCreateCRS(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "5714");
+ verifyCreateCRS(CommonCRS.Vertical.DEPTH.crs(), "5715");
+ }
+
+ /**
+ * Asserts that the result of {@link EPSGFactoryFallback#createObject(String)} is the given prime meridian.
+ */
+ private static void verifyCreatePrimeMeridian(final PrimeMeridian expected, final String code) throws FactoryException {
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createPrimeMeridian(code));
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createObject(code));
+ }
+
+ /**
+ * Asserts that the result of {@link EPSGFactoryFallback#createObject(String)} is the given ellipsoid.
+ */
+ private static void verifyCreateEllipsoid(final Ellipsoid expected, final String code) throws FactoryException {
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createEllipsoid(code));
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createObject(code));
+ }
+
+ /**
+ * Asserts that the result of {@link EPSGFactoryFallback#createObject(String)} is the given datum.
+ */
+ private static void verifyCreateDatum(final Datum expected, final String code) throws FactoryException {
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createDatum(code));
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createObject(code));
}
/**
- * Asserts that the result of {@link CommonCRS#forCode(String, String, FactoryException)} is the given CRS.
+ * Asserts that the result of {@link EPSGFactoryFallback#createObject(String)} is the given CRS.
*/
- private static void verifyCreate(final SingleCRS expected, final String code) throws FactoryException {
+ private static void verifyCreateCRS(final SingleCRS expected, final String code) throws FactoryException {
assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createCoordinateReferenceSystem(code));
+ assertSame(code, expected, EPSGFactoryFallback.INSTANCE.createObject(code));
}
/**
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -286,14 +286,6 @@ public final strictfp class CoordinateSy
}
@Override
- public Unit<?> getUnitReplacement(Unit<?> unit) {
- if (Units.isAngular(unit)) {
- unit = NonSI.GRADE;
- }
- return unit;
- }
-
- @Override
public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit) {
if (Units.isAngular(unit)) {
unit = NonSI.GRADE;
@@ -305,11 +297,6 @@ public final strictfp class CoordinateSy
public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) {
return direction;
}
-
- @Override
- public AxisDirection getDirectionReplacement(final AxisDirection direction) {
- return direction;
- }
});
assertEqualsIgnoreMetadata(targetCS, actualCS);
}
@@ -330,16 +317,6 @@ public final strictfp class CoordinateSy
}
@Override
- public Unit<?> getUnitReplacement(final Unit<?> unit) {
- return unit;
- }
-
- @Override
- public AxisDirection getDirectionReplacement(final AxisDirection direction) {
- return direction;
- }
-
- @Override
public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, final Unit<?> unit) {
return unit;
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -17,11 +17,11 @@
package org.apache.sis.internal.converter;
import java.util.Date;
-import java.util.ServiceLoader;
import org.opengis.util.CodeList;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.ObjectConverter;
import org.apache.sis.util.UnconvertibleObjectException;
+import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.system.SystemListener;
import org.apache.sis.internal.system.Modules;
@@ -50,7 +50,7 @@ import org.apache.sis.internal.system.Mo
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*/
public final class SystemRegistry extends ConverterRegistry {
@@ -105,7 +105,7 @@ public final class SystemRegistry extend
*/
@Override
protected void initialize() {
- for (ObjectConverter<?,?> converter : ServiceLoader.load(ObjectConverter.class, getClass().getClassLoader())) {
+ for (ObjectConverter<?,?> converter : DefaultFactories.createServiceLoader(ObjectConverter.class)) {
if (converter instanceof SystemConverter<?,?>) {
converter = ((SystemConverter<?,?>) converter).unique();
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java?rev=1748710&r1=1748709&r2=1748710&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java [UTF-8] Thu Jun 16 12:37:54 2016
@@ -18,13 +18,13 @@ package org.apache.sis.internal.jaxb;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.ServiceLoader;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.SystemListener;
+import org.apache.sis.internal.system.DefaultFactories;
/**
@@ -40,7 +40,7 @@ import org.apache.sis.internal.system.Sy
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*
* @see org.apache.sis.xml.MarshallerPool
@@ -92,7 +92,7 @@ public abstract class TypeRegistration {
* 2) The ClassLoader between different invocations may be different in an OSGi context.
*/
final ArrayList<Class<?>> types = new ArrayList<Class<?>>();
- for (final TypeRegistration t : ServiceLoader.load(TypeRegistration.class)) {
+ for (final TypeRegistration t : DefaultFactories.createServiceLoader(TypeRegistration.class)) {
t.getTypes(types);
}
return types.toArray(new Class<?>[types.size()]);