mapbox / leaflet-pip

point in polygon intersections for leaflet
https://mapbox.github.io/leaflet-pip/
BSD 2-Clause "Simplified" License
199 stars 46 forks source link

Create a copy of point before reversing #18

Closed codebling closed 8 years ago

codebling commented 8 years ago

If leafletPip.bassackwards is true, then the passed point is reversed in-place, which is a little rude.

leafletPip.bassackwards = true;
p=[45.51, -73.59];
leafletPip.pointInLayer(p, map.featureLayer, true);
//now p=[-73.59, 45.51];
leafletPip.pointInLayer(p, map.featureLayer, true);
//now p=[45.51, -73.59];

Bassackwards is bassackwards, but rude is rude. This change creates a copy of p before reversing it, such that in the example above, p would not be changed.

Tests pass 10/10.

tmcw commented 8 years ago

:+1: thx