sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1802137 - in /sis/branches/JDK8/core/sis-utility/src: main/java/org/apache/sis/measure/Units.java test/java/org/apache/sis/measure/ConventionalUnitTest.java test/java/org/apache/sis/measure/UnitsTest.java
Date Mon, 17 Jul 2017 13:12:34 GMT
Author: desruisseaux
Date: Mon Jul 17 13:12:34 2017
New Revision: 1802137

URL: http://svn.apache.org/viewvc?rev=1802137&view=rev
Log:
Fix erroneous conversion factor between m/s and km/h units. 

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1802137&r1=1802136&r2=1802137&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8]
Mon Jul 17 13:12:34 2017
@@ -597,7 +597,7 @@ public final class Units extends Static
     public static final Unit<Speed> METRES_PER_SECOND;
 
     /**
-     * Unit of measurement defined as 60/1000 metres per second (1 km/h).
+     * Unit of measurement defined as 1/3.6 metres per second (1 km/h).
      * The {@linkplain ConventionalUnit#getSystemUnit() system unit} is {@link #METRES_PER_SECOND}
      * and the unlocalized name is “kilometres per hour”.
      *
@@ -1147,7 +1147,7 @@ public final class Units extends Static
          */
         mps.related(1);
         METRES_PER_SECOND   = mps;
-        KILOMETRES_PER_HOUR = add(mps, LinearConverter.scale(6, 100), "km∕h", ACCEPTED,
(short) 0);
+        KILOMETRES_PER_HOUR = add(mps, LinearConverter.scale(10, 36), "km∕h", ACCEPTED,
(short) 0);
         /*
          * All Unit<Pressure>.
          */

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java?rev=1802137&r1=1802136&r2=1802137&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
[UTF-8] Mon Jul 17 13:12:34 2017
@@ -71,7 +71,7 @@ public final strictfp class Conventional
         verify(Units.SECOND,            Units.HOUR,                   "h",  3600);
         verify(Units.PASCAL,            Units.PASCAL,                "Pa",     1);
         verify(Units.PASCAL,            Units.HECTOPASCAL,          "hPa",   100);
-        verify(Units.METRES_PER_SECOND, Units.KILOMETRES_PER_HOUR, "km∕h",  0.06);
+        verify(Units.METRES_PER_SECOND, Units.KILOMETRES_PER_HOUR, "km∕h",  1/3.6);
         verify(Units.CUBIC_METRE,       Units.LITRE,                  "L",  1E-3);
         verify(Units.KILOGRAM,          Units.KILOGRAM,              "kg",     1);
         verify(Units.KILOGRAM,          Units.GRAM,                   "g",  1E-3);

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java?rev=1802137&r1=1802136&r2=1802137&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
[UTF-8] Mon Jul 17 13:12:34 2017
@@ -187,6 +187,15 @@ public final strictfp class UnitsTest ex
     }
 
     /**
+     * Verifies some conversion factors.
+     */
+    @Test
+    public void testConversionFactors() {
+        assertEquals(1000, KILOMETRE        .getConverterTo(METRE)              .convert(1),
STRICT);
+        assertEquals( 3.6, METRES_PER_SECOND.getConverterTo(KILOMETRES_PER_HOUR).convert(1),
STRICT);
+    }
+
+    /**
      * Tests getting a unit for a given quantity type.
      */
     @Test
@@ -305,24 +314,24 @@ public final strictfp class UnitsTest ex
         assertSame(METRE,  valueOf("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])"));
         assertSame(METRE,  valueOf("gmxUom.xml#m"));
 
-        assertSame(TROPICAL_YEAR,   valueOfEPSG(1029));
-        assertSame(SECOND,          valueOfEPSG(1040));
-        assertSame(FOOT,            valueOfEPSG(9002));
-        assertSame(US_SURVEY_FOOT,  valueOfEPSG(9003));
-        assertSame(NAUTICAL_MILE,   valueOfEPSG(9030));
-        assertSame(KILOMETRE,       valueOfEPSG(9036));
-        assertSame(RADIAN,          valueOfEPSG(9101));
-        assertSame(ARC_MINUTE,      valueOfEPSG(9103));
-        assertSame(ARC_SECOND,      valueOfEPSG(9104));
-        assertSame(GRAD,            valueOfEPSG(9105));
-        assertSame(MICRORADIAN,     valueOfEPSG(9109));
+        assertSame(TROPICAL_YEAR,                   valueOfEPSG(1029));
+        assertSame(SECOND,                          valueOfEPSG(1040));
+        assertSame(FOOT,                            valueOfEPSG(9002));
+        assertSame(US_SURVEY_FOOT,                  valueOfEPSG(9003));
+        assertSame(NAUTICAL_MILE,                   valueOfEPSG(9030));
+        assertSame(KILOMETRE,                       valueOfEPSG(9036));
+        assertSame(RADIAN,                          valueOfEPSG(9101));
+        assertSame(ARC_MINUTE,                      valueOfEPSG(9103));
+        assertSame(ARC_SECOND,                      valueOfEPSG(9104));
+        assertSame(GRAD,                            valueOfEPSG(9105));
+        assertSame(MICRORADIAN,                     valueOfEPSG(9109));
         assertSame(SexagesimalConverter.DMS_SCALED, valueOfEPSG(9107));
         assertSame(SexagesimalConverter.DMS_SCALED, valueOfEPSG(9108));
         assertSame(SexagesimalConverter.DMS,        valueOfEPSG(9110));
         assertSame(SexagesimalConverter.DM,         valueOfEPSG(9111));
-        assertSame(UNITY,           valueOfEPSG(9203));
-        assertSame(UNITY,           valueOfEPSG(9201));
-        assertSame(PPM,             valueOfEPSG(9202));
+        assertSame(UNITY,                           valueOfEPSG(9203));
+        assertSame(UNITY,                           valueOfEPSG(9201));
+        assertSame(PPM,                             valueOfEPSG(9202));
     }
 
     /**



Mime
View raw message