Author: desruisseaux
Date: Mon Oct 9 09:40:02 2017
New Revision: 1811545
URL: http://svn.apache.org/viewvc?rev=1811545&view=rev
Log:
Merge from JDK8 branch.
Added:
sis/branches/JDK7/application/sis-console/src/main/artifact/lib/darwin/
- copied from r1811544,
sis/branches/JDK8/application/sis-console/src/main/artifact/lib/darwin/
sis/branches/JDK7/application/sis-console/src/main/artifact/lib/linux/
- copied from r1811544,
sis/branches/JDK8/application/sis-console/src/main/artifact/lib/linux/
sis/branches/JDK7/application/sis-console/src/main/artifact/lib/windows/
- copied from r1811544,
sis/branches/JDK8/application/sis-console/src/main/artifact/lib/windows/
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/EllipsoidalHeightCombiner.java
- copied unchanged from r1811544,
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/EllipsoidalHeightCombiner.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java
- copied unchanged from r1811544,
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CompoundCRSBuilder.java
- copied unchanged from r1811544,
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CompoundCRSBuilder.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/metadata/EllipsoidalHeightCombinerTest.java
- copied unchanged from r1811544,
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/metadata/EllipsoidalHeightCombinerTest.java
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/application/sis-console/pom.xml
sis/branches/JDK7/application/sis-console/src/main/artifact/lib/README
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackInput.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/package-info.java
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/OS.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 9 09:40:02 2017
@@ -1,5 +1,5 @@
/sis/branches/Android:1430670-1480699
/sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1811310
+/sis/branches/JDK8:1584960-1811544
/sis/branches/JDK9:1773327-1803064
/sis/trunk:1394364-1508466,1519089-1519674
Modified: sis/branches/JDK7/application/sis-console/pom.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/pom.xml?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/pom.xml (original)
+++ sis/branches/JDK7/application/sis-console/pom.xml Mon Oct 9 09:40:02 2017
@@ -100,6 +100,29 @@ Console application.
</plugins>
</build>
+ <!-- Create the binary distribution file, including PACK200 bundle. -->
+ <profiles>
+ <profile>
+ <id>apache-release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.sis.core</groupId>
+ <artifactId>sis-build-helper</artifactId>
+ <version>${sis.plugin.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>dist</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<!-- ===========================================================
Dependencies
@@ -129,6 +152,12 @@ Console application.
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.sis.storage</groupId>
+ <artifactId>sis-gdal</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<!-- Test dependencies -->
<dependency>
Modified: sis/branches/JDK7/application/sis-console/src/main/artifact/lib/README
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/artifact/lib/README?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/artifact/lib/README
[UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/artifact/lib/README
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -1,4 +1,12 @@
This directory contains the sis.jar file together with optional dependencies.
Recognized optional dependencies are:
+ - Derby database
- UCAR netCDF library
+ - ESRI Geometry API
+ - Java Topology Suite
+
+The "linux", "darwin" and "windows" sub-directories contain bridges to Proj.4
+and other libraries through Java Native Interfaces (JNI). They do not contain
+the actual libraries however; Apache SIS uses the libraries installed on host
+computer by packages manager, if any. Those libraries are optional.
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -21,11 +21,14 @@ import java.io.IOException;
import java.io.FilenameFilter;
import java.io.FileInputStream;
import java.io.FilterOutputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
@@ -36,24 +39,23 @@ import static org.apache.sis.internal.ma
/**
* Creates a ZIP files containing the content of the
<code>application/sis-console/src/main/artifact</code>
* directory together with the Pack200 file created by
<code>BundleCreator</code>.
- * This mojo can be invoked from the command line as below:
+ * This MOJO can be invoked from the command line in the {@code sis-console}
module as below:
*
- * <blockquote><code>mvn org.apache.sis.core:sis-build-helper:dist
--non-recursive</code></blockquote>
- *
- * Do not forget the <code>--non-recursive</code> option, otherwise the Mojo
will be executed many time.
+ * <blockquote><code>mvn package
org.apache.sis.core:sis-build-helper:dist</code></blockquote>
*
* <p><b>Current limitation:</b>
* The current implementation uses some hard-coded paths and filenames.
- * See the <cite>Distribution file and Pack200 bundle</cite> section in the
<code>src/site/apt/index.apt</code>
- * file for more information.</p>
+ * See the <cite>Distribution file and Pack200 bundle</cite> section in
+ * <a href="http://sis.apache.org/build.html">Build from source</a> page
+ * for more information.</p>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
* @since 0.4
* @module
*/
-@Mojo(name = "dist", defaultPhase = LifecyclePhase.INSTALL)
-public class Assembler extends AbstractMojo implements FilenameFilter {
+@Mojo(name = "dist", defaultPhase = LifecyclePhase.INSTALL,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
+public final class Assembler extends AbstractMojo implements FilenameFilter {
/**
* Project information (name, version, URL).
*/
@@ -61,6 +63,13 @@ public class Assembler extends AbstractM
private MavenProject project;
/**
+ * Base directory of the module to compile.
+ * Artifact content is expected in the {@code "src/main/artifact"}
subdirectory.
+ */
+ @Parameter(property="basedir", required=true, readonly=true)
+ private String baseDirectory;
+
+ /**
* The root directory (without the "<code>target/binaries</code>"
sub-directory) where JARs
* are to be copied. It should be the directory of the root
<code>pom.xml</code>.
*/
@@ -80,13 +89,14 @@ public class Assembler extends AbstractM
*/
@Override
public void execute() throws MojoExecutionException {
- final File sourceDirectory = new File(rootDirectory, ARTIFACT_PATH);
+ final File sourceDirectory = new File(baseDirectory, ARTIFACT_PATH);
if (!sourceDirectory.isDirectory()) {
throw new MojoExecutionException("Directory not found: " +
sourceDirectory);
}
final File targetDirectory = new File(rootDirectory, TARGET_DIRECTORY);
final String version = project.getVersion();
final String artifactBase = FINALNAME_PREFIX + version;
+ final Map<String,byte[]> nativeFiles = new LinkedHashMap<>();
try {
final File targetFile = new
File(distributionDirectory(targetDirectory), artifactBase + ".zip");
try (ZipArchiveOutputStream zip = new
ZipArchiveOutputStream(targetFile)) {
@@ -97,20 +107,28 @@ 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(), version,
targetDirectory);
- final ZipArchiveEntry entry = new ZipArchiveEntry(
- artifactBase + '/' + LIB_DIRECTORY + '/' + FATJAR_FILE
+ PACK_EXTENSION);
+ final Packer packer = new Packer(project.getName(), version,
BundleCreator.files(project), targetDirectory, nativeFiles);
+ ZipArchiveEntry entry = new ZipArchiveEntry(artifactBase + '/'
+ LIB_DIRECTORY + '/' + FATJAR_FILE + PACK_EXTENSION);
entry.setMethod(ZipArchiveEntry.STORED);
zip.putArchiveEntry(entry);
packer.preparePack200(FATJAR_FILE + ".jar").pack(new
FilterOutputStream(zip) {
- /*
- * Closes the archive entry, not the ZIP file.
- */
- @Override
- public void close() throws IOException {
+ /** Closes the archive entry, not the ZIP file. */
+ @Override public void close() throws IOException {
zip.closeArchiveEntry();
}
});
+ /*
+ * At this point we finished creating all entries in the ZIP
file, except native resources.
+ * Copy them now.
+ */
+ for (final Map.Entry<String,byte[]> nf :
nativeFiles.entrySet()) {
+ entry = new ZipArchiveEntry(artifactBase + '/' +
LIB_DIRECTORY + '/' + nf.getKey());
+ entry.setUnixMode(0555); // Readable and executable
for all, but not writable.
+ zip.putArchiveEntry(entry);
+ zip.write(nf.getValue());
+ zip.closeArchiveEntry();
+ nf.setValue(null);
+ }
}
} catch (IOException e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
@@ -136,6 +154,7 @@ public class Assembler extends AbstractM
out.putArchiveEntry(entry);
if (!entry.isDirectory()) {
try (FileInputStream in = new FileInputStream(file)) {
+ // TODO: use InputStream.transferTo(OutputStream) with JDK9.
int n;
while ((n = in.read(buffer)) >= 0) {
out.write(buffer, 0, n);
@@ -159,6 +178,6 @@ public class Assembler extends AbstractM
*/
@Override
public boolean accept(final File directory, final String filename) {
- return !filename.isEmpty() && filename.charAt(0) != '.';
+ return !filename.isEmpty() && filename.charAt(0) != '.' &&
!filename.equals(CONTENT_FILE);
}
}
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -18,11 +18,15 @@ package org.apache.sis.internal.maven;
import java.io.File;
import java.io.IOException;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import static org.apache.sis.internal.maven.Filenames.*;
@@ -38,16 +42,17 @@ import static org.apache.sis.internal.ma
*
* <p><b>Current limitation:</b>
* The current implementation uses some hard-coded paths and filenames.
- * See the <cite>Distribution file and Pack200 bundle</cite> section in the
<code>src/site/apt/index.apt</code>
- * file for more information.</p>
+ * See the <cite>Distribution file and Pack200 bundle</cite> section in
+ * <a href="http://sis.apache.org/build.html">Build from source</a> page
+ * for more information.</p>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
* @since 0.3
* @module
*/
-@Mojo(name = "pack", defaultPhase = LifecyclePhase.INSTALL)
-public class BundleCreator extends AbstractMojo {
+@Mojo(name = "pack", defaultPhase = LifecyclePhase.INSTALL,
requiresDependencyResolution = ResolutionScope.COMPILE)
+public final class BundleCreator extends AbstractMojo {
/**
* Project information (name, version, URL).
*/
@@ -80,10 +85,30 @@ public class BundleCreator extends Abstr
}
final String version = project.getVersion();
try {
- final Packer packer = new Packer(project.getName(), version,
targetDirectory);
+ final Packer packer = new Packer(project.getName(), version,
files(project), targetDirectory, null);
packer.preparePack200(FINALNAME_PREFIX + version + ".jar").pack();
} catch (IOException e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
}
}
+
+ /**
+ * Returns all files to include for the given Maven project.
+ */
+ static Set<File> files(final MavenProject project) throws
MojoExecutionException {
+ final Set<File> files = new LinkedHashSet<>();
+ files.add(project.getArtifact().getFile());
+ for (final Artifact dep : project.getArtifacts()) {
+ final String scope = dep.getScope();
+ if (Artifact.SCOPE_COMPILE.equalsIgnoreCase(scope) ||
+ Artifact.SCOPE_RUNTIME.equalsIgnoreCase(scope))
+ {
+ files.add(dep.getFile());
+ }
+ }
+ if (files.remove(null)) {
+ throw new MojoExecutionException("Invocation of this MOJO shall be
done together with a \"package\" Maven phase.");
+ }
+ return files;
+ }
}
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -48,7 +48,8 @@ final class Filenames {
/**
* The name of the file inside {@value #BINARIES_DIRECTORY} where to list
SIS JAR files and their
- * dependencies on platforms that do not support hard links.
+ * dependencies on platforms that do not support hard links. Also the file
to ignore when copying
+ * entries in a ZIP file.
*/
static final String CONTENT_FILE = "content.txt";
@@ -59,9 +60,9 @@ final class Filenames {
static final String DISTRIBUTION_DIRECTORY = "distribution";
/**
- * The path to the directory (relative to the project root) to zip for
creating the distribution ZIP file.
+ * The path to the directory (relative to the project directory) to zip
for creating the distribution ZIP file.
*/
- static final String ARTIFACT_PATH =
"application/sis-console/src/main/artifact";
+ static final String ARTIFACT_PATH = "src/main/artifact";
/**
* The name of the sub-directory inside {@value #ARTIFACT_PATH} where the
Pack200 file will be located.
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -262,10 +262,10 @@ public final class JarCollector extends
/**
* Loads the {@value #CONTENT_FILE} from the given directory, if it exists.
- * Otherwise returns an empty but modifiable set. This method is invoked
only on
+ * Otherwise returns an empty but modifiable set. This method is invoked on
* platforms that do not support hard links.
*/
- static Set<String> loadDependencyList(final File dependenciesFile) throws
IOException {
+ private static Set<String> loadDependencyList(final File dependenciesFile)
throws IOException {
final Set<String> dependencies = new LinkedHashSet<>();
if (dependenciesFile.exists()) {
try (BufferedReader in = new BufferedReader(new
FileReader(dependenciesFile))) {
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackInput.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackInput.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackInput.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackInput.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -16,6 +16,7 @@
*/
package org.apache.sis.internal.maven;
+import java.util.Map;
import java.util.Enumeration;
import java.util.jar.*;
import java.io.File;
@@ -29,7 +30,7 @@ import java.io.InputStream;
* Those files will be open in read-only mode.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 0.8
* @since 0.3
* @module
*/
@@ -51,6 +52,12 @@ final class PackInput implements Closeab
static final String SERVICES = META_INF + "services/";
/**
+ * The prefix of native resources in JAR files. All those resources will
be excluded from
+ * the PACK200 file and stored in {@link #nativeFiles} instead (unless the
map is null).
+ */
+ private static final String NATIVE = "native/";
+
+ /**
* The attribute name in {@code MANIFEST.MF} files for splash screen.
*/
static final Attributes.Name SPLASH_SCREEN = new
Attributes.Name("SplashScreen-Image");
@@ -63,12 +70,19 @@ final class PackInput implements Closeab
/**
* The main class obtained from the manifest, or {@code null} if none.
*/
- public final String mainClass;
+ final String mainClass;
/**
* The splash screen image obtained from the manifest, or {@code null} if
none.
*/
- public final String splashScreen;
+ final String splashScreen;
+
+ /**
+ * The map where to store native files found during iteration over the JAR
entries.
+ * Keys are filename without the {@value #NATIVE} prefix. Values are the
actual data.
+ * If null, then no native files filtering is done.
+ */
+ private final Map<String,byte[]> nativeFiles;
/**
* An enumeration over the entries. We are going to iterate only once.
@@ -83,10 +97,12 @@ final class PackInput implements Closeab
/**
* Opens the given JAR file in read-only mode.
*
- * @param file the file to open.
+ * @param file the file to open.
+ * @param nativeFiles if non-null, where to store native files found
during iteration over the JAR entries.
* @throws IOException if the file can't be open.
*/
- PackInput(final File file) throws IOException {
+ PackInput(final File file, final Map<String,byte[]> nativeFiles) throws
IOException {
+ this.nativeFiles = nativeFiles;
this.file = new JarFile(file);
final Manifest manifest = this.file.getManifest();
if (manifest != null) {
@@ -106,7 +122,7 @@ final class PackInput implements Closeab
*
* @return the next entry, or {@code null} if the iteration is finished.
*/
- JarEntry nextEntry() {
+ JarEntry nextEntry() throws IOException {
if (entries == null) {
entries = file.entries();
}
@@ -118,6 +134,14 @@ final class PackInput implements Closeab
continue;
}
}
+ if (nativeFiles != null && name.startsWith(NATIVE)) {
+ if (!entry.isDirectory()) {
+ if (nativeFiles.put(name.substring(NATIVE.length()),
load()) != null) {
+ throw new IOException("Duplicated entry: " + name);
+ }
+ }
+ continue;
+ }
entry.setMethod(JarEntry.DEFLATED);
entry.setCompressedSize(-1); // Change in
method has changed the compression size.
return entry;
@@ -138,6 +162,26 @@ final class PackInput implements Closeab
}
/**
+ * Loads in memory the content of current JAR entry.
+ * This method should be invoked only for entries of reasonable size.
+ */
+ private byte[] load() throws IOException {
+ final long size = entry.getSize();
+ if (size <= 0 || size > Integer.MAX_VALUE) {
+ throw new IOException("Unsupported size for \"" + entry.getName()
+ "\": " + size);
+ }
+ final byte[] content = new byte[(int) size];
+ final int actual;
+ try (InputStream in = getInputStream()) {
+ actual = in.read(content);
+ }
+ if (actual != size) {
+ throw new IOException("Expected " + size + " bytes in \"" +
entry.getName() + "\" but found " + actual);
+ }
+ return content;
+ }
+
+ /**
* Returns the input stream for the current entry.
*
* @param entry The entry for which to get an input stream.
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -215,7 +215,7 @@ final class PackOutput implements Closea
final byte[] buffer = new byte[64 * 1024];
for (final Iterator<Map.Entry<File,PackInput>> it =
inputJARs.entrySet().iterator(); it.hasNext();) {
final Map.Entry<File,PackInput> inputJAR = it.next();
- it.remove(); // Needs to be removed before the inner loop below.
+ it.remove(); // Needs to be
removed before the inner loop below.
try (PackInput input = inputJAR.getValue()) {
for (JarEntry entry; (entry = input.nextEntry()) != null;) {
final String name = entry.getName();
@@ -253,7 +253,7 @@ final class PackOutput implements Closea
* @param buffer temporary buffer to reuse at each method call.
* @throws IOException if an error occurred during the copy.
*/
- void copy(final InputStream in, final byte[] buffer) throws IOException {
+ private void copy(final InputStream in, final byte[] buffer) throws
IOException {
int n;
while ((n = in.read(buffer)) >= 0) {
outputStream.write(buffer, 0, n);
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -18,11 +18,8 @@ package org.apache.sis.internal.maven;
import java.util.Map;
import java.util.Set;
-import java.util.Arrays;
import java.util.LinkedHashMap;
import java.io.File;
-import java.io.FilenameFilter;
-import java.io.FileNotFoundException;
import java.io.IOException;
import static org.apache.sis.internal.maven.Filenames.*;
@@ -34,55 +31,51 @@ import static org.apache.sis.internal.ma
* or listed in the {@code target/binaries/content.txt} file.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 0.8
* @since 0.3
* @module
*/
-final class Packer implements FilenameFilter {
+final class Packer {
/**
* The project name and version to declare in the manifest file, or {@code
null} if none.
*/
private final String projectName, version;
/**
+ * JAR files of the main project together with its dependencies.
+ */
+ private final Set<File> files;
+
+ /**
* The Maven target directory. Shall contain the {@code "binaries"}
sub-directory,
* which shall contain all JAR files collected by {@code sis-build-helper}
plugin.
*/
private final File targetDirectory;
/**
- * The directory of input JAR files. Shall be {@code "target/binaries"}.
+ * The map where to store native files found during iteration over the JAR
entries.
+ * Keys are filename without the {@value #NATIVE} prefix. Values are the
actual data.
+ * If null, then no native files filtering is done.
*/
- private final File binariesDirectory;
+ private final Map<String,byte[]> nativeFiles;
/**
* Creates a packer.
*
* @param projectName the project name 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 files the JAR files of the main project together
with its dependencies.
* @param targetDirectory the Maven target directory.
- * @throws FileNotFoundException if the {@code target/binaries} directory
is not found.
+ * @param nativeFiles if non-null, where to store native files found
during iteration over the JAR entries.
*/
- Packer(final String projectName, final String version, final File
targetDirectory) throws FileNotFoundException {
- this.projectName = projectName;
- this.version = version;
+ Packer(final String projectName, final String version, final Set<File>
files, final File targetDirectory,
+ final Map<String,byte[]> nativeFiles)
+ {
+ this.projectName = projectName;
+ this.version = version;
+ this.files = files;
this.targetDirectory = targetDirectory;
- this.binariesDirectory = new File(targetDirectory, BINARIES_DIRECTORY);
- if (!binariesDirectory.isDirectory()) {
- throw new FileNotFoundException("Directory not found: " +
binariesDirectory);
- }
- }
-
- /**
- * Filter the input JAR files. This is for internal usage by {@link
#createOutputJAR(String)} only.
- *
- * @param directory the directory (ignored).
- * @param name the filename.
- * @return {@code true} if the given filename ends with {@code ".jar"}.
- */
- @Override
- public boolean accept(final File directory, final String name) {
- return name.endsWith(".jar");
+ this.nativeFiles = nativeFiles;
}
/**
@@ -90,18 +83,12 @@ final class Packer implements FilenameFi
* All input JAR files are opened by this method. They will need to be
closed by {@link PackInput#close()}.
*/
private Map<File,PackInput> getInputJARs() throws IOException {
- final Set<String> filenames = JarCollector.loadDependencyList(new
File(binariesDirectory, CONTENT_FILE));
- filenames.addAll(Arrays.asList(binariesDirectory.list(this)));
- final Map<File,PackInput> inputJARs = new
LinkedHashMap<>(filenames.size() * 4/3);
- for (final String filename : filenames) {
- File file = new File(filename);
- if (!file.isAbsolute()) {
- file = new File(binariesDirectory, filename);
- }
+ final Map<File,PackInput> inputJARs = new LinkedHashMap<>(files.size()
* 4/3);
+ for (final File file : files) {
if (!file.isFile() || !file.canRead()) {
throw new IllegalArgumentException("Not a file or can not
read: " + file);
}
- if (inputJARs.put(file, new PackInput(file)) != null) {
+ if (inputJARs.put(file, new PackInput(file, nativeFiles)) != null)
{
throw new IllegalArgumentException("Duplicated JAR: " + file);
}
}
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/package-info.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/package-info.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/package-info.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/package-info.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -21,7 +21,7 @@
* for building Apache SIS. See the Maven-generated module description for
more information.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.3
+ * @version 0.8
* @since 0.3
* @module
*/
Modified:
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -31,6 +31,7 @@ import org.apache.maven.artifact.Artifac
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import static java.util.jar.Pack200.Packer;
@@ -43,7 +44,7 @@ import static java.util.jar.Pack200.Pack
* @since 0.8
* @module
*/
-@Mojo(name = "unopkg", defaultPhase = LifecyclePhase.PACKAGE)
+@Mojo(name = "unopkg", defaultPhase = LifecyclePhase.PACKAGE,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public final class UnoPkg extends AbstractMojo implements FilenameFilter {
/**
* The subdirectory (relative to {@link #baseDirectory}) where the UNO
files are expected.
@@ -62,7 +63,7 @@ public final class UnoPkg extends Abstra
/**
* Base directory of the module to compile.
- * The UNO files are expect in the {@code "src/main/unopkg"} subdirectory.
+ * The UNO files are expected in the {@code "src/main/unopkg"}
subdirectory.
* The plugin will look for the {@code META-INF/manifest.xml} and {@code
*.rdb} files in that directory.
*/
@Parameter(property="basedir", required=true, readonly=true)
@@ -184,6 +185,8 @@ public final class UnoPkg extends Abstra
}
/*
* Copies the dependencies, optionally in a single PACK200 entry.
+ * We discard most debug information because stack traces are not
+ * easy to get from an application running in OpenOffice anyway.
*/
Pack200.Packer packer = null;
if (Boolean.parseBoolean(pack200)) {
@@ -199,11 +202,10 @@ public final class UnoPkg extends Abstra
p.put(Packer.DEFLATE_HINT, Packer.TRUE); //
transmitting a single request to use "compress" mode.
p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR); // throw
an error if an attribute is unrecognized.
}
- for (final Artifact artifact : project.getDependencyArtifacts()) {
+ for (final Artifact artifact : project.getArtifacts()) {
final String scope = artifact.getScope();
- if (scope != null && // Maven 2.0.6 bug?
- (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE) ||
- scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME)))
+ if (Artifact.SCOPE_COMPILE.equalsIgnoreCase(scope) ||
+ Artifact.SCOPE_RUNTIME.equalsIgnoreCase(scope))
{
final File file = artifact.getFile();
String name = file.getName();
@@ -211,7 +213,7 @@ public final class UnoPkg extends Abstra
name = prefix + name;
}
if (packer != null && name.endsWith(".jar")) {
- name = name.substring(0, name.length()-3) + "pack";
+ name = name.substring(0, name.length() - 3) + "pack";
try (JarFile jar = new FilteredJarFile(file)) {
out.putNextEntry(new ZipEntry(name));
packer.pack(jar, out);
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -31,17 +31,14 @@ import org.opengis.referencing.crs.CRSFa
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.crs.DerivedCRS;
-import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CSFactory;
import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.datum.DatumFactory;
import org.opengis.referencing.datum.PrimeMeridian;
-import org.opengis.referencing.datum.VerticalDatum;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.CoordinateOperationFactory;
@@ -58,7 +55,6 @@ import org.apache.sis.internal.system.De
import org.apache.sis.internal.system.OptionalDependency;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.io.wkt.FormattableObject;
-import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Deprecable;
@@ -438,85 +434,6 @@ public class ReferencingServices extends
}
/**
- * Creates a compound CRS, but we special processing for (two-dimensional
Geographic + ellipsoidal heights) tupples.
- * If any such tupple is found, a three-dimensional geographic CRS is
created instead than the compound CRS.
- *
- * @param crsFactory the factory to use for creating compound or
three-dimensional geographic CRS.
- * @param csFactory the factory to use for creating three-dimensional
ellipsoidal CS, if needed.
- * @param properties name and other properties to give to the new object.
- * @param components ordered array of {@code CoordinateReferenceSystem}
objects.
- * @return the coordinate reference system for the given properties.
- * @throws FactoryException if the object creation failed.
- *
- * @since 0.7
- */
- public final CoordinateReferenceSystem createCompoundCRS(final CRSFactory
crsFactory, final CSFactory csFactory,
- final Map<String,?> properties, CoordinateReferenceSystem...
components) throws FactoryException
- {
- for (int i=0; i<components.length; i++) {
- final CoordinateReferenceSystem vertical = components[i];
- if (vertical instanceof VerticalCRS) {
- final VerticalDatum datum = ((VerticalCRS)
vertical).getDatum();
- if (datum != null && datum.getVerticalDatumType() ==
VerticalDatumTypes.ELLIPSOIDAL) {
- int axisPosition = 0;
- EllipsoidalCS cs = null;
- CoordinateReferenceSystem crs = null;
- if (i == 0 || (cs = getCsIfGeographic2D(crs = components[i
- 1])) == null) {
- /*
- * GeographicCRS are normally before VerticalCRS. But
Apache SIS is tolerant to the
- * opposite order (note however that such ordering is
illegal according ISO 19162).
- */
- if (i+1 >= components.length || (cs =
getCsIfGeographic2D(crs = components[i + 1])) == null) {
- continue;
- }
- axisPosition = 1;
- }
- /*
- * At this point we have the horizontal and vertical
components. The horizontal component
- * begins at 'axisPosition', which is almost always zero.
Create the three-dimensional CRS.
- * If the result is the CRS to be returned directly by
this method (components.length == 2),
- * use the properties given in argument. Otherwise we need
to use other properties; current
- * implementation recycles the properties of the existing
two-dimensional CRS.
- */
- final CoordinateSystemAxis[] axes = new
CoordinateSystemAxis[3];
- axes[axisPosition++ ] = cs.getAxis(0);
- axes[axisPosition++ ] = cs.getAxis(1);
- axes[axisPosition %= 3] =
vertical.getCoordinateSystem().getAxis(0);
- cs = csFactory.createEllipsoidalCS(getProperties(cs),
axes[0], axes[1], axes[2]);
- crs = crsFactory.createGeographicCRS((components.length ==
2) ? properties : getProperties(crs),
- ((GeodeticCRS) crs).getDatum(), cs);
- /*
- * Remove the VerticalCRS and store the three-dimensional
GeographicCRS in place of the previous
- * two-dimensional GeographicCRS. Then let the loop
continues in case there is other CRS to merge
- * (should never happen, but we are paranoiac).
- */
- components = ArraysExt.remove(components, i, 1);
- if (axisPosition != 0) i--; // GeographicCRS
before VerticalCRS (usual case).
- components[i] = crs;
- }
- }
- }
- switch (components.length) {
- case 0: return null;
- case 1: return components[0];
- default: return crsFactory.createCompoundCRS(properties,
components);
- }
- }
-
- /**
- * Returns the coordinate system if the given CRS is a two-dimensional
geographic CRS, or {@code null} otherwise.
- */
- private static EllipsoidalCS getCsIfGeographic2D(final
CoordinateReferenceSystem crs) {
- if (crs instanceof GeodeticCRS) {
- final CoordinateSystem cs = crs.getCoordinateSystem();
- if (cs instanceof EllipsoidalCS && cs.getDimension() == 2) {
- return (EllipsoidalCS) cs;
- }
- }
- return null;
- }
-
- /**
* Creates a format for {@link DirectPosition} instances.
*
* @param locale the locale for the new {@code Format}, or {@code
null} for {@code Locale.ROOT}.
@@ -616,11 +533,12 @@ public class ReferencingServices extends
* Returns the properties of the given object.
*
* @param object the object from which to get the properties.
+ * @param keepId {@code true} for preserving the identifiers, {@code
false} for discarding them.
* @return the properties of the given object.
*
* @since 0.6
*/
- public Map<String,?> getProperties(final IdentifiedObject object) {
+ public Map<String,?> getProperties(final IdentifiedObject object, final
boolean keepId) {
return Collections.singletonMap(IdentifiedObject.NAME_KEY,
object.getName());
}
Modified:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -70,6 +70,7 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.internal.metadata.VerticalDatumTypes;
import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.metadata.TransformationAccuracy;
+import org.apache.sis.internal.metadata.EllipsoidalHeightCombiner;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.util.CharSequences;
@@ -1928,7 +1929,7 @@ class GeodeticObjectParser extends MathT
if
(VerticalDatumType.OTHER_SURFACE.equals(datum.getVerticalDatumType())) {
final VerticalDatumType type =
VerticalDatumTypes.guess(datum.getName().getCode(), datum.getAlias(),
cs.getAxis(0));
if (!VerticalDatumType.OTHER_SURFACE.equals(type)) {
- datum =
datumFactory.createVerticalDatum(referencing.getProperties(datum), type);
+ datum =
datumFactory.createVerticalDatum(referencing.getProperties(datum, true), type);
}
}
verticalCRS = crsFactory.createVerticalCRS(properties, datum,
(VerticalCS) cs);
@@ -2179,8 +2180,9 @@ class GeodeticObjectParser extends MathT
components.add(crs);
}
try {
- return referencing.createCompoundCRS(crsFactory, csFactory,
parseMetadataAndClose(element, name, null),
- components.toArray(new
CoordinateReferenceSystem[components.size()]));
+ return new EllipsoidalHeightCombiner(crsFactory, csFactory,
opFactory).createCompoundCRS(
+ parseMetadataAndClose(element, name, null),
+ components.toArray(new
CoordinateReferenceSystem[components.size()]));
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -40,10 +40,10 @@ import org.opengis.referencing.datum.Tem
import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.Conversion;
-import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.metadata.EllipsoidalHeightCombiner;
import org.apache.sis.internal.referencing.provider.TransverseMercator;
import org.apache.sis.internal.referencing.provider.PolarStereographicA;
import org.apache.sis.measure.Latitude;
@@ -424,7 +424,13 @@ public class GeodeticObjectBuilder exten
* @throws FactoryException if the object creation failed.
*/
public CoordinateReferenceSystem createCompoundCRS(final
CoordinateReferenceSystem... components) throws FactoryException {
- return
ReferencingServices.getInstance().createCompoundCRS(getCRSFactory(),
getCSFactory(), properties, components);
+ return new EllipsoidalHeightCombiner() {
+ @Override public void initialize(final int factoryTypes) {
+ if ((factoryTypes & CRS) != 0) crsFactory =
getCRSFactory();
+ if ((factoryTypes & CS) != 0) csFactory =
getCSFactory();
+ if ((factoryTypes & OPERATION) != 0) opFactory =
getCoordinateOperationFactory();
+ }
+ }.createCompoundCRS(properties, components);
}
/**
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -33,6 +33,8 @@ import org.opengis.referencing.crs.*;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.VerticalDatum;
+import org.opengis.referencing.datum.VerticalDatumType;
import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.util.FactoryException;
import org.apache.sis.internal.system.DefaultFactories;
@@ -173,6 +175,30 @@ public final class ReferencingUtilities
}
/**
+ * Returns {@code true} if the type of the given datum is ellipsoidal. A
vertical datum is not allowed
+ * to be ellipsoidal according ISO 19111, but Apache SIS relaxes this
restriction in some limited cases,
+ * for example when parsing a string in the legacy WKT 1 format. Apache
SIS should not expose those
+ * vertical heights as much as possible, and instead try to combine them
with three-dimensional
+ * geographic or projected CRS as soon as it can.
+ *
+ * @param datum the datum to test, or {@code null} if none.
+ * @return {@code true} if the given datum is non null and of ellipsoidal
type.
+ *
+ * @see org.apache.sis.internal.metadata.VerticalDatumTypes#ELLIPSOIDAL
+ *
+ * @since 0.8
+ */
+ public static boolean isEllipsoidalHeight(final VerticalDatum datum) {
+ if (datum != null) {
+ final VerticalDatumType type = datum.getVerticalDatumType();
+ if (type != null) {
+ return "ELLIPSOIDAL".equalsIgnoreCase(type.name());
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns the ellipsoid used by the specified coordinate reference
system, provided that the two first dimensions
* use an instance of {@link GeographicCRS}. Otherwise (i.e. if the two
first dimensions are not geographic),
* returns {@code null}.
@@ -327,13 +353,16 @@ public final class ReferencingUtilities
*/
public static StringBuilder toPropertyName(final Class<?> base, final
Class<?> type) {
final UML uml = type.getAnnotation(UML.class);
- if (uml != null && uml.specification() == Specification.ISO_19111) {
- final String name = uml.identifier();
- final int length = name.length();
- final StringBuilder buffer = new
StringBuilder(length).append(name, name.indexOf('_') + 1, length);
- if (buffer.length() != 0) {
- buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
- return buffer;
+ if (uml != null) {
+ final Specification spec = uml.specification();
+ if (spec == Specification.ISO_19111 || spec ==
Specification.ISO_19111_2) {
+ final String name = uml.identifier();
+ final int length = name.length();
+ final StringBuilder buffer = new
StringBuilder(length).append(name, name.indexOf('_') + 1, length);
+ if (buffer.length() != 0) {
+ buffer.setCharAt(0,
Character.toLowerCase(buffer.charAt(0)));
+ return buffer;
+ }
}
}
for (final Class<?> c : type.getInterfaces()) {
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -149,6 +149,18 @@ public final class Resources extends Ind
public static final short DuplicatedParameterName_4 = 16;
/**
+ * Compound coordinate reference systems can not contain two
{0,choice,1#horizontal|2#vertical}
+ * components.
+ */
+ public static final short DuplicatedSpatialComponents_1 = 76;
+
+ /**
+ * Compound coordinate reference systems should not contain
ellipsoidal height. Use a
+ * three-dimensional {0,choice,0#geographic|1#projected} system
instead.
+ */
+ public static final short EllipsoidalHeightNotAllowed_1 = 77;
+
+ /**
* There is no factory for version {1} of “{0}” authority. Fallback on
default version for
* objects creation.
*/
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
[ISO-8859-1] Mon Oct 9 09:40:02 2017
@@ -55,6 +55,8 @@ ColinearAxisDirections_2 = Axis
CoordinateOperationNotFound_2 = Coordinate conversion of transformation
from system \u201c{0}\u201d to \u201c{1}\u201d has not been found.
DatumOriginShallBeDate = Origin of temporal datum shall be a date.
DuplicatedParameterName_4 = Name or alias for parameter
\u201c{0}\u201d at index {1} conflict with name \u201c{2}\u201d at index {3}.
+DuplicatedSpatialComponents_1 = Compound coordinate reference systems can
not contain two {0,choice,1#horizontal|2#vertical} components.
+EllipsoidalHeightNotAllowed_1 = Compound coordinate reference systems
should not contain ellipsoidal height. Use a three-dimensional
{0,choice,0#geographic|1#projected} system instead.
IllegalAxisDirection_2 = Coordinate system of class \u2018{0}\u2019
can not have axis in the {1} direction.
IllegalOperationDimension_3 = Dimensions of \u201c{0}\u201d operation
can not be ({1} \u2192 {2}).
IllegalOperationForValueClass_1 = This operation can not be applied to
values of class \u2018{0}\u2019.
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
[ISO-8859-1] Mon Oct 9 09:40:02 2017
@@ -60,6 +60,8 @@ ColinearAxisDirections_2 = Les
CoordinateOperationNotFound_2 = La conversion ou transformation des
coordonn\u00e9es du syst\u00e8me \u00ab\u202f{0}\u202f\u00bb vers
\u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e.
DatumOriginShallBeDate = L\u2019origine d\u2019un
r\u00e9f\u00e9rentiel temporel doit \u00eatre une date.
DuplicatedParameterName_4 = Le nom ou un alias pour le param\u00e8tre
\u00ab\u202f{0}\u202f\u00bb \u00e0 l\u2019index {1} duplique le nom
\u00ab\u202f{2}\u202f\u00bb \u00e0 l\u2019index {3}.
+DuplicatedSpatialComponents_1 = Un syst\u00e8me de r\u00e9f\u00e9rence des
coordonn\u00e9es ne peut pas contenir deux composantes
{0,choice,1#horizontales|2#verticales}.
+EllipsoidalHeightNotAllowed_1 = Un syst\u00e8me de r\u00e9f\u00e9rence des
coordonn\u00e9es ne devrait pas contenir une hauteur ellipso\u00efdale.
Utilisez plut\u00f4t un syst\u00e8me
{0,choice,0#g\u00e9ographique|1#projet\u00e9} \u00e0 trois dimensions.
IllegalAxisDirection_2 = Les syst\u00e8mes de coordonn\u00e9es de
classe \u2018{0}\u2019 ne peuvent pas avoir d\u2019axe dans la direction
\u00ab\u202f{1}\u202f\u00bb.
IllegalOperationDimension_3 = Les dimensions de l\u2019op\u00e9ration
\u00ab\u202f{0}\u202f\u00bb ne peuvent pas \u00eatre ({1} \u2192 {2}).
IllegalOperationForValueClass_1 = Cette op\u00e9ration ne peut pas
s\u2019appliquer aux valeurs de classe \u2018{0}\u2019.
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -91,6 +91,7 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.internal.referencing.provider.Affine;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.Constants;
+import org.apache.sis.util.CharSequences;
import org.apache.sis.util.collection.Containers;
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.resources.Errors;
@@ -695,13 +696,15 @@ public final class ServicesForMetadata e
* Returns the properties of the given object.
*
* @param object the object from which to get the properties.
+ * @param keepId {@code true} for preserving the identifiers, {@code
false} for discarding them.
* @return the properties of the given object.
*
* @since 0.6
*/
@Override
- public Map<String,?> getProperties(final IdentifiedObject object) {
- return IdentifiedObjects.getProperties(object);
+ public Map<String,?> getProperties(final IdentifiedObject object, final
boolean keepId) {
+ return IdentifiedObjects.getProperties(object, keepId ?
CharSequences.EMPTY_ARRAY
+ : new String[] {IdentifiedObject.IDENTIFIERS_KEY});
}
/**
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -31,6 +31,7 @@ import org.opengis.util.GenericName;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
+import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.Projection;
@@ -127,6 +128,15 @@ public abstract class MapProjection exte
}
/**
+ * The three-dimensional counterpart of this two-dimensional map
projection.
+ * This is created when first needed.
+ *
+ * @see #redimension(int, int)
+ * @see GeodeticOperation#redimensioned
+ */
+ private OperationMethod redimensioned;
+
+ /**
* Constructs a math transform provider from a set of parameters. The
provider
* {@linkplain #getIdentifiers() identifiers} will be the same than the
parameter ones.
*
@@ -147,6 +157,26 @@ public abstract class MapProjection exte
}
/**
+ * Returns this operation method with the specified number of dimensions.
+ * The number of dimensions can be only 2 or 3, and must be the same for
source and target CRS.
+ *
+ * @return the redimensioned projection method, or {@code this} if no
change is needed.
+ *
+ * @since 0.8
+ */
+ @Override
+ public final OperationMethod redimension(final int sourceDimensions, final
int targetDimensions) {
+ if (sourceDimensions != 3 || targetDimensions != 3) {
+ return super.redimension(sourceDimensions, targetDimensions);
+ } else synchronized (this) {
+ if (redimensioned == null) {
+ redimensioned = new MapProjection3D(this);
+ }
+ return redimensioned;
+ }
+ }
+
+ /**
* Validates the given parameter value. This method duplicates the
verification already
* done by {@link
org.apache.sis.parameter.DefaultParameterValue#setValue(Object, Unit)}.
* But we check again because we have no guarantee that the parameters
given by the user
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -35,6 +35,7 @@ import org.opengis.referencing.crs.Proje
import org.opengis.referencing.crs.EngineeringCRS;
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.crs.TemporalCRS;
+import org.opengis.referencing.crs.ParametricCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.CoordinateSystem;
import org.apache.sis.referencing.cs.AxesConvention;
@@ -42,6 +43,7 @@ import org.apache.sis.referencing.cs.Def
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.referencing.Resources;
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.util.UnmodifiableArrayList;
@@ -107,7 +109,7 @@ import org.apache.sis.io.wkt.Convention;
* SIS factories and static constants.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.7
+ * @version 0.8
*
* @see
org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createCompoundCRS(String)
*
@@ -184,13 +186,58 @@ public class DefaultCompoundCRS extends
*
* @param properties the properties to be given to the coordinate
reference system.
* @param components the sequence of coordinate reference systems making
this compound CRS.
+ * @throws IllegalArgumentException if the given array does not contain at
least two components,
+ * or if two consecutive components are a geographic CRS with an
ellipsoidal height.
*
* @see
org.apache.sis.referencing.factory.GeodeticObjectFactory#createCompoundCRS(Map,
CoordinateReferenceSystem...)
*/
public DefaultCompoundCRS(final Map<String,?> properties, final
CoordinateReferenceSystem... components) {
super(properties, createCoordinateSystem(properties, components));
setComponents(Arrays.asList(components));
- // 'singles' is computed by the above method call.
+ /*
+ * 'singles' is computed by the above method call. Now verify that we
do not have an ellipsoidal
+ * height with a geographic or projected CRS (see
https://issues.apache.org/jira/browse/SIS-303).
+ * Note that this is already be done if the given array does not
contain nested CompoundCRS.
+ */
+ if (singles != this.components) {
+ verify(properties, singles.toArray(new SingleCRS[singles.size()]));
+ }
+ }
+
+ /**
+ * Verifies that the given array does not contain duplicated horizontal or
vertical components.
+ * Verifies also that if there is an horizontal component, then there is
no ellipsoidal height
+ * defined separately.
+ *
+ * @param properties the user-specified properties, for determining the
locale of error messages.
+ * @param components the components to verify.
+ */
+ private static void verify(final Map<String,?> properties, final
CoordinateReferenceSystem[] components) {
+ int allTypes = 0;
+ int isProjected = 0; // 0 for false, 1 for
true.
+ boolean isEllipsoidalHeight = false;
+ for (final CoordinateReferenceSystem component : components) {
+ final int type;
+ if (component instanceof GeodeticCRS) {
+ type = 1; // Must match the number used in
Resources.Keys.DuplicatedSpatialComponents_1.
+ } else if (component instanceof ProjectedCRS) {
+ isProjected = 1;
+ type = 1; // Intentionally same number than for
GeographicCRS case.
+ } else if (component instanceof VerticalCRS) {
+ isEllipsoidalHeight =
ReferencingUtilities.isEllipsoidalHeight(((VerticalCRS) component).getDatum());
+ type = 2; // Must match the number used in
Resources.Keys.DuplicatedSpatialComponents_1.
+ } else {
+ continue; // Skip other types. In particular, we allow 2
temporal CRS (used in meteorology).
+ }
+ if (allTypes == (allTypes |= type)) {
+ throw new
IllegalArgumentException(Resources.forProperties(properties)
+
.getString(Resources.Keys.DuplicatedSpatialComponents_1, type));
+ }
+ }
+ if (isEllipsoidalHeight && ((allTypes & 1) != 0)) {
+ throw new
IllegalArgumentException(Resources.forProperties(properties)
+ .getString(Resources.Keys.EllipsoidalHeightNotAllowed_1,
isProjected));
+ }
}
/**
@@ -204,6 +251,7 @@ public class DefaultCompoundCRS extends
final CoordinateReferenceSystem[] components)
{
ArgumentChecks.ensureNonNull("components", components);
+ verify(properties, components);
if (components.length < 2) {
throw new
IllegalArgumentException(Errors.getResources(properties).getString(
Errors.Keys.TooFewArguments_2, 2, components.length));
@@ -296,7 +344,6 @@ public class DefaultCompoundCRS extends
*
* @see #getComponents()
*/
- @SuppressWarnings("SuspiciousToArrayCall")
private void setComponents(final List<? extends CoordinateReferenceSystem>
crs) {
if (setSingleComponents(crs)) {
components = singles; // Shares the same
list.
@@ -407,7 +454,7 @@ public class DefaultCompoundCRS extends
return false;
}
case 1: {
- if (crs instanceof VerticalCRS) { // TODO: accept also
ParametricCRS here.
+ if (crs instanceof VerticalCRS || crs instanceof
ParametricCRS) {
state = 2; continue; // Next CRS can only be
temporal.
}
// Fallthrough (the current CRS may be temporal)
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -33,8 +33,6 @@ import org.opengis.metadata.Identifier;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.parameter.ParameterValueGroup;
import org.apache.sis.internal.metadata.AxisDirections;
-import org.apache.sis.internal.metadata.VerticalDatumTypes;
-import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.referencing.provider.Geographic2Dto3D;
import org.apache.sis.internal.referencing.provider.Geographic3Dto2D;
@@ -629,7 +627,7 @@ public class CoordinateOperationFinder e
VerticalCRS heightCRS = targetCRS; // First candidate, will be
replaced if it doesn't fit.
VerticalCS heightCS = heightCRS.getCoordinateSystem();
if (equalsIgnoreMetadata(heightCS.getAxis(0), expectedAxis)) {
- isEllipsoidalHeight =
VerticalDatumTypes.ELLIPSOIDAL.equals(heightCRS.getDatum().getVerticalDatumType());
+ isEllipsoidalHeight =
ReferencingUtilities.isEllipsoidalHeight(heightCRS.getDatum());
} else {
heightCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
heightCS = heightCRS.getCoordinateSystem();
@@ -840,8 +838,8 @@ public class CoordinateOperationFinder e
} else if (stepComponents.length == 1) {
stepTargetCRS = target; // Slight optimization
of the next block.
} else {
- stepTargetCRS =
toAuthorityDefinition(CoordinateReferenceSystem.class,
ReferencingServices.getInstance()
- .createCompoundCRS(factorySIS.getCRSFactory(),
factorySIS.getCSFactory(), derivedFrom(target), stepComponents));
+ stepTargetCRS =
toAuthorityDefinition(CoordinateReferenceSystem.class,
+ new CompoundCRSBuilder(factory,
factorySIS).createCompoundCRS(derivedFrom(target), stepComponents));
}
int delta = source.getCoordinateSystem().getDimension();
final int startAtDimension = endAtDimension;
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -1045,10 +1045,7 @@ class CoordinateOperationRegistry {
}
}
return toAuthorityDefinition(CoordinateReferenceSystem.class,
- ReferencingServices.getInstance().createCompoundCRS(
- factorySIS.getCRSFactory(),
- factorySIS.getCSFactory(),
- derivedFrom(crs), crs,
CommonCRS.Vertical.ELLIPSOIDAL.crs()));
+ new CompoundCRSBuilder(factory,
factorySIS).createCompoundCRS(derivedFrom(crs), crs,
CommonCRS.Vertical.ELLIPSOIDAL.crs()));
}
/**
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -21,6 +21,7 @@ import org.opengis.referencing.cs.*;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.VerticalDatum;
import org.opengis.referencing.IdentifiedObject;
import org.apache.sis.referencing.datum.HardCodedDatum;
import org.apache.sis.referencing.crs.HardCodedCRS;
@@ -56,6 +57,14 @@ public final strictfp class ReferencingU
}
/**
+ * Tests {@link ReferencingUtilities#isEllipsoidalHeight(VerticalDatum)}.
+ */
+ @Test
+ public void testEllipsoidalHeight() {
+ assertTrue(isEllipsoidalHeight(HardCodedDatum.ELLIPSOID));
+ }
+
+ /**
* Asserts that normalization of the given CRS produces {@link
HardCodedCRS#WGS84} (ignoring metadata).
*
* @param message the message to show in case of failure.
@@ -110,7 +119,7 @@ public final strictfp class ReferencingU
assertEquals("cylindricalCS",
toPropertyName(CoordinateSystem.class, CylindricalCS .class).toString());
assertEquals("ellipsoidalCS",
toPropertyName(CoordinateSystem.class, EllipsoidalCS .class).toString());
assertEquals("linearCS",
toPropertyName(CoordinateSystem.class, LinearCS .class).toString());
-// assertEquals("parametricCS",
toPropertyName(CoordinateSystem.class, ParametricCS .class).toString());
+ assertEquals("parametricCS",
toPropertyName(CoordinateSystem.class, ParametricCS .class).toString());
assertEquals("polarCS",
toPropertyName(CoordinateSystem.class, PolarCS .class).toString());
assertEquals("sphericalCS",
toPropertyName(CoordinateSystem.class, SphericalCS .class).toString());
assertEquals("timeCS",
toPropertyName(CoordinateSystem.class, TimeCS .class).toString());
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -16,26 +16,17 @@
*/
package org.apache.sis.internal.referencing;
-import java.util.Map;
-import java.util.Collections;
import org.opengis.geometry.Envelope;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.metadata.extent.VerticalExtent;
-import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
import org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent;
import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.crs.HardCodedCRS;
-import org.apache.sis.referencing.factory.GeodeticObjectFactory;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -54,11 +45,20 @@ import static org.apache.sis.test.TestUt
* @module
*/
@DependsOn({
- org.apache.sis.referencing.CRSTest.class,
org.apache.sis.referencing.CommonCRSTest.class
})
public final strictfp class ServicesForMetadataTest extends TestCase {
/**
+ * Tests {@link
org.apache.sis.metadata.iso.extent.Extents#centroid(GeographicBoundingBox)}.
+ *
+ * @since 0.8
+ */
+ @Test
+ public void testGeographicBoundingBoxCentroid() {
+ org.apache.sis.metadata.iso.extent.ExtentsTest.testCentroid();
+ }
+
+ /**
* Creates a test envelope with the given CRS and initialized with
* [-10 … 70]° of longitude, [-20 … 30]° of latitude, [-40 … 60] metres of
elevation
* and [51000 … 52000] modified Julian days.
@@ -97,7 +97,6 @@ public final strictfp class ServicesForM
assertEqualsIgnoreMetadata(expectedCRS.crs(), extent.getVerticalCRS());
}
-
/**
* Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope,
DefaultGeographicBoundingBox)}
* from a three-dimensional envelope.
@@ -163,64 +162,4 @@ public final strictfp class ServicesForM
verifySpatialExtent((GeographicBoundingBox)
getSingleton(extent.getSpatialExtent()));
verifyVerticalExtent(CommonCRS.Vertical.MEAN_SEA_LEVEL,
extent.getVerticalExtent());
}
-
- /**
- * Tests {@link ServicesForMetadata#createCompoundCRS
ReferencingUtilities.createCompoundCRS(…)}.
- *
- * @throws FactoryException if a CRS can not be created.
- *
- * @see <a href="https://issues.apache.org/jira/browse/SIS-303">SIS-303</a>
- *
- * @since 0.7
- */
- @Test
- public void testCreateCompoundCRS() throws FactoryException {
- final ReferencingServices services = ServicesForMetadata.getInstance();
- final GeodeticObjectFactory factory = new GeodeticObjectFactory();
- final Map<String,String> properties =
Collections.singletonMap(CoordinateReferenceSystem.NAME_KEY, "WGS 84 (4D)");
- /*
- * createCompoundCRS(…) should not combine GeographicCRS with
non-ellipsoidal height.
- */
- CoordinateReferenceSystem compound =
services.createCompoundCRS(factory, factory, properties,
- HardCodedCRS.WGS84, HardCodedCRS.GRAVITY_RELATED_HEIGHT,
HardCodedCRS.TIME);
- assertArrayEqualsIgnoreMetadata(new SingleCRS[] {HardCodedCRS.WGS84,
HardCodedCRS.GRAVITY_RELATED_HEIGHT, HardCodedCRS.TIME},
- CRS.getSingleComponents(compound).toArray());
- /*
- * createCompoundCRS(…) should combine GeographicCRS with ellipsoidal
height.
- */
- compound = services.createCompoundCRS(factory, factory, properties,
- HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT);
- assertArrayEqualsIgnoreMetadata(new SingleCRS[]
{HardCodedCRS.WGS84_3D},
- CRS.getSingleComponents(compound).toArray());
- /*
- * createCompoundCRS(…) should combine GeographicCRS with ellipsoidal
height and keep time.
- */
- compound = services.createCompoundCRS(factory, factory, properties,
- HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT,
HardCodedCRS.TIME);
- assertArrayEqualsIgnoreMetadata(new SingleCRS[]
{HardCodedCRS.WGS84_3D, HardCodedCRS.TIME},
- CRS.getSingleComponents(compound).toArray());
- /*
- * Non-standard feature: accept (VerticalCRS + GeodeticCRS) order.
- * The test below use the reverse order for all axes compared to the
previous test.
- */
- compound = services.createCompoundCRS(factory, factory, properties,
- HardCodedCRS.TIME, HardCodedCRS.ELLIPSOIDAL_HEIGHT,
HardCodedCRS.WGS84_φλ);
- final Object[] components =
CRS.getSingleComponents(compound).toArray();
- assertEquals(2, components.length);
- assertEqualsIgnoreMetadata(HardCodedCRS.TIME, components[0]);
- assertInstanceOf("Shall be a three-dimensional geographic CRS.",
GeographicCRS.class, components[1]);
- assertAxisDirectionsEqual("Shall be a three-dimensional geographic
CRS.",
- ((CoordinateReferenceSystem)
components[1]).getCoordinateSystem(),
- AxisDirection.UP, AxisDirection.NORTH, AxisDirection.EAST);
- }
-
- /**
- * Tests {@link
org.apache.sis.metadata.iso.extent.Extents#centroid(GeographicBoundingBox)}.
- *
- * @since 0.8
- */
- @Test
- public void testGeographicBoundingBoxCentroid() {
- org.apache.sis.metadata.iso.extent.ExtentsTest.testCentroid();
- }
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
[UTF-8] Mon Oct 9 09:40:02 2017
@@ -109,7 +109,7 @@ public final strictfp class ProvidersTes
/**
* Returns the subset of {@link #methods()} which are expected to support
- * {@link AbstractProvider#redimension(int, int)}.
+ * {@link AbstractProvider#redimension(int, int)}, not including map
projections.
*/
private static Class<?>[] redimensionables() {
return new Class<?>[] {
@@ -224,6 +224,13 @@ public final strictfp class ProvidersTes
}
}
}
+ } else if (method instanceof MapProjection) {
+ final OperationMethod proj3D = ((MapProjection)
method).redimension(sourceDimensions ^ 1, targetDimensions ^ 1);
+ assertNotSame("redimension(3,3) should return a new method.",
method, proj3D);
+ assertSame("redimension(2,2) should give back the original
method.", method,
+ ((DefaultOperationMethod)
proj3D).redimension(sourceDimensions, targetDimensions));
+ assertSame("Value of redimension(3,3) should have been
cached.", proj3D,
+ ((MapProjection) method).redimension(sourceDimensions
^ 1, targetDimensions ^ 1));
} else try {
((DefaultOperationMethod) method).redimension(sourceDimensions
^ 1, targetDimensions ^ 1);
fail("Type " + method.getClass().getName() + " is not in our
list of redimensionable methods.");