You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/11/01 21:03:08 UTC
svn commit: r1767577 [2/15] - in /sis/trunk: ./ application/
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-openoffice/
application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ core/
core/sis-feature/src/main/j...
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1767577&r1=1767576&r2=1767577&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Tue Nov 1 21:03:06 2016
@@ -31,10 +31,8 @@ import java.text.NumberFormat;
import java.text.FieldPosition;
import java.lang.reflect.Array;
import java.math.RoundingMode;
-import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
-import javax.measure.unit.UnitFormat;
-import javax.measure.quantity.Quantity;
+import javax.measure.Unit;
+import javax.measure.Quantity;
import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
@@ -73,11 +71,11 @@ import org.apache.sis.util.resources.Voc
import org.apache.sis.internal.util.X364;
import org.apache.sis.internal.util.Citations;
import org.apache.sis.internal.util.Constants;
-import org.apache.sis.internal.util.PatchedUnitFormat;
import org.apache.sis.internal.util.StandardDateFormat;
import org.apache.sis.internal.simple.SimpleExtent;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.internal.metadata.ReferencingServices;
+import org.apache.sis.measure.UnitFormat;
import org.apache.sis.measure.Range;
import org.apache.sis.measure.MeasurementRange;
import org.apache.sis.metadata.iso.ImmutableIdentifier;
@@ -230,7 +228,7 @@ public class Formatter implements Locali
/**
* The object to use for formatting unit symbols.
*/
- private final PatchedUnitFormat unitFormat;
+ private final UnitFormat unitFormat;
/**
* Dummy field position.
@@ -329,10 +327,10 @@ public class Formatter implements Locali
/**
* Creates a new formatter instance with the specified convention, symbols and indentation.
*
- * @param convention The convention to use.
- * @param symbols The symbols.
- * @param indentation The amount of spaces to use in indentation for WKT formatting,
- * or {@link WKTFormat#SINGLE_LINE} for formatting the whole WKT on a single line.
+ * @param convention the convention to use.
+ * @param symbols the symbols.
+ * @param indentation the amount of spaces to use in indentation for WKT formatting,
+ * or {@link WKTFormat#SINGLE_LINE} for formatting the whole WKT on a single line.
*/
public Formatter(final Convention convention, final Symbols symbols, final int indentation) {
ArgumentChecks.ensureNonNull("convention", convention);
@@ -346,8 +344,12 @@ public class Formatter implements Locali
this.indentation = (byte) indentation;
this.numberFormat = symbols.createNumberFormat();
this.dateFormat = new StandardDateFormat(symbols.getLocale());
- this.unitFormat = new PatchedUnitFormat(UnitFormat.getInstance(symbols.getLocale()));
+ this.unitFormat = new UnitFormat(symbols.getLocale());
this.buffer = new StringBuffer();
+ unitFormat.setStyle(UnitFormat.Style.NAME);
+ if (convention.usesCommonUnits) {
+ unitFormat.setLocale(Locale.US);
+ }
}
/**
@@ -363,9 +365,9 @@ public class Formatter implements Locali
this.symbols = symbols;
this.lineSeparator = this.symbols.lineSeparator();
this.indentation = WKTFormat.DEFAULT_INDENTATION;
- this.numberFormat = numberFormat; // No clone needed.
- this.dateFormat = dateFormat; // No clone needed.
- this.unitFormat = new PatchedUnitFormat(unitFormat);
+ this.numberFormat = numberFormat; // No clone needed.
+ this.dateFormat = dateFormat;
+ this.unitFormat = unitFormat;
// Do not set the buffer. It will be set by WKTFormat.format(\u2026).
}
@@ -381,13 +383,13 @@ public class Formatter implements Locali
* Sets the convention, authority, colors and indentation to use for formatting WKT elements.
* This method does not validate the argument \u2014 validation must be done by the caller.
*
- * @param convention The convention, or {@code null} for the default value.
- * @param authority The authority, or {@code null} for inferring it from the convention.
- * @param colors The syntax coloring, or {@code null} if none.
- * @param toUpperCase Whether keywords shall be converted to upper cases.
- * @param longKeywords {@code -1} for short keywords, {@code +1} for long keywords or 0 for the default.
- * @param indentation The amount of spaces to use in indentation for WKT formatting,
- * or {@link WKTFormat#SINGLE_LINE}.
+ * @param convention the convention, or {@code null} for the default value.
+ * @param authority the authority, or {@code null} for inferring it from the convention.
+ * @param colors the syntax coloring, or {@code null} if none.
+ * @param toUpperCase whether keywords shall be converted to upper cases.
+ * @param longKeywords {@code -1} for short keywords, {@code +1} for long keywords or 0 for the default.
+ * @param indentation the amount of spaces to use in indentation for WKT formatting,
+ * or {@link WKTFormat#SINGLE_LINE}.
*/
final void configure(Convention convention, final Citation authority, final Colors colors,
final byte toUpperCase, final byte longKeywords, final byte indentation)
@@ -399,13 +401,13 @@ public class Formatter implements Locali
this.longKeywords = longKeywords;
this.indentation = indentation;
this.transliterator = (convention == Convention.INTERNAL) ? Transliterator.IDENTITY : Transliterator.DEFAULT;
- unitFormat.isLocaleUS = convention.usesCommonUnits;
+ unitFormat.setLocale(convention.usesCommonUnits ? Locale.US : Locale.ROOT);
}
/**
* Returns the convention to use for formatting the WKT. The default is {@link Convention#WKT2}.
*
- * @return The convention (never {@code null}).
+ * @return the convention (never {@code null}).
*
* @see WKTFormat#setConvention(Convention)
* @see FormattableObject#toString(Convention)
@@ -426,7 +428,7 @@ public class Formatter implements Locali
* <li>Any other user-supplied mapping.</li>
* </ul>
*
- * @return The mapper between Java character sequences and the characters to write in WKT.
+ * @return the mapper between Java character sequences and the characters to write in WKT.
*
* @see WKTFormat#setTransliterator(Transliterator)
*
@@ -447,7 +449,7 @@ public class Formatter implements Locali
* However if the preferred authority is OGC, then the formatted datum name will rather look like
* <cite>"WGS84"</cite> (the exact string depends on the object aliases).</div>
*
- * @return The authority for projection and parameter names.
+ * @return the authority for projection and parameter names.
*
* @see WKTFormat#getNameAuthority()
* @see org.apache.sis.referencing.IdentifiedObjects#getName(IdentifiedObject, Citation)
@@ -460,7 +462,7 @@ public class Formatter implements Locali
* Returns the locale to use for localizing {@link InternationalString} instances.
* This is <em>not</em> the locale for formatting dates and numbers.
*
- * @return The locale to use for localizing international strings.
+ * @return the locale to use for localizing international strings.
*/
@Override
public final Locale getLocale() {
@@ -521,7 +523,7 @@ public class Formatter implements Locali
* the indentation by the amount of spaces specified at construction time,
* and a value of {@code -1} reduces it by the same amount.
*
- * @param amount +1 for increasing the indentation, or -1 for decreasing it, or 0 for no-op.
+ * @param amount +1 for increasing the indentation, or -1 for decreasing it, or 0 for no-op.
*/
public void indent(final int amount) {
margin = Math.max(0, margin + indentation*amount);
@@ -532,9 +534,9 @@ public class Formatter implements Locali
* This method can be used by {@link FormattableObject#formatTo(Formatter)}
* implementations for choosing the return value.
*
- * @param shortKeyword The keyword to return if the style is {@link KeywordStyle#SHORT}.
- * @param longKeyword The keyword to return if the style is {@link KeywordStyle#LONG}.
- * @return The short or long keyword depending on the keyword style setting.
+ * @param shortKeyword the keyword to return if the style is {@link KeywordStyle#SHORT}.
+ * @param longKeyword the keyword to return if the style is {@link KeywordStyle#LONG}.
+ * @return the short or long keyword depending on the keyword style setting.
*
* @see WKTFormat#setKeywordStyle(KeywordStyle)
*
@@ -567,8 +569,8 @@ public class Formatter implements Locali
/**
* Appends a separator if needed, then opens a new element.
*
- * @param newLine {@code true} for invoking {@link #newLine()} first.
- * @param keyword The element keyword (e.g. {@code "DATUM"}, {@code "AXIS"}, <i>etc</i>).
+ * @param newLine {@code true} for invoking {@link #newLine()} first.
+ * @param keyword the element keyword (e.g. {@code "DATUM"}, {@code "AXIS"}, <i>etc</i>).
*/
private void openElement(final boolean newLine, String keyword) {
if (newLine && buffer.length() != elementStart) {
@@ -585,7 +587,7 @@ public class Formatter implements Locali
/**
* Closes the element opened by {@link #openElement(boolean, String)}.
*
- * @param newLine {@code true} for invoking {@link #newLine()} last.
+ * @param newLine {@code true} for invoking {@link #newLine()} last.
*/
private void closeElement(final boolean newLine) {
buffer.appendCodePoint(symbols.getClosingBracket(0));
@@ -617,7 +619,7 @@ public class Formatter implements Locali
* <tr><td>{@code Remarks[\u2026]}</td> <td></td> <td>{@link ReferenceSystem}, {@link CoordinateOperation}</td></tr>
* </table></blockquote>
*
- * @param object The formattable object to append to the WKT, or {@code null} if none.
+ * @param object the formattable object to append to the WKT, or {@code null} if none.
*/
public void append(final FormattableObject object) {
if (object == null) {
@@ -726,6 +728,7 @@ public class Formatter implements Locali
* A {@code <remark>} can be included within the descriptions of source and target CRS embedded within
* a coordinate transformation as well as within the coordinate transformation itself.</blockquote>
*/
+ @SuppressWarnings("null")
private void appendComplement(final IdentifiedObject object, final FormattableObject parent, final FormattableObject gp) {
isComplement = true;
final boolean showIDs; // Whether to format ID[\u2026] elements.
@@ -779,7 +782,6 @@ public class Formatter implements Locali
appendForSubtypes(object);
}
if (showIDs) {
- @SuppressWarnings("null")
Collection<ReferenceIdentifier> identifiers = object.getIdentifiers();
if (identifiers != null) { // Paranoiac check
if (filterID) {
@@ -848,8 +850,8 @@ public class Formatter implements Locali
* This is because {@code GeographicBoundingBox} does not specify the datum, so this box
* is an approximative information only.
*
- * @param bbox The geographic bounding box to append to the WKT, or {@code null}.
- * @param fractionDigits The number of fraction digits to use. The recommended value is 2.
+ * @param bbox the geographic bounding box to append to the WKT, or {@code null}.
+ * @param fractionDigits the number of fraction digits to use. The recommended value is 2.
*/
public void append(final GeographicBoundingBox bbox, final int fractionDigits) {
if (bbox != null) {
@@ -887,7 +889,7 @@ public class Formatter implements Locali
final double min = range.getMinDouble();
final double max = range.getMaxDouble();
int minimumFractionDigits = Math.max(0, DecimalFunctions.fractionDigitsForDelta(max - min, false));
- int maximumFractionDigits = minimumFractionDigits + 2; // Arbitrarily allow 2 more digits.
+ int maximumFractionDigits = minimumFractionDigits + 2; // Arbitrarily allow 2 more digits.
if (maximumFractionDigits > VERTICAL_ACCURACY) {
maximumFractionDigits = VERTICAL_ACCURACY;
minimumFractionDigits = 0;
@@ -899,8 +901,8 @@ public class Formatter implements Locali
numberFormat.setRoundingMode(RoundingMode.FLOOR); appendPreset(min);
numberFormat.setRoundingMode(RoundingMode.CEILING); appendPreset(max);
final Unit<?> unit = range.unit();
- if (!convention.isSimplified() || !SI.METRE.equals(unit)) {
- append(unit); // Unit are optional if they are metres.
+ if (!convention.isSimplified() || !Units.METRE.equals(unit)) {
+ append(unit); // Unit are optional if they are metres.
}
resetColor();
closeElement(true);
@@ -934,7 +936,7 @@ public class Formatter implements Locali
/**
* Appends the given math transform, typically (but not necessarily) in a {@code PARAM_MT[\u2026]} element.
*
- * @param transform The transform object to append to the WKT, or {@code null} if none.
+ * @param transform the transform object to append to the WKT, or {@code null} if none.
*/
public void append(final MathTransform transform) {
if (transform != null) {
@@ -964,10 +966,10 @@ public class Formatter implements Locali
* </ul>
* </div>
*
- * @param keyword The {@linkplain KeywordCase#CAMEL_CASE camel-case} keyword.
- * Example: {@code "Scope"}, {@code "Area"} or {@code "Remarks"}.
- * @param text The text, or {@code null} if none.
- * @param type The key of the colors to apply if syntax coloring is enabled.
+ * @param keyword the {@linkplain KeywordCase#CAMEL_CASE camel-case} keyword.
+ * Example: {@code "Scope"}, {@code "Area"} or {@code "Remarks"}.
+ * @param text the text, or {@code null} if none.
+ * @param type the key of the colors to apply if syntax coloring is enabled.
*/
private void appendOnNewLine(final String keyword, final InternationalString text, final ElementKind type) {
ArgumentChecks.ensureNonNull("keyword", keyword);
@@ -985,8 +987,8 @@ public class Formatter implements Locali
* Appends a character string between quotes.
* The {@linkplain Symbols#getSeparator() element separator} will be written before the text if needed.
*
- * @param text The string to format to the WKT, or {@code null} if none.
- * @param type The key of the colors to apply if syntax coloring is enabled, or {@code null} if none.
+ * @param text the string to format to the WKT, or {@code null} if none.
+ * @param type the key of the colors to apply if syntax coloring is enabled, or {@code null} if none.
*/
public void append(final String text, final ElementKind type) {
if (text != null) {
@@ -1077,7 +1079,7 @@ public class Formatter implements Locali
* (for example {@code "northEast"}).
* For the WKT 1 format, this method uses the programmatic name instead (for example {@code "NORTH_EAST"}).</p>
*
- * @param code The code list to append to the WKT, or {@code null} if none.
+ * @param code the code list to append to the WKT, or {@code null} if none.
*/
public void append(final CodeList<?> code) {
if (code != null) {
@@ -1098,7 +1100,7 @@ public class Formatter implements Locali
* Appends a date.
* The {@linkplain Symbols#getSeparator() element separator} will be written before the date if needed.
*
- * @param date The date to append to the WKT, or {@code null} if none.
+ * @param date the date to append to the WKT, or {@code null} if none.
*/
public void append(final Date date) {
if (date != null) {
@@ -1111,7 +1113,7 @@ public class Formatter implements Locali
* Appends a boolean value.
* The {@linkplain Symbols#getSeparator() element separator} will be written before the boolean if needed.
*
- * @param value The boolean to append to the WKT.
+ * @param value the boolean to append to the WKT.
*/
public void append(final boolean value) {
appendSeparator();
@@ -1122,7 +1124,7 @@ public class Formatter implements Locali
* Appends an integer value.
* The {@linkplain Symbols#getSeparator() element separator} will be written before the number if needed.
*
- * @param number The integer to append to the WKT.
+ * @param number the integer to append to the WKT.
*/
public void append(final long number) {
appendSeparator();
@@ -1140,7 +1142,7 @@ public class Formatter implements Locali
* Appends an floating point value.
* The {@linkplain Symbols#getSeparator() element separator} will be written before the number if needed.
*
- * @param number The floating point value to append to the WKT.
+ * @param number the floating point value to append to the WKT.
*/
public void append(final double number) {
appendSeparator();
@@ -1222,9 +1224,9 @@ public class Formatter implements Locali
* {@linkplain Convention#WKT2 WKT 2 convention}.
*
* <div class="note"><b>Example:</b>
- * {@code append(SI.KILOMETRE)} will append "{@code LengthUnit["km", 1000]}" to the WKT.</div>
+ * {@code append(Units.KILOMETRE)} will append "{@code LengthUnit["km", 1000]}" to the WKT.</div>
*
- * @param unit The unit to append to the WKT, or {@code null} if none.
+ * @param unit the unit to append to the WKT, or {@code null} if none.
*
* @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#35">WKT 2 specification �7.4</a>
*/
@@ -1232,15 +1234,15 @@ public class Formatter implements Locali
if (unit != null) {
final boolean isSimplified = (longKeywords == 0) ? convention.isSimplified() : (longKeywords < 0);
final boolean isWKT1 = convention.majorVersion() == 1;
- final Unit<?> base = unit.toSI();
+ final Unit<?> base = unit.getSystemUnit();
final String keyword;
- if (base.equals(SI.METRE)) {
+ if (base.equals(Units.METRE)) {
keyword = isSimplified ? WKTKeywords.Unit : WKTKeywords.LengthUnit;
- } else if (base.equals(SI.RADIAN)) {
+ } else if (base.equals(Units.RADIAN)) {
keyword = isSimplified ? WKTKeywords.Unit : WKTKeywords.AngleUnit;
- } else if (base.equals(Unit.ONE)) {
+ } else if (base.equals(Units.UNITY)) {
keyword = isSimplified ? WKTKeywords.Unit : WKTKeywords.ScaleUnit;
- } else if (base.equals(SI.SECOND)) {
+ } else if (base.equals(Units.SECOND)) {
keyword = WKTKeywords.TimeUnit; // "Unit" alone is not allowed for time units according ISO 19162.
} else {
keyword = WKTKeywords.ParametricUnit;
@@ -1252,13 +1254,17 @@ public class Formatter implements Locali
closeQuote(fromIndex);
resetColor();
final double conversion = Units.toStandardUnit(unit);
- appendExact(conversion);
+ if (Double.isNaN(conversion) && Units.isAngular(unit)) {
+ appendExact(Math.PI / 180); // Presume that we have sexagesimal degrees (see below).
+ } else {
+ appendExact(conversion);
+ }
/*
- * The EPSG code in UNIT elements is generally not recommended.
- * But we make an exception for sexagesimal units (EPSG:9108, 9110 and 9111)
- * because they can not be represented by a simple scale factor in WKT.
+ * The EPSG code in UNIT elements is generally not recommended. But we make an exception for sexagesimal
+ * units (EPSG:9108, 9110 and 9111) because they can not be represented by a simple scale factor in WKT.
+ * Those units are identified by a conversion factor set to NaN since the conversion is non-linear.
*/
- if (convention == Convention.INTERNAL || PatchedUnitFormat.toFormattable(unit) != unit) {
+ if (convention == Convention.INTERNAL || Double.isNaN(conversion)) {
final Integer code = Units.getEpsgCode(unit, getEnclosingElement(1) instanceof CoordinateSystemAxis);
if (code != null) {
openElement(false, isWKT1 ? WKTKeywords.Authority : WKTKeywords.Id);
@@ -1295,7 +1301,7 @@ public class Formatter implements Locali
* <li>Otherwise the given value is appended as a quoted text with its {@code toString()} representation.</li>
* </ul>
*
- * @param value The value to append to the WKT, or {@code null}.
+ * @param value the value to append to the WKT, or {@code null}.
*/
public void appendAny(final Object value) {
if (value == null) {
@@ -1382,8 +1388,8 @@ public class Formatter implements Locali
* This method is useful for {@code FormattableObject} which are wrapper around another object.
* It allows to delegate the WKT formatting to the wrapped object.
*
- * @param other The object to format with this formatter.
- * @return The value returned by {@link FormattableObject#formatTo(Formatter)}.
+ * @param other the object to format with this formatter.
+ * @return the value returned by {@link FormattableObject#formatTo(Formatter)}.
*
* @since 0.5
*/
@@ -1400,8 +1406,8 @@ public class Formatter implements Locali
* Returns the enclosing WKT element, or {@code null} if element being formatted is the root.
* This method can be invoked by child elements having some aspects that depend on the enclosing element.
*
- * @param depth 1 for the immediate parent, 2 for the parent of the parent, <i>etc.</i>
- * @return The parent element at the given depth, or {@code null}.
+ * @param depth 1 for the immediate parent, 2 for the parent of the parent, <i>etc.</i>
+ * @return the parent element at the given depth, or {@code null}.
*/
public FormattableObject getEnclosingElement(int depth) {
ArgumentChecks.ensurePositive("depth", depth);
@@ -1418,8 +1424,8 @@ public class Formatter implements Locali
* The main purpose of this method is to allow {@code AXIS[\u2026]} elements to determine if they should
* inherit the unit specified by the enclosing CRS, or if they should specify their unit explicitly.</div>
*
- * @param depth 1 for the immediate parent, 2 for the parent of the parent, <i>etc.</i>
- * @return Whether the parent element at the given depth has invoked {@code addContextualUnit(\u2026)} at least once.
+ * @param depth 1 for the immediate parent, 2 for the parent of the parent, <i>etc.</i>
+ * @return whether the parent element at the given depth has invoked {@code addContextualUnit(\u2026)} at least once.
*/
public boolean hasContextualUnit(final int depth) {
ArgumentChecks.ensurePositive("depth", depth);
@@ -1437,17 +1443,17 @@ public class Formatter implements Locali
* If the WKT conventions are {@code WKT1_COMMON_UNITS}, then this method ignores the given unit
* and returns {@code null}. See {@link Convention#WKT1_COMMON_UNITS} javadoc for more information.
*
- * @param <Q> The unit quantity.
- * @param unit The contextual unit to add, or {@code null} if none.
- * @return The previous contextual unit for quantity {@code Q}, or {@code null} if none.
+ * @param <Q> the unit quantity.
+ * @param unit the contextual unit to add, or {@code null} if none.
+ * @return the previous contextual unit for quantity {@code Q}, or {@code null} if none.
*/
@SuppressWarnings("unchecked")
- public <Q extends Quantity> Unit<Q> addContextualUnit(final Unit<Q> unit) {
+ public <Q extends Quantity<Q>> Unit<Q> addContextualUnit(final Unit<Q> unit) {
if (unit == null || convention.usesCommonUnits) {
return null;
}
hasContextualUnit |= 1;
- return (Unit<Q>) units.put(unit.toSI(), unit);
+ return (Unit<Q>) units.put(unit.getSystemUnit(), unit);
}
/**
@@ -1460,15 +1466,15 @@ public class Formatter implements Locali
* formatter.restoreContextualUnit(unit, previous);
* }
*
- * @param unit The value given in argument to {@code addContextualUnit(unit)} (can be {@code null}).
- * @param previous The value returned by {@code addContextualUnit(unit)} (can be {@code null}).
+ * @param unit the value given in argument to {@code addContextualUnit(unit)} (can be {@code null}).
+ * @param previous the value returned by {@code addContextualUnit(unit)} (can be {@code null}).
* @throws IllegalStateException if this method has not been invoked in the pattern documented above.
*
* @since 0.6
*/
public void restoreContextualUnit(final Unit<?> unit, final Unit<?> previous) {
if (previous == null) {
- if (unit != null && units.remove(unit.toSI()) != unit) {
+ if (unit != null && units.remove(unit.getSystemUnit()) != unit) {
/*
* The unit that we removed was not the expected one. Probably the user has invoked
* addContextualUnit(\u2026) again without a matching call to restoreContextualUnit(\u2026).
@@ -1480,7 +1486,7 @@ public class Formatter implements Locali
}
}
hasContextualUnit &= ~1;
- } else if (units.put(previous.toSI(), previous) != unit) {
+ } else if (units.put(previous.getSystemUnit(), previous) != unit) {
/*
* The unit that we replaced was not the expected one. Probably the user has invoked
* addContextualUnit(\u2026) again without a matching call to restoreContextualUnit(\u2026).
@@ -1497,15 +1503,15 @@ public class Formatter implements Locali
* This method searches for a unit specified by {@link #addContextualUnit(Unit)}
* which {@linkplain Unit#isCompatible(Unit) is compatible} with the given unit.
*
- * @param <Q> The quantity of the unit.
- * @param unit The unit to replace by the contextual unit, or {@code null}.
- * @return A contextual unit compatible with the given unit, or {@code unit}
+ * @param <Q> the quantity of the unit.
+ * @param unit the unit to replace by the contextual unit, or {@code null}.
+ * @return a contextual unit compatible with the given unit, or {@code unit}
* (which may be null) if no contextual unit has been found.
*/
- public <Q extends Quantity> Unit<Q> toContextualUnit(final Unit<Q> unit) {
+ public <Q extends Quantity<Q>> Unit<Q> toContextualUnit(final Unit<Q> unit) {
if (unit != null) {
@SuppressWarnings("unchecked")
- final Unit<Q> candidate = (Unit<Q>) units.get(unit.toSI());
+ final Unit<Q> candidate = (Unit<Q>) units.get(unit.getSystemUnit());
if (candidate != null) {
return candidate;
}
@@ -1547,8 +1553,8 @@ public class Formatter implements Locali
* to format is more complex than what the WKT specification allows.
* Applications can test {@link #isInvalidWKT()} later for checking WKT validity.
*
- * @param unformattable The object that can not be formatted,
- * @param cause The cause for the failure to format, or {@code null} if the cause is not an exception.
+ * @param unformattable the object that can not be formatted,
+ * @param cause the cause for the failure to format, or {@code null} if the cause is not an exception.
*/
public void setInvalidWKT(final IdentifiedObject unformattable, final Exception cause) {
ArgumentChecks.ensureNonNull("unformattable", unformattable);
@@ -1565,8 +1571,8 @@ public class Formatter implements Locali
* This method can be used as an alternative to {@link #setInvalidWKT(IdentifiedObject, Exception)} when the
* problematic object is not an instance of {@code IdentifiedObject}.
*
- * @param unformattable The class of the object that can not be formatted,
- * @param cause The cause for the failure to format, or {@code null} if the cause is not an exception.
+ * @param unformattable the class of the object that can not be formatted,
+ * @param cause the cause for the failure to format, or {@code null} if the cause is not an exception.
*/
public void setInvalidWKT(final Class<?> unformattable, final Exception cause) {
ArgumentChecks.ensureNonNull("unformattable", unformattable);
@@ -1642,7 +1648,7 @@ public class Formatter implements Locali
/**
* Returns the WKT formatted by this object.
*
- * @return The WKT formatted by this formatter.
+ * @return the WKT formatted by this formatter.
*/
public String toWKT() {
return buffer.toString();
@@ -1651,7 +1657,7 @@ public class Formatter implements Locali
/**
* Returns a string representation of this formatter for debugging purpose.
*
- * @return A string representation of this formatter.
+ * @return a string representation of this formatter.
*/
@Debug
@Override
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1767577&r1=1767576&r2=1767577&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Tue Nov 1 21:03:06 2016
@@ -32,15 +32,13 @@ import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.ParseException;
-import javax.measure.unit.Unit;
-import javax.measure.unit.UnitFormat;
-import javax.measure.unit.SI;
-import javax.measure.unit.NonSI;
+import javax.measure.Unit;
import javax.measure.quantity.Angle;
import javax.measure.quantity.Length;
-import javax.measure.quantity.Quantity;
-import javax.measure.quantity.Duration;
-import javax.measure.converter.ConversionException;
+import javax.measure.Quantity;
+import javax.measure.quantity.Time;
+import javax.measure.format.ParserException;
+import javax.measure.IncommensurableException;
import org.opengis.util.Factory;
import org.opengis.metadata.Identifier;
@@ -59,6 +57,7 @@ import org.opengis.referencing.datum.*;
import org.opengis.referencing.operation.*;
import org.apache.sis.measure.Units;
+import org.apache.sis.measure.UnitFormat;
import org.apache.sis.metadata.iso.ImmutableIdentifier;
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.metadata.iso.extent.DefaultExtent;
@@ -93,7 +92,7 @@ import static java.util.Collections.sing
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Johann Sorel (Geomatys)
* @since 0.6
- * @version 0.7
+ * @version 0.8
* @module
*/
class GeodeticObjectParser extends MathTransformParser implements Comparator<CoordinateSystemAxis> {
@@ -133,7 +132,7 @@ class GeodeticObjectParser extends MathT
/**
* During WKT 1 parsing, {@code true} means that {@code PRIMEM} and {@code PARAMETER} angular units
- * need to be forced to {@code NonSI.DEGREE_ANGLE} instead than inferred from the context.
+ * need to be forced to {@code Units.DEGREE} instead than inferred from the context.
* Note that this rule does not apply to {@code AXIS} elements
*
* <p>This flag is ignored during WKT 2 parsing.</p>
@@ -195,9 +194,9 @@ class GeodeticObjectParser extends MathT
* Do not change the method signature even if it doesn't break the compilation, unless the
* reflection code is also updated.</p>
*
- * @param defaultProperties Default properties to give to the object to create.
- * @param factories An object implementing {@link DatumFactory}, {@link CSFactory} and {@link CRSFactory}.
- * @param mtFactory The factory to use to create {@link MathTransform} objects.
+ * @param defaultProperties default properties to give to the object to create.
+ * @param factories an object implementing {@link DatumFactory}, {@link CSFactory} and {@link CRSFactory}.
+ * @param mtFactory the factory to use to create {@link MathTransform} objects.
*/
public GeodeticObjectParser(final Map<String,?> defaultProperties,
final ObjectFactory factories, final MathTransformFactory mtFactory)
@@ -218,14 +217,14 @@ class GeodeticObjectParser extends MathT
* Constructs a parser for the specified set of symbols using the specified set of factories.
* This constructor is for {@link WKTFormat} usage only.
*
- * @param symbols The set of symbols to use.
- * @param fragments Reference to the {@link WKTFormat#fragments} map, or an empty map if none.
- * @param numberFormat The number format provided by {@link WKTFormat}, or {@code null} for a default format.
- * @param dateFormat The date format provided by {@link WKTFormat}, or {@code null} for a default format.
- * @param unitFormat The unit format provided by {@link WKTFormat}, or {@code null} for a default format.
- * @param convention The WKT convention to use.
- * @param errorLocale The locale for error messages (not for parsing), or {@code null} for the system default.
- * @param factories On input, the factories to use. On output, the factories used. Can be null.
+ * @param symbols the set of symbols to use.
+ * @param fragments reference to the {@link WKTFormat#fragments} map, or an empty map if none.
+ * @param numberFormat the number format provided by {@link WKTFormat}, or {@code null} for a default format.
+ * @param dateFormat the date format provided by {@link WKTFormat}, or {@code null} for a default format.
+ * @param unitFormat the unit format provided by {@link WKTFormat}, or {@code null} for a default format.
+ * @param convention the WKT convention to use.
+ * @param errorLocale the locale for error messages (not for parsing), or {@code null} for the system default.
+ * @param factories on input, the factories to use. On output, the factories used. Can be null.
*/
GeodeticObjectParser(final Symbols symbols, final Map<String,Element> fragments,
final NumberFormat numberFormat, final DateFormat dateFormat, final UnitFormat unitFormat,
@@ -275,9 +274,9 @@ class GeodeticObjectParser extends MathT
/**
* Parses a <cite>Well Know Text</cite> (WKT).
*
- * @param text The text to be parsed.
- * @param position The position to start parsing from.
- * @return The parsed object.
+ * @param text the text to be parsed.
+ * @param position the position to start parsing from.
+ * @return the parsed object.
* @throws ParseException if the string can not be parsed.
*/
@Override
@@ -321,8 +320,8 @@ class GeodeticObjectParser extends MathT
/**
* Parses the next element in the specified <cite>Well Know Text</cite> (WKT) tree.
*
- * @param element The element to be parsed.
- * @return The object.
+ * @param element the element to be parsed.
+ * @return the parsed object.
* @throws ParseException if the element can not be parsed.
*/
@Override
@@ -336,8 +335,8 @@ class GeodeticObjectParser extends MathT
return value;
}
Object object;
- if ((object = parseAxis (FIRST, element, null, SI.METRE)) == null &&
- (object = parsePrimeMeridian (FIRST, element, false, NonSI.DEGREE_ANGLE)) == null &&
+ if ((object = parseAxis (FIRST, element, null, Units.METRE )) == null &&
+ (object = parsePrimeMeridian (FIRST, element, false, Units.DEGREE)) == null &&
(object = parseDatum (FIRST, element, null )) == null &&
(object = parseEllipsoid (FIRST, element )) == null &&
(object = parseToWGS84 (FIRST, element )) == null &&
@@ -356,9 +355,9 @@ class GeodeticObjectParser extends MathT
/**
* Parses a coordinate reference system element.
*
- * @param element The parent element.
- * @param mandatory {@code true} if a CRS must be present, or {@code false} if optional.
- * @return The next element as a {@code CoordinateReferenceSystem} object.
+ * @param element the parent element.
+ * @param mandatory {@code true} if a CRS must be present, or {@code false} if optional.
+ * @return the next element as a {@code CoordinateReferenceSystem} object.
* @throws ParseException if the next element can not be parsed.
*/
private CoordinateReferenceSystem parseCoordinateReferenceSystem(final Element element, final boolean mandatory)
@@ -385,10 +384,10 @@ class GeodeticObjectParser extends MathT
/**
* Parses a coordinate reference system wrapped in an element of the given name.
*
- * @param parent The parent element containing the CRS to parse.
+ * @param parent the parent element containing the CRS to parse.
* @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
* @param keyword "SourceCRS", "TargetCRS" or "InterpolationCRS".
- * @return The coordinate reference system, or {@code null} if none.
+ * @return the coordinate reference system, or {@code null} if none.
* @throws ParseException if the CRS can not be parsed.
*/
private CoordinateReferenceSystem parseCoordinateReferenceSystem(final Element parent, final int mode,
@@ -407,8 +406,8 @@ class GeodeticObjectParser extends MathT
* Returns the value associated to {@link IdentifiedObject#IDENTIFIERS_KEY} as an {@code Identifier} object.
* This method shall accept all value types that {@link #parseMetadataAndClose(Element, Object)} may store.
*
- * @param identifier The {@link #properties} value, or {@code null}.
- * @return The identifier, or {@code null} if the given value was null.
+ * @param identifier the {@link #properties} value, or {@code null}.
+ * @return the identifier, or {@code null} if the given value was null.
*/
private static Identifier toIdentifier(final Object identifier) {
return (identifier instanceof Identifier[]) ? ((Identifier[]) identifier)[0] : (Identifier) identifier;
@@ -428,10 +427,10 @@ class GeodeticObjectParser extends MathT
* we will use the name of the enclosed datum. Indeed, it is not uncommon to have the same name for
* a geographic CRS and its geodetic datum.
*
- * @param parent The parent element.
- * @param name The name of the parent object being parsed.
- * @param fallback The fallback to use if {@code name} is empty.
- * @return A properties map with the parent name and the optional authority code.
+ * @param parent the parent element.
+ * @param name the name of the parent object being parsed.
+ * @param fallback the fallback to use if {@code name} is empty.
+ * @return a properties map with the parent name and the optional authority code.
* @throws ParseException if an element can not be parsed.
*/
@SuppressWarnings("ReturnOfCollectionOrArrayField")
@@ -540,9 +539,9 @@ class GeodeticObjectParser extends MathT
while ((element = parent.pullElement(OPTIONAL, WKTKeywords.VerticalExtent)) != null) {
final double minimum = element.pullDouble("minimum");
final double maximum = element.pullDouble("maximum");
- Unit<Length> unit = parseScaledUnit(element, WKTKeywords.LengthUnit, SI.METRE);
+ Unit<Length> unit = parseScaledUnit(element, WKTKeywords.LengthUnit, Units.METRE);
element.close(ignoredElements);
- if (unit == null) unit = SI.METRE;
+ if (unit == null) unit = Units.METRE;
if (extent == null) extent = new DefaultExtent();
verticalElements = new VerticalInfo(verticalElements, extent, minimum, maximum, unit).resolve(verticalCRS);
}
@@ -616,17 +615,17 @@ class GeodeticObjectParser extends MathT
* Unit was a mandatory element in WKT 1, but became optional in WKT 2 because the unit may be specified
* in each {@code AXIS[\u2026]} element instead than for the whole coordinate system.
*
- * @param parent The parent element.
- * @param keyword The unit keyword (e.g. {@code "LengthUnit"} or {@code "AngleUnit"}).
- * @param baseUnit The base unit, usually {@code SI.METRE} or {@code SI.RADIAN}.
- * @return The {@code "UNIT"} element as an {@link Unit} object, or {@code null} if none.
+ * @param parent the parent element.
+ * @param keyword the unit keyword (e.g. {@code "LengthUnit"} or {@code "AngleUnit"}).
+ * @param baseUnit the base unit, usually {@code Units.METRE} or {@code Units.RADIAN}.
+ * @return the {@code "UNIT"} element as an {@link Unit} object, or {@code null} if none.
* @throws ParseException if the {@code "UNIT"} can not be parsed.
*
* @todo Authority code is currently discarded after parsing. We may consider to create a subclass of
* {@link Unit} which implements {@link IdentifiedObject} in a future version.
*/
@SuppressWarnings("unchecked")
- private <Q extends Quantity> Unit<Q> parseScaledUnit(final Element parent,
+ private <Q extends Quantity<Q>> Unit<Q> parseScaledUnit(final Element parent,
final String keyword, final Unit<Q> baseUnit) throws ParseException
{
final Element element = parent.pullElement(OPTIONAL, keyword, WKTKeywords.Unit);
@@ -635,18 +634,18 @@ class GeodeticObjectParser extends MathT
}
final String name = element.pullString("name");
final double factor = element.pullDouble("factor");
- Unit<Q> unit = Units.multiply(baseUnit, factor);
+ Unit<Q> unit = baseUnit.multiply(factor);
Unit<?> verify = parseUnitID(element);
element.close(ignoredElements);
/*
- * Consider the following element: UNIT[\u201ckm\u201d, 1000, ID[\u201cEPSG\u201d, \u201c9036\u201d]]
+ * Consider the following element: UNIT[\u201ckilometre\u201d, 1000, ID[\u201cEPSG\u201d, \u201c9036\u201d]]
*
* - if the authority code (\u201c9036\u201d) refers to a unit incompatible with 'baseUnit' (\u201cmetre\u201d), log a warning.
* - otherwise: 1) unconditionally replace the parsed unit (\u201ckm\u201d) by the unit referenced by the authority code.
* 2) if the new unit is not equivalent to the old one (i.e. different scale factor), log a warning.
*/
if (verify != null) {
- if (!baseUnit.toSI().equals(verify.toSI())) {
+ if (!baseUnit.getSystemUnit().equals(verify.getSystemUnit())) {
warning(parent, element, Errors.formatInternational(Errors.Keys.InconsistentUnitsForCS_1, verify), null);
} else if (Math.abs(unit.getConverterTo(unit = (Unit<Q>) verify).convert(1) - 1) > Numerics.COMPARISON_THRESHOLD) {
warning(parent, element, Errors.formatInternational(Errors.Keys.UnexpectedScaleFactorForUnit_2, verify, factor), null);
@@ -662,14 +661,14 @@ class GeodeticObjectParser extends MathT
if (verify == null) {
try {
verify = parseUnit(name);
- } catch (IllegalArgumentException | ParseException e) {
+ } catch (ParserException e) {
log(new LogRecord(Level.FINE, e.toString()));
}
if (verify != null) try {
if (Math.abs(verify.getConverterToAny(unit).convert(1) - 1) > Numerics.COMPARISON_THRESHOLD) {
warning(parent, element, Errors.formatInternational(Errors.Keys.UnexpectedScaleFactorForUnit_2, verify, factor), null);
}
- } catch (ConversionException e) {
+ } catch (IncommensurableException e) {
throw (ParseException) new LocalizedParseException(errorLocale,
Errors.Keys.InconsistentUnitsForCS_1, new Object[] {verify}, element.offset).initCause(e);
}
@@ -707,13 +706,13 @@ class GeodeticObjectParser extends MathT
* <li>Otherwise if {@code dimension is 3}, then the CS is assumed to be for a geocentric CRS.</li>
* </ul>
*
- * @param parent The parent element.
- * @param type The expected type (Cartesian | ellipsoidal | vertical | etc\u2026), or null�if unknown.
- * @param dimension The minimal number of dimensions. Can be 1 if unknown.
- * @param isWKT1 {@code true} if the parent element is an element from the WKT 1 standard.
- * @param defaultUnit The contextual unit (usually {@code SI.METRE} or {@code SI.RADIAN}), or {@code null} if unknown.
- * @param datum The datum of the enclosing CRS, or {@code null} if unknown.
- * @return The {@code "CS"}, {@code "UNIT"} and/or {@code "AXIS"} elements as a Coordinate System, or {@code null}.
+ * @param parent the parent element.
+ * @param type the expected type (Cartesian | ellipsoidal | vertical | etc\u2026), or null�if unknown.
+ * @param dimension the minimal number of dimensions. Can be 1 if unknown.
+ * @param isWKT1 {@code true} if the parent element is an element from the WKT 1 standard.
+ * @param defaultUnit the contextual unit (usually {@code Units.METRE} or {@code Units.RADIAN}), or {@code null} if unknown.
+ * @param datum the datum of the enclosing CRS, or {@code null} if unknown.
+ * @return the {@code "CS"}, {@code "UNIT"} and/or {@code "AXIS"} elements as a Coordinate System, or {@code null}.
* @throws ParseException if an element can not be parsed.
* @throws FactoryException if the factory can not create the coordinate system.
*/
@@ -816,7 +815,7 @@ class GeodeticObjectParser extends MathT
if (dimension >= 3) { // Non-standard but SIS is tolerant to this case.
z = "h";
nz = AxisNames.ELLIPSOIDAL_HEIGHT;
- unit = SI.METRE;
+ unit = Units.METRE;
}
break;
}
@@ -842,7 +841,7 @@ class GeodeticObjectParser extends MathT
direction = AxisDirection.UP;
z = "h";
nz = AxisNames.ELLIPSOIDAL_HEIGHT;
- unit = SI.METRE;
+ unit = Units.METRE;
}
break;
}
@@ -1014,12 +1013,12 @@ class GeodeticObjectParser extends MathT
* AXIS["Easting (E(X))", EAST]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param csType The coordinate system type (Cartesian | ellipsoidal | vertical | etc\u2026), or null�if unknown.
- * @param defaultUnit The contextual unit (usually {@code SI.METRE} or {@code SI.RADIAN}), or {@code null} if unknown.
- * @return The {@code "AXIS"} element as a {@link CoordinateSystemAxis} object, or {@code null}
- * if the axis was not required and there is no axis object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param csType the coordinate system type (Cartesian | ellipsoidal | vertical | etc\u2026), or null�if unknown.
+ * @param defaultUnit the contextual unit (usually {@code Units.METRE} or {@code Units.RADIAN}), or {@code null} if unknown.
+ * @return the {@code "AXIS"} element as a {@link CoordinateSystemAxis} object,
+ * or {@code null} if the axis was not required and there is no axis object.
* @throws ParseException if the {@code "AXIS"} element can not be parsed.
*/
private CoordinateSystemAxis parseAxis(final int mode, final Element parent, final String csType,
@@ -1049,10 +1048,10 @@ class GeodeticObjectParser extends MathT
final Element meridian = element.pullElement(OPTIONAL, WKTKeywords.Meridian);
if (meridian != null) {
double angle = meridian.pullDouble("meridian");
- final Unit<Angle> m = parseScaledUnit(meridian, WKTKeywords.AngleUnit, SI.RADIAN);
+ final Unit<Angle> m = parseScaledUnit(meridian, WKTKeywords.AngleUnit, Units.RADIAN);
meridian.close(ignoredElements);
if (m != null) {
- angle = m.getConverterTo(NonSI.DEGREE_ANGLE).convert(angle);
+ angle = m.getConverterTo(Units.DEGREE).convert(angle);
}
direction = referencing.directionAlongMeridian(direction, angle);
}
@@ -1120,8 +1119,8 @@ class GeodeticObjectParser extends MathT
* some axes have an {@code ORDER} element (which is illegal according ISO 19162), then those axes will
* be sorted before the axes without {@code ORDER} element.
*
- * @param o1 The first axis to compare.
- * @param o2 The second axis to compare.
+ * @param o1 the first axis to compare.
+ * @param o2 the second axis to compare.
* @return -1 if {@code o1} should be before {@code o2},
* +1 if {@code o2} should be before {@code o1}, or
* 0 if undetermined (no axis order change).
@@ -1151,11 +1150,11 @@ class GeodeticObjectParser extends MathT
* PRIMEM["<name>", <longitude> {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isWKT1 {@code true} if this method is invoked while parsing a WKT 1 element.
- * @param angularUnit The contextual unit.
- * @return The {@code "PrimeMeridian"} element as a {@link PrimeMeridian} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isWKT1 {@code true} if this method is invoked while parsing a WKT 1 element.
+ * @param angularUnit the contextual unit.
+ * @return the {@code "PrimeMeridian"} element as a {@link PrimeMeridian} object.
* @throws ParseException if the {@code "PrimeMeridian"} element can not be parsed.
*
* @see org.apache.sis.referencing.datum.DefaultPrimeMeridian#formatTo(Formatter)
@@ -1164,7 +1163,7 @@ class GeodeticObjectParser extends MathT
throws ParseException
{
if (isWKT1 && usesCommonUnits) {
- angularUnit = NonSI.DEGREE_ANGLE;
+ angularUnit = Units.DEGREE;
}
final Element element = parent.pullElement(mode, WKTKeywords.PrimeMeridian, WKTKeywords.PrimeM);
if (element == null) {
@@ -1172,7 +1171,7 @@ class GeodeticObjectParser extends MathT
}
final String name = element.pullString("name");
final double longitude = element.pullDouble("longitude");
- final Unit<Angle> unit = parseScaledUnit(element, WKTKeywords.AngleUnit, SI.RADIAN);
+ final Unit<Angle> unit = parseScaledUnit(element, WKTKeywords.AngleUnit, Units.RADIAN);
if (unit != null) {
angularUnit = unit;
} else if (angularUnit == null) {
@@ -1193,9 +1192,9 @@ class GeodeticObjectParser extends MathT
* TOWGS84[<dx>, <dy>, <dz>, <ex>, <ey>, <ez>, <ppm>]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "TOWGS84"} element as a {@link org.apache.sis.referencing.datum.BursaWolfParameters} object,
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "TOWGS84"} element as a {@link org.apache.sis.referencing.datum.BursaWolfParameters} object,
* or {@code null} if no {@code "TOWGS84"} has been found.
* @throws ParseException if the {@code "TOWGS84"} can not be parsed.
*/
@@ -1225,9 +1224,9 @@ class GeodeticObjectParser extends MathT
* SPHEROID["<name>", <semi-major axis>, <inverse flattening> {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "Ellipsoid"} element as an {@link Ellipsoid} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "Ellipsoid"} element as an {@link Ellipsoid} object.
* @throws ParseException if the {@code "Ellipsoid"} element can not be parsed.
*
* @see org.apache.sis.referencing.datum.DefaultEllipsoid#formatTo(Formatter)
@@ -1240,9 +1239,9 @@ class GeodeticObjectParser extends MathT
final String name = element.pullString("name");
final double semiMajorAxis = element.pullDouble("semiMajorAxis");
double inverseFlattening = element.pullDouble("inverseFlattening");
- Unit<Length> unit = parseScaledUnit(element, WKTKeywords.LengthUnit, SI.METRE);
+ Unit<Length> unit = parseScaledUnit(element, WKTKeywords.LengthUnit, Units.METRE);
if (unit == null) {
- unit = SI.METRE;
+ unit = Units.METRE;
}
final Map<String,?> properties = parseMetadataAndClose(element, name, null);
try {
@@ -1272,9 +1271,9 @@ class GeodeticObjectParser extends MathT
/**
* Parses a {@code "Method"} (WKT 2) element, without the parameters.
*
- * @param parent The parent element.
- * @param keywords The element keywords.
- * @return The operation method.
+ * @param parent the parent element.
+ * @param keywords the element keywords.
+ * @return the operation method.
* @throws ParseException if the {@code "Method"} element can not be parsed.
*/
private OperationMethod parseMethod(final Element parent, final String... keywords) throws ParseException {
@@ -1321,12 +1320,12 @@ class GeodeticObjectParser extends MathT
* element which is itself inside the {@code ProjectedCRS} element. This is different than WKT 1, which
* puts this element right into the the {@code ProjectedCRS} element without {@code Conversion} wrapper.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param wrapper "Conversion" or "DerivingConversion" wrapper name, or null if parsing a WKT 1.
- * @param defaultUnit The unit (usually linear) of the parent element, or {@code null}.
- * @param defaultAngularUnit The angular unit of the sibling {@code GeographicCRS} element, or {@code null}.
- * @return The {@code "Method"} element and its parameters as a defining conversion.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param wrapper "Conversion" or "DerivingConversion" wrapper name, or null if parsing a WKT 1.
+ * @param defaultUnit the unit (usually linear) of the parent element, or {@code null}.
+ * @param defaultAngularUnit the angular unit of the sibling {@code GeographicCRS} element, or {@code null}.
+ * @return the {@code "Method"} element and its parameters as a defining conversion.
* @throws ParseException if the {@code "Method"} element can not be parsed.
*/
private Conversion parseDerivingConversion(final int mode, Element parent, final String wrapper,
@@ -1391,10 +1390,10 @@ class GeodeticObjectParser extends MathT
* DATUM["<name>", <spheroid> {,<to wgs84>} {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param meridian the prime meridian, or {@code null} for Greenwich.
- * @return The {@code "Datum"} element as a {@link GeodeticDatum} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param meridian the prime meridian, or {@code null} for Greenwich.
+ * @return the {@code "Datum"} element as a {@link GeodeticDatum} object.
* @throws ParseException if the {@code "Datum"} element can not be parsed.
*
* @see org.apache.sis.referencing.datum.DefaultGeodeticDatum#formatTo(Formatter)
@@ -1431,10 +1430,10 @@ class GeodeticObjectParser extends MathT
* VERT_DATUM["<name>", <datum type> {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isWKT1 {@code true} if the parent is a WKT 1 element.
- * @return The {@code "VerticalDatum"} element as a {@link VerticalDatum} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isWKT1 {@code true} if the parent is a WKT 1 element.
+ * @return the {@code "VerticalDatum"} element as a {@link VerticalDatum} object.
* @throws ParseException if the {@code "VerticalDatum"} element can not be parsed.
*/
private VerticalDatum parseVerticalDatum(final int mode, final Element parent, final boolean isWKT1)
@@ -1469,9 +1468,9 @@ class GeodeticObjectParser extends MathT
* TimeDatum["<name>", TimeOrigin[<time origin>] {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "TimeDatum"} element as a {@link TemporalDatum} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "TimeDatum"} element as a {@link TemporalDatum} object.
* @throws ParseException if the {@code "TimeDatum"} element can not be parsed.
*/
private TemporalDatum parseTimeDatum(final int mode, final Element parent) throws ParseException {
@@ -1497,9 +1496,9 @@ class GeodeticObjectParser extends MathT
* ParametricDatum["<name>", Anchor[...] {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "ParametricDatum"} element as a {@link ParametricDatum} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "ParametricDatum"} element as a {@link ParametricDatum} object.
* @throws ParseException if the {@code "ParametricDatum"} element can not be parsed.
*/
private Datum parseParametricDatum(final int mode, final Element parent) throws ParseException {
@@ -1527,10 +1526,10 @@ class GeodeticObjectParser extends MathT
*
* The datum type (WKT 1 only) is currently ignored.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isWKT1 {@code true} if the parent is a WKT 1 element.
- * @return The {@code "EngineeringDatum"} element as an {@link EngineeringDatum} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isWKT1 {@code true} if the parent is a WKT 1 element.
+ * @return the {@code "EngineeringDatum"} element as an {@link EngineeringDatum} object.
* @throws ParseException if the {@code "EngineeringDatum"} element can not be parsed.
*/
private EngineeringDatum parseEngineeringDatum(final int mode, final Element parent, final boolean isWKT1) throws ParseException {
@@ -1556,9 +1555,9 @@ class GeodeticObjectParser extends MathT
* Parses an {@code "ImageDatum"} (WKT 2) element. The syntax is given by
* <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#81">WKT 2 specification �12.2</a>.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "ImageDatum"} element as an {@link ImageDatum} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "ImageDatum"} element as an {@link ImageDatum} object.
* @throws ParseException if the {@code "ImageDatum"} element can not be parsed.
*/
private ImageDatum parseImageDatum(final int mode, final Element parent) throws ParseException {
@@ -1586,10 +1585,10 @@ class GeodeticObjectParser extends MathT
* LOCAL_CS["<name>", <local datum>, <unit>, <axis>, {,<axis>}* {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
- * @return The {@code "EngineeringCRS"} element as an {@link EngineeringCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
+ * @return the {@code "EngineeringCRS"} element as an {@link EngineeringCRS} object.
* @throws ParseException if the {@code "EngineeringCRS"} element can not be parsed.
*/
private SingleCRS parseEngineeringCRS(final int mode, final Element parent, final boolean isBaseCRS)
@@ -1659,9 +1658,9 @@ class GeodeticObjectParser extends MathT
* Parses an {@code "ImageCRS"} (WKT 2) element. The syntax is given by
* <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#79">WKT 2 specification �12</a>.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "ImageCRS"} element as an {@link ImageCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "ImageCRS"} element as an {@link ImageCRS} object.
* @throws ParseException if the {@code "ImageCRS"} element can not be parsed.
*/
private ImageCRS parseImageCRS(final int mode, final Element parent) throws ParseException {
@@ -1701,12 +1700,12 @@ class GeodeticObjectParser extends MathT
* GEOCCS["<name>", <datum>, <prime meridian>, <linear unit> {,<axis> ,<axis> ,<axis>} {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param dimension The minimal number of dimensions (usually 2).
- * @param csType The default coordinate system type, or {@code null} if unknown.
- * Should be non-null only when parsing a {@link GeneralDerivedCRS#getBaseCRS()} component.
- * @return The {@code "GeodeticCRS"} element as a {@link GeographicCRS} or {@link GeocentricCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param dimension the minimal number of dimensions (usually 2).
+ * @param csType the default coordinate system type, or {@code null} if unknown.
+ * Should be non-null only when parsing a {@link GeneralDerivedCRS#getBaseCRS()} component.
+ * @return the {@code "GeodeticCRS"} element as a {@link GeographicCRS} or {@link GeocentricCRS} object.
* @throws ParseException if the {@code "GeodeticCRS"} element can not be parsed.
*
* @see org.apache.sis.referencing.crs.DefaultGeographicCRS#formatTo(Formatter)
@@ -1751,7 +1750,7 @@ class GeodeticObjectParser extends MathT
if (Units.isAngular(csUnit)) {
angularUnit = csUnit.asType(Angle.class);
} else {
- angularUnit = NonSI.DEGREE_ANGLE;
+ angularUnit = Units.DEGREE;
if (csUnit == null) {
/*
* A UNIT[\u2026] is mandatory either in the CoordinateSystem as a whole (csUnit != null),
@@ -1760,7 +1759,7 @@ class GeodeticObjectParser extends MathT
* We recognize those cases by a non-null 'csType' given in argument to this method.
*/
if (WKTKeywords.ellipsoidal.equals(csType)) {
- csUnit = NonSI.DEGREE_ANGLE; // For BaseGeodCRS in ProjectedCRS.
+ csUnit = Units.DEGREE; // For BaseGeodCRS in ProjectedCRS.
}
}
}
@@ -1772,7 +1771,7 @@ class GeodeticObjectParser extends MathT
*/
isWKT1 = true;
csType = WKTKeywords.ellipsoidal;
- angularUnit = parseScaledUnit(element, WKTKeywords.AngleUnit, SI.RADIAN);
+ angularUnit = parseScaledUnit(element, WKTKeywords.AngleUnit, Units.RADIAN);
csUnit = angularUnit;
dimension = 2;
break;
@@ -1783,8 +1782,8 @@ class GeodeticObjectParser extends MathT
*/
isWKT1 = true;
csType = WKTKeywords.Cartesian;
- angularUnit = NonSI.DEGREE_ANGLE;
- csUnit = parseScaledUnit(element, WKTKeywords.LengthUnit, SI.METRE);
+ angularUnit = Units.DEGREE;
+ csUnit = parseScaledUnit(element, WKTKeywords.LengthUnit, Units.METRE);
dimension = 3;
break;
}
@@ -1868,10 +1867,10 @@ class GeodeticObjectParser extends MathT
* VERT_CS["<name>", <vert datum>, <linear unit>, {<axis>,} {,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
- * @return The {@code "VerticalCRS"} element as a {@link VerticalCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
+ * @return the {@code "VerticalCRS"} element as a {@link VerticalCRS} object.
* @throws ParseException if the {@code "VerticalCRS"} element can not be parsed.
*/
@SuppressWarnings("null")
@@ -1953,10 +1952,10 @@ class GeodeticObjectParser extends MathT
/**
* Parses {@code "TimeCRS"} element.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
- * @return The {@code "TimeCRS"} element as a {@link TemporalCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
+ * @return the {@code "TimeCRS"} element as a {@link TemporalCRS} object.
* @throws ParseException if the {@code "TimeCRS"} element can not be parsed.
*/
private SingleCRS parseTimeCRS(final int mode, final Element parent, final boolean isBaseCRS)
@@ -1966,8 +1965,8 @@ class GeodeticObjectParser extends MathT
if (element == null) {
return null;
}
- final String name = element.pullString("name");
- final Unit<Duration> unit = parseScaledUnit(element, WKTKeywords.TimeUnit, SI.SECOND);
+ final String name = element.pullString("name");
+ final Unit<Time> unit = parseScaledUnit(element, WKTKeywords.TimeUnit, Units.SECOND);
/*
* A TemporalCRS can be either a "normal" one (with a non-null datum), or a DerivedCRS of kind TemporalCRS.
* In the later case, the datum is null and we have instead DerivingConversion element from a BaseTimeCRS.
@@ -2013,10 +2012,10 @@ class GeodeticObjectParser extends MathT
/**
* Parses {@code "ParametricCRS"} element.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
- * @return The {@code "ParametricCRS"} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
+ * @return the {@code "ParametricCRS"} object.
* @throws ParseException if the {@code "ParametricCRS"} element can not be parsed.
*/
private SingleCRS parseParametricCRS(final int mode, final Element parent, final boolean isBaseCRS)
@@ -2081,10 +2080,10 @@ class GeodeticObjectParser extends MathT
* <linear unit> {,<twin axes>}{,<authority>}]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
- * @return The {@code "ProjectedCRS"} element as a {@link ProjectedCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @param isBaseCRS {@code true} if parsing the CRS inside a {@code DerivedCRS}.
+ * @return the {@code "ProjectedCRS"} element as a {@link ProjectedCRS} object.
* @throws ParseException if the {@code "ProjectedCRS"} element can not be parsed.
*/
private ProjectedCRS parseProjectedCRS(final int mode, final Element parent, final boolean isBaseCRS)
@@ -2116,15 +2115,15 @@ class GeodeticObjectParser extends MathT
* - lengths shall be given in the unit for the projected CRS axes.
* - angles shall be given in the unit for the base geographic CRS of the projected CRS.
*/
- Unit<Length> csUnit = parseScaledUnit(element, WKTKeywords.LengthUnit, SI.METRE);
+ Unit<Length> csUnit = parseScaledUnit(element, WKTKeywords.LengthUnit, Units.METRE);
final Unit<Length> linearUnit;
final Unit<Angle> angularUnit;
if (isWKT1 && usesCommonUnits) {
- linearUnit = SI.METRE;
- angularUnit = NonSI.DEGREE_ANGLE;
+ linearUnit = Units.METRE;
+ angularUnit = Units.DEGREE;
} else {
linearUnit = csUnit;
- angularUnit = AxisDirections.getAngularUnit(geoCRS.getCoordinateSystem(), NonSI.DEGREE_ANGLE);
+ angularUnit = AxisDirections.getAngularUnit(geoCRS.getCoordinateSystem(), Units.DEGREE);
}
final Conversion conversion = parseDerivingConversion(MANDATORY, element,
isWKT1 ? null : WKTKeywords.Conversion, linearUnit, angularUnit);
@@ -2137,7 +2136,7 @@ class GeodeticObjectParser extends MathT
* in the WKT of base CRS. In this case only, we will default to metre.
*/
if (csUnit == null && isBaseCRS) {
- csUnit = SI.METRE;
+ csUnit = Units.METRE;
}
final CoordinateSystem cs;
try {
@@ -2165,9 +2164,9 @@ class GeodeticObjectParser extends MathT
* In the particular case where there is a geographic CRS and an ellipsoidal height,
* this method rather build a three-dimensional geographic CRS.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "CompoundCRS"} element as a {@link CompoundCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "CompoundCRS"} element as a {@link CompoundCRS} object.
* @throws ParseException if the {@code "CompoundCRS"} element can not be parsed.
*/
private CoordinateReferenceSystem parseCompoundCRS(final int mode, final Element parent) throws ParseException {
@@ -2197,9 +2196,9 @@ class GeodeticObjectParser extends MathT
* FITTED_CS["<name>", <to base>, <base cs>]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "FITTED_CS"} element as a {@link CompoundCRS} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "FITTED_CS"} element as a {@link CompoundCRS} object.
* @throws ParseException if the {@code "COMPD_CS"} element can not be parsed.
*/
private DerivedCRS parseFittedCS(final int mode, final Element parent) throws ParseException {
@@ -2230,7 +2229,7 @@ class GeodeticObjectParser extends MathT
buffer.append(number);
axes[i] = csFactory.createCoordinateSystemAxis(
singletonMap(CoordinateSystemAxis.NAME_KEY, buffer.toString()),
- number, AxisDirection.OTHER, Unit.ONE);
+ number, AxisDirection.OTHER, Units.UNITY);
}
final Map<String,Object> properties = parseMetadataAndClose(element, name, baseCRS);
final CoordinateSystem derivedCS = referencing.createAbstractCS(
@@ -2250,9 +2249,9 @@ class GeodeticObjectParser extends MathT
* Parses a {@code "CoordinateOperation"} element. The syntax is given by
* <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#113">WKT 2 specification �17</a>.
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "CoordinateOperation"} element as a {@link CoordinateOperation} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "CoordinateOperation"} element as a {@link CoordinateOperation} object.
* @throws ParseException if the {@code "CoordinateOperation"} element can not be parsed.
*/
private CoordinateOperation parseOperation(final int mode, final Element parent) throws ParseException {
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java?rev=1767577&r1=1767576&r2=1767577&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] Tue Nov 1 21:03:06 2016
@@ -22,10 +22,9 @@ import java.util.Locale;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParseException;
-import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
-import javax.measure.unit.UnitFormat;
+import javax.measure.Unit;
import javax.measure.quantity.Angle;
+import javax.measure.format.ParserException;
import org.opengis.util.FactoryException;
import org.opengis.util.NoSuchIdentifierException;
import org.opengis.parameter.ParameterValue;
@@ -43,6 +42,7 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.internal.util.LocalizedParseException;
import org.apache.sis.internal.util.Constants;
import org.apache.sis.measure.Units;
+import org.apache.sis.measure.UnitFormat;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.resources.Errors;
@@ -57,7 +57,7 @@ import static org.apache.sis.util.Argume
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Rueben Schulz (UBC)
* @since 0.6
- * @version 0.6
+ * @version 0.8
* @module
*
* @see <a href="http://www.geoapi.org/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html">Well Know Text specification</a>
@@ -82,7 +82,7 @@ class MathTransformParser extends Abstra
* For each {@code UNIT_KEYWORDS[i]} element, the associated base unit is {@code BASE_UNIT[i]}.
*/
private static final Unit<?>[] BASE_UNITS = {
- SI.METRE, SI.RADIAN, Unit.ONE, SI.SECOND
+ Units.METRE, Units.RADIAN, Units.UNITY, Units.SECOND
};
/**
@@ -110,7 +110,7 @@ class MathTransformParser extends Abstra
* Do not change the method signature even if it doesn't break the compilation, unless the reflection code
* is also updated.</p>
*
- * @param mtFactory The factory to use to create {@link MathTransform} objects.
+ * @param mtFactory the factory to use to create {@link MathTransform} objects.
*/
public MathTransformParser(final MathTransformFactory mtFactory) {
this(Symbols.getDefault(), Collections.<String,Element>emptyMap(), null, null, null, mtFactory, null);
@@ -119,13 +119,13 @@ class MathTransformParser extends Abstra
/**
* Creates a parser using the specified set of symbols and factory.
*
- * @param symbols The set of symbols to use.
- * @param fragments Reference to the {@link WKTFormat#fragments} map, or an empty map if none.
- * @param numberFormat The number format provided by {@link WKTFormat}, or {@code null} for a default format.
- * @param dateFormat The date format provided by {@link WKTFormat}, or {@code null} for a default format.
- * @param unitFormat The unit format provided by {@link WKTFormat}, or {@code null} for a default format.
- * @param mtFactory The factory to use to create {@link MathTransform} objects.
- * @param errorLocale The locale for error messages (not for parsing), or {@code null} for the system default.
+ * @param symbols the set of symbols to use.
+ * @param fragments reference to the {@link WKTFormat#fragments} map, or an empty map if none.
+ * @param numberFormat the number format provided by {@link WKTFormat}, or {@code null} for a default format.
+ * @param dateFormat the date format provided by {@link WKTFormat}, or {@code null} for a default format.
+ * @param unitFormat the unit format provided by {@link WKTFormat}, or {@code null} for a default format.
+ * @param mtFactory the factory to use to create {@link MathTransform} objects.
+ * @param errorLocale the locale for error messages (not for parsing), or {@code null} for the system default.
*/
MathTransformParser(final Symbols symbols, final Map<String,Element> fragments,
final NumberFormat numberFormat, final DateFormat dateFormat, final UnitFormat unitFormat,
@@ -148,8 +148,8 @@ class MathTransformParser extends Abstra
/**
* Parses the next element in the specified <cite>Well Know Text</cite> (WKT) tree.
*
- * @param element The element to be parsed.
- * @return The parsed object, or {@code null} if the element is not recognized.
+ * @param element the element to be parsed.
+ * @return the parsed object, or {@code null} if the element is not recognized.
* @throws ParseException if the element can not be parsed.
*/
@Override
@@ -160,9 +160,9 @@ class MathTransformParser extends Abstra
/**
* Parses the next {@code MathTransform} in the specified <cite>Well Know Text</cite> (WKT) tree.
*
- * @param element The parent element.
- * @param mandatory {@code true} if a math transform must be present, or {@code false} if optional.
- * @return The next element as a {@code MathTransform} object, or {@code null}.
+ * @param element the parent element.
+ * @param mandatory {@code true} if a math transform must be present, or {@code false} if optional.
+ * @return the next element as a {@code MathTransform} object, or {@code null}.
* @throws ParseException if the next element can not be parsed.
*/
final MathTransform parseMathTransform(final Element element, final boolean mandatory) throws ParseException {
@@ -195,8 +195,8 @@ class MathTransformParser extends Abstra
* and 9111) can hardly be expressed in an other way than by their EPSG code. Thankfully, identifiers in
* {@code UNIT} elements are rare, so risk of conflicts should be low.</div>
*
- * @param parent The parent {@code "UNIT"} element.
- * @return The unit from the identifier code, or {@code null} if none.
+ * @param parent the parent {@code "UNIT"} element.
+ * @return the unit from the identifier code, or {@code null} if none.
* @throws ParseException if the {@code "ID"} can not be parsed.
*/
final Unit<?> parseUnitID(final Element parent) throws ParseException {
@@ -224,8 +224,8 @@ class MathTransformParser extends Abstra
* Parses an optional {@code "UNIT"} element of unknown dimension.
* This method tries to infer the quantity dimension from the unit keyword.
*
- * @param parent The parent element.
- * @return The {@code "UNIT"} element, or {@code null} if none.
+ * @param parent the parent element.
+ * @return the {@code "UNIT"} element, or {@code null} if none.
* @throws ParseException if the {@code "UNIT"} can not be parsed.
*/
final Unit<?> parseUnit(final Element parent) throws ParseException {
@@ -242,12 +242,12 @@ class MathTransformParser extends Abstra
return unit;
}
if (index >= 0 && index < BASE_UNITS.length) {
- return Units.multiply(BASE_UNITS[index], factor);
+ return BASE_UNITS[index].multiply(factor);
}
// If we can not infer the base type, we have to rely on the name.
try {
return parseUnit(name);
- } catch (IllegalArgumentException e) {
+ } catch (ParserException e) {
throw (ParseException) new LocalizedParseException(errorLocale,
Errors.Keys.UnknownUnit_1, new Object[] {name}, element.offset).initCause(e);
}
@@ -256,17 +256,17 @@ class MathTransformParser extends Abstra
/**
* Parses a sequence of {@code "PARAMETER"} elements.
*
- * @param element The parent element containing the parameters to parse.
- * @param parameters The group where to store the parameter values.
- * @param defaultUnit The default unit (for arbitrary quantity, including angular), or {@code null}.
- * @param defaultAngularUnit The default angular unit, or {@code null} if none. This is determined by the
- * context, especially when {@link GeodeticObjectParser} parses a {@code ProjectedCRS} element.
+ * @param element the parent element containing the parameters to parse.
+ * @param parameters the group where to store the parameter values.
+ * @param defaultUnit the default unit (for arbitrary quantity, including angular), or {@code null}.
+ * @param defaultAngularUnit the default angular unit, or {@code null} if none. This is determined by the context,
+ * especially when {@link GeodeticObjectParser} parses a {@code ProjectedCRS} element.
* @throws ParseException if the {@code "PARAMETER"} element can not be parsed.
*/
final void parseParameters(final Element element, final ParameterValueGroup parameters,
final Unit<?> defaultUnit, final Unit<Angle> defaultAngularUnit) throws ParseException
{
- final Unit<?> defaultSI = (defaultUnit != null) ? defaultUnit.toSI() : null;
+ final Unit<?> defaultSI = (defaultUnit != null) ? defaultUnit.getSystemUnit(): null;
Element param = element;
try {
while ((param = element.pullElement(OPTIONAL, WKTKeywords.Parameter)) != null) {
@@ -287,10 +287,10 @@ class MathTransformParser extends Abstra
if (isNumeric && unit == null) {
unit = descriptor.getUnit();
if (unit != null) {
- final Unit<?> si = unit.toSI();
+ final Unit<?> si = unit.getSystemUnit();
if (si.equals(defaultSI)) {
unit = defaultUnit;
- } else if (si.equals(SI.RADIAN)) {
+ } else if (si.equals(Units.RADIAN)) {
unit = defaultAngularUnit;
}
}
@@ -325,8 +325,8 @@ class MathTransformParser extends Abstra
* PARAM_MT["<classification-name>" {,<parameter>}* ]
* }
*
- * @param parent The parent element.
- * @return The {@code "PARAM_MT"} element as an {@link MathTransform} object.
+ * @param parent the parent element.
+ * @return the {@code "PARAM_MT"} element as an {@link MathTransform} object.
* @throws ParseException if the {@code "PARAM_MT"} element can not be parsed.
*/
private MathTransform parseParamMT(final Element parent) throws ParseException {
@@ -367,8 +367,8 @@ class MathTransformParser extends Abstra
* INVERSE_MT[<math transform>]
* }
*
- * @param parent The parent element.
- * @return The {@code "INVERSE_MT"} element as an {@link MathTransform} object.
+ * @param parent the parent element.
+ * @return the {@code "INVERSE_MT"} element as an {@link MathTransform} object.
* @throws ParseException if the {@code "INVERSE_MT"} element can not be parsed.
*/
private MathTransform parseInverseMT(final Element parent) throws ParseException {
@@ -393,8 +393,8 @@ class MathTransformParser extends Abstra
* PASSTHROUGH_MT[<integer>, <math transform>]
* }
*
- * @param parent The parent element.
- * @return The {@code "PASSTHROUGH_MT"} element as an {@link MathTransform} object.
+ * @param parent the parent element.
+ * @return the {@code "PASSTHROUGH_MT"} element as an {@link MathTransform} object.
* @throws ParseException if the {@code "PASSTHROUGH_MT"} element can not be parsed.
*/
private MathTransform parsePassThroughMT(final Element parent) throws ParseException {
@@ -419,9 +419,9 @@ class MathTransformParser extends Abstra
* CONCAT_MT[<math transform> {,<math transform>}*]
* }
*
- * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
- * @param parent The parent element.
- * @return The {@code "CONCAT_MT"} element as an {@link MathTransform} object.
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent the parent element.
+ * @return the {@code "CONCAT_MT"} element as an {@link MathTransform} object.
* @throws ParseException if the {@code "CONCAT_MT"} element can not be parsed.
*/
private MathTransform parseConcatMT(final Element parent) throws ParseException {