sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1564365 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/io/wkt/Formatter.java test/java/org/apache/sis/io/wkt/FormatterTest.java
Date Tue, 04 Feb 2014 16:11:07 GMT
Author: desruisseaux
Date: Tue Feb  4 16:11:07 2014
New Revision: 1564365

URL: http://svn.apache.org/r1564365
Log:
VERTICALEXTENT shall apply rounding toward floor and ceil as appropriate.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1564365&r1=1564364&r2=1564365&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Tue Feb  4 16:11:07 2014
@@ -95,6 +95,18 @@ public class Formatter {
     private static final Class<? extends IdentifiedObject> AUTHORITY_EXCLUDE = CoordinateSystemAxis.class;
 
     /**
+     * Accuracy of geographic bounding boxes, in number of fraction digits.
+     * We use the accuracy recommended by ISO 19162.
+     */
+    private static final int BBOX_ACCURACY = 2;
+
+    /**
+     * Maximal accuracy of vertical extents, in number of fraction digits.
+     * The value used here is arbitrary and may change in any future SIS version.
+     */
+    private static final int VERTICAL_ACCURACY = 3;
+
+    /**
      * The value of {@code X364.FOREGROUND_DEFAULT.sequence()}, hard-coded for avoiding
      * {@link org.apache.sis.internal.util.X364} class loading.
      */
@@ -607,13 +619,17 @@ public class Formatter {
         append("SCOPE", scope, ElementKind.SCOPE);
         if (area != null) {
             append("AREA", area.getDescription(), ElementKind.EXTENT);
-            append(Extents.getGeographicBoundingBox(area), 2);
+            append(Extents.getGeographicBoundingBox(area), BBOX_ACCURACY);
             final MeasurementRange<Double> range = Extents.getVerticalRange(area);
             if (range != null) {
                 openElement("VERTICALEXTENT");
                 setColor(ElementKind.EXTENT);
-                append(range.getMinDouble());
-                append(range.getMaxDouble());
+                numberFormat.setMinimumFractionDigits(0);
+                numberFormat.setMaximumFractionDigits(VERTICAL_ACCURACY);
+                numberFormat.setRoundingMode(RoundingMode.FLOOR);
+                appendPreset(range.getMinDouble());
+                numberFormat.setRoundingMode(RoundingMode.CEILING);
+                appendPreset(range.getMaxDouble());
                 final Unit<?> unit = range.unit();
                 if (!convention.isSimple() || !SI.METRE.equals(unit)) {
                     requestNewLine = false;
@@ -1201,5 +1217,6 @@ public class Formatter {
         highlightError = false;
         requestNewLine = false;
         margin         = 0;
+        colorApplied   = 0;
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1564365&r1=1564364&r2=1564365&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] Tue Feb  4 16:11:07 2014
@@ -74,7 +74,7 @@ public final strictfp class FormatterTes
                 "  SCOPE[“Large scale topographic mapping and cadastre.”],\n" +
                 "  AREA[“Netherlands offshore.”],\n" +
                 "  BBOX[51.43, 2.54, 55.77, 6.40],\n" +
-                "  VERTICALEXTENT[-1000.0, -10.0, LENGTHUNIT[“metre”, 1.0]],\n" +
+                "  VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1.0]],\n" +
                 "  REMARKS[“注です。”]]",
                 new AbstractReferenceSystem(properties));
     }



Mime
View raw message