]> granicus.if.org Git - postgis/commitdiff
jdbc: org.postgis.Point.equals() is not reflexive (#1313)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 15 Feb 2012 22:45:29 +0000 (22:45 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 15 Feb 2012 22:45:29 +0000 (22:45 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9211 b70326c6-7e19-0410-871a-916f4a2858ee

java/jdbc/src/org/postgis/Point.java

index 04c031916a1d6e479f74716dbc72d97833c5b8fd..24de605940307e06afaa175cf9c99fe21fceb285 100644 (file)
@@ -50,11 +50,20 @@ public class Point extends Geometry {
         return equals(other);
     }
 
+       public static boolean double_equals(double a, double b) {
+               if ( Double.isNaN(a) && Double.isNaN(b) ) {
+                       return true;
+               }
+               else {
+                       return (a == b);
+               }
+       }
+
     public final boolean equals(Point other) {
-        boolean xequals = x == other.x;
-        boolean yequals = y == other.y;
-        boolean zequals = ((dimension == 2) || (z == other.z));
-        boolean mequals = ((haveMeasure == false) || (m == other.m));
+        boolean xequals = double_equals(x, other.x);
+        boolean yequals = double_equals(y, other.y);
+        boolean zequals = ((dimension == 2) || double_equals(z, other.z));
+        boolean mequals = ((haveMeasure == false) || double_equals(m,other.m));
         boolean result = xequals && yequals && zequals && mequals;
         return result;
     }