You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/09/25 16:55:51 UTC
svn commit: r1627555 [2/3] - in /sis/trunk: ./
core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/
core/sis-build-helper/src/main/javadoc/
core/sis-feature/src/test/java/org/apache/sis/feature/
core/sis-metadata/src/main/java/org/apache...
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -79,11 +79,12 @@ final class StandardImplementation exten
* @param implementationPackage The root package for metadata implementations. with a trailing {@code '.'}.
* @param prefix The prefix of implementation class. This array is not cloned.
* @param acronyms An array of (full text, acronyms) pairs. This array is not cloned.
+ * @param dependencies The dependencies to other metadata standards, or {@code null} if none.
*/
- StandardImplementation(final String citation, final String interfacePackage,
- final String implementationPackage, final String[] prefix, final String[] acronyms)
+ StandardImplementation(final String citation, final String interfacePackage, final String implementationPackage,
+ final String[] prefix, final String[] acronyms, final MetadataStandard[] dependencies)
{
- super(citation, interfacePackage);
+ super(citation, interfacePackage, dependencies);
this.implementationPackage = implementationPackage;
this.prefix = prefix;
this.acronyms = acronyms;
@@ -115,8 +116,8 @@ final class StandardImplementation exten
* CodeLists, Enums and Exceptions.
*/
if (type != null && type.isInterface()) {
- String name = type.getName();
- if (name.startsWith(interfacePackage)) {
+ String classname = type.getName();
+ if (isSupported(classname)) {
synchronized (implementations) {
Class<?> candidate = implementations.get(type);
if (candidate != null) {
@@ -128,7 +129,7 @@ final class StandardImplementation exten
* have been replaced by their acronym (if any).
*/
final StringBuilder buffer = new StringBuilder(implementationPackage)
- .append(name, interfacePackage.length(), name.length());
+ .append(classname, interfacePackage.length(), classname.length());
if (acronyms != null) {
for (int i=0; i<acronyms.length; i+=2) {
final String acronym = acronyms[i];
@@ -145,9 +146,9 @@ final class StandardImplementation exten
final int prefixPosition = buffer.lastIndexOf(".") + 1;
int length = 0;
for (final String p : prefix) {
- name = buffer.replace(prefixPosition, prefixPosition + length, p).toString();
+ classname = buffer.replace(prefixPosition, prefixPosition + length, p).toString();
try {
- candidate = Class.forName(name);
+ candidate = Class.forName(classname);
} catch (ClassNotFoundException e) {
Logging.recoverableException(MetadataStandard.class, "getImplementation", e);
length = p.length();
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -619,10 +619,10 @@ public class ImmutableIdentifier extends
* The {@code CITATION[…]} element inside an {@code ID[…]}.
*/
private static final class Cite extends FormattableObject {
- /** The component of the citation to format. */
+ /** The value of the citation to format. */
private final String identifier;
- /** Creates a new citation with the given component. */
+ /** Creates a new citation with the given value. */
Cite(final String identifier) {
this.identifier = identifier;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -86,6 +86,11 @@ public class DefaultBand extends Default
private Unit<Length> boundUnits;
/**
+ * Designation of criterion for defining maximum and minimum wavelengths for a spectral band.
+ */
+ private BandDefinition bandBoundaryDefinition;
+
+ /**
* Wavelength at which the response is the highest.
*/
private Double peakResponse;
@@ -96,11 +101,6 @@ public class DefaultBand extends Default
private Integer toneGradation;
/**
- * Designation of criterion for defining maximum and minimum wavelengths for a spectral band.
- */
- private BandDefinition bandBoundaryDefinition;
-
- /**
* Smallest distance between which separate points can be distinguished, as specified in
* instrument design.
*/
@@ -181,57 +181,57 @@ public class DefaultBand extends Default
}
/**
- * Returns the longest wavelength that the sensor is capable of collecting within a designated band.
- * The units of measurement is given by {@link #getUnits()}.
+ * Returns the shortest wavelength that the sensor is capable of collecting within a designated band.
+ * The units of measurement is given by {@link #getBoundUnit()}.
*
- * @return Longest wavelength that the sensor is capable of collecting within a designated band,
+ * @return Shortest wavelength that the sensor is capable of collecting within a designated band,
* or {@code null} if unspecified.
*
* @since 0.5
*/
@ValueRange(minimum = 0)
-/// @XmlElement(name = "boundMax")
- public Double getBoundMax() {
- return boundMax;
+/// @XmlElement(name = "boundMin")
+ public Double getBoundMin() {
+ return boundMin;
}
/**
- * Sets the longest wavelength that the sensor is capable of collecting within a designated band.
+ * Sets the shortest wavelength that the sensor is capable of collecting within a designated band.
*
- * @param newValue The new longest wavelength.
+ * @param newValue The new shortest wavelength.
*
* @since 0.5
*/
- public void setBoundMax(final Double newValue) {
+ public void setBoundMin(final Double newValue) {
checkWritePermission();
- boundMax = newValue;
+ boundMin = newValue;
}
/**
- * Returns the shortest wavelength that the sensor is capable of collecting within a designated band.
- * The units of measurement is given by {@link #getBoundUnit()}.
+ * Returns the longest wavelength that the sensor is capable of collecting within a designated band.
+ * The units of measurement is given by {@link #getUnits()}.
*
- * @return Shortest wavelength that the sensor is capable of collecting within a designated band,
+ * @return Longest wavelength that the sensor is capable of collecting within a designated band,
* or {@code null} if unspecified.
*
* @since 0.5
*/
@ValueRange(minimum = 0)
-/// @XmlElement(name = "boundMin")
- public Double getBoundMin() {
- return boundMin;
+/// @XmlElement(name = "boundMax")
+ public Double getBoundMax() {
+ return boundMax;
}
/**
- * Sets the shortest wavelength that the sensor is capable of collecting within a designated band.
+ * Sets the longest wavelength that the sensor is capable of collecting within a designated band.
*
- * @param newValue The new shortest wavelength.
+ * @param newValue The new longest wavelength.
*
* @since 0.5
*/
- public void setBoundMin(final Double newValue) {
+ public void setBoundMax(final Double newValue) {
checkWritePermission();
- boundMin = newValue;
+ boundMax = newValue;
}
/**
@@ -259,6 +259,27 @@ public class DefaultBand extends Default
}
/**
+ * Returns the designation of criterion for defining maximum and minimum wavelengths for a spectral band.
+ *
+ * @return Criterion for defining maximum and minimum wavelengths, or {@code null}.
+ */
+ @Override
+ @XmlElement(name = "bandBoundaryDefinition", namespace = Namespaces.GMI)
+ public BandDefinition getBandBoundaryDefinition() {
+ return bandBoundaryDefinition;
+ }
+
+ /**
+ * Sets designation of criterion for defining maximum and minimum wavelengths for a spectral band.
+ *
+ * @param newValue The new band definition.
+ */
+ public void setBandBoundaryDefinition(final BandDefinition newValue) {
+ checkWritePermission();
+ bandBoundaryDefinition = newValue;
+ }
+
+ /**
* Returns the units of data as a unit of length.
*
* <div class="warning"><b>Upcoming API change — generalization</b><br>
@@ -387,27 +408,6 @@ public class DefaultBand extends Default
}
/**
- * Returns the designation of criterion for defining maximum and minimum wavelengths for a spectral band.
- *
- * @return Criterion for defining maximum and minimum wavelengths, or {@code null}.
- */
- @Override
- @XmlElement(name = "bandBoundaryDefinition", namespace = Namespaces.GMI)
- public BandDefinition getBandBoundaryDefinition() {
- return bandBoundaryDefinition;
- }
-
- /**
- * Sets designation of criterion for defining maximum and minimum wavelengths for a spectral band.
- *
- * @param newValue The new band definition.
- */
- public void setBandBoundaryDefinition(final BandDefinition newValue) {
- checkWritePermission();
- bandBoundaryDefinition = newValue;
- }
-
- /**
* Returns the smallest distance between which separate points can be distinguished,
* as specified in instrument design.
*
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -84,44 +84,50 @@ public class DefaultSampleDimension exte
private static final long serialVersionUID = 4517148689016920767L;
/**
+ * Minimum value of data values in each dimension included in the resource.
+ */
+ private Double minValue;
+
+ /**
* Maximum value of data values in each dimension included in the resource.
*/
private Double maxValue;
/**
- * Minimum value of data values in each dimension included in the resource.
+ * Mean value of data values in each dimension included in the resource.
*/
- private Double minValue;
+ private Double meanValue;
/**
- * Units of data in each dimension included in the resource.
+ * Number of values used in a thematicClassification resource.
*/
- private Unit<?> units;
+ private Integer numberOfValues;
/**
- * Scale factor which has been applied to the cell value.
+ * Standard deviation of data values in each dimension included in the resource.
*/
- private Double scaleFactor;
+ private Double standardDeviation;
/**
- * Physical value corresponding to a cell value of zero.
+ * Units of data in each dimension included in the resource.
*/
- private Double offset;
+ private Unit<?> units;
/**
- * Mean value of data values in each dimension included in the resource.
+ * Scale factor which has been applied to the cell value.
*/
- private Double meanValue;
+ private Double scaleFactor;
/**
- * Number of values used in a thematicClassification resource.
+ * Physical value corresponding to a cell value of zero.
*/
- private Integer numberOfValues;
+ private Double offset;
/**
- * Standard deviation of data values in each dimension included in the resource.
+ * Maximum number of significant bits in the uncompressed representation
+ * for the value in each band of each pixel.
*/
- private Double standardDeviation;
+ private Integer bitsPerValue;
/**
* Type of other attribute description.
@@ -135,12 +141,6 @@ public class DefaultSampleDimension exte
private Record otherProperty;
/**
- * Maximum number of significant bits in the uncompressed representation
- * for the value in each band of each pixel.
- */
- private Integer bitsPerValue;
-
- /**
* Constructs an initially empty sample dimension.
*/
public DefaultSampleDimension() {
@@ -166,17 +166,17 @@ public class DefaultSampleDimension exte
* Initializes this sample dimension to the values of the given object.
*/
private void init(final DefaultSampleDimension object) {
- maxValue = object.getMaxValue();
minValue = object.getMinValue();
- units = object.getUnits();
- scaleFactor = object.getScaleFactor();
- offset = object.getOffset();
+ maxValue = object.getMaxValue();
meanValue = object.getMeanValue();
numberOfValues = object.getNumberOfValues();
standardDeviation = object.getStandardDeviation();
+ units = object.getUnits();
+ scaleFactor = object.getScaleFactor();
+ offset = object.getOffset();
+ bitsPerValue = object.getBitsPerValue();
otherPropertyType = object.getOtherPropertyType();
otherProperty = object.getOtherProperty();
- bitsPerValue = object.getBitsPerValue();
}
/**
@@ -247,6 +247,75 @@ public class DefaultSampleDimension exte
// Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
/**
* </pre>
+ * Returns the mean value of data values in each dimension included in the resource.
+ *
+ * @return The mean value of data values in each dimension included in the resource, or {@code null} if none.
+ */
+/// @XmlElement(name = "meanValue")
+ @UML(identifier="meanValue", obligation=OPTIONAL, specification=ISO_19115)
+ public Double getMeanValue() {
+ return meanValue;
+ }
+
+ /**
+ * Sets the mean value of data values in each dimension included in the resource.
+ *
+ * @param newValue The new mean value of data values in each dimension included in the resource.
+ */
+ public void setMeanValue(final Double newValue) {
+ checkWritePermission();
+ meanValue = newValue;
+ }
+
+ // Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
+ /**
+ * </pre>
+ * Returns the number of values used in a thematic classification resource.
+ *
+ * @return The number of values used in a thematic classification resource, or {@code null} if none.
+ */
+/// @XmlElement(name = "numberOfValues")
+ @UML(identifier="numberOfValues", obligation=OPTIONAL, specification=ISO_19115)
+ public Integer getNumberOfValues() {
+ return numberOfValues;
+ }
+
+ /**
+ * Sets the number of values used in a thematic classification resource.
+ *
+ * @param newValues The new number of values used in a thematic classification resource.
+ */
+ public void setNumberOfValues(final Integer newValues) {
+ checkWritePermission();
+ numberOfValues = newValues;
+ }
+
+ // Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
+ /**
+ * </pre>
+ * Returns the standard deviation of data values in each dimension included in the resource.
+ *
+ * @return Standard deviation of data values in each dimension included in the resource, or {@code null} if none.
+ */
+/// @XmlElement(name = "standardDeviation")
+ @UML(identifier="standardDeviation", obligation=OPTIONAL, specification=ISO_19115)
+ public Double getStandardDeviation() {
+ return standardDeviation;
+ }
+
+ /**
+ * Sets the standard deviation of data values in each dimension included in the resource.
+ *
+ * @param newValue The new standard deviation of data values in each dimension included in the resource.
+ */
+ public void setStandardDeviation(final Double newValue) {
+ checkWritePermission();
+ standardDeviation = newValue;
+ }
+
+ // Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
+ /**
+ * </pre>
* Returns the units of data in the dimension.
*
* @return The units of data in the dimension, or {@code null} if unspecified.
@@ -316,70 +385,28 @@ public class DefaultSampleDimension exte
// Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
/**
* </pre>
- * Returns the mean value of data values in each dimension included in the resource.
- *
- * @return The mean value of data values in each dimension included in the resource, or {@code null} if none.
- */
-/// @XmlElement(name = "meanValue")
- @UML(identifier="meanValue", obligation=OPTIONAL, specification=ISO_19115)
- public Double getMeanValue() {
- return meanValue;
- }
-
- /**
- * Sets the mean value of data values in each dimension included in the resource.
- *
- * @param newValue The new mean value of data values in each dimension included in the resource.
- */
- public void setMeanValue(final Double newValue) {
- checkWritePermission();
- meanValue = newValue;
- }
-
- // Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
- /**
- * </pre>
- * Returns the number of values used in a thematic classification resource.
- *
- * @return The number of values used in a thematic classification resource, or {@code null} if none.
- */
-/// @XmlElement(name = "numberOfValues")
- @UML(identifier="numberOfValues", obligation=OPTIONAL, specification=ISO_19115)
- public Integer getNumberOfValues() {
- return numberOfValues;
- }
-
- /**
- * Sets the number of values used in a thematic classification resource.
- *
- * @param newValues The new number of values used in a thematic classification resource.
- */
- public void setNumberOfValues(final Integer newValues) {
- checkWritePermission();
- numberOfValues = newValues;
- }
-
- // Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
- /**
- * </pre>
- * Returns the standard deviation of data values in each dimension included in the resource.
+ * Returns the maximum number of significant bits in the uncompressed representation
+ * for the value in each band of each pixel.
*
- * @return Standard deviation of data values in each dimension included in the resource, or {@code null} if none.
+ * @return Maximum number of significant bits in the uncompressed representation
+ * for the value in each band of each pixel, or {@code null} if none.
*/
-/// @XmlElement(name = "standardDeviation")
- @UML(identifier="standardDeviation", obligation=OPTIONAL, specification=ISO_19115)
- public Double getStandardDeviation() {
- return standardDeviation;
+ @ValueRange(minimum = 1)
+/// @XmlElement(name = "bitsPerValues")
+ @UML(identifier="bitsPerValue", obligation=OPTIONAL, specification=ISO_19115)
+ public Integer getBitsPerValue() {
+ return bitsPerValue;
}
/**
- * Sets the standard deviation of data values in each dimension included in the resource.
+ * Sets the maximum number of significant bits in the uncompressed representation
+ * for the value in each band of each pixel.
*
- * @param newValue The new standard deviation of data values in each dimension included in the resource.
+ * @param newValue The new maximum number of significant bits.
*/
- public void setStandardDeviation(final Double newValue) {
+ public void setBitsPerValue(final Integer newValue) {
checkWritePermission();
- standardDeviation = newValue;
+ bitsPerValue = newValue;
}
// Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
@@ -429,31 +456,4 @@ public class DefaultSampleDimension exte
checkWritePermission();
otherProperty = newValue;
}
-
- // Leading </pre> is a workaround for a javadoc 6 bug on methods having @UML annotation.
- /**
- * </pre>
- * Returns the maximum number of significant bits in the uncompressed representation
- * for the value in each band of each pixel.
- *
- * @return Maximum number of significant bits in the uncompressed representation
- * for the value in each band of each pixel, or {@code null} if none.
- */
- @ValueRange(minimum = 1)
-/// @XmlElement(name = "bitsPerValues")
- @UML(identifier="bitsPerValue", obligation=OPTIONAL, specification=ISO_19115)
- public Integer getBitsPerValue() {
- return bitsPerValue;
- }
-
- /**
- * Sets the maximum number of significant bits in the uncompressed representation
- * for the value in each band of each pixel.
- *
- * @param newValue The new maximum number of significant bits.
- */
- public void setBitsPerValue(final Integer newValue) {
- checkWritePermission();
- bitsPerValue = newValue;
- }
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -87,19 +87,19 @@ public class DefaultExtent extends ISOMe
private InternationalString description;
/**
- * Provides geographic component of the extent of the referring object
+ * Provides geographic component of the extent of the referring object.
*/
private Collection<GeographicExtent> geographicElements;
/**
- * Provides temporal component of the extent of the referring object
+ * Provides vertical component of the extent of the referring object.
*/
- private Collection<TemporalExtent> temporalElements;
+ private Collection<VerticalExtent> verticalElements;
/**
- * Provides vertical component of the extent of the referring object
+ * Provides temporal component of the extent of the referring object.
*/
- private Collection<VerticalExtent> verticalElements;
+ private Collection<TemporalExtent> temporalElements;
/**
* Constructs an initially empty extent.
@@ -215,43 +215,43 @@ public class DefaultExtent extends ISOMe
}
/**
- * Provides temporal component of the extent of the referring object.
+ * Provides vertical component of the extent of the referring object.
*
- * @return The temporal extent, or an empty set if none.
+ * @return The vertical extent, or an empty set if none.
*/
@Override
- @XmlElement(name = "temporalElement")
- public Collection<TemporalExtent> getTemporalElements() {
- return temporalElements = nonNullCollection(temporalElements, TemporalExtent.class);
+ @XmlElement(name = "verticalElement")
+ public Collection<VerticalExtent> getVerticalElements() {
+ return verticalElements = nonNullCollection(verticalElements, VerticalExtent.class);
}
/**
- * Sets temporal component of the extent of the referring object.
+ * Sets vertical component of the extent of the referring object.
*
- * @param newValues The new temporal elements.
+ * @param newValues The new vertical elements.
*/
- public void setTemporalElements(final Collection<? extends TemporalExtent> newValues) {
- temporalElements = writeCollection(newValues, temporalElements, TemporalExtent.class);
+ public void setVerticalElements(final Collection<? extends VerticalExtent> newValues) {
+ verticalElements = writeCollection(newValues, verticalElements, VerticalExtent.class);
}
/**
- * Provides vertical component of the extent of the referring object.
+ * Provides temporal component of the extent of the referring object.
*
- * @return The vertical extent, or an empty set if none.
+ * @return The temporal extent, or an empty set if none.
*/
@Override
- @XmlElement(name = "verticalElement")
- public Collection<VerticalExtent> getVerticalElements() {
- return verticalElements = nonNullCollection(verticalElements, VerticalExtent.class);
+ @XmlElement(name = "temporalElement")
+ public Collection<TemporalExtent> getTemporalElements() {
+ return temporalElements = nonNullCollection(temporalElements, TemporalExtent.class);
}
/**
- * Sets vertical component of the extent of the referring object.
+ * Sets temporal component of the extent of the referring object.
*
- * @param newValues The new vertical elements.
+ * @param newValues The new temporal elements.
*/
- public void setVerticalElements(final Collection<? extends VerticalExtent> newValues) {
- verticalElements = writeCollection(newValues, verticalElements, VerticalExtent.class);
+ public void setTemporalElements(final Collection<? extends TemporalExtent> newValues) {
+ temporalElements = writeCollection(newValues, temporalElements, TemporalExtent.class);
}
/**
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -23,9 +23,11 @@ import org.opengis.referencing.operation
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
import org.apache.sis.measure.Units;
import org.apache.sis.internal.util.X364;
import org.apache.sis.test.mock.MatrixMock;
+import org.apache.sis.test.mock.VerticalCRSMock;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -38,7 +40,7 @@ import static org.apache.sis.test.Metada
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.5
* @module
*/
@DependsOn({ConventionTest.class, SymbolsTest.class, ColorsTest.class})
@@ -64,6 +66,19 @@ public final strictfp class FormatterTes
}
/**
+ * Tests (indirectly) formatting of a vertical extent.
+ */
+ @Test
+ public void testAppendVerticalExtent() {
+ final DefaultVerticalExtent extent = new DefaultVerticalExtent(102, 108, VerticalCRSMock.HEIGHT_ft);
+ assertWktEquals(Convention.WKT2, "VerticalExtent[102, 108, LengthUnit[“ft”, 0.3048]]", extent);
+
+ extent.setMinimumValue(100.2);
+ extent.setMaximumValue(100.8);
+ assertWktEquals(Convention.WKT2, "VerticalExtent[100.2, 100.8, LengthUnit[“ft”, 0.3048]]", extent);
+ }
+
+ /**
* Tests (indirectly) {@link Formatter#append(Matrix)}.
*/
@Test
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -22,11 +22,14 @@ import java.util.HashSet;
import java.util.Collection;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.quality.Completeness;
+import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.crs.GeographicCRS;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.metadata.iso.citation.HardCodedCitations;
import org.apache.sis.metadata.iso.acquisition.DefaultPlatform;
import org.apache.sis.metadata.iso.acquisition.DefaultInstrument;
import org.apache.sis.metadata.iso.quality.AbstractCompleteness;
+import org.apache.sis.internal.simple.SimpleIdentifiedObject;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.test.DependsOnMethod;
@@ -34,6 +37,7 @@ import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import static java.util.Collections.singleton;
import static org.apache.sis.test.Assert.*;
import static org.apache.sis.test.TestUtilities.getSingleton;
@@ -64,13 +68,76 @@ import static org.apache.sis.test.TestUt
ValueMapTest.class})
public final strictfp class MetadataStandardTest extends TestCase {
/**
+ * Tests {@link MetadataStandard#isMetadata(Class)}.
+ */
+ @Test
+ public void testIsMetadata() {
+ MetadataStandard std = MetadataStandard.ISO_19115;
+ assertFalse("isMetadata(String)", std.isMetadata(String.class));
+ assertTrue ("isMetadata(Citation)", std.isMetadata(Citation.class));
+ assertTrue ("isMetadata(DefaultCitation)", std.isMetadata(DefaultCitation.class));
+ assertFalse("isMetadata(IdentifiedObject)", std.isMetadata(IdentifiedObject.class));
+ assertFalse("isMetadata(SimpleIdentifiedObject)", std.isMetadata(SimpleIdentifiedObject.class));
+ assertFalse("isMetadata(GeographicCRS)", std.isMetadata(GeographicCRS.class));
+
+ std = MetadataStandard.ISO_19111;
+ assertFalse("isMetadata(String)", std.isMetadata(String.class));
+ assertTrue ("isMetadata(Citation)", std.isMetadata(Citation.class)); // Dependency
+ assertTrue ("isMetadata(DefaultCitation)", std.isMetadata(DefaultCitation.class)); // Dependency
+ assertTrue ("isMetadata(IdentifiedObject)", std.isMetadata(IdentifiedObject.class));
+ assertTrue ("isMetadata(SimpleIdentifiedObject)", std.isMetadata(SimpleIdentifiedObject.class));
+ assertTrue ("isMetadata(GeographicCRS)", std.isMetadata(GeographicCRS.class));
+
+ std = MetadataStandard.ISO_19123;
+ assertFalse("isMetadata(String)", std.isMetadata(String.class));
+ assertTrue ("isMetadata(Citation)", std.isMetadata(Citation.class)); // Transitive dependency
+ assertTrue ("isMetadata(DefaultCitation)", std.isMetadata(DefaultCitation.class)); // Transivive dependency
+ assertTrue ("isMetadata(IdentifiedObject)", std.isMetadata(IdentifiedObject.class)); // Dependency
+ assertTrue ("isMetadata(SimpleIdentifiedObject)", std.isMetadata(SimpleIdentifiedObject.class)); // Dependency
+ assertTrue ("isMetadata(GeographicCRS)", std.isMetadata(GeographicCRS.class)); // Dependency
+ }
+
+ /**
* Tests {@link MetadataStandard#getInterface(Class)}.
*/
@Test
+ @DependsOnMethod("testIsMetadata")
public void testGetInterface() {
- final MetadataStandard std = MetadataStandard.ISO_19115;
- assertEquals(Citation.class, std.getInterface(DefaultCitation.class));
- assertEquals(Completeness.class, std.getInterface(AbstractCompleteness.class));
+ MetadataStandard std = MetadataStandard.ISO_19115;
+ assertEquals("getInterface(Citation)", Citation.class, std.getInterface(Citation.class));
+ assertEquals("getInterface(DefaultCitation)", Citation.class, std.getInterface(DefaultCitation.class));
+ assertEquals("getInterface(AbstractCompleteness)", Completeness.class, std.getInterface(AbstractCompleteness.class));
+
+ std = MetadataStandard.ISO_19111;
+ assertEquals("getInterface(Citation)", Citation.class, std.getInterface(Citation.class));
+ assertEquals("getInterface(DefaultCitation)", Citation.class, std.getInterface(DefaultCitation.class));
+ assertEquals("getInterface(AbstractCompleteness)", Completeness.class, std.getInterface(AbstractCompleteness.class));
+ assertEquals("getInterface(IdentifiedObject)", IdentifiedObject.class, std.getInterface(IdentifiedObject.class));
+ assertEquals("getInterface(SimpleIdentifiedObject)", IdentifiedObject.class, std.getInterface(SimpleIdentifiedObject.class));
+ assertEquals("getInterface(GeographicCRS)", GeographicCRS.class, std.getInterface(GeographicCRS.class));
+
+ // Verify that the cache has not been updated in inconsistent way.
+ testIsMetadata();
+ }
+
+ /**
+ * Tests {@link MetadataStandard#getAccessor(Class, boolean)}.
+ */
+ @Test
+ @DependsOnMethod("testGetInterface")
+ public void testGetAccessor() {
+ MetadataStandard std = MetadataStandard.ISO_19115;
+ assertEquals("getAccessor(DefaultCitation)", Citation.class, std.getAccessor(DefaultCitation.class, true).type);
+ assertEquals("getAccessor(AbstractCompleteness)", Completeness.class, std.getAccessor(AbstractCompleteness.class, true).type);
+ assertNull ("getAccessor(SimpleIdentifiedObject)", std.getAccessor(SimpleIdentifiedObject.class, false));
+
+ std = MetadataStandard.ISO_19111;
+ assertEquals("getAccessor(DefaultCitation)", Citation.class, std.getAccessor(DefaultCitation.class, true).type);
+ assertEquals("getAccessor(AbstractCompleteness)", Completeness.class, std.getAccessor(AbstractCompleteness.class, true).type);
+ assertEquals("getAccessor(SimpleIdentifiedObject)", IdentifiedObject.class, std.getAccessor(SimpleIdentifiedObject.class, true).type);
+
+ // Verify that the cache has not been updated in inconsistent way.
+ testGetInterface();
}
/**
@@ -78,8 +145,9 @@ public final strictfp class MetadataStan
* A {@link ClassCastException} is expected.
*/
@Test
+ @DependsOnMethod("testGetInterface")
public void testGetWrongInterface() {
- final MetadataStandard std = new MetadataStandard("SIS", "org.apache.sis.dummy.");
+ final MetadataStandard std = new MetadataStandard("SIS", "org.apache.sis.dummy.", null);
try {
std.getInterface(DefaultCitation.class);
fail("No dummy interface expected.");
@@ -93,6 +161,7 @@ public final strictfp class MetadataStan
* Tests the {@link MetadataStandard#equals(Object, Object, ComparisonMode)} method.
*/
@Test
+ @DependsOnMethod("testGetAccessor")
public void testEquals() {
final MetadataStandard std = MetadataStandard.ISO_19115;
@@ -121,7 +190,7 @@ public final strictfp class MetadataStan
final DefaultPlatform platform = new DefaultPlatform();
platform.setDescription(new SimpleInternationalString("A platform."));
instrument.setMountedOn(platform);
- platform.getInstruments().add(instrument);
+ platform.setInstruments(singleton(instrument));
return platform;
}
@@ -147,6 +216,7 @@ public final strictfp class MetadataStan
* {@code MetadataStandard} methods depend on it ({@code equals}, {@code hashCode}, {@code prune}, <i>etc.</i>).
*/
@Test
+ @DependsOnMethod("testGetAccessor")
public void testValueMap() {
final DefaultCitation instance = new DefaultCitation(HardCodedCitations.EPSG);
final Map<String,Object> map = MetadataStandard.ISO_19115.asValueMap(instance,
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -28,6 +28,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;
+import static java.util.Collections.singleton;
import static org.apache.sis.metadata.ValueExistencePolicy.isNullOrEmpty;
@@ -69,9 +70,9 @@ public final strictfp class PrunerTest e
identification = new DefaultDataIdentification();
extent = new DefaultExtent();
bbox = new DefaultGeographicBoundingBox();
- extent.getGeographicElements().add(bbox);
- identification.getExtents().add(extent);
- metadata.getIdentificationInfo().add(identification);
+ extent.setGeographicElements(singleton(bbox));
+ identification.setExtents(singleton(extent));
+ metadata.setIdentificationInfo(singleton(identification));
}
/**
@@ -123,8 +124,8 @@ public final strictfp class PrunerTest e
*/
private void createCyclicMetadata() {
final DefaultAcquisitionInformation acquisition = new DefaultAcquisitionInformation();
- acquisition.getPlatforms().add(MetadataStandardTest.createCyclicMetadata());
- metadata.getAcquisitionInformation().add(acquisition);
+ acquisition.setPlatforms(singleton(MetadataStandardTest.createCyclicMetadata()));
+ metadata.setAcquisitionInformation(singleton(acquisition));
}
/**
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -84,17 +84,17 @@ public final strictfp class TreeNodeTest
AbstractParty party = new DefaultOrganisation("Some organisation", null, null, null);
DefaultResponsibleParty responsibility = new DefaultResponsibleParty(Role.DISTRIBUTOR);
responsibility.setParties(singleton(party));
- citation.getCitedResponsibleParties().add(responsibility);
+ assertTrue(citation.getCitedResponsibleParties().add(responsibility));
// Add a second responsible party with deeper hierarchy.
final DefaultContact contact = new DefaultContact();
final DefaultAddress address = new DefaultAddress();
- address.getElectronicMailAddresses().add("Some email");
- contact.getAddresses().add(address);
+ address.setElectronicMailAddresses(singleton("Some email"));
+ contact.setAddresses(singleton(address));
party = new DefaultIndividual("Some person of contact", null, contact);
responsibility = new DefaultResponsibleParty(Role.POINT_OF_CONTACT);
responsibility.setParties(singleton(party));
- citation.getCitedResponsibleParties().add(responsibility);
+ assertTrue(citation.getCitedResponsibleParties().add(responsibility));
return citation;
}
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableFormatTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableFormatTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableFormatTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -38,8 +38,9 @@ import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
-import static org.apache.sis.test.Assert.*;
+import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
+import static org.apache.sis.test.Assert.*;
/**
@@ -84,10 +85,12 @@ public final strictfp class TreeTableFor
final InternationalString title = new SimpleInternationalString("Undercurrent");
citation.setTitle(title);
citation.setISBN("9782505004509");
- citation.getPresentationForms().add(PresentationForm.DOCUMENT_HARDCOPY);
- citation.getPresentationForms().add(PresentationForm.IMAGE_HARDCOPY);
- citation.getAlternateTitles().add(new SimpleInternationalString("Alt A"));
- citation.getAlternateTitles().add(new SimpleInternationalString("Alt B"));
+ citation.setPresentationForms(asList(
+ PresentationForm.DOCUMENT_HARDCOPY,
+ PresentationForm.IMAGE_HARDCOPY));
+ citation.setAlternateTitles(asList(
+ new SimpleInternationalString("Alt A"),
+ new SimpleInternationalString("Alt B")));
final DefaultResponsibleParty author = new DefaultResponsibleParty(Role.AUTHOR);
author.setParties(singleton(new DefaultIndividual("Testsuya Toyoda", null, null)));
@@ -95,6 +98,8 @@ public final strictfp class TreeTableFor
final DefaultResponsibleParty duplicated = new DefaultResponsibleParty();
duplicated.setParties(singleton(new DefaultIndividual("A japanese author", null, null)));
citation.getCitedResponsibleParties().add(duplicated);
+ citation.setCitedResponsibleParties(asList(
+ author, duplicated));
return citation;
}
@@ -132,13 +137,11 @@ public final strictfp class TreeTableFor
final DefaultCitation titled = new DefaultCitation("Some specification");
final DefaultCitation coded = new DefaultCitation();
final DefaultCitation untitled = new DefaultCitation();
- titled .getPresentationForms().add(PresentationForm.DOCUMENT_HARDCOPY);
- coded .getPresentationForms().add(PresentationForm.IMAGE_HARDCOPY);
- untitled.getCitedResponsibleParties().add(new DefaultResponsibleParty(Role.AUTHOR));
+ titled .setPresentationForms(singleton(PresentationForm.DOCUMENT_HARDCOPY));
+ coded .setPresentationForms(singleton(PresentationForm.IMAGE_HARDCOPY));
+ untitled.setCitedResponsibleParties(singleton(new DefaultResponsibleParty(Role.AUTHOR)));
final DefaultProcessing processing = new DefaultProcessing();
- processing.getDocumentations().add(titled);
- processing.getDocumentations().add(coded);
- processing.getDocumentations().add(untitled);
+ processing.setDocumentations(asList(titled, coded, untitled));
final String text = format.format(processing.asTreeTable());
assertMultilinesEquals(
"Processing\n" +
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -93,7 +93,7 @@ public final strictfp class ValueMapTest
author = new DefaultResponsibleParty();
citation = new DefaultCitation(title);
author.setParties(singleton(new DefaultIndividual("Testsuya Toyoda", null, null)));
- citation.getCitedResponsibleParties().add(author);
+ citation.setCitedResponsibleParties(singleton(author));
citation.setISBN("9782505004509");
citation.setEdition(NilReason.UNKNOWN.createNilObject(InternationalString.class));
return MetadataStandard.ISO_19115.asValueMap(citation, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -39,6 +39,7 @@ import org.apache.sis.test.XMLTestCase;
import org.apache.sis.xml.XML;
import org.junit.Test;
+import static java.util.Collections.singleton;
import static org.junit.Assert.*;
@@ -131,7 +132,7 @@ public final strictfp class CustomMetada
@Deprecated @Override public Collection<AggregateInformation> getAggregationInfo() {return null;}
};
final DefaultMetadata data = new DefaultMetadata();
- assertTrue(data.getIdentificationInfo().add(identification));
+ data.setIdentificationInfo(singleton(identification));
final String xml = XML.marshal(data);
/*
* A few simple checks.
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -55,7 +55,7 @@ public final strictfp class HardCodedCit
final DefaultCitation c = new DefaultCitation("Open Geospatial consortium");
c.setAlternateTitles(singleton(new SimpleInternationalString("OGC")));
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
- c.getIdentifiers().add(new DefaultIdentifier("OGC"));
+ c.setIdentifiers(singleton(new DefaultIdentifier("OGC")));
c.freeze();
OGC = c;
}
@@ -70,7 +70,7 @@ public final strictfp class HardCodedCit
final DefaultCitation c = new DefaultCitation("International Organization for Standardization");
c.setAlternateTitles(singleton(new SimpleInternationalString("ISO")));
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
- c.getIdentifiers().add(new DefaultIdentifier("ISO"));
+ c.setIdentifiers(singleton(new DefaultIdentifier("ISO")));
c.freeze();
ISO = c;
}
@@ -96,32 +96,49 @@ public final strictfp class HardCodedCit
static {
final DefaultCitation c = new DefaultCitation("International Association of Oil & Gas Producers");
c.setAlternateTitles(singleton(new SimpleInternationalString("OGP")));
- c.getIdentifiers().add(new DefaultIdentifier("OGP"));
+ c.setIdentifiers(singleton(new DefaultIdentifier("OGP")));
c.freeze();
OGP = c;
}
/**
* The <a href="http://www.epsg.org">European Petroleum Survey Group</a> authority.
- * An {@linkplain Citation#getAlternateTitles() alternate title} for this citation is
- * "EPSG" (according ISO 19115, alternate titles often contain abbreviations). In
- * addition, this citation contains the "EPSG" {@linkplain Citation#getIdentifiers identifier}.
+ * An {@linkplain Citation#getAlternateTitles() alternate title} for this citation is "EPSG"
+ * (according ISO 19115, alternate titles often contain abbreviations). In addition,
+ * this citation contains the "EPSG" {@linkplain Citation#getIdentifiers() identifier}.
+ *
+ * <p>String representation:</p>
+ *
+ * {@preformat text
+ * Citation
+ * ├─Title………………………………………………………… European Petroleum Survey Group
+ * ├─Alternate title……………………………… EPSG
+ * ├─Identifier
+ * │ └─Code………………………………………………… EPSG
+ * ├─Cited responsible party
+ * │ ├─Party
+ * │ │ ├─Name……………………………………… International Association of Oil & Gas Producers
+ * │ │ └─Contact info
+ * │ │ └─Online resource
+ * │ │ ├─Linkage………… http://www.epsg.org
+ * │ │ └─Function……… Information
+ * │ └─Role………………………………………………… Principal investigator
+ * └─Presentation form………………………… Table digital
+ * }
*/
public static final DefaultCitation EPSG;
static {
- final SimpleInternationalString title = new SimpleInternationalString("European Petroleum Survey Group");
final DefaultOnlineResource r = new DefaultOnlineResource(URI.create("http://www.epsg.org"));
r.setFunction(OnLineFunction.INFORMATION);
final DefaultResponsibleParty p = new DefaultResponsibleParty(Role.PRINCIPAL_INVESTIGATOR);
- p.setOrganisationName(title);
- p.setContactInfo(new DefaultContact(r));
+ p.setParties(singleton(new DefaultOrganisation(OGP.getTitle(), null, null, new DefaultContact(r))));
- final DefaultCitation c = new DefaultCitation(title);
+ final DefaultCitation c = new DefaultCitation("European Petroleum Survey Group");
c.setAlternateTitles(singleton(new SimpleInternationalString("EPSG")));
c.setPresentationForms(singleton(PresentationForm.TABLE_DIGITAL));
- c.getIdentifiers().add(new DefaultIdentifier("EPSG"));
- c.getCitedResponsibleParties().add(p);
+ c.setIdentifiers(singleton(new DefaultIdentifier("EPSG")));
+ c.setCitedResponsibleParties(singleton(p));
c.freeze();
EPSG = c;
}
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -27,6 +27,7 @@ import org.apache.sis.util.logging.Warni
import org.apache.sis.test.XMLTestCase;
import org.junit.Test;
+import static java.util.Collections.singleton;
import static org.apache.sis.test.Assert.*;
import static org.apache.sis.test.TestUtilities.getSingleton;
@@ -139,7 +140,7 @@ public final strictfp class DefaultLegal
"</gmd:MD_LegalConstraints>\n";
final DefaultLegalConstraints c = new DefaultLegalConstraints();
- c.getUseConstraints().add(Restriction.LICENSE);
+ c.setUseConstraints(singleton(Restriction.LICENSE));
assertXmlEquals(xml, marshal(c), "xmlns:*");
/*
* Unmarshall and ensure that we got back the original LICENCE code, not a new "LICENSE" code.
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -29,6 +29,7 @@ import org.apache.sis.test.TestCase;
import org.apache.sis.test.TestUtilities;
import org.junit.Test;
+import static java.util.Collections.singleton;
import static org.apache.sis.test.Assert.*;
@@ -62,8 +63,8 @@ public final strictfp class DefaultDataI
* └─Code……………………………………………………………………… NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc
*/
final DefaultCitation citation = new DefaultCitation("Sea Surface Temperature Analysis Model");
- citation.getDates().add(new DefaultCitationDate(TestUtilities.date("2005-09-22 00:00:00"), DateType.CREATION));
- citation.getIdentifiers().add(new DefaultIdentifier("SST_Global.nc"));
+ citation.setDates(singleton(new DefaultCitationDate(TestUtilities.date("2005-09-22 00:00:00"), DateType.CREATION)));
+ citation.setIdentifiers(singleton(new DefaultIdentifier("SST_Global.nc")));
/*
* Descriptive keywords
* ├─Keyword………………………………………………………………………… EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature
@@ -97,10 +98,10 @@ public final strictfp class DefaultDataI
*/
final DefaultDataIdentification info = new DefaultDataIdentification(citation,
"NCEP SST Global 5.0 x 2.5 degree model data", null, null);
- info.getSpatialRepresentationTypes().add(SpatialRepresentationType.GRID);
- info.getDescriptiveKeywords().add(keywords);
- info.getResourceConstraints().add(new DefaultConstraints("Freely available"));
- info.getExtents().add(Extents.WORLD);
+ info.setSpatialRepresentationTypes(singleton(SpatialRepresentationType.GRID));
+ info.setDescriptiveKeywords(singleton(keywords));
+ info.setResourceConstraints(singleton(new DefaultConstraints("Freely available")));
+ info.setExtents(singleton(Extents.WORLD));
return info;
}
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -89,7 +89,8 @@ import org.junit.BeforeClass;
org.apache.sis.io.wkt.ConventionTest.class,
org.apache.sis.io.wkt.SymbolsTest.class,
org.apache.sis.io.wkt.ColorsTest.class,
- org.apache.sis.io.wkt.FormatterTest.class
+ org.apache.sis.io.wkt.FormatterTest.class,
+ org.apache.sis.io.wkt.WKTFormatTest.class
})
public final strictfp class MetadataTestSuite extends TestSuite {
/**
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -19,6 +19,8 @@ package org.apache.sis.internal.jaxb.ref
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.internal.jaxb.gml.CodeListAdapter;
+import static org.apache.sis.internal.referencing.HardCoded.EPSG;
+
/**
* JAXB adapter for (un)marshalling of GeoAPI code list.
@@ -52,6 +54,6 @@ public final class CS_AxisDirection exte
*/
@Override
protected String getCodeSpace() {
- return "EPSG";
+ return EPSG;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -19,6 +19,8 @@ package org.apache.sis.internal.jaxb.ref
import org.opengis.referencing.cs.RangeMeaning;
import org.apache.sis.internal.jaxb.gml.CodeListAdapter;
+import static org.apache.sis.internal.referencing.HardCoded.EPSG;
+
/**
* JAXB adapter for (un)marshalling of GeoAPI code list.
@@ -52,6 +54,6 @@ public final class CS_RangeMeaning exten
*/
@Override
protected String getCodeSpace() {
- return "EPSG";
+ return EPSG;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -331,18 +331,6 @@ public class DefaultParameterDescriptor<
}
/**
- * Creates a new parameter value instance initialized with the {@linkplain #getDefaultValue() default value}.
- * The {@linkplain DefaultParameterDescriptor parameter descriptor} for the created parameter value will be
- * {@code this} object.
- *
- * @return A parameter initialized to the default value.
- */
- @Override
- public ParameterValue<T> createValue() {
- return new DefaultParameterValue<T>(this);
- }
-
- /**
* Returns the class that describe the type of the parameter.
*
* @return The parameter value class.
@@ -455,6 +443,18 @@ public class DefaultParameterDescriptor<
}
/**
+ * Creates a new parameter value instance initialized with the {@linkplain #getDefaultValue() default value}.
+ * The {@linkplain DefaultParameterDescriptor parameter descriptor} for the created parameter value will be
+ * {@code this} object.
+ *
+ * @return A parameter initialized to the default value.
+ */
+ @Override
+ public ParameterValue<T> createValue() {
+ return new DefaultParameterValue<T>(this);
+ }
+
+ /**
* Compares the specified object with this parameter for equality.
* The strictness level is controlled by the second argument.
* This method compares the following properties in every cases:
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -263,19 +263,6 @@ public class DefaultParameterDescriptorG
}
/**
- * Creates a new instance of {@linkplain DefaultParameterValueGroup parameter value group}
- * initialized with the {@linkplain DefaultParameterDescriptor#getDefaultValue default values}.
- * The {@linkplain DefaultParameterValueGroup#getDescriptor() parameter descriptor} for the
- * created group will be {@code this} object.
- *
- * @return A new parameter instance initialized to the default value.
- */
- @Override
- public ParameterValueGroup createValue() {
- return new DefaultParameterValueGroup(this);
- }
-
- /**
* Returns all parameters in this group.
*
* @return The parameter descriptors in this group.
@@ -323,6 +310,19 @@ public class DefaultParameterDescriptorG
}
/**
+ * Creates a new instance of {@linkplain DefaultParameterValueGroup parameter value group}
+ * initialized with the {@linkplain DefaultParameterDescriptor#getDefaultValue default values}.
+ * The {@linkplain DefaultParameterValueGroup#getDescriptor() parameter descriptor} for the
+ * created group will be {@code this} object.
+ *
+ * @return A new parameter instance initialized to the default value.
+ */
+ @Override
+ public ParameterValueGroup createValue() {
+ return new DefaultParameterValueGroup(this);
+ }
+
+ /**
* Compares the specified object with this parameter group for equality.
*
* @return {@inheritDoc}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -47,6 +47,7 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.referencing.crs.DefaultCompoundCRS;
import org.apache.sis.metadata.iso.extent.Extents;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.Static;
@@ -79,7 +80,7 @@ import static org.apache.sis.util.Argume
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.4
+ * @version 0.5
* @module
*/
public final class CRS extends Static {
@@ -156,42 +157,21 @@ public final class CRS extends Static {
throw new NoSuchIdentifierException(Errors.format(Errors.Keys.MissingAuthority_1, code), code);
}
/*
- * Code below this point is a temporary implementation to
- * be removed after we ported the EPSG authority factory.
+ * Delegate to the factory for the code space of the given code. If no authority factory
+ * is available, or if the factory failed to create the CRS, delegate to CommonCRS. Note
+ * that CommonCRS is not expected to succeed if the real EPSG factory threw an exception,
+ * so we will log a message at the warning level in such case.
*/
- NumberFormatException cause = null;
- try {
- if (authority.equalsIgnoreCase("CRS")) {
- switch (Integer.parseInt(value)) {
- case 27: return CommonCRS.NAD27.normalizedGeographic();
- case 83: return CommonCRS.NAD83.normalizedGeographic();
- case 84: return CommonCRS.WGS84.normalizedGeographic();
- }
- } else if (authority.equalsIgnoreCase("EPSG")) {
- final int n = Integer.parseInt(value);
- if (n != 0) { // CommonCRS uses 0 as a sentinel value for "no EPSG code".
- for (final CommonCRS candidate : CommonCRS.values()) {
- if (candidate.geographic == n) return candidate.geographic();
- if (candidate.geocentric == n) return candidate.geocentric();
- if (candidate.geo3D == n) return candidate.geographic3D();
- }
- for (final CommonCRS.Vertical candidate : CommonCRS.Vertical.values()) {
- if (candidate.isEPSG && candidate.crs == n) {
- return candidate.crs();
- }
- }
- }
- } else {
- throw new NoSuchIdentifierException(Errors.format(Errors.Keys.UnknownAuthority_1, authority), authority);
- }
- } catch (NumberFormatException e) {
- cause = e;
+ CRSAuthorityFactory factory = null; // TODO
+ if (factory != null) try {
+ return factory.createCoordinateReferenceSystem(value);
+ } catch (FactoryException failure) {
+ final CoordinateReferenceSystem crs = CommonCRS.forCode(authority, value, failure);
+ Logging.unexpectedException(CRS.class, "forCode", failure); // See above comment.
+ return crs;
+ } else {
+ return CommonCRS.forCode(authority, value, null);
}
- final NoSuchAuthorityCodeException e = new NoSuchAuthorityCodeException(
- Errors.format(Errors.Keys.NoSuchAuthorityCode_3, authority, CoordinateReferenceSystem.class, value),
- authority, value, code);
- e.initCause(cause);
- throw e;
}
/**
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -24,12 +24,15 @@ import javax.measure.unit.Unit;
import javax.measure.quantity.Duration;
import org.opengis.util.FactoryException;
import org.opengis.util.InternationalString;
+import org.opengis.util.NoSuchIdentifierException;
+import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.GeocentricCRS;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.TimeCS;
import org.opengis.referencing.cs.VerticalCS;
import org.opengis.referencing.cs.CartesianCS;
@@ -56,11 +59,17 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.internal.system.SystemListener;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.measure.Units;
import static java.util.Collections.singletonMap;
import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
+import static org.apache.sis.internal.referencing.HardCoded.CRS;
+import static org.apache.sis.internal.referencing.HardCoded.EPSG;
+import static org.apache.sis.internal.referencing.HardCoded.CRS27;
+import static org.apache.sis.internal.referencing.HardCoded.CRS83;
+import static org.apache.sis.internal.referencing.HardCoded.CRS84;
/**
@@ -105,7 +114,7 @@ import static org.opengis.referencing.Id
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.5
* @module
*/
public enum CommonCRS {
@@ -1338,4 +1347,60 @@ public enum CommonCRS {
static void failure(final Object caller, final String method, final FactoryException e) {
Logging.unexpectedException(caller.getClass(), method, e);
}
+
+ /**
+ * Returns a coordinate reference system for the given authority code.
+ * This method is invoked as a fallback when {@link CRS#forCode(String)}
+ * can not create a CRS for a given code.
+ *
+ * @param authority The authority, either {@code "CRS"} or {@code "EPSG"} (case-insensitive).
+ * @param code The code, to be parsed as an integer.
+ * @param failure The exception to throw in case of failure, or {@code null} for creating our own.
+ * A non-null value is provided when a real EPSG factory exists but failed to create the CRS.
+ * In such case, we want to report the error from the real factory instead than from this fallback.
+ *
+ * @since 0.5
+ */
+ static CoordinateReferenceSystem forCode(final String authority, final String code, final FactoryException failure)
+ throws FactoryException
+ {
+ NumberFormatException cause = null;
+ try {
+ if (authority.equalsIgnoreCase(CRS)) {
+ switch (Integer.parseInt(code)) {
+ case CRS27: return CommonCRS.NAD27.normalizedGeographic();
+ case CRS83: return CommonCRS.NAD83.normalizedGeographic();
+ case CRS84: return CommonCRS.WGS84.normalizedGeographic();
+ }
+ } else if (authority.equalsIgnoreCase(EPSG)) {
+ final int n = Integer.parseInt(code);
+ if (n != 0) { // CommonCRS uses 0 as a sentinel value for "no EPSG code".
+ for (final CommonCRS candidate : CommonCRS.values()) {
+ if (candidate.geographic == n) return candidate.geographic();
+ if (candidate.geocentric == n) return candidate.geocentric();
+ if (candidate.geo3D == n) return candidate.geographic3D();
+ }
+ for (final CommonCRS.Vertical candidate : CommonCRS.Vertical.values()) {
+ if (candidate.isEPSG && candidate.crs == n) {
+ return candidate.crs();
+ }
+ }
+ }
+ } else if (failure != null) {
+ throw failure;
+ } else {
+ throw new NoSuchIdentifierException(Errors.format(Errors.Keys.UnknownAuthority_1, authority), authority);
+ }
+ } catch (NumberFormatException e) {
+ cause = e;
+ }
+ if (failure != null) {
+ throw failure;
+ }
+ final NoSuchAuthorityCodeException e = new NoSuchAuthorityCodeException(
+ Errors.format(Errors.Keys.NoSuchAuthorityCode_3, authority, CoordinateReferenceSystem.class, code),
+ authority, code, code);
+ e.initCause(cause);
+ throw e;
+ }
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -17,15 +17,28 @@
package org.apache.sis.referencing.crs;
import java.util.Map;
+import java.util.HashMap;
+import java.util.Arrays;
import javax.xml.bind.annotation.XmlTransient;
-import org.opengis.referencing.cs.CoordinateSystem;
-import org.opengis.referencing.cs.EllipsoidalCS;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.cs.EllipsoidalCS;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.measure.Longitude;
+import static org.apache.sis.internal.referencing.HardCoded.CRS;
+import static org.apache.sis.internal.referencing.HardCoded.EPSG;
+import static org.apache.sis.internal.referencing.HardCoded.CRS27;
+import static org.apache.sis.internal.referencing.HardCoded.CRS83;
+import static org.apache.sis.internal.referencing.HardCoded.CRS84;
+
/**
* A coordinate reference system based on an ellipsoidal approximation of the geoid.
@@ -43,12 +56,22 @@ import org.apache.sis.io.wkt.Formatter;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
- * @version 0.4
+ * @version 0.5
* @module
*/
@XmlTransient
public class DefaultGeographicCRS extends DefaultGeodeticCRS implements GeographicCRS {
/**
+ * Some codes in the EPSG namespace, in ascending order.
+ */
+ private static final short[] EPSG_CODES = {4267, 4269, 4326};
+
+ /**
+ * Codes in the CRS namespace for each code listed in the {@link #EPSG} list.
+ */
+ private static final byte[] CRS_CODES = {CRS27, CRS83, CRS84};
+
+ /**
* Serial number for inter-operability with different versions.
*/
private static final long serialVersionUID = 861224913438092335L;
@@ -196,9 +219,32 @@ public class DefaultGeographicCRS extend
/**
* Returns a coordinate reference system of the same type than this CRS but with different axes.
+ *
+ * {@section Special case}
+ * If the first axis is the longitude in the [-180 … +180]° range and the identifier is EPSG:4267,
+ * EPSG:4269 or EPSG:4326, then this method magically add the CRS:27, CRS:83 or CRS:84 identifier.
+ * Without this special case, the normal behavior would be no identifier. The expected behavior is
+ * that {@code CommonCRS.WGS84.normalizedGeographic()} returns a CRS having the "CRS:84" identifier.
*/
@Override
- final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ final AbstractCRS createSameType(Map<String,?> properties, final CoordinateSystem cs) {
+ final CoordinateSystemAxis axis = cs.getAxis(0);
+ if (axis.getMinimumValue() == Longitude.MIN_VALUE &&
+ axis.getMaximumValue() == Longitude.MAX_VALUE) // For excluding the AxesConvention.POSITIVE_RANGE case.
+ {
+ for (final ReferenceIdentifier identifier : super.getIdentifiers()) {
+ if (EPSG.equals(identifier.getCodeSpace())) try {
+ final int i = Arrays.binarySearch(EPSG_CODES, Short.parseShort(identifier.getCode()));
+ if (i >= 0) {
+ final Map<String,Object> c = new HashMap<String,Object>(properties);
+ c.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.OGC, CRS, Short.toString(CRS_CODES[i])));
+ properties = c;
+ }
+ } catch (NumberFormatException e) {
+ // Okay to igore, because it is not the purpose of this method to disallow non-numeric codes.
+ }
+ }
+ }
return new DefaultGeographicCRS(properties, super.getDatum(), (EllipsoidalCS) cs);
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java Thu Sep 25 14:55:49 2014
@@ -29,8 +29,8 @@ import org.opengis.referencing.datum.Tem
import org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter;
import org.apache.sis.internal.metadata.MetadataUtilities;
import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.FormattableObject;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
@@ -72,7 +72,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-1.2)
- * @version 0.4
+ * @version 0.5
* @module
*
* @see org.apache.sis.referencing.CommonCRS.Temporal#datum()
@@ -287,12 +287,30 @@ public class DefaultTemporalDatum extend
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
- final Convention convention = formatter.getConvention();
- if (convention == Convention.INTERNAL) {
- formatter.append(MetadataUtilities.toDate(origin)); // This is an extension compared to ISO 19162.
- } else if (convention.majorVersion() == 1) {
+ formatter.append(new Origin(MetadataUtilities.toDate(origin)));
+ if (formatter.getConvention().majorVersion() == 1) {
formatter.setInvalidWKT(this, null);
}
return "TimeDatum";
}
+
+ /**
+ * The {@code TIMEORIGIN[â¦]} element inside an {@code TDATUM[â¦]}.
+ */
+ private static final class Origin extends FormattableObject {
+ /** The value of the origin to format. */
+ private final Date origin;
+
+ /** Creates a new time origin with the given value. */
+ Origin(final Date origin) {
+ this.origin = origin;
+ }
+
+ /** Formats the time origin. */
+ @Override
+ protected String formatTo(final Formatter formatter) {
+ formatter.append(origin);
+ return "TimeOrigin";
+ }
+ }
}
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -37,7 +37,7 @@ import static org.opengis.referencing.Id
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Johann Sorel (Geomatys)
* @since 0.4 (derived from geotk-2.1)
- * @version 0.4
+ * @version 0.5
* @module
*/
@DependsOn(DefaultParameterDescriptorTest.class)
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -51,6 +51,8 @@ public final strictfp class CRSTest exte
* Tests {@link CRS#forCode(String)} with EPSG codes.
*
* @throws FactoryException If a CRS can not be constructed.
+ *
+ * @see CommonCRSTest#testForCode()
*/
@Test
public void testForEpsgCode() throws FactoryException {
@@ -77,6 +79,8 @@ public final strictfp class CRSTest exte
* Tests {@link CRS#forCode(String)} with CRS codes.
*
* @throws FactoryException If a CRS can not be constructed.
+ *
+ * @see CommonCRSTest#testForCode()
*/
@Test
@DependsOnMethod("testForEpsgCode")
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -18,6 +18,8 @@ package org.apache.sis.referencing;
import java.util.Date;
import org.opengis.test.Validators;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.crs.GeographicCRS;
@@ -43,7 +45,7 @@ import static org.apache.sis.test.TestUt
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-2.2)
- * @version 0.4
+ * @version 0.5
* @module
*/
@DependsOn({
@@ -196,4 +198,43 @@ public final strictfp class CommonCRSTes
assertEquals(name, days, origin.getTime() / DAY_LENGTH - julianEpoch, 0);
}
}
+
+ /**
+ * Tests {@link CommonCRS#forCode(String, String, FactoryException)}.
+ *
+ * @throws FactoryException If a CRS can not be constructed.
+ *
+ * @see CRSTest#testForEpsgCode()
+ * @see CRSTest#testForCrsCode()
+ *
+ * @since 0.5
+ */
+ @Test
+ public void testForCode() throws FactoryException {
+ verifyForCode(CommonCRS.WGS84 .geographic(), "EPSG", "4326");
+ verifyForCode(CommonCRS.WGS72 .geographic(), "EPSG", "4322");
+ verifyForCode(CommonCRS.SPHERE.geographic(), "EPSG", "4047");
+ verifyForCode(CommonCRS.NAD83 .geographic(), "EPSG", "4269");
+ verifyForCode(CommonCRS.NAD27 .geographic(), "EPSG", "4267");
+ verifyForCode(CommonCRS.ETRS89.geographic(), "EPSG", "4258");
+ verifyForCode(CommonCRS.ED50 .geographic(), "EPSG", "4230");
+ verifyForCode(CommonCRS.WGS84 .geocentric(), "EPSG", "4978");
+ verifyForCode(CommonCRS.WGS72 .geocentric(), "EPSG", "4984");
+ verifyForCode(CommonCRS.ETRS89.geocentric(), "EPSG", "4936");
+ verifyForCode(CommonCRS.WGS84 .geographic3D(), "EPSG", "4979");
+ verifyForCode(CommonCRS.WGS72 .geographic3D(), "EPSG", "4985");
+ verifyForCode(CommonCRS.ETRS89.geographic3D(), "EPSG", "4937");
+ verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "EPSG", "5714");
+ verifyForCode(CommonCRS.Vertical.DEPTH.crs(), "EPSG", "5715");
+ verifyForCode(CommonCRS.WGS84.normalizedGeographic(), "CRS", "84");
+ verifyForCode(CommonCRS.NAD83.normalizedGeographic(), "CRS", "83");
+ verifyForCode(CommonCRS.NAD27.normalizedGeographic(), "CRS", "27");
+ }
+
+ /**
+ * Asserts that the result of {@link CommonCRS#forCode(String, String, FactoryException)} is the given CRS.
+ */
+ private static void verifyForCode(final SingleCRS expected, final String authority, final String code) throws FactoryException {
+ assertSame(code, expected, CommonCRS.forCode(authority, code, null));
+ }
}
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java?rev=1627555&r1=1627554&r2=1627555&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] Thu Sep 25 14:55:49 2014
@@ -162,7 +162,7 @@ public final strictfp class DefaultCompo
" UNIT[“metre”, 1],\n" +
" AXIS[“Gravity-related height”, UP]],\n" +
" TIMECRS[“Time”,\n" +
- " TIMEDATUM[“UNIX”],\n" +
+ " TIMEDATUM[“Modified Julian”, TIMEORIGIN[1858-11-17T00:00:00.0Z]],\n" +
" UNIT[“day”, 86400],\n" +
" AXIS[“Time”, FUTURE]]]",
HardCodedCRS.GEOID_4D);
@@ -190,7 +190,7 @@ public final strictfp class DefaultCompo
" Axis[“Gravity-related height (H)”, up],\n" +
" LengthUnit[“metre”, 1]],\n" +
" TimeCRS[“Time”,\n" +
- " TimeDatum[“UNIX”],\n" +
+ " TimeDatum[“Modified Julian”, TimeOrigin[1858-11-17T00:00:00.0Z]],\n" +
" CS[“temporal”, 1],\n" +
" Axis[“Time (t)”, future],\n" +
" TimeUnit[“day”, 86400]],\n" +