Author: desruisseaux
Date: Mon Mar 23 20:16:29 2015
New Revision: 1668720
URL: http://svn.apache.org/r1668720
Log:
Parameters: write remarks in footnote when formatting the parameter
descriptions.
The intend is to flag the parameters which are not formally defined by EPSG.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -140,7 +140,7 @@ public abstract class MapProjection exte
*/
static GenericName sameNameAs(final Citation authority, final
GeneralParameterDescriptor parameters) {
for (final GenericName candidate : parameters.getAlias()) {
- if (((Identifier) candidate).getAuthority() == authority) {
+ if (candidate instanceof Identifier && ((Identifier)
candidate).getAuthority() == authority) {
return candidate;
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -128,9 +128,9 @@ public final class Mercator2SP extends M
.addDeprecatedName( "Mercator (2SP)", "Mercator (variant
B)") // Prior to EPSG version 7.6
.addName(Citations.OGC, "Mercator_2SP")
.addName(Citations.ESRI, "Mercator")
+ .addName(Citations.NETCDF, "Mercator")
.addName(sameNameAs(Citations.GEOTIFF, Mercator1SP.PARAMETERS))
.addName(sameNameAs(Citations.PROJ4, Mercator1SP.PARAMETERS))
- .addName(Citations.NETCDF, "Mercator")
.addIdentifier(Citations.S57, "8")
.createGroupForMapProjection(
STANDARD_PARALLEL,
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -102,7 +102,7 @@ import static org.apache.sis.util.collec
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
public class ParameterFormat extends TabularFormat<Object> {
@@ -446,12 +446,13 @@ public class ParameterFormat extends Tab
private void format(final String name, final ParameterDescriptorGroup
group,
final ParameterValueGroup values, final Appendable out) throws
IOException
{
- final boolean isBrief = (contentLevel == ContentLevel.BRIEF);
- final boolean showObligation = !isBrief || (values == null);
- final boolean hasColors = (colors != null);
- final String lineSeparator = this.lineSeparator;
- final ParameterTableRow header = new ParameterTableRow(group,
displayLocale, preferredCodespaces, isBrief);
- final String groupCodespace = header.getCodeSpace();
+ final boolean isBrief = (contentLevel ==
ContentLevel.BRIEF);
+ final boolean showObligation = !isBrief || (values ==
null);
+ final boolean hasColors = (colors != null);
+ final String lineSeparator = this.lineSeparator;
+ final Map<String,Integer> remarks = new LinkedHashMap<>();
+ final ParameterTableRow header = new
ParameterTableRow(group, displayLocale, preferredCodespaces, remarks, isBrief);
+ final String groupCodespace = header.getCodeSpace();
/*
* Prepares the informations to be printed later as table rows. We
scan all rows before to print them
* in order to compute the width of codespaces. During this process,
we split the objects to be printed
@@ -498,7 +499,7 @@ public class ParameterFormat extends Tab
}
ParameterTableRow row = descriptorValues.get(descriptor);
if (row == null) {
- row = new ParameterTableRow(descriptor, displayLocale,
preferredCodespaces, isBrief);
+ row = new ParameterTableRow(descriptor, displayLocale,
preferredCodespaces, remarks, isBrief);
descriptorValues.put(descriptor, row);
if (row.codespaceWidth > codespaceWidth) {
codespaceWidth = row.codespaceWidth;
@@ -726,6 +727,13 @@ public class ParameterFormat extends Tab
table.nextLine(horizontalBorder);
table.flush();
/*
+ * Write remarks, if any.
+ */
+ for (final Map.Entry<String,Integer> remark : remarks.entrySet()) {
+ ParameterTableRow.writeFootnoteNumber(out, remark.getValue());
+ out.append(' ').append(remark.getKey()).append(lineSeparator);
+ }
+ /*
* Now formats all groups deferred to the end of this table, with
recursive calls to
* this method (recursive calls use their own TableWriter instance, so
they may result
* in a different cell layout). Most of the time, there is no such
additional group.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -32,10 +32,12 @@ import java.text.FieldPosition;
import javax.measure.unit.Unit;
import org.opengis.util.NameSpace;
import org.opengis.util.GenericName;
+import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
import org.opengis.referencing.IdentifiedObject;
import org.apache.sis.io.wkt.Colors;
import org.apache.sis.io.wkt.ElementKind;
+import org.apache.sis.util.Characters;
import org.apache.sis.measure.Range;
import org.apache.sis.measure.RangeFormat;
import org.apache.sis.internal.metadata.NameToIdentifier;
@@ -51,7 +53,7 @@ import static org.apache.sis.util.iso.De
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
final class ParameterTableRow {
@@ -110,13 +112,19 @@ final class ParameterTableRow {
final List<Object> units;
/**
+ * Reference to a remark, or {@code 0} if none.
+ */
+ private int remarks;
+
+ /**
* Creates a new row in a table to be formatted by {@link ParameterFormat}.
*
- * @param object The object for which to get the (<var>codespace(s)</var>,
<var>name(s)</var>).
- * @param locale The locale for formatting the names.
+ * @param object The object for which to get the
(<var>codespace(s)</var>, <var>name(s)</var>).
+ * @param locale The locale for formatting the names and the remarks.
+ * @param remarks An initially empty map, to be filled with any remarks we
may found.
*/
- ParameterTableRow(final IdentifiedObject object, final Locale locale,
- final Set<String> preferredCodespaces, final boolean isBrief)
+ ParameterTableRow(final IdentifiedObject object, final Locale locale,
final Set<String> preferredCodespaces,
+ final Map<String,Integer> remarks, final boolean isBrief)
{
values = new ArrayList<>(2); // In the vast majority of cases, we will
have only one value.
units = new ArrayList<>(2);
@@ -177,6 +185,15 @@ final class ParameterTableRow {
}
}
}
+ /*
+ * Take the remarks, if any.
+ */
+ final InternationalString r = object.getRemarks();
+ if (r != null) {
+ final int n = remarks.size() + 1;
+ final Integer p = remarks.putIfAbsent(r.toString(locale), n);
+ this.remarks = (p != null) ? p : n;
+ }
}
/**
@@ -296,7 +313,7 @@ final class ParameterTableRow {
* can be {@code true}.
*
* <p><b>This method can be invoked only once per {@code
ParameterTableRow} instance</b>,
- * at its implementation destroys the internal list of identifiers.</p>
+ * as its implementation destroys the internal list of identifiers.</p>
*
* @param out Where to write.
* @param writeCodespaces {@code true} for writing codespaces, or {@code
false} for omitting them.
@@ -345,6 +362,14 @@ final class ParameterTableRow {
writeColor(out, RESET, colors != null);
it.remove();
/*
+ * Write the footnote number if there is a remark associated
to this parameter.
+ * We write the remark only for the first name or identifier.
+ */
+ if (remarks != 0) {
+ writeFootnoteNumber(out, remarks);
+ remarks = 0;
+ }
+ /*
* Write all identifiers between parenthesis after the firt
name only.
* Aliases (to be written in a new iteration) will not have
identifier.
*/
@@ -373,6 +398,18 @@ final class ParameterTableRow {
}
}
+ /**
+ * Writes the footnote number to the given appendable.
+ * The number is written in superscript if possible.
+ */
+ static void writeFootnoteNumber(final Appendable out, final int n) throws
IOException {
+ if (n >= 0 && n < 10) {
+ out.append(Characters.toSuperScript((char) ('0' + n)));
+ } else {
+ out.append('(').append(Integer.toString(n)).append(')');
+ }
+ }
+
/**
* Returns the string representation of the given parameter name.
*/
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -22,6 +22,7 @@ import java.util.Locale;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.util.InternationalString;
+import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.util.Static;
import static org.apache.sis.util.CharSequences.equalsFiltered;
@@ -320,6 +321,9 @@ public final class Citations extends Sta
* @since 0.6
*/
public static String getUnicodeIdentifier(final Citation citation) {
+ if (citation instanceof IdentifierSpace<?>) {
+ return ((IdentifierSpace<?>) citation).getName();
+ }
final String identifier = getIdentifier(citation, true);
if (identifier != null) {
/*
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -98,7 +98,7 @@ public final class Messages extends Inde
public static final short MismatchedEllipsoidAxisLength_3 = 9;
/**
- * This parameter from the “{0}” projection is not formally a
parameter of “{1}” projection.
+ * This parameter borrowed from the “{0}” projection is not formally a
“{1}” parameter.
*/
public static final short NotFormallyAnEpsgParameter_2 = 10;
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] Mon Mar 23 20:16:29 2015
@@ -23,5 +23,5 @@ IgnoredPropertyAssociatedTo_1 = Ignore
PropertyHiddenBy_2 = Property \u201c{0}\u201d is hidden by
\u201c{1}\u201d.
LocalesDiscarded = Text were discarded for some locales.
MismatchedEllipsoidAxisLength_3 = The \u201c{1}\u201d parameter could have
been omitted. But it has been given a value of {2} which does not match the
definition of the \u201c{0}\u201d ellipsoid.
-NotFormallyAnEpsgParameter_2 = This parameter from the \u201c{0}\u201d
projection is not formally a parameter of \u201c{1}\u201d projection.
+NotFormallyAnEpsgParameter_2 = This parameter borrowed from the
\u201c{0}\u201d projection is not formally a \u201c{1}\u201d parameter.
UnparsableValueStoredAsText_2 = Can not parse \u201c{1}\u201d as an instance
of \u2018{0}\u2019. The value is stored as plain text instead, but will be
ignored by some processing.
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] Mon Mar 23 20:16:29 2015
@@ -23,5 +23,5 @@ IgnoredPropertyAssociatedTo_1 = Une pr
PropertyHiddenBy_2 = La propri\u00e9t\u00e9
\u00ab\u202f{0}\u202f\u00bb est masqu\u00e9e par \u00ab\u202f{1}\u202f\u00bb.
LocalesDiscarded = Des textes ont \u00e9t\u00e9 ignor\u00e9s
pour certaines langues.
MismatchedEllipsoidAxisLength_3 = Le param\u00e8tre
\u00ab\u202f{1}\u202f\u00bb aurait pu \u00eatre omis. Mais il lui a
\u00e9t\u00e9 donn\u00e9 la valeur {2} qui ne correspond pas \u00e0 la
d\u00e9finition de l\u2019ellipso\u00efde \u00ab\u202f{0}\u202f\u00bb.
-NotFormallyAnEpsgParameter_2 = Ce param\u00e8tre de la projection
\u00ab\u202f{0}\u202f\u00bb n\u2019est pas formellement un param\u00e8tre de la
projection \u00ab\u202f{1}\u202f\u00bb.
+NotFormallyAnEpsgParameter_2 = Ce param\u00e8tre emprunt\u00e9 \u00e0 la
projection \u00ab\u202f{0}\u202f\u00bb n\u2019est pas formellement un
param\u00e8tre de \u00ab\u202f{1}\u202f\u00bb.
UnparsableValueStoredAsText_2 = La valeur \u00ab\u202f{1}\u202f\u00bb ne
peut pas \u00eatre interpr\u00e9t\u00e9e comme une instance de \u2018{0}\u2019.
Elle est donc m\u00e9moris\u00e9e sous sa forme textuelle, mais sera
ignor\u00e9e par certains traitements.
Modified:
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java?rev=1668720&r1=1668719&r2=1668720&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
[UTF-8] Mon Mar 23 20:16:29 2015
@@ -18,6 +18,7 @@ package org.apache.sis.internal.util;
import org.opengis.metadata.citation.Citation;
import org.apache.sis.internal.simple.SimpleCitation;
+import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -62,5 +63,25 @@ public final strictfp class CitationsTes
public void testGetUnicodeIdentifier() {
final SimpleCitation citation = new SimpleCitation("
Valid\u2060Id\u200Bentifier ");
assertEquals("ValidIdentifier",
Citations.getUnicodeIdentifier(citation));
+
+ assertNull("Shall not be taken as a valid identifier.",
+ Citations.getUnicodeIdentifier(new SimpleCitation("Proj.4")));
+ assertEquals("Shall fallback on the the identifier space name.",
+ "TheProj4Space", Citations.getUnicodeIdentifier(new Proj4()));
+ }
+
+ /**
+ * A citation which is also an {@link IdentifierSpace}, for {@link
#testGetUnicodeIdentifier()} purpose.
+ */
+ @SuppressWarnings("serial")
+ private static final class Proj4 extends SimpleCitation implements
IdentifierSpace<Integer> {
+ Proj4() {
+ super("Proj.4");
+ }
+
+ @Override
+ public String getName() {
+ return "TheProj4Space"; // Intentionally a very different name
than "Proj4".
+ }
}
}