Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapping is slow because of slow atPoint operation #1251

Open
bartvde opened this issue Feb 18, 2014 · 0 comments
Open

snapping is slow because of slow atPoint operation #1251

bartvde opened this issue Feb 18, 2014 · 0 comments

Comments

@bartvde
Copy link
Member

bartvde commented Feb 18, 2014

This was reported to me. OpenLayers.Geometry.prototype.atPoint is slow because of time taken in OpenLayers.Util.toFloat and the constructor of OpenLayers.Bounds.

The following code which bypasses those is twice as fast:

OpenLayers.Geometry.prototype.atPoint = function(lonlat, toleranceLon, toleranceLat) {
   var atPoint = false;
   var bounds = this.getBounds();
   if ((bounds != null) && (lonlat != null)) { 
       var dX = (toleranceLon != null) ? toleranceLon : 0;
       var dY = (toleranceLat != null) ? toleranceLat : 0; 
       var tb = this.bounds;
       var x = lonlat.lon;
       var y = lonlat.lat;
       atPoint = (x > (tb.left - dX)) && (x < (tb.right + dX)) &&  (y > (tb.bottom - dY)) && (y < (tb.top + dY));
   }
   return atPoint; 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant