Skip to content

Commit f2468d5

Browse files
committed
Merge pull request Esri#103 from Esri/geodist_issue
A fix for geodist hang
2 parents 20224f9 + df0ce3b commit f2468d5

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

src/main/java/com/esri/core/geometry/GeoDist.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static public void geodesic_distance_ngs(double a, double e2, double lam1,
257257
/* top of the long-line loop (kind = 1) */
258258

259259
q_continue_looping = true;
260-
while (q_continue_looping == true) {
260+
while (q_continue_looping && it < 100) {
261261
it = it + 1;
262262

263263
if (kind == 1) {

src/main/java/com/esri/core/geometry/SpatialReferenceImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.HashMap;
2828
import java.util.Map;
2929
import java.util.concurrent.locks.ReentrantLock;
30-
3130
import java.lang.ref.*;
3231

3332
import com.esri.core.geometry.Envelope2D;
@@ -230,8 +229,8 @@ static double geodesicDistanceOnWGS84Impl(Point ptFrom, Point ptTo) {
230229
double e2 = 0.0066943799901413165; // ellipticity for WGS_1984
231230
double rpu = Math.PI / 180.0;
232231
PeDouble answer = new PeDouble();
233-
GeoDist.geodesic_distance_ngs(a, e2, ptFrom.getXY().x * rpu,
234-
ptFrom.getXY().y * rpu, ptTo.getXY().x * rpu, ptTo.getXY().y
232+
GeoDist.geodesic_distance_ngs(a, e2, ptFrom.getX() * rpu,
233+
ptFrom.getY() * rpu, ptTo.getX() * rpu, ptTo.getY()
235234
* rpu, answer, null, null);
236235
return answer.val;
237236
}

src/test/java/com/esri/core/geometry/TestGeodetic.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,37 @@ public void testRotationInvariance() {
5050
}
5151
}
5252

53+
@Test
54+
public void testDistanceFailure() {
55+
{
56+
Point p1 = new Point(-60.668485, -31.996013333333334);
57+
Point p2 = new Point(119.13731666666666, 32.251583333333336);
58+
double d = GeometryEngine.geodesicDistanceOnWGS84(p1, p2);
59+
assertTrue(Math.abs(d - 19973410.50579736) < 1e-13 * 19973410.50579736);
60+
}
61+
62+
{
63+
Point p1 = new Point(121.27343833333333, 27.467438333333334);
64+
Point p2 = new Point(-58.55804833333333, -27.035613333333334);
65+
double d = GeometryEngine.geodesicDistanceOnWGS84(p1, p2);
66+
assertTrue(Math.abs(d - 19954707.428360686) < 1e-13 * 19954707.428360686);
67+
}
68+
69+
{
70+
Point p1 = new Point(-53.329865, -36.08110166666667);
71+
Point p2 = new Point(126.52895166666667, 35.97385);
72+
double d = GeometryEngine.geodesicDistanceOnWGS84(p1, p2);
73+
assertTrue(Math.abs(d - 19990586.700431127) < 1e-13 * 19990586.700431127);
74+
}
75+
76+
{
77+
Point p1 = new Point(-4.7181166667, 36.1160166667);
78+
Point p2 = new Point(175.248925, -35.7606716667);
79+
double d = GeometryEngine.geodesicDistanceOnWGS84(p1, p2);
80+
assertTrue(Math.abs(d - 19964450.206594173) < 1e-12 * 19964450.206594173);
81+
}
82+
}
83+
5384
@Test
5485
public void testLengthAccurateCR191313() {
5586
/*

0 commit comments

Comments
 (0)