Select to view content in your preferred language

Bug in esri.geometry.geometricDensify in 2.2?

876
4
04-27-2011 11:51 AM
PhillipReed
New Contributor
This function seems to fail sometimes for points that are very far apart (20,000 km or so -- I'm not sure exactly where the error happens).  Instead of returning a Polyline that is broken up into lots of little segments, it returns a Polyline with two points, one of which is the original start point and the second of which is NaN,NaN.  For example, try this:

var pline = new esri.geometry.Polyline();
pline.addPath([[-48.6, 39.4], [130.9, -39.3]]);
var result = esri.geometry.geodesicDensify(pline, 10000);
if( isNaN( result.paths[0][1][0] ) ) {
    alert("It's a bug!");
}


Changing the distance by even a short amount seems to work perfectly -- for example, replace the -48.6 above with a -48.5, and it runs just fine.  I've tested it in Firefox 4.0 and Chromium 12.0.747.0 in Ubuntu Linux 10.10, and it behaves exactly the same way in both browsers.

Does anybody else see this?  Anybody know what's going wrong?
0 Kudos
4 Replies
derekswingley1
Deactivated User
This is a strange one...I think it is a bug. It looks like only it happens when the difference between x coords is between 179.5 and 180.5. How'd you find this?
0 Kudos
PhillipReed
New Contributor
I think I pretty much just got unlucky; I've got some code that is drawing lines of bearing, and uses 20,000 km as the default length.  Some of them just happened to have coordinates that caused the function to fail.
0 Kudos
derekswingley1
Deactivated User
Can you log this as a bug with Esri support?
0 Kudos
JianHuang
Deactivated User
Phillip,

This is a known limit of the algorithm itself, instead of a bug. When two points are nearly antipodal to each other, the algorithm couldn't converge to get the geodetic distance and azimuth. We will "fix" the issue by implementing another algorithm when the case happens.
Thanks.
0 Kudos