jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1561396 - in /jena/trunk/jena-spatial/src: main/java/org/apache/jena/query/spatial/ main/java/org/apache/jena/query/spatial/pfunction/ test/java/org/apache/jena/query/spatial/pfunction/
Date Sat, 25 Jan 2014 20:41:10 GMT
Author: andy
Date: Sat Jan 25 20:41:10 2014
New Revision: 1561396

URL: http://svn.apache.org/r1561396
Log:
JENA-623\nDefault circle distance to "kilometres".\nUse International Bureau of Weights and
Measures spellings.\nAnd Amercian ones.

Modified:
    jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java
    jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithCircleBase.java
    jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsNearByPF.java
    jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsWithinCirclePF.java

Modified: jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java?rev=1561396&r1=1561395&r2=1561396&view=diff
==============================================================================
--- jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java
(original)
+++ jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java
Sat Jan 25 20:41:10 2014
@@ -25,17 +25,25 @@ import com.spatial4j.core.distance.Dista
 
 public class DistanceUnitsUtils {
 
+    public final static String defaultDistanceUnit = "kilometres" ;
+    
 	public final static List<String> SUPPORTED_UNITS;
 	static {
+	 // International spelling "metres" 
+	 // As used by http://en.wikipedia.org/wiki/International_Bureau_of_Weights_and_Measures
 		SUPPORTED_UNITS = new ArrayList<String>();
-		SUPPORTED_UNITS.add("kilometers");
+		SUPPORTED_UNITS.add("kilometres");           
+        SUPPORTED_UNITS.add("kilometers");           // America spelling
 		SUPPORTED_UNITS.add("km");
-		SUPPORTED_UNITS.add("meters");
+		SUPPORTED_UNITS.add("meters");        
+        SUPPORTED_UNITS.add("metres");
 		SUPPORTED_UNITS.add("m");
 		SUPPORTED_UNITS.add("centimeters");
+        SUPPORTED_UNITS.add("centimetres");
 		SUPPORTED_UNITS.add("cm");
-		SUPPORTED_UNITS.add("milimeters");
-		SUPPORTED_UNITS.add("mm");
+		SUPPORTED_UNITS.add("millimetres");
+        SUPPORTED_UNITS.add("millimeters");
+        SUPPORTED_UNITS.add("mm");
 		SUPPORTED_UNITS.add("miles");
 		SUPPORTED_UNITS.add("mi");
 		SUPPORTED_UNITS.add("degrees");
@@ -45,19 +53,20 @@ public class DistanceUnitsUtils {
 	public static double dist2Degrees(double dist, String units) {
 		double degrees = dist;
 
-		if (units.equals("kilometers") || units.equals("km"))
+		if (units.equals("kilometers") || units.equals("kilometres") || units.equals("km"))
 			return DistanceUtils.dist2Degrees(dist,
 					DistanceUtils.EARTH_MEAN_RADIUS_KM);
 
-		else if (units.equals("meters") || units.equals("m"))
+		else if (units.equals("meters") || units.equals("metres") || units.equals("m"))
 			return DistanceUtils.dist2Degrees(dist / 1000,
 					DistanceUtils.EARTH_MEAN_RADIUS_KM);
 
-		else if (units.equals("centimeters") || units.equals("cm"))
+		else if (units.equals("centimeters") || units.equals("centimetres") || units.equals("cm"))
 			return DistanceUtils.dist2Degrees(dist / (1000 * 100),
 					DistanceUtils.EARTH_MEAN_RADIUS_KM) ;
 
-		else if (units.equals("milimeters") || units.equals("mm"))
+		else if ( units.equals("millimeters") || units.equals("millimetres") || units.equals("mm")
|| 
+		          units.equals("milimeters") || units.equals("milimetres") ) // Common spelling
mistake.
 			return DistanceUtils.dist2Degrees(dist / (1000 * 1000),
 					DistanceUtils.EARTH_MEAN_RADIUS_KM) ;
 

Modified: jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithCircleBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithCircleBase.java?rev=1561396&r1=1561395&r2=1561396&view=diff
==============================================================================
--- jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithCircleBase.java
(original)
+++ jena/trunk/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithCircleBase.java
Sat Jan 25 20:41:10 2014
@@ -121,7 +121,7 @@ public abstract class SpatialOperationWi
 			return null;
 		}
 
-		String units = "miles";
+		String units = DistanceUnitsUtils.defaultDistanceUnit  ;         // Kilometres
 		int limit = -1;
 
 		idx++;

Modified: jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsNearByPF.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsNearByPF.java?rev=1561396&r1=1561395&r2=1561396&view=diff
==============================================================================
--- jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsNearByPF.java
(original)
+++ jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsNearByPF.java
Sat Jan 25 20:41:10 2014
@@ -182,7 +182,7 @@ public abstract class AbstractTestIsNear
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:nearby (51.3000 -2.71000 100.0 'kilometers') .", "}");
+				" ?s spatial:nearby (51.3000 -2.71000 100.0 'kilometres') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]
@@ -208,7 +208,7 @@ public abstract class AbstractTestIsNear
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:nearby (51.3000 -2.71000 10000.0 'meters') .", "}");
+				" ?s spatial:nearby (51.3000 -2.71000 10000.0 'metres') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]
@@ -231,7 +231,7 @@ public abstract class AbstractTestIsNear
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:nearby (51.3000 -2.71000 1000000.0 'centimeters') .", "}");
+				" ?s spatial:nearby (51.3000 -2.71000 1000000.0 'centimetres') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]
@@ -254,7 +254,7 @@ public abstract class AbstractTestIsNear
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:nearby (51.3000 -2.71000 10000000.0 'milimeters') .", "}");
+				" ?s spatial:nearby (51.3000 -2.71000 10000000.0 'millimetres') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]

Modified: jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsWithinCirclePF.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsWithinCirclePF.java?rev=1561396&r1=1561395&r2=1561396&view=diff
==============================================================================
--- jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsWithinCirclePF.java
(original)
+++ jena/trunk/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/AbstractTestIsWithinCirclePF.java
Sat Jan 25 20:41:10 2014
@@ -208,7 +208,7 @@ public abstract class AbstractTestIsWith
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:withinCircle (51.3000 -2.71000 10000.0 'meters') .", "}");
+				" ?s spatial:withinCircle (51.3000 -2.71000 10000.0 'metres') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]
@@ -231,7 +231,7 @@ public abstract class AbstractTestIsWith
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:withinCircle (51.3000 -2.71000 1000000.0 'centimeters') .", "}");
+				" ?s spatial:withinCircle (51.3000 -2.71000 1000000.0 'centimetres') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]
@@ -254,7 +254,7 @@ public abstract class AbstractTestIsWith
 		
 		queryString = StrUtils.strjoinNL(QUERY_PROLOG, "SELECT ?s",
 				"WHERE {",
-				" ?s spatial:withinCircle (51.3000 -2.71000 10000000.0 'milimeters') .", "}");
+				" ?s spatial:withinCircle (51.3000 -2.71000 10000000.0 'millimeters') .", "}");
 		expectedURIs = (new HashSet<String>());
 		expectedURIs.addAll( Arrays.asList((
 				new String[]



Mime
View raw message