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 2015/10/16 17:16:24 UTC
svn commit: r1709036 [2/2] - in /sis/branches/JDK8/core:
sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/
sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/
sis-referencing/src/main/java/org/apache/sis/pa...
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -27,6 +27,7 @@ import org.opengis.referencing.datum.Ver
import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.io.wkt.Formatter;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -48,7 +49,7 @@ import static org.apache.sis.util.Argume
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.6
+ * @version 0.7
* @module
*
* @see org.apache.sis.referencing.datum.DefaultVerticalDatum
@@ -67,9 +68,13 @@ public class DefaultVerticalCRS extends
/**
* The datum.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setDatum(VerticalDatum)}</p>
+ *
+ * @see #getDatum()
*/
- @XmlElement(name = "verticalDatum", required = true)
- private final VerticalDatum datum;
+ private VerticalDatum datum;
/**
* Creates a coordinate reference system from the given properties, datum and coordinate system.
@@ -182,7 +187,8 @@ public class DefaultVerticalCRS extends
* @return The datum.
*/
@Override
- public final VerticalDatum getDatum() {
+ @XmlElement(name = "verticalDatum", required = true)
+ public VerticalDatum getDatum() {
return datum;
}
@@ -250,7 +256,25 @@ public class DefaultVerticalCRS extends
* reserved to JAXB, which will assign values to the fields using reflexion.
*/
private DefaultVerticalCRS() {
- datum = null;
+ /*
+ * The datum and the coordinate system are mandatory for SIS working. We do not verify their presence
+ * here because the verification would have to be done in an 'afterMarshal(…)' method and throwing an
+ * exception in that method causes the whole unmarshalling to fail. But the SC_CRS adapter does some
+ * verifications.
+ */
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getDatum()
+ */
+ private void setDatum(final VerticalDatum value) {
+ if (datum == null) {
+ datum = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultVerticalCRS.class, "setDatum", "verticalDatum");
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -66,7 +66,7 @@ import static org.apache.sis.util.Utilit
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.6
+ * @version 0.7
* @module
*
* @see DefaultCoordinateSystemAxis
@@ -99,9 +99,13 @@ public class AbstractCS extends Abstract
/**
* The sequence of axes for this coordinate system.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setAxis(CoordinateSystemAxis[])}</p>
+ *
+ * @see #getAxis(int)
*/
- @XmlElement(name = "axis")
- private final CoordinateSystemAxis[] axes;
+ private CoordinateSystemAxis[] axes;
/**
* Other coordinate systems derived from this coordinate systems for other axes conventions.
@@ -210,14 +214,18 @@ public class AbstractCS extends Abstract
*/
protected AbstractCS(final CoordinateSystem cs) {
super(cs);
- if (cs instanceof AbstractCS) {
- axes = ((AbstractCS) cs).axes; // Share the array.
- } else {
- axes = new CoordinateSystemAxis[cs.getDimension()];
- for (int i=0; i<axes.length; i++) {
- axes[i] = cs.getAxis(i);
- }
+ axes = (cs instanceof AbstractCS) ? ((AbstractCS) cs).axes : getAxes(cs);
+ }
+
+ /**
+ * Returns the axes of the given coordinate system.
+ */
+ private static CoordinateSystemAxis[] getAxes(final CoordinateSystem cs) {
+ final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[cs.getDimension()];
+ for (int i=0; i<axes.length; i++) {
+ axes[i] = cs.getAxis(i);
}
+ return axes;
}
/**
@@ -483,5 +491,27 @@ public class AbstractCS extends Abstract
AbstractCS() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
axes = EMPTY;
+ /*
+ * Coordinate system axes are mandatory for SIS working. We do not verify their presence here
+ * (because the verification would have to be done in an 'afterMarshal(…)' method and throwing
+ * an exception in that method causes the whole unmarshalling to fail). But the CS_CoordinateSystem
+ * adapter does some verifications.
+ */
+ }
+
+ /**
+ * Invoked by JAXB at marshalling time.
+ */
+ @XmlElement(name = "axis")
+ private CoordinateSystemAxis[] getAxis() {
+ return getAxes(this); // Give a chance to users to override getAxis(int).
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ */
+ @SuppressWarnings("AssignmentToCollectionOrArrayFieldFromParameter")
+ private void setAxis(final CoordinateSystemAxis[] values) {
+ axes = values;
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import java.util.List;
+import javax.xml.bind.annotation.XmlTransient;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.metadata.AxisDirections;
@@ -54,6 +55,7 @@ import static org.apache.sis.util.Utilit
* @version 0.6
* @module
*/
+@XmlTransient
public class DefaultCompoundCS extends AbstractCS {
/**
* Serial number for inter-operability with different versions.
@@ -168,8 +170,9 @@ public class DefaultCompoundCS extends A
*
* @return All coordinate systems in this compound CS.
*/
+ @SuppressWarnings("ReturnOfCollectionOrArrayField")
public List<CoordinateSystem> getComponents() {
- return components;
+ return components; // Unmodifiable.
}
/*
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -180,22 +180,34 @@ public class DefaultCoordinateSystemAxis
/**
* The abbreviation used for this coordinate system axes.
* Examples are <cite>"X"</cite> and <cite>"Y"</cite>.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setAbbreviation(String)}</p>
+ *
+ * @see #getAbbreviation()
*/
- @XmlElement(name = "axisAbbrev", required = true)
- private final String abbreviation;
+ private String abbreviation;
/**
* Direction of this coordinate system axis. In the case of Cartesian projected
* coordinates, this is the direction of this coordinate system axis locally.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setDirection(AxisDirection)}</p>
+ *
+ * @see #getDirection()
*/
- @XmlElement(name = "axisDirection", required = true)
- private final AxisDirection direction;
+ private AxisDirection direction;
/**
* The unit of measure used for this coordinate system axis.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setUnit(Unit)}</p>
+ *
+ * @see #getUnit()
*/
- @XmlAttribute(name= "uom", required = true)
- private final Unit<?> unit;
+ private Unit<?> unit;
/**
* Minimal and maximal value for this axis, or negative/positive infinity if none.
@@ -208,9 +220,13 @@ public class DefaultCoordinateSystemAxis
/**
* The range meaning for this axis, or {@code null} if unspecified.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setRangeMeaning(RangeMeaning)}</p>
+ *
+ * @see #getRangeMeaning()
*/
- @XmlElement
- private final RangeMeaning rangeMeaning;
+ private RangeMeaning rangeMeaning;
/**
* Constructs an axis from a set of properties. The properties given in argument follow the same rules
@@ -397,6 +413,7 @@ public class DefaultCoordinateSystemAxis
* @return The direction of this coordinate system axis.
*/
@Override
+ @XmlElement(name = "axisDirection", required = true)
public AxisDirection getDirection() {
return direction;
}
@@ -408,6 +425,7 @@ public class DefaultCoordinateSystemAxis
* @return The coordinate system axis abbreviation.
*/
@Override
+ @XmlElement(name = "axisAbbrev", required = true)
public String getAbbreviation() {
return abbreviation;
}
@@ -420,6 +438,7 @@ public class DefaultCoordinateSystemAxis
* @return The unit of measure used for ordinate values along this coordinate system axis.
*/
@Override
+ @XmlAttribute(name= "uom", required = true)
public Unit<?> getUnit() {
return unit;
}
@@ -469,6 +488,7 @@ public class DefaultCoordinateSystemAxis
* @return The meaning of axis value range, or {@code null} if unspecified.
*/
@Override
+ @XmlElement(name = "rangeMeaning")
public RangeMeaning getRangeMeaning() {
return rangeMeaning;
}
@@ -854,12 +874,66 @@ public class DefaultCoordinateSystemAxis
*/
private DefaultCoordinateSystemAxis() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
- abbreviation = null;
- direction = null;
- unit = null;
- rangeMeaning = null;
minimumValue = NEGATIVE_INFINITY;
maximumValue = POSITIVE_INFINITY;
+ /*
+ * Direction and unit of measurement are mandatory for SIS working. We do not verify their presence here
+ * because the verification would have to be done in an 'afterMarshal(…)' method and throwing an exception
+ * in that method causes the whole unmarshalling to fail. But the CD_CoordinateSystemAxis adapter does some
+ * verifications.
+ */
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getAbbreviation()
+ */
+ private void setAbbreviation(final String value) {
+ if (abbreviation == null) {
+ abbreviation = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setAbbreviation", "abbreviation");
+ }
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getDirection()
+ */
+ private void setDirection(final AxisDirection value) {
+ if (direction == null) {
+ direction = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setDirection", "direction");
+ }
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getUnit()
+ */
+ private void setUnit(final Unit<?> value) {
+ if (unit == null) {
+ unit = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setUnit", "unit");
+ }
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getRangeMeaning()
+ */
+ private void setRangeMeaning(final RangeMeaning value) {
+ if (rangeMeaning == null) {
+ rangeMeaning = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setRangeMeaning", "rangeMeaning");
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -34,7 +34,7 @@
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.6
+ * @version 0.7
* @module
*/
@XmlSchema(location = "http://schemas.opengis.net/gml/3.2.1/coordinateSystems.xsd",
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -65,7 +65,7 @@ import java.util.Objects;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.6
+ * @version 0.7
* @module
*
* @see org.apache.sis.referencing.cs.AbstractCS
@@ -74,7 +74,7 @@ import java.util.Objects;
@XmlType(name = "AbstractDatumType", propOrder = {
"domainOfValidity",
"scope",
- "anchorDefinition",
+ "anchorPoint",
"realizationEpoch"
})
@XmlRootElement(name = "AbstractDatum")
@@ -99,9 +99,13 @@ public class AbstractDatum extends Abstr
/**
* Description, possibly including coordinates, of the point or points used to anchor the datum
* to the Earth. Also known as the "origin", especially for Engineering and Image Datums.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setAnchorPoint(InternationalString)}</p>
+ *
+ * @see #getAnchorPoint()
*/
- @XmlElement
- private final InternationalString anchorDefinition;
+ private InternationalString anchorDefinition;
/**
* The time after which this datum definition is valid. This time may be precise
@@ -115,15 +119,23 @@ public class AbstractDatum extends Abstr
/**
* Area or region in which this datum object is valid.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setDomainOfValidity(Extent)}</p>
+ *
+ * @see #getDomainOfValidity()
*/
- @XmlElement
- private final Extent domainOfValidity;
+ private Extent domainOfValidity;
/**
* Description of domain of usage, or limitations of usage, for which this datum object is valid.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setScope(InternationalString)}</p>
+ *
+ * @see #getScope()
*/
- @XmlElement
- private final InternationalString scope;
+ private InternationalString scope;
/**
* Creates a datum from the given properties.
@@ -274,6 +286,7 @@ public class AbstractDatum extends Abstr
* @return Description, possibly including coordinates, of the point or points used to anchor the datum to the Earth.
*/
@Override
+ @XmlElement(name = "anchorDefinition")
public InternationalString getAnchorPoint() {
return anchorDefinition;
}
@@ -302,6 +315,7 @@ public class AbstractDatum extends Abstr
* @see org.apache.sis.metadata.iso.extent.DefaultExtent
*/
@Override
+ @XmlElement(name = "domainOfValidity")
public Extent getDomainOfValidity() {
return domainOfValidity;
}
@@ -312,6 +326,7 @@ public class AbstractDatum extends Abstr
* @return Description of domain of usage, or limitations of usage, for which this datum object is valid.
*/
@Override
+ @XmlElement(name = "scope", required = true)
public InternationalString getScope() {
return scope;
}
@@ -462,14 +477,26 @@ public class AbstractDatum extends Abstr
*/
AbstractDatum() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
- anchorDefinition = null;
realizationEpoch = Long.MIN_VALUE;
- domainOfValidity = null;
- scope = null;
}
/**
* Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getAnchorPoint()
+ */
+ private void setAnchorPoint(final InternationalString value) {
+ if (anchorDefinition == null) {
+ anchorDefinition = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setAnchorPoint", "anchorDefinition");
+ }
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getRealizationEpoch()
*/
private void setRealizationEpoch(final Date value) {
if (realizationEpoch == Long.MIN_VALUE) {
@@ -478,4 +505,30 @@ public class AbstractDatum extends Abstr
ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setRealizationEpoch", "realizationEpoch");
}
}
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getDomainOfValidity()
+ */
+ private void setDomainOfValidity(final Extent value) {
+ if (domainOfValidity == null) {
+ domainOfValidity = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setDomainOfValidity", "domainOfValidity");
+ }
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getScope()
+ */
+ private void setScope(final InternationalString value) {
+ if (scope == null) {
+ scope = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setScope", "scope");
+ }
+ }
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -31,9 +31,9 @@ import org.opengis.metadata.Identifier;
import org.opengis.referencing.datum.Ellipsoid;
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.internal.util.Numerics;
-import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.gml.Measure;
import org.apache.sis.internal.jaxb.referencing.SecondDefiningParameter;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.referencing.Formulas;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.referencing.IdentifiedObjects;
@@ -112,12 +112,12 @@ import java.util.Objects;
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.7
* @module
*
* @see org.apache.sis.referencing.CommonCRS#ellipsoid()
*/
-@XmlType(name="EllipsoidType", propOrder={
+@XmlType(name = "EllipsoidType", propOrder = {
"semiMajorAxisMeasure",
"secondDefiningParameter"
})
@@ -698,8 +698,12 @@ public class DefaultEllipsoid extends Ab
*/
private DefaultEllipsoid() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
- // We need to let the DefaultEllipsoid fields unitialized
- // because afterUnmarshal(…) will check for zero values.
+ /*
+ * We need to let the DefaultEllipsoid fields unitialized because afterUnmarshal(…)
+ * will check for zero values. We can not thrown an exception from 'afterUnmarshal'
+ * because it would cause the whole unmarshalling to fail. But the CD_Ellipsoid
+ * adapter does some verifications.
+ */
}
/**
@@ -722,6 +726,7 @@ public class DefaultEllipsoid extends Ab
}
}
if (unit == null) {
+ unit = SI.METRE;
Measure.missingUOM(DefaultEllipsoid.class, "semiMajorAxis");
}
}
@@ -743,13 +748,13 @@ public class DefaultEllipsoid extends Ab
* @see #afterUnmarshal(Unmarshaller, Object)
*/
private void setSemiMajorAxisMeasure(final Measure measure) {
- if (semiMajorAxis != 0) {
- warnDuplicated("semiMajorAxis");
- } else {
+ if (semiMajorAxis == 0) {
final Unit<Length> uom = unit; // In case semi-minor were defined before semi-major.
ensureStrictlyPositive("semiMajorAxis", semiMajorAxis = measure.value);
unit = measure.getUnit(Length.class);
harmonizeAxisUnits(uom);
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultEllipsoid.class, "setSemiMajorAxisMeasure", "semiMajorAxis");
}
}
@@ -758,7 +763,7 @@ public class DefaultEllipsoid extends Ab
* returned object contains the values for {@link #semiMinorAxis} or {@link #inverseFlattening},
* according to the {@link #isIvfDefinitive()} value. This method is for JAXB marshalling only.
*/
- @XmlElement(name = "secondDefiningParameter")
+ @XmlElement(name = "secondDefiningParameter", required = true)
private SecondDefiningParameter getSecondDefiningParameter() {
return new SecondDefiningParameter(this, true);
}
@@ -778,9 +783,7 @@ public class DefaultEllipsoid extends Ab
final Measure measure = second.measure;
if (measure != null) {
final boolean isIvfDefinitive = second.isIvfDefinitive();
- if ((isIvfDefinitive ? inverseFlattening : semiMinorAxis) != 0) {
- warnDuplicated("secondDefiningParameter");
- } else {
+ if ((isIvfDefinitive ? inverseFlattening : semiMinorAxis) == 0) {
ivfDefinitive = isIvfDefinitive;
double value = measure.value;
if (isIvfDefinitive) {
@@ -792,6 +795,9 @@ public class DefaultEllipsoid extends Ab
ensureStrictlyPositive("semiMinorAxis", semiMinorAxis = value);
harmonizeAxisUnits(measure.getUnit(Length.class));
}
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultEllipsoid.class,
+ "setSecondDefiningParameter", "secondDefiningParameter");
}
}
}
@@ -809,13 +815,4 @@ public class DefaultEllipsoid extends Ab
semiMinorAxis = uom.getConverterTo(unit).convert(semiMinorAxis);
}
}
-
- /**
- * Emits a warning telling that the given element is repeated twice.
- */
- private static void warnDuplicated(final String element) {
- // We cheat a bit for the "unmarshal" method name since there is not such method...
- Context.warningOccured(Context.current(), DefaultEllipsoid.class, "unmarshal",
- Errors.class, Errors.Keys.DuplicatedElement_1, element);
- }
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -37,6 +37,7 @@ import org.apache.sis.metadata.iso.exten
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.referencing.ExtentSelector;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.util.logging.Logging;
@@ -122,7 +123,7 @@ import java.util.Objects;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.7
* @module
*
* @see DefaultEllipsoid
@@ -153,15 +154,23 @@ public class DefaultGeodeticDatum extend
/**
* The ellipsoid.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setEllipsoid(Ellipsoid)}</p>
+ *
+ * @see #getEllipsoid()
*/
- @XmlElement
- private final Ellipsoid ellipsoid;
+ private Ellipsoid ellipsoid;
/**
* The prime meridian.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setPrimeMeridian(PrimeMeridian)}</p>
+ *
+ * @see #getPrimeMeridian()
*/
- @XmlElement
- private final PrimeMeridian primeMeridian;
+ private PrimeMeridian primeMeridian;
/**
* Bursa-Wolf parameters for datum shifts, or {@code null} if none.
@@ -313,6 +322,7 @@ public class DefaultGeodeticDatum extend
* @return The ellipsoid.
*/
@Override
+ @XmlElement(name = "ellipsoid", required = true)
public Ellipsoid getEllipsoid() {
return ellipsoid;
}
@@ -323,6 +333,7 @@ public class DefaultGeodeticDatum extend
* @return The prime meridian.
*/
@Override
+ @XmlElement(name = "primeMeridian", required = true)
public PrimeMeridian getPrimeMeridian() {
return primeMeridian;
}
@@ -590,8 +601,38 @@ public class DefaultGeodeticDatum extend
* reserved to JAXB, which will assign values to the fields using reflexion.
*/
private DefaultGeodeticDatum() {
- ellipsoid = null;
- primeMeridian = null;
- bursaWolf = null;
+ bursaWolf = null;
+ /*
+ * Ellipsoid and PrimeMeridian are mandatory for SIS working. We do not verify their presence here
+ * (because the verification would have to be done in an 'afterMarshal(…)' method and throwing an
+ * exception in that method causes the whole unmarshalling to fail). But the CD_GeodeticDatum
+ * adapter does some verifications.
+ */
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getEllipsoid()
+ */
+ private void setEllipsoid(final Ellipsoid value) {
+ if (ellipsoid == null) {
+ ellipsoid = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultGeodeticDatum.class, "setEllipsoid", "ellipsoid");
+ }
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getPrimeMeridian()
+ */
+ private void setPrimeMeridian(final PrimeMeridian value) {
+ if (primeMeridian == null) {
+ primeMeridian = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultGeodeticDatum.class, "setPrimeMeridian", "primeMeridian");
+ }
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -26,6 +26,7 @@ import org.opengis.metadata.Identifier;
import org.opengis.referencing.datum.ImageDatum;
import org.opengis.referencing.datum.PixelInCell;
import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.util.ComparisonMode;
@@ -48,7 +49,7 @@ import java.util.Objects;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.7
* @module
*/
@XmlType(name = "ImageDatumType")
@@ -61,9 +62,13 @@ public class DefaultImageDatum extends A
/**
* Specification of the way the image grid is associated with the image data attributes.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setPixelInCell(PixelInCell)}</p>
+ *
+ * @see #getPixelInCell()
*/
- @XmlElement(required = true)
- private final PixelInCell pixelInCell;
+ private PixelInCell pixelInCell;
/**
* Creates an image datum from the given properties. The properties map is given
@@ -181,6 +186,7 @@ public class DefaultImageDatum extends A
* @return The way image grid is associated with image data attributes.
*/
@Override
+ @XmlElement(required = true)
public PixelInCell getPixelInCell() {
return pixelInCell;
}
@@ -266,6 +272,18 @@ public class DefaultImageDatum extends A
* reserved to JAXB, which will assign values to the fields using reflexion.
*/
private DefaultImageDatum() {
- pixelInCell = null;
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getPixelInCell()
+ */
+ private void setPixelInCell(final PixelInCell value) {
+ if (pixelInCell == null) {
+ pixelInCell = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultImageDatum.class, "setPixelInCell", "pixelInCell");
+ }
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -84,7 +84,7 @@ import org.apache.sis.internal.referenci
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
* @since 0.4
- * @version 0.6
+ * @version 0.7
* @module
*
* @see org.apache.sis.referencing.CommonCRS#primeMeridian()
@@ -406,6 +406,12 @@ public class DefaultPrimeMeridian extend
*/
private DefaultPrimeMeridian() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
+ /*
+ * Angular units are mandatory for SIS working. We do not verify their presence here (because the
+ * verification would have to be done in an 'afterMarshal(…)' method and throwing an exception in
+ * that method causes the whole unmarshalling to fail). But the CD_PrimeMeridian adapter does some
+ * verifications.
+ */
}
/**
@@ -427,11 +433,10 @@ public class DefaultPrimeMeridian extend
/*
* Missing unit: if the Greenwich longitude is zero, any angular unit gives the same result
* (assuming that the missing unit was not applying an offset), so we can select a default.
- * If the Greenwich longitude is not zero, we can not guess. Our object will be invalid.
+ * If the Greenwich longitude is not zero, presume egrees but log a warning.
*/
- if (greenwichLongitude == 0) {
- angularUnit = NonSI.DEGREE_ANGLE;
- } else {
+ angularUnit = NonSI.DEGREE_ANGLE;
+ if (greenwichLongitude != 0) {
Measure.missingUOM(DefaultPrimeMeridian.class, "setGreenwichMeasure");
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -215,8 +215,8 @@ public class DefaultTemporalDatum extend
* @return The date and time origin of this temporal datum.
*/
@Override
- @XmlElement(name = "origin")
@XmlSchemaType(name = "dateTime")
+ @XmlElement(name = "origin", required = true)
@XmlJavaTypeAdapter(UniversalTimeAdapter.class)
public Date getOrigin() {
return MetadataUtilities.toDate(origin);
@@ -322,6 +322,11 @@ public class DefaultTemporalDatum extend
*/
private DefaultTemporalDatum() {
origin = Long.MIN_VALUE;
+ /*
+ * The origin is mandatory for SIS working. We do not verify its presence here because the verification
+ * would have to be done in an 'afterMarshal(…)' method and throwing an exception in that method causes
+ * the whole unmarshalling to fail. But the CD_TemporalDatum adapter does some verifications.
+ */
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/package-info.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/package-info.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -43,7 +43,7 @@
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.7
* @module
*/
@XmlSchema(location = "http://schemas.opengis.net/gml/3.2.1/datums.xsd",
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -52,6 +52,7 @@ import org.apache.sis.internal.referenci
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.util.UnmodifiableArrayList;
import org.apache.sis.internal.system.Semaphores;
import static org.apache.sis.util.Utilities.deepEquals;
@@ -92,11 +93,11 @@ import java.util.Objects;
* @version 0.7
* @module
*/
-@XmlType(name="AbstractCoordinateOperationType", propOrder = {
+@XmlType(name = "AbstractCoordinateOperationType", propOrder = {
"domainOfValidity",
"scope",
"operationVersion",
- "coordinateOperationAccuracy",
+ "accuracy",
"source",
"target"
})
@@ -148,32 +149,44 @@ public class AbstractCoordinateOperation
/**
* Version of the coordinate transformation
* (i.e., instantiation due to the stochastic nature of the parameters).
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setOperationVersion(String)}</p>
+ *
+ * @see #getOperationVersion()
*/
- @XmlElement
- private final String operationVersion;
+ private String operationVersion;
/**
* Estimate(s) of the impact of this operation on point accuracy, or {@code null} if none.
*
* <p><b>Consider this field as final!</b>
- * This field is non-final only for the convenience of constructors.</p>
+ * This field is non-final only for the convenience of constructors and for initialization
+ * at XML unmarshalling time by {@link #setAccuracy(PositionalAccuracy[])}.</p>
*
* @see #getCoordinateOperationAccuracy()
*/
- @XmlElement
Collection<PositionalAccuracy> coordinateOperationAccuracy;
/**
* Area in which this operation is valid, or {@code null} if not available.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setDomainOfValidity(Extent)}</p>
+ *
+ * @see #getDomainOfValidity()
*/
- @XmlElement
- private final Extent domainOfValidity;
+ private Extent domainOfValidity;
/**
* Description of domain of usage, or limitations of usage, for which this operation is valid.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setScope(InternationalString)}</p>
+ *
+ * @see #getScope()
*/
- @XmlElement
- private final InternationalString scope;
+ private InternationalString scope;
/**
* Transform from positions in the {@linkplain #getSourceCRS source coordinate reference system}
@@ -507,6 +520,7 @@ check: for (int isTarget=0; ; isTar
* @return The coordinate operation version, or {@code null} in none.
*/
@Override
+ @XmlElement(name = "operationVersion")
public String getOperationVersion() {
return operationVersion;
}
@@ -522,7 +536,7 @@ check: for (int isTarget=0; ; isTar
*/
@Override
public Collection<PositionalAccuracy> getCoordinateOperationAccuracy() {
- return (coordinateOperationAccuracy != null) ? coordinateOperationAccuracy : Collections.emptySet();
+ return CollectionsExt.nonNull(coordinateOperationAccuracy);
}
/**
@@ -573,6 +587,7 @@ check: for (int isTarget=0; ; isTar
* @return The coordinate operation valid domain, or {@code null} if not available.
*/
@Override
+ @XmlElement(name = "domainOfValidity")
public Extent getDomainOfValidity() {
return domainOfValidity;
}
@@ -583,6 +598,7 @@ check: for (int isTarget=0; ; isTar
* @return A description of domain of usage, or {@code null} if none.
*/
@Override
+ @XmlElement(name = "scope", required = true)
public InternationalString getScope() {
return scope;
}
@@ -844,9 +860,6 @@ check: for (int isTarget=0; ; isTar
*/
AbstractCoordinateOperation() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
- operationVersion = null;
- domainOfValidity = null;
- scope = null;
}
/**
@@ -886,4 +899,64 @@ check: for (int isTarget=0; ; isTar
ReferencingUtilities.propertyAlreadySet(AbstractCoordinateOperation.class, "setTarget", "targetCRS");
}
}
+
+ /**
+ * Invoked by JAXB only at marshalling time.
+ */
+ @XmlElement(name = "coordinateOperationAccuracy")
+ private PositionalAccuracy[] getAccuracy() {
+ final Collection<PositionalAccuracy> accuracy = getCoordinateOperationAccuracy();
+ final int size = accuracy.size();
+ return (size != 0) ? accuracy.toArray(new PositionalAccuracy[size]) : null;
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ */
+ private void setAccuracy(final PositionalAccuracy[] values) {
+ if (coordinateOperationAccuracy == null) {
+ coordinateOperationAccuracy = UnmodifiableArrayList.wrap(values);
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractCoordinateOperation.class, "setAccuracy", "coordinateOperationAccuracy");
+ }
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getOperationVersion()
+ */
+ private void setOperationVersion(final String value) {
+ if (operationVersion == null) {
+ operationVersion = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractCoordinateOperation.class, "setOperationVersion", "operationVersion");
+ }
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getDomainOfValidity()
+ */
+ private void setDomainOfValidity(final Extent value) {
+ if (domainOfValidity == null) {
+ domainOfValidity = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractCoordinateOperation.class, "setDomainOfValidity", "domainOfValidity");
+ }
+ }
+
+ /**
+ * Invoked by JAXB only at unmarshalling time.
+ *
+ * @see #getScope()
+ */
+ private void setScope(final InternationalString value) {
+ if (scope == null) {
+ scope = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractCoordinateOperation.class, "setScope", "scope");
+ }
+ }
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -63,12 +63,18 @@ import java.util.Objects;
* Shared implementation for {@link DefaultConversion} and {@link DefaultTransformation}.
* Does not need to be public, as users should handle only conversions or transformations.
*
+ * <p><b>Note:</b> this class is not strictly equivalent to {@code <gml:AbstractSingleOperationType>}
+ * because the GML schema does not define the method and parameters in this base class. Instead, they
+ * repeat those two elements in the {@code <gml:Conversion>} and {@code <gml:Transformation>} subtypes.
+ * An other difference is that SIS does not use {@code AbstractSingleOperation} as the base class of
+ * {@link DefaultPassThroughOperation}.</p>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.6
* @version 0.7
* @module
*/
-@XmlType(name="AbstractSingleOperationType", propOrder = {
+@XmlType(name = "AbstractSingleOperationType", propOrder = { // See note in class javadoc.
"method",
"parameters"
})
@@ -85,9 +91,13 @@ class AbstractSingleOperation extends Ab
/**
* The operation method.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setMethod(OperationMethod)}</p>
+ *
+ * @see #getMethod()
*/
- @XmlElement
- private final OperationMethod method;
+ private OperationMethod method;
/**
* The parameter values, or {@code null} for inferring it from the math transform.
@@ -269,6 +279,7 @@ class AbstractSingleOperation extends Ab
* @return A description of the operation method.
*/
@Override
+ @XmlElement(name = "method", required = true)
public OperationMethod getMethod() {
return method;
}
@@ -408,7 +419,24 @@ class AbstractSingleOperation extends Ab
* reserved to JAXB, which will assign values to the fields using reflexion.
*/
AbstractSingleOperation() {
- method = null;
+ /*
+ * The method is mandatory for SIS working. We do not verify its presence here because the verification
+ * would have to be done in an 'afterMarshal(…)' method and throwing an exception in that method causes
+ * the whole unmarshalling to fail. But the CC_CoordinateOperation adapter does some verifications.
+ */
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getMethod()
+ */
+ private void setMethod(final OperationMethod value) {
+ if (method == null) {
+ method = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(AbstractSingleOperation.class, "setMethod", "method");
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -21,6 +21,7 @@ import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedHashSet;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
@@ -344,6 +345,7 @@ final class DefaultConcatenatedOperation
* reserved to JAXB, which will assign values to the fields using reflexion.
*/
private DefaultConcatenatedOperation() {
+ operations = Collections.emptyList();
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -118,7 +118,7 @@ import java.util.Objects;
* {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory}.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.6
+ * @version 0.7
* @since 0.5
* @module
*
@@ -126,7 +126,7 @@ import java.util.Objects;
* @see DefaultTransformation
* @see org.apache.sis.referencing.operation.transform.MathTransformProvider
*/
-@XmlType(name="OperationMethodType", propOrder = {
+@XmlType(name = "OperationMethodType", propOrder = {
"formulaCitation",
"formulaDescription",
"sourceDimensions",
@@ -161,19 +161,25 @@ public class DefaultOperationMethod exte
* Number of dimensions in the source CRS of this operation method.
* May be {@code null} if this method can work with any number of
* source dimensions (e.g. <cite>Affine Transform</cite>).
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setSourceDimensions(Integer)}</p>
+ *
+ * @see #getSourceDimensions()
*/
- @XmlElement
- @XmlSchemaType(name = "positiveInteger")
- private final Integer sourceDimensions;
+ private Integer sourceDimensions;
/**
* Number of dimensions in the target CRS of this operation method.
* May be {@code null} if this method can work with any number of
* target dimensions (e.g. <cite>Affine Transform</cite>).
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setTargetDimensions(Integer)}</p>
+ *
+ * @see #getTargetDimensions()
*/
- @XmlElement
- @XmlSchemaType(name = "positiveInteger")
- private final Integer targetDimensions;
+ private Integer targetDimensions;
/**
* The set of parameters, or {@code null} if none.
@@ -564,6 +570,8 @@ public class DefaultOperationMethod exte
* @see org.apache.sis.referencing.operation.transform.AbstractMathTransform#getSourceDimensions()
*/
@Override
+ @XmlElement(name = "sourceDimensions")
+ @XmlSchemaType(name = "positiveInteger")
public Integer getSourceDimensions() {
return sourceDimensions;
}
@@ -577,6 +585,8 @@ public class DefaultOperationMethod exte
* @see org.apache.sis.referencing.operation.transform.AbstractMathTransform#getTargetDimensions()
*/
@Override
+ @XmlElement(name = "targetDimensions")
+ @XmlSchemaType(name = "positiveInteger")
public Integer getTargetDimensions() {
return targetDimensions;
}
@@ -777,8 +787,32 @@ public class DefaultOperationMethod exte
*/
private DefaultOperationMethod() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
- sourceDimensions = null;
- targetDimensions = null;
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getSourceDimensions()
+ */
+ private void setSourceDimensions(final Integer value) {
+ if (sourceDimensions == null) {
+ sourceDimensions = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultOperationMethod.class, "setSourceDimensions", "sourceDimensions");
+ }
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getTargetDimensions()
+ */
+ private void setTargetDimensions(final Integer value) {
+ if (targetDimensions == null) {
+ targetDimensions = value;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultOperationMethod.class, "setTargetDimensions", "targetDimensions");
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -268,6 +268,11 @@ public class DefaultPassThroughOperation
* reserved to JAXB, which will assign values to the fields using reflexion.
*/
private DefaultPassThroughOperation() {
+ /*
+ * A sub-operation is mandatory for SIS working. We do not verify its presence here because the verification
+ * would have to be done in an 'afterMarshal(…)' method and throwing an exception in that method causes the
+ * whole unmarshalling to fail. But the CC_CoordinateOperation adapter does some verifications.
+ */
}
/**
@@ -277,7 +282,11 @@ public class DefaultPassThroughOperation
* @see #getOperation()
*/
private void setOperation(final CoordinateOperation op) {
- operation = op;
+ if (operation == null) {
+ operation = op;
+ } else {
+ ReferencingUtilities.propertyAlreadySet(DefaultPassThroughOperation.class, "setOperation", "coordOperation");
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -160,7 +160,7 @@
* @author Rémi Maréchal (Geomatys)
* @author Adrian Custer (Geomatys)
* @since 0.6
- * @version 0.6
+ * @version 0.7
* @module
*
* @see <a href="http://www.remotesensing.org/geotiff/proj_list">Projections list on RemoteSensing.org</a>
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/package-info.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/package-info.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -67,7 +67,7 @@
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Guilhem Legal (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.7
* @module
*/
@XmlSchema(location = "http://schemas.opengis.net/gml/3.2.1/referenceSystems.xsd",
@@ -78,6 +78,7 @@
})
@XmlAccessorType(XmlAccessType.NONE)
@XmlJavaTypeAdapters({
+ @XmlJavaTypeAdapter(EX_Extent.class),
@XmlJavaTypeAdapter(CI_Citation.class),
@XmlJavaTypeAdapter(RS_Identifier.class),
@XmlJavaTypeAdapter(StringAdapter.class),
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -33,6 +33,7 @@ import org.apache.sis.xml.ReferenceResol
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.util.resources.Errors;
/**
@@ -601,6 +602,21 @@ public abstract class PropertyType<Value
return metadata;
}
+ /**
+ * Invoked by subclasses when the unmarshalled object is missing a component.
+ * This method is invoked when the missing component is essential to SIS working.
+ * This method is not invoked if the missing component is flagged as mandatory by GML,
+ * but is not mandatory for SIS working.
+ *
+ * @param missing The name of the missing XML component.
+ * @throws IllegalArgumentException Always thrown.
+ *
+ * @since 0.7
+ */
+ protected final void incomplete(final String missing) throws IllegalArgumentException {
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingComponentInElement_2, getBoundType(), missing));
+ }
+
/*
* Do not provide the following method here:
*
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java?rev=1709036&r1=1709035&r2=1709036&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] Fri Oct 16 15:16:23 2015
@@ -21,6 +21,7 @@ import org.opengis.referencing.crs.Verti
import org.apache.sis.internal.jaxb.gco.PropertyType;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.Classes;
/**
@@ -61,7 +62,7 @@ import org.apache.sis.util.resources.Err
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.7
* @module
*
* @see org.apache.sis.internal.jaxb.AdapterReplacement
@@ -126,11 +127,16 @@ public class SC_VerticalCRS extends Prop
* of {@link VerticalCRS}, then this method assigns that value to the {@link #metadata} field.
* Otherwise this method does nothing.
*
- * @param metadata The unmarshalled metadata.
+ * @param crs The unmarshalled metadata.
*/
- public final void setElement(final Object metadata) {
- if (metadata instanceof VerticalCRS) {
- this.metadata = (VerticalCRS) metadata;
+ public final void setElement(final Object crs) {
+ if (crs instanceof VerticalCRS) {
+ metadata = (VerticalCRS) crs;
+ if (metadata.getCoordinateSystem() == null) incomplete("coordinateSystem");
+ if (metadata.getDatum() == null) incomplete("verticalDatum");
+ } else {
+ Context.warningOccured(Context.current(), SC_VerticalCRS.class, "setElement", Errors.class,
+ Errors.Keys.UnexpectedValueInElement_2, "verticalCRS", Classes.getShortClassName(crs));
}
}
}