sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1802138 - in /sis/branches/JDK7: ./ core/sis-utility/src/main/java/org/apache/sis/measure/ core/sis-utility/src/test/java/org/apache/sis/measure/ storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/
Date Mon, 17 Jul 2017 13:17:34 GMT
Author: desruisseaux
Date: Mon Jul 17 13:17:33 2017
New Revision: 1802138

URL: http://svn.apache.org/viewvc?rev=1802138&view=rev
Log:
Merge from JDK8 branch (in particular unit conversion factor fix).

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
    sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 17 13:17:33 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1802070
+/sis/branches/JDK8:1584960-1802137
 /sis/branches/JDK9:1773327-1789983
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1802138&r1=1802137&r2=1802138&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8]
Mon Jul 17 13:17:33 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”.
      *
@@ -1149,7 +1149,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/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java?rev=1802138&r1=1802137&r2=1802138&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
[UTF-8] Mon Jul 17 13:17:33 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/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java?rev=1802138&r1=1802137&r2=1802138&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
[UTF-8] Mon Jul 17 13:17:33 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));
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java?rev=1802138&r1=1802137&r2=1802138&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
[UTF-8] Mon Jul 17 13:17:33 2017
@@ -18,6 +18,7 @@ package org.apache.sis.storage.gdal;
 
 import javax.measure.Unit;
 import javax.measure.quantity.Angle;
+import org.opengis.metadata.Identifier;
 import org.opengis.util.FactoryException;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
@@ -33,6 +34,7 @@ import org.opengis.referencing.cs.Ellips
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.operation.Projection;
 import org.opengis.referencing.operation.CoordinateOperation;
 import org.apache.sis.referencing.factory.UnavailableFactoryException;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -45,11 +47,19 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Static;
 import org.apache.sis.measure.Units;
-import org.opengis.referencing.operation.Projection;
 
 
 /**
- * Bindings to the {@literal Proj.4} library.
+ * Bindings to the {@literal Proj.4} library as static convenience methods.
+ * The methods in this class allow to:
+ *
+ * <ul>
+ *   <li>{@linkplain #createCRS Create a Coordinate Reference System instance from
a Proj.4 definition string}.</li>
+ *   <li>Conversely, {@link #definition get a Proj.4 definition string from a Coordinate
Reference System}.</li>
+ *   <li>{@linkplain #createOperation Create a coordinate operation backed by Proj.4
between two arbitrary CRS}.</li>
+ * </ul>
+ *
+ * Most methods in this class delegate to {@link Proj4Factory}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Johann Sorel (Geomatys)
@@ -94,6 +104,12 @@ public final class Proj4 extends Static
      * @throws FactoryException if the Proj.4 definition string can not be created from the
given CRS.
      */
     public static String definition(final CoordinateReferenceSystem crs) throws FactoryException
{
+        ArgumentChecks.ensureNonNull("crs", crs);
+        for (final Identifier id : crs.getIdentifiers()) {
+            if (id instanceof PJ) {
+                return ((PJ) id).getCode();
+            }
+        }
         final String method;
         final GeodeticDatum datum;
         final ParameterValueGroup parameters;



Mime
View raw message