From: Paul Ramsey Date: Wed, 15 Feb 2012 22:45:29 +0000 (+0000) Subject: jdbc: org.postgis.Point.equals() is not reflexive (#1313) X-Git-Tag: 2.0.0alpha6~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=918b57008b92a1208c98774fd6b319e5c415ce1e;p=postgis jdbc: org.postgis.Point.equals() is not reflexive (#1313) git-svn-id: http://svn.osgeo.org/postgis/trunk@9211 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/java/jdbc/src/org/postgis/Point.java b/java/jdbc/src/org/postgis/Point.java index 04c031916..24de60594 100644 --- a/java/jdbc/src/org/postgis/Point.java +++ b/java/jdbc/src/org/postgis/Point.java @@ -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; }