sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1743925 - in /sis/branches/JDK8: application/sis-console/src/main/java/org/apache/sis/console/ core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/ core/sis-utility/src/main/java/org/apache/sis/util/resources/
Date Sun, 15 May 2016 17:42:44 GMT
Author: desruisseaux
Date: Sun May 15 17:42:44 2016
New Revision: 1743925

URL: http://svn.apache.org/viewvc?rev=1743925&view=rev
Log:
Command-line "transform" operation in "--verbose" mode should format the CoordinateOperation
instead than the MathTransform.
The user should be notified if that coordinate operation can not be formatted in valid WKT.
Should also format the domain of validity.

Modified:
    sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    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/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
[UTF-8] (original)
+++ sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
[UTF-8] Sun May 15 17:42:44 2016
@@ -28,9 +28,11 @@ import javax.measure.unit.NonSI;
 import javax.measure.unit.SI;
 import javax.measure.converter.ConversionException;
 import org.opengis.metadata.Metadata;
-import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.geometry.MismatchedDimensionException;
 import org.opengis.util.FactoryException;
+import org.opengis.util.InternationalString;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.ReferenceSystem;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
@@ -58,6 +60,7 @@ import org.apache.sis.io.wkt.Colors;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Transliterator;
 import org.apache.sis.io.wkt.WKTFormat;
+import org.apache.sis.io.wkt.Warnings;
 import org.apache.sis.math.DecimalFunctions;
 import org.apache.sis.math.MathFunctions;
 import org.apache.sis.measure.Units;
@@ -198,39 +201,10 @@ final class TransformCommand extends Met
         printHeader(Vocabulary.Keys.Destination); printNameAndIdentifier(operation.getTargetCRS(),
false);
         printHeader(Vocabulary.Keys.Operations);  printOperations (operation, false);
         outHeader.nextLine();
+        printDomainOfValidity(operation.getDomainOfValidity());
+        printAccuracy(CRS.getLinearAccuracy(operation));
         if (options.containsKey(Option.VERBOSE)) {
-            final WKTFormat f = new WKTFormat(locale, timezone);
-            f.setConvention(options.containsKey(Option.DEBUG) ? Convention.INTERNAL : convention);
-            if (colors) {
-                f.setColors(Colors.DEFAULT);
-            }
-            final CharSequence[] lines = CharSequences.splitOnEOL(f.format(operation.getMathTransform()));
-            for (int i=0; i<lines.length; i++) {
-                if (i == 0) {
-                    printHeader(Vocabulary.Keys.Details);
-                } else {
-                    printCommentLinePrefix();
-                    outHeader.nextColumn();
-                }
-                outHeader.append(lines[i]);
-                outHeader.nextLine();
-            }
-        }
-        double accuracy = CRS.getLinearAccuracy(operation);
-        if (accuracy >= 0) {
-            if (accuracy == 0) {
-                accuracy = Formulas.LINEAR_TOLERANCE;
-            }
-            printHeader(Vocabulary.Keys.Accuracy);
-            if (colors) {
-                outHeader.append(X364.FOREGROUND_YELLOW.sequence());    // Same as Colors.DEFAULT
for ElementKind.NUMBER
-            }
-            outHeader.append(Double.toString(accuracy));
-            if (colors) {
-                outHeader.append(X364.FOREGROUND_DEFAULT.sequence());
-            }
-            outHeader.append(" metres");
-            outHeader.nextLine();
+            printDetails();
         }
         outHeader.flush();
         outHeader = null;
@@ -354,6 +328,92 @@ final class TransformCommand extends Met
             }
         }
     }
