Author: desruisseaux
Date: Thu Mar 20 00:22:59 2014
New Revision: 1579489
URL: http://svn.apache.org/r1579489
Log:
Merge from the JDK6 branch.
Added:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
- copied unchanged from r1579488,
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java
Modified:
sis/trunk/ (props changed)
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands.properties
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands_fr.properties
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/ClassFormat.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStore.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1578178-1579486
Merged /sis/branches/JDK6:r1578179-1579488
Modified:
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
[UTF-8] (original)
+++
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -41,7 +41,7 @@ import org.apache.sis.util.logging.Monol
* Each command can accepts an arbitrary amount of the following options:
*
* <blockquote><table class="compact">
- * <tr><td>{@code --format} </td><td>The output format (XML or
text).</td></tr>
+ * <tr><td>{@code --format} </td><td>The output format: {@code xml}, {@code
wkt}, {@code wkt1} or {@code text}.</td></tr>
* <tr><td>{@code --locale} </td><td>The locale to use for the command
output.</td></tr>
* <tr><td>{@code --timezone} </td><td>The timezone for the dates to be
formatted.</td></tr>
* <tr><td>{@code --encoding} </td><td>The encoding to use for the command
output.</td></tr>
@@ -150,10 +150,11 @@ public final class Command {
command = new HelpSC(-1, args);
} else {
commandName = commandName.toLowerCase(Locale.US);
- if (commandName.equals("about")) command = new AboutSC
(commandIndex, args);
- else if (commandName.equals("help")) command = new HelpSC
(commandIndex, args);
- else if (commandName.equals("mime-type")) command = new
MimeTypeSC(commandIndex, args);
- else if (commandName.equals("metadata")) command = new
MetadataSC(commandIndex, args);
+ if (commandName.equals("about")) command = new AboutSC
( commandIndex, args);
+ else if (commandName.equals("help")) command = new HelpSC
( commandIndex, args);
+ else if (commandName.equals("mime-type")) command = new
MimeTypeSC( commandIndex, args);
+ else if (commandName.equals("metadata")) command = new
MetadataSC(false, commandIndex, args);
+ else if (commandName.equals("crs")) command = new
MetadataSC(true, commandIndex, args);
else throw new InvalidCommandException(Errors.format(
Errors.Keys.UnknownCommand_1, commandName),
commandName);
}
Modified:
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
[UTF-8] (original)
+++
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -22,6 +22,11 @@ import java.io.IOException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.JAXBException;
import org.opengis.metadata.Metadata;
+import org.opengis.referencing.ReferenceSystem;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.io.wkt.WKTFormat;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.io.wkt.Colors;
import org.apache.sis.metadata.MetadataStandard;
import org.apache.sis.metadata.ValueExistencePolicy;
import org.apache.sis.storage.DataStore;
@@ -36,7 +41,8 @@ import org.apache.sis.xml.XML;
/**
- * The "metadata" subcommand.
+ * The "metadata" and "crs" subcommands.
+ * CRS are considered as a kind of metadata here.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
@@ -45,14 +51,25 @@ import org.apache.sis.xml.XML;
*/
final class MetadataSC extends SubCommand {
/**
- * Creates the {@code "metadata"} sub-command.
+ * {@code true} for the {@code "crs"} sub-command,
+ * or {@code false} for the {@code "metadata"} sub-command.
*/
- MetadataSC(final int commandIndex, final String... args) throws
InvalidOptionException {
- super(commandIndex, args, EnumSet.of(Option.FORMAT, Option.LOCALE,
Option.TIMEZONE, Option.ENCODING, Option.HELP));
+ private final boolean isCRS;
+
+ /**
+ * Creates the {@code "metadata"} or {@code "crs"} sub-command.
+ *
+ * @param isCRS {@code true} for the {@code "crs"} sub-command,
+ * or {@code false} for the {@code "metadata"} sub-command.
+ */
+ MetadataSC(final boolean isCRS, final int commandIndex, final String...
args) throws InvalidOptionException {
+ super(commandIndex, args, EnumSet.of(Option.FORMAT, Option.LOCALE,
Option.TIMEZONE, Option.ENCODING,
+ Option.COLORS, Option.HELP));
+ this.isCRS = isCRS;
}
/**
- * Prints metadata information.
+ * Prints metadata or CRS information.
*
* @throws DataStoreException If an error occurred while reading the file.
* @throws JAXBException If an error occurred while producing the XML
output.
@@ -62,18 +79,30 @@ final class MetadataSC extends SubComman
public int run() throws InvalidOptionException, DataStoreException,
JAXBException, IOException {
/*
* Output format can be either "text" (the default) or "xml".
+ * In the case of "crs" sub-command, we accept also WKT variants.
*/
boolean toXML = false;
+ Convention wkt = null;
final String format = options.get(Option.FORMAT);
if (format != null && !format.equalsIgnoreCase("text")) {
- if (!format.equalsIgnoreCase("xml")) {
- throw new InvalidOptionException(Errors.format(
- Errors.Keys.IllegalOptionValue_2, "format", format),
format);
+ toXML = format.equalsIgnoreCase("xml");
+ if (!toXML) {
+ if (isCRS) {
+ if (format.equalsIgnoreCase("wkt") ||
format.equalsIgnoreCase("wkt2")) {
+ wkt = Convention.WKT2;
+ } else if (format.equalsIgnoreCase("wkt1")) {
+ wkt = Convention.WKT1;
+ }
+ }
+ if (wkt == null) {
+ throw new InvalidOptionException(Errors.format(
+ Errors.Keys.IllegalOptionValue_2, "format",
format), format);
+ }
}
- toXML = true;
}
/*
* Read metadata from the data storage.
+ * If we are executing the "crs" sub-command, extract the first CRS.
*/
if (hasUnexpectedFileCount(1, 1)) {
return Command.INVALID_ARGUMENT_EXIT_CODE;
@@ -85,31 +114,52 @@ final class MetadataSC extends SubComman
} finally {
store.close();
}
+ if (metadata == null) {
+ return 0;
+ }
+ CoordinateReferenceSystem crs = null;
+ if (isCRS) {
+ for (final ReferenceSystem rs : metadata.getReferenceSystemInfo())
{
+ if (rs instanceof CoordinateReferenceSystem) {
+ crs = (CoordinateReferenceSystem) rs;
+ break;
+ }
+ }
+ if (crs == null) {
+ return 0;
+ }
+ }
/*
* Format metadata to the standard output stream.
*/
- if (metadata != null) {
- if (toXML) {
- final MarshallerPool pool = new MarshallerPool(null);
- final Marshaller marshaller = pool.acquireMarshaller();
- marshaller.setProperty(XML.LOCALE, locale);
- marshaller.setProperty(XML.TIMEZONE, timezone);
- if (isConsole()) {
- marshaller.marshal(metadata, out);
- } else {
- out.flush();
- marshaller.setProperty(Marshaller.JAXB_ENCODING,
encoding.name());
- marshaller.marshal(metadata, System.out); // Use
OutputStream instead than Writer.
- System.out.flush();
- }
+ if (toXML) {
+ final MarshallerPool pool = new MarshallerPool(null);
+ final Marshaller marshaller = pool.acquireMarshaller();
+ marshaller.setProperty(XML.LOCALE, locale);
+ marshaller.setProperty(XML.TIMEZONE, timezone);
+ if (isConsole()) {
+ marshaller.marshal(crs != null ? crs : metadata, out);
} else {
- final TreeTable tree =
MetadataStandard.ISO_19115.asTreeTable(metadata,
ValueExistencePolicy.NON_EMPTY);
- final TreeTableFormat tf = new TreeTableFormat(locale,
timezone);
- tf.setColumns(TableColumn.NAME, TableColumn.VALUE);
- tf.format(tree, out);
+ out.flush();
+ marshaller.setProperty(Marshaller.JAXB_ENCODING,
encoding.name());
+ marshaller.marshal(crs != null ? crs : metadata, System.out);
// Use OutputStream instead than Writer.
+ System.out.flush();
+ }
+ } else if (wkt != null) {
+ final WKTFormat f = new WKTFormat(locale, timezone);
+ f.setConvention(wkt);
+ if (colors) {
+ f.setColors(Colors.DEFAULT);
}
- out.flush();
+ f.format(crs, out);
+ out.println();
+ } else {
+ final TreeTable tree =
MetadataStandard.ISO_19115.asTreeTable(metadata,
ValueExistencePolicy.NON_EMPTY);
+ final TreeTableFormat tf = new TreeTableFormat(locale, timezone);
+ tf.setColumns(TableColumn.NAME, TableColumn.VALUE);
+ tf.format(tree, out);
}
+ out.flush();
return 0;
}
Modified:
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
[UTF-8] (original)
+++
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -85,7 +85,7 @@ abstract class SubCommand {
* This is the value specified by the {@code --colors} arguments if
present,
* or a value inferred from the system otherwise.
*/
- protected final Boolean colors;
+ protected final boolean colors;
/**
* Output stream to the console. This output stream uses the encoding
Modified:
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands.properties
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands.properties?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands.properties
[ISO-8859-1] (original)
+++
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands.properties
[ISO-8859-1] Thu Mar 20 00:22:59 2014
@@ -4,5 +4,6 @@ Usage=Usage: sis <command> [options] [fi
help=Show a help overview.
about=Show information about Apache SIS and system configuration.
+crs=Show Coordinate Reference System information for the given file.
mime-type=Show MIME type for the given file.
metadata=Show metadata information for the given file.
Modified:
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands_fr.properties
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands_fr.properties?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands_fr.properties
[ISO-8859-1] (original)
+++
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Commands_fr.properties
[ISO-8859-1] Thu Mar 20 00:22:59 2014
@@ -4,5 +4,6 @@ Usage=Usage: sis <commande> [options] [f
help=Affiche un écran d\u2019aide.
about=Affiche des informations à propos de Apache SIS et de la configuration
du système.
+crs=Affiche le système de référence des coordonnées du fichier spécifié.
mime-type=Affiche le type MIME du fichier spécifié.
metadata=Affiche les méta-données du fichier spécifié.
Modified:
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
[ISO-8859-1] (original)
+++
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
[ISO-8859-1] Thu Mar 20 00:22:59 2014
@@ -1,5 +1,5 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.
-format=The output format (for instance XML or text).
+format=The output format: xml, wkt, wkt1 or text.
locale=The locale to use for the command output.
timezone=The timezone for the dates to be formatted.
encoding=The encoding to use for the command output.
Modified:
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
[ISO-8859-1] (original)
+++
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
[ISO-8859-1] Thu Mar 20 00:22:59 2014
@@ -1,5 +1,5 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.
-format=Le format de sortie (par exemple XML ou texte).
+format=Le format de sortie: xml, wkt, wkt1 ou text.
locale=Les paramètres régionaux à utiliser pour la sortie de la commande.
timezone=Le fuseau horaire des dates à écrire.
encoding=L\u2019encodage des caractères à utiliser pour la sortie de la
commande.
Modified:
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java
[UTF-8] (original)
+++
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -46,7 +46,7 @@ public final strictfp class MetadataSCTe
public void testNetCDF() throws Exception {
final URL url = MetadataSCTest.class.getResource("NCEP-SST.nc");
assertNotNull("NCEP-SST.nc", url);
- final MetadataSC test = new MetadataSC(0, SubCommand.TEST,
url.toString());
+ final MetadataSC test = new MetadataSC(false, 0, SubCommand.TEST,
url.toString());
test.run();
verifyNetCDF("Metadata", test.outputBuffer.toString());
}
@@ -73,7 +73,7 @@ public final strictfp class MetadataSCTe
@DependsOnMethod("testNetCDF")
public void testFormatXML() throws Exception {
final URL url = MetadataSCTest.class.getResource("NCEP-SST.nc");
- final MetadataSC test = new MetadataSC(0, SubCommand.TEST,
url.toString(), "--format", "XML");
+ final MetadataSC test = new MetadataSC(false, 0, SubCommand.TEST,
url.toString(), "--format", "XML");
test.run();
verifyNetCDF("<?xml", test.outputBuffer.toString());
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -66,11 +66,11 @@ public class Colors implements Cloneable
map.put(ElementKind.PARAMETER, X364.FOREGROUND_GREEN);
map.put(ElementKind.METHOD, X364.FOREGROUND_GREEN);
map.put(ElementKind.DATUM, X364.FOREGROUND_GREEN);
+ map.put(ElementKind.SCOPE, X364.FOREGROUND_GRAY);
+ map.put(ElementKind.EXTENT, X364.FOREGROUND_GRAY);
+ map.put(ElementKind.CITATION, X364.FOREGROUND_GRAY);
+ map.put(ElementKind.REMARKS, X364.FOREGROUND_GRAY);
map.put(ElementKind.ERROR, X364.BACKGROUND_RED);
- map.put(ElementKind.SCOPE, X364.BACKGROUND_GRAY);
- map.put(ElementKind.EXTENT, X364.BACKGROUND_GRAY);
- map.put(ElementKind.CITATION, X364.BACKGROUND_GRAY);
- map.put(ElementKind.REMARKS, X364.BACKGROUND_GRAY);
DEFAULT.isImmutable = true;
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -22,19 +22,25 @@ import java.awt.geom.Area;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
+// GeoAPI import
+import org.opengis.geometry.DirectPosition;
+
//SIS imports
import org.apache.sis.distance.DistanceUtils;
import org.apache.sis.geometry.DirectPosition2D;
-import org.apache.sis.geometry.GeneralDirectPosition;
+import org.apache.sis.measure.Longitude;
/**
* Represents a 2D point associated with a radius to enable great circle
* estimation on earth surface.
*
- * @deprecated Replaced by {@link org.opengis.geometry.DirectPosition}, which
is derived from OGC/ISO specifications.
+ * <div class="warning"><b>Warning:</b> This class may be refactored as a
geometric object in a future SIS version.
+ * Current implementation does not verify the CRS of circle center or the
datum.</div>
*/
-@Deprecated
-public class LatLonPointRadius extends GeneralDirectPosition {
+public class LatLonPointRadius {
+
+ private final DirectPosition center;
+ private final double radius;
/**
* Creates a representation of point-radius search region.
@@ -44,8 +50,9 @@ public class LatLonPointRadius extends G
* @param radius
* the radius of the search region
*/
- public LatLonPointRadius(DirectPosition2D center, double radius) {
- super(center.x, center.y, radius);
+ public LatLonPointRadius(DirectPosition center, double radius) {
+ this.center = center;
+ this.radius = radius;
}
/**
@@ -58,7 +65,7 @@ public class LatLonPointRadius extends G
* circular region
*/
public DirectPosition2D[] getCircularRegionApproximation(int numberOfPoints)
{
- if (super.getOrdinate(2) >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
+ if (radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
DirectPosition2D[] points = new DirectPosition2D[5];
points[0] = new DirectPosition2D(-180.0, -90.0);
points[1] = new DirectPosition2D(-180.0, 90.0);
@@ -75,8 +82,8 @@ public class LatLonPointRadius extends G
for (int i = 0; i < numberOfPoints; i++)
{
- points[i] = DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
- super.getOrdinate(0), super.getOrdinate(2), i * bearingIncrement);
+ points[i] = DistanceUtils.getPointOnGreatCircle(center.getOrdinate(1),
+ center.getOrdinate(0), radius, i * bearingIncrement);
}
points[numberOfPoints] = points[0];
@@ -92,30 +99,30 @@ public class LatLonPointRadius extends G
* @return Java Rectangle2D object that bounds the circlar search region
*/
public Rectangle2D getRectangularRegionApproximation(int numberOfPoints) {
- if (super.getOrdinate(2) >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
+ if (radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
}
int numberOfCrossOvers = 0;
Path2D path = new Path2D.Double();
- DirectPosition2D initPT =
DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
- super.getOrdinate(0), super.getOrdinate(2), 0);
+ DirectPosition2D initPT =
DistanceUtils.getPointOnGreatCircle(center.getOrdinate(1),
+ center.getOrdinate(0), radius, 0);
path.moveTo(initPT.x + 180.0, initPT.y + 90.0);
DirectPosition2D currPT = initPT;
for (int i = 1; i < 360; i++) {
- DirectPosition2D pt =
DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
- super.getOrdinate(0), super.getOrdinate(2), i);
+ DirectPosition2D pt =
DistanceUtils.getPointOnGreatCircle(center.getOrdinate(1),
+ center.getOrdinate(0), radius, i);
path.lineTo(pt.x + 180.0, pt.y + 90.0);
- if (dateLineCrossOver(getNormLon(currPT.x), getNormLon(pt.x))) {
+ if (dateLineCrossOver(Longitude.normalize(currPT.x),
Longitude.normalize(pt.x))) {
numberOfCrossOvers++;
}
currPT = pt;
}
- if (dateLineCrossOver(getNormLon(initPT.x), getNormLon(currPT.x))) {
+ if (dateLineCrossOver(Longitude.normalize(initPT.x),
Longitude.normalize(currPT.x))) {
numberOfCrossOvers++;
}
@@ -125,17 +132,15 @@ public class LatLonPointRadius extends G
*/
if (numberOfCrossOvers == 1) {
Rectangle2D r = path.getBounds2D();
- Rectangle2D lowerHalf = new Rectangle2D.Double(0.0, 0.0, 360.0, r
- .getMaxY());
- if (lowerHalf.contains(super.getOrdinate(0) + 180, super.getOrdinate(1)
+ 90)) {
+ Rectangle2D lowerHalf = new Rectangle2D.Double(0.0, 0.0, 360.0,
r.getMaxY());
+ if (lowerHalf.contains(center.getOrdinate(0) + 180.0,
center.getOrdinate(1) + 90.0)) {
return lowerHalf;
} else {
- return new Rectangle2D.Double(0.0, r.getMinY(), 360.0, 180.0 - r
- .getMinY());
+ return new Rectangle2D.Double(0.0, r.getMinY(), 360.0, 180.0 -
r.getMinY());
}
}
- if (path.contains(super.getOrdinate(0) + 180, super.getOrdinate(1) + 90)) {
+ if (path.contains(center.getOrdinate(0) + 180.0, center.getOrdinate(1) +
90.0)) {
Rectangle2D r = path.getBounds2D();
if ((r.getMaxX() - r.getMinX()) > 359.0) {
return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
@@ -158,24 +163,6 @@ public class LatLonPointRadius extends G
}
/**
- * Normalizes the longitude values to be between -180.0 and 180.0
- *
- * @return longitude value that is between -180.0 and 180.0 inclusive
- */
- private static double getNormLon(double normLon) {
- if (normLon > 180.0) {
- while (normLon > 180.0) {
- normLon -= 360.0;
- }
- } else if (normLon < -180.0) {
- while (normLon < -180.0) {
- normLon += 360.0;
- }
- }
- return normLon;
- }
-
- /**
* Returns true if the line segment connecting the two specified longitudes
* crosses the international dateline.
*
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -24,6 +24,9 @@ import org.apache.sis.geometry.DirectPos
* Class to calculate distances on earth surface. Actual calculation code very
* similar to Apache SIS but refractor to allow use of custom classes.
*
+ * <div class="warning"><b>Warning:</b> This class may change in a future SIS
version. Current implementation
+ * performs computations on a sphere of hard-coded radius. A future
implementation should perform computations
+ * on a given ellipsoid.</div>
*/
public class DistanceUtils {
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -22,27 +22,23 @@
*
* <p>Parameters are organized in <cite>groups</cite>. A group may be for
example the set of all parameters needed
* for the definition of a <cite>Mercator projection</cite>.
- * Parameter groups have some similarity with {@code java.util.Map} where:</p>
+ * Parameter groups have some similarities with {@code java.util.Map}
where:</p>
*
* <ul>
* <li>Keys are (indirectly) parameter
* {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getName() names}.</li>
- * <li>Values are typically (but not restricted to) {@code int}, {@code
int[]}, {@code double}, {@code double[]},
+ * <li>Values are (indirectly) typically of type {@code int}, {@code int[]},
{@code double}, {@code double[]},
* {@code boolean}, {@link java.lang.String}, {@link java.net.URI} or
- * {@link org.apache.sis.metadata.iso.citation.DefaultCitation Citation}
- * (note: there is a level of indirection through those values).</li>
- * <li>Each parameter (equivalent to map entry) defines its own set of
constraints on acceptable values:
- * <ul>
- * <li>The base {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getValueClass() value
class}.</li>
- * <li>Optionally the {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getValueDomain()
- * value domain} (i.e. minimum and maximum valid values) or an
enumeration of
- * {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getValidValues() valid
values}.</li>
- * </ul>
- * </li>
- * <li>Each entry can have a
- * {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getDefaultValue() default
value} and an
+ * {@link org.apache.sis.metadata.iso.citation.DefaultCitation
Citation}.</li>
+ * <li>Each parameter (equivalent to map entry) constraints the values to a
base
+ * {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getValueClass() value
class},
+ * and optionally to a {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getValueDomain()
+ * value domain} (i.e. minimum and maximum valid values) or an
enumeration of
+ * {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getValidValues() valid
values}.</li>
+ * <li>Each parameter can have a
+ * {@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getDefaultValue() default
value} and a
* {@linkplain org.apache.sis.parameter.DefaultParameterValue#getUnit()
unit of measurement}.</li>
- * <li>Some parameters are mandatory ({@link
org.apache.sis.parameter.DefaultParameterDescriptor#getMinimumOccurs()
+ * <li>Some parameters are mandatory ({@linkplain
org.apache.sis.parameter.DefaultParameterDescriptor#getMinimumOccurs()
* minimum occurrence} = 1), meaning that they can not be removed from
the group.
* They can be left to their default value however.</li>
* <li>Group may contain other groups.</li>
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -282,8 +282,28 @@ public class AbstractCRS extends Abstrac
* <div class="note"><b>Implementation note:</b>
* It was easy to put JAXB annotations directly on datum fields in
subclasses because each CRS type
* can be associated to only one datum type. But we do not have this
convenience for coordinate systems,
- * where the same CRS may accept more than one kind of CS. In GML, the
different kinds of CS are marshalled
- * in different XML elements.</div>
+ * where the same CRS may accept different kinds of CS. In GML, the
different kinds of CS are marshalled
+ * as different XML elements. The usual way to handle such {@code
<xs:choice>} with JAXB is to annotate
+ * a single method like below:
+ *
+ * {@preformat java
+ * @Override
+ * @XmlElements({
+ * @XmlElement(name = "cartesianCS", type =
DefaultCartesianCS.class),
+ * @XmlElement(name = "affineCS", type =
DefaultAffineCS.class),
+ * @XmlElement(name = "cylindricalCS", type =
DefaultCylindricalCS.class),
+ * @XmlElement(name = "linearCS", type =
DefaultLinearCS.class),
+ * @XmlElement(name = "polarCS", type =
DefaultPolarCS.class),
+ * @XmlElement(name = "sphericalCS", type =
DefaultSphericalCS.class),
+ * @XmlElement(name = "userDefinedCS", type =
DefaultUserDefinedCS.class)
+ * })
+ * public CoordinateSystem getCoordinateSystem() {
+ * return super.getCoordinateSystem();
+ * }
+ * }
+ *
+ * However our attempts to apply this approach have not been conclusive.
+ * For an unknown reason, the unmarlshalled CS object was empty.</div>
*
* @param name The property name, used only in case of error message to
format.
* @throws IllegalStateException If the coordinate system has already been
set.
Modified:
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -57,7 +57,7 @@ public final strictfp class TensorParame
}
/**
- * Tests {@link TensorParameters#getDimensionDescriptor(int[])}.
+ * Tests {@link TensorParameters#getDimensionDescriptor(int)}.
*/
@Test
public void testGetDimensionDescriptor() {
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/ClassFormat.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/ClassFormat.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/ClassFormat.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/ClassFormat.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -23,7 +23,7 @@ import org.apache.sis.util.Classes;
/**
- * Used by {@link CompoundFormat} for formatting the names of object of type
{@link Class}.
+ * Used by {@link CompoundFormat} for formatting the name of objects of type
{@link Class}.
*
* {@section Thread safety}
* The same {@link #INSTANCE} can be safely used by many threads without
synchronization on the part of the caller.
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -32,11 +32,13 @@ import java.text.SimpleDateFormat;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
+import org.opengis.referencing.IdentifiedObject;
import org.apache.sis.measure.Angle;
import org.apache.sis.measure.AngleFormat;
import org.apache.sis.measure.Range;
import org.apache.sis.measure.RangeFormat;
import org.apache.sis.util.Localized;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.internal.util.LocalizedParseException;
@@ -417,6 +419,11 @@ public abstract class CompoundFormat<T>
return new RangeFormat(locale);
} else if (valueType == Class.class) {
return ClassFormat.INSTANCE;
+ } else {
+ final Class<?>[] interfaces = valueType.getInterfaces();
+ if (ArraysExt.contains(interfaces, IdentifiedObject.class)) {
+ return new IdentifiedObjectFormat(locale);
+ }
}
return null;
}
Modified:
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStore.java
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStore.java?rev=1579489&r1=1579488&r2=1579489&view=diff
==============================================================================
---
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStore.java
[UTF-8] (original)
+++
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStore.java
[UTF-8] Thu Mar 20 00:22:59 2014
@@ -26,10 +26,12 @@ import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.transform.stream.StreamSource;
import org.opengis.metadata.Metadata;
+import org.opengis.referencing.ReferenceSystem;
import org.apache.sis.xml.XML;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.metadata.iso.DefaultMetadata;
import org.apache.sis.util.logging.WarningListener;
import org.apache.sis.util.resources.Errors;
@@ -41,6 +43,7 @@ import org.apache.sis.util.resources.Err
*
* <ul>
* <li>{@link Metadata}, typically built from the {@code <gmd:MD_Metadata>}
XML element.</li>
+ * <li>{@link ReferenceSystem}, accessible by {@link
Metadata#getReferenceSystemInfo()}.</li>
* </ul>
*
* The above list may be extended in any future SIS version.
@@ -68,6 +71,11 @@ public class XMLStore extends DataStore
private Object object;
/**
+ * The metadata object, determined when first needed.
+ */
+ private Metadata metadata;
+
+ /**
* Creates a new XML store from the given file, URL or stream.
*
* @param connector Information about the storage (URL, stream,
<i>etc</i>).
@@ -162,11 +170,22 @@ public class XMLStore extends DataStore
@Override
public Metadata getMetadata() throws DataStoreException {
unmarshal();
- return (object instanceof Metadata) ? (Metadata) object : null;
+ if (metadata == null) {
+ if (object instanceof Metadata) {
+ metadata = (Metadata) object;
+ } else if (object instanceof ReferenceSystem) {
+ final DefaultMetadata d = new DefaultMetadata();
+ d.getReferenceSystemInfo().add((ReferenceSystem) object);
+ metadata = d;
+ }
+ }
+ return metadata;
}
/**
* Closes this data store and releases any underlying resources.
+ *
+ * @throws DataStoreException If an error occurred while closing this data
store.
*/
@Override
public void close() throws DataStoreException {