+
+    /**
+     * Prints the accuracy.
+     */
+    private void printAccuracy(double accuracy) {
+        if (accuracy >= 0) {
+            if (accuracy == 0) {
+                accuracy = Formulas.LINEAR_TOLERANCE;
+            }
+            printHeader(Vocabulary.Keys.Accuracy);
+            if (colors) {
+                outHeader.append(X364.FOREGROUND_YELLOW.sequence());    // Same as Colors.DEFAULT
for ElementKind.NUMBER
+            }
+            outHeader.append(Double.toString(accuracy));
+            if (colors) {
+                outHeader.append(X364.FOREGROUND_DEFAULT.sequence());
+            }
+            outHeader.append(" metres");
+            outHeader.nextLine();
+        }
+    }
+
+    /**
+     * Prints a textual description of the domain of validity. This method tries to reduce
the string length by
+     * the use of some heuristic rules based on the syntax used in EPSG dataset. For example
the following string:
+     *
+     * <blockquote>Canada - onshore and offshore - Alberta; British Columbia (BC);
Manitoba; New Brunswick (NB);
+     * Newfoundland and Labrador; Northwest Territories (NWT); Nova Scotia (NS); Nunavut;
Ontario; Prince Edward
+     * Island (PEI); Quebec; Saskatchewan; Yukon.</blockquote>
+     *
+     * is replaced by:
+     *
+     * <blockquote>Canada - onshore and offshore</blockquote>
+     */
+    private void printDomainOfValidity(final Extent domain) {
+        if (domain != null) {
+            final InternationalString description = domain.getDescription();
+            if (description != null) {
+                String text = description.toString(locale);
+                if (text.length() >= 80) {
+                    int end = text.indexOf(';');
+                    if (end >= 0) {
+                        int s = text.lastIndexOf('-', end);
+                        if (s >= 0) {
+                            end = s;
+                        }
+                        text = text.substring(0, end).trim();
+                    }
+                }
+                printHeader(Vocabulary.Keys.Domain);
+                outHeader.append(text);
+                outHeader.nextLine();
+            }
+        }
+    }
+
+    /**
+     * Prints the coordinate operation or math transform in Well Known Text format.
+     * This information is printed only if the {@code --verbose} option was specified.
+     */
+    private void printDetails() {
+        final boolean debug = options.containsKey(Option.DEBUG);
+        final WKTFormat f = new WKTFormat(locale, timezone);
+        if (colors) f.setColors(Colors.DEFAULT);
+        f.setConvention(convention);
+        CharSequence[] lines = CharSequences.splitOnEOL(f.format(debug ? operation.getMathTransform()
: operation));
+        for (int i=0; i<lines.length; i++) {
+            if (i == 0) {
+                printHeader(Vocabulary.Keys.Details);
+            } else {
+                printCommentLinePrefix();
+                outHeader.nextColumn();
+            }
+            outHeader.append(lines[i]);
+            outHeader.nextLine();
+        }
+        final Warnings warnings = f.getWarnings();
+        if (warnings != null) {
+            lines = CharSequences.splitOnEOL(warnings.toString());
+            if (lines.length != 0) {                                            // Paranoiac
check.
+                printHeader(Vocabulary.Keys.Note);
+                outHeader.append(lines[0]);
+                outHeader.nextLine();
+            }
+        }
+    }
 
     /**
      * Prints a quoted text in the given color.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] Sun May 15 17:42:44 2016
@@ -911,7 +911,11 @@ check:      for (int isTarget=0; ; isTar
         if (formatter.getConvention().majorVersion() == 1) {
             formatter.setInvalidWKT(this, null);
         }
-        return isComponent ? "CoordinateOperationStep" : WKTKeywords.CoordinateOperation;
+        if (isComponent) {
+            formatter.setInvalidWKT(this, null);
+            return "CoordinateOperationStep";
+        }
+        return WKTKeywords.CoordinateOperation;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Sun May 15 17:42:44 2016
@@ -151,7 +151,7 @@ public final class Errors extends Indexe
         public static final short CanNotRead_1 = 9;
 
         /**
-         * Can not represent “{1}” in the {0} format.
+         * Can not represent “{1}” in a strictly standard-compliant {0} format.
          */
         public static final short CanNotRepresentInFormat_2 = 10;
 

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Sun May 15 17:42:44 2016
@@ -41,7 +41,7 @@ CanNotMapAxisToDirection_2        = Can
 CanNotOpen_1                      = Can not open \u201c{0}\u201d.
 CanNotParseFile_2                 = Can not parse \u201c{1}\u201d as a file in the {0} format.
 CanNotRead_1                      = Can not read \u201c{0}\u201d.
-CanNotRepresentInFormat_2         = Can not represent \u201c{1}\u201d in the {0} format.
+CanNotRepresentInFormat_2         = Can not represent \u201c{1}\u201d in a strictly standard-compliant
{0} format.
 CanNotSeparateTargetDimension_1   = Target dimension {0} depends on excluded source dimensions.
 CanNotSetParameterValue_1         = Can not set a value for parameter \u201c{0}\u201d.
 CanNotSetPropertyValue_1          = Can not set a value for property \u201c{0}\u201d.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Sun May 15 17:42:44 2016
@@ -38,7 +38,7 @@ CanNotMapAxisToDirection_2        = Aucu
 CanNotOpen_1                      = Ne peut pas ouvrir \u00ab\u202f{0}\u202f\u00bb.
 CanNotParseFile_2                 = Ne peut pas lire \u00ab\u202f{1}\u202f\u00bb comme un
fichier au format {0}.
 CanNotRead_1                      = Ne peut pas lire \u00ab\u202f{0}\u202f\u00bb.
-CanNotRepresentInFormat_2         = Ne peut pas repr\u00e9senter \u00ab\u202f{1}\u202f\u00bb
dans le format {0}.
+CanNotRepresentInFormat_2         = Ne peut pas repr\u00e9senter \u00ab\u202f{1}\u202f\u00bb
dans un format {0} strictement conforme.
 CanNotSeparateTargetDimension_1   = La dimension de destination {0} d\u00e9pend de dimensions
sources qui ont \u00e9t\u00e9 exclues.
 CanNotSetParameterValue_1         = Ne peut pas d\u00e9finir une valeur pour le param\u00e8tre
\u00ab\u202f{0}\u202f\u00bb.
 CanNotSetPropertyValue_1          = Ne peut pas d\u00e9finir une valeur pour la propri\u00e9t\u00e9
\u00ab\u202f{0}\u202f\u00bb.

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=1743925&r1=1743924&r2=1743925&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] Sun May 15 17:42:44 2016
@@ -249,7 +249,7 @@ public final class Messages extends Inde
         public static final short MisnamedParameter_1 = 18;
 
         /**
-         * Formatting of “{0}” is not conform to the format standard.
+         * This “{0}” formatting is a departure from standard format.
          */
         public static final short NonConformFormatting_1 = 15;
 

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=1743925&r1=1743924&r2=1743925&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] Sun May 15 17:42:44 2016
@@ -54,7 +54,7 @@ PropertyHiddenBy_2               = Prope
 MismatchedOperationFactories_2   = No coordinate operation from \u201c{0}\u201d to \u201c{1}\u201d
because of mismatched factories.
 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.
 MisnamedParameter_1              = Despite its name, this parameter is effectively \u201c{0}\u201d.
-NonConformFormatting_1           = Formatting of \u201c{0}\u201d is not conform to the format
standard.
+NonConformFormatting_1           = This \u201c{0}\u201d formatting is a departure from standard
format.
 NotFormalProjectionParameter_1   = This parameter borrowed from the \u201c{0}\u201d projection
is not formally a parameter of this projection.
 UnknownElementsInText            = The text contains unknown elements:
 UnknownKeywordInRecord_2         = Loading of \u201c{0}\u201d done, but some records were
ignored because of unrecognized keywords: {1}

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=1743925&r1=1743924&r2=1743925&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] Sun May 15 17:42:44 2016
@@ -61,7 +61,7 @@ PropertyHiddenBy_2               = La pr
 MismatchedOperationFactories_2   = Il n\u2019y a pas d\u2019op\u00e9rations allant de \u00ab\u202f{0}\u202f\u00bb
vers \u00ab\u202f{1}\u202f\u00bb parce que ces derniers sont associ\u00e9s \u00e0 deux fabriques
diff\u00e9rentes.
 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.
 MisnamedParameter_1              = Malgr\u00e9 son nom, ce param\u00e8tre produit en r\u00e9alit\u00e9
l\u2019effet d\u2019un \u00ab\u202f{0}\u202f\u00bb.
-NonConformFormatting_1           = L\u2019\u00e9criture de \u00ab\u202f{0}\u202f\u00bb n\u2019est
pas conforme au format standard.
+NonConformFormatting_1           = Cette \u00e9criture de \u00ab\u202f{0}\u202f\u00bb d\u00e9vie
du format standard.
 NotFormalProjectionParameter_1   = Ce param\u00e8tre emprunt\u00e9 \u00e0 la projection \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas formellement un param\u00e8tre de cette projection.
 UnknownElementsInText            = Le texte contient des \u00e9l\u00e9ments inconnus\u00a0:
 UnknownKeywordInRecord_2         = La lecture de \u00ab\u202f{0}\u202f\u00bb a \u00e9t\u00e9
faite, mais en ignorant certains enregistrements \u00e0 cause de mots-cl\u00e9s non reconnus:
{1}

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Sun May 15 17:42:44 2016
@@ -232,6 +232,11 @@ public final class Vocabulary extends In
         public static final short DittoMark = 82;
 
         /**
+         * Domain
+         */
+        public static final short Domain = 113;
+
+        /**
          * Dublin Julian
          */
         public static final short DublinJulian = 17;
@@ -412,6 +417,11 @@ public final class Vocabulary extends In
         public static final short None = 91;
 
         /**
+         * Note
+         */
+        public static final short Note = 114;
+
+        /**
          * Number of ‘NaN’
          */
         public static final short NumberOfNaN = 38;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Sun May 15 17:42:44 2016
@@ -49,6 +49,7 @@ Details                 = Details
 Dimensions              = Dimensions
 Directory               = Directory
 DittoMark               = \u2033
+Domain                  = Domain
 DublinJulian            = Dublin Julian
 Ellipsoid               = Ellipsoid
 EllipsoidChange         = Ellipsoid change
@@ -85,6 +86,7 @@ Methods                 = Methods
 ModifiedJulian          = Modified Julian
 Name                    = Name
 None                    = None
+Note                    = Note
 NumberOfValues          = Number of values
 NumberOfNaN             = Number of \u2018NaN\u2019
 Obligation              = Obligation

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1743925&r1=1743924&r2=1743925&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Sun May 15 17:42:44 2016
@@ -56,6 +56,7 @@ Details                 = D\u00e9tails
 Dimensions              = Dimensions
 Directory               = R\u00e9pertoire
 DittoMark               = \u2033
+Domain                  = Domaine
 DublinJulian            = Julien Dublin
 Ellipsoid               = Ellipso\u00efde
 EllipsoidChange         = Changement d\u2019ellipso\u00efde
@@ -92,6 +93,7 @@ Methods                 = M\u00e9thodes
 ModifiedJulian          = Julien modifi\u00e9
 Name                    = Nom
 None                    = Aucun
+Note                    = Note
 NumberOfValues          = Nombre de valeurs
 NumberOfNaN             = Nombre de \u2018NaN\u2019
 Obligation              = Obligation



Mime
View raw message