Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-lasso

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-lasso - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

18

dist/leaflet-lasso.cjs.js

@@ -131,7 +131,5 @@ 'use strict';

function polygonIntersects(polygon, layerGeometry) {
if (layerGeometry.type === "Point") {
return spatial.contains(polygon, layerGeometry);
}
// try contains first (fast), then intersects (slower)
return spatial.contains(polygon, layerGeometry) || spatial.intersects(polygon, layerGeometry);
return layerGeometry.type === "Point" ?
spatial.contains(polygon, layerGeometry) :
spatial.intersects(polygon, layerGeometry);
}

@@ -153,12 +151,16 @@ function getLayersInPolygon(polygon, layers, options) {

}
if (!polygonBounds.intersects(layerBounds)) {
var boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
// check full geometry (slower)
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
return options.intersect ?
var geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -165,0 +167,0 @@ return selectedLayers;

import { polyline, polygon, Layer, Polyline, latLngBounds, Circle, GeoJSON, CircleMarker, Marker, point, Path, MarkerCluster, Util, Handler, DomUtil, DomEvent, Control } from 'leaflet';
import { contains, calculateBounds, toCircle, intersects } from '@terraformer/spatial';
import { contains, intersects, calculateBounds, toCircle } from '@terraformer/spatial';

@@ -127,7 +127,5 @@ /*! *****************************************************************************

function polygonIntersects(polygon, layerGeometry) {
if (layerGeometry.type === "Point") {
return contains(polygon, layerGeometry);
}
// try contains first (fast), then intersects (slower)
return contains(polygon, layerGeometry) || intersects(polygon, layerGeometry);
return layerGeometry.type === "Point" ?
contains(polygon, layerGeometry) :
intersects(polygon, layerGeometry);
}

@@ -149,12 +147,16 @@ function getLayersInPolygon(polygon, layers, options) {

}
if (!polygonBounds.intersects(layerBounds)) {
var boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
// check full geometry (slower)
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
return options.intersect ?
var geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -161,0 +163,0 @@ return selectedLayers;

@@ -843,7 +843,5 @@ (function (global, factory) {

function polygonIntersects(polygon, layerGeometry) {
if (layerGeometry.type === "Point") {
return contains(polygon, layerGeometry);
}
// try contains first (fast), then intersects (slower)
return contains(polygon, layerGeometry) || intersects(polygon, layerGeometry);
return layerGeometry.type === "Point" ?
contains(polygon, layerGeometry) :
intersects(polygon, layerGeometry);
}

@@ -865,12 +863,16 @@ function getLayersInPolygon(polygon, layers, options) {

}
if (!polygonBounds.intersects(layerBounds)) {
var boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
// check full geometry (slower)
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
return options.intersect ?
var geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -877,0 +879,0 @@ return selectedLayers;

@@ -20,3 +20,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e((t=t||self).LeafletLasso={},t.L)}(this,(function(t,e){"use strict";

* Mon May 18 2020 14:30:36 GMT-0700 (Pacific Daylight Time)
*/var g=function(t,e){if(t.length!==e.length)return!1;for(var o=t.slice().sort(p),n=e.slice().sort(p),r=0;r<o.length;r++){if(o[r].length!==n[r].length)return!1;for(var i=0;i<o.length;i++)if(o[r][i]!==n[r][i])return!1}return!0},h=function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++){var l=s[a],u=l[0],c=l[1];(null===e||u<e)&&(e=u),(null===o||u>o)&&(o=u),(null===n||c<n)&&(n=c),(null===r||c>r)&&(r=c)}return[e,n,o,r]},y=function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++){var s=t[i],a=s[0],l=s[1];(null===e||a<e)&&(e=a),(null===o||a>o)&&(o=a),(null===n||l<n)&&(n=l),(null===r||l>r)&&(r=l)}return[e,n,o,r]},v=function(t){for(var e=[],o=t.features.length-1;o>=0;o--){var n=A(t.features[o].geometry);e.push([n[0],n[1]]),e.push([n[2],n[3]])}return y(e)},m=function(t){for(var e=[],o=t.geometries.length-1;o>=0;o--){var n=A(t.geometries[o]);e.push([n[0],n[1]]),e.push([n[2],n[3]])}return y(e)},A=function t(e){if(e.type)switch(e.type){case"Point":return[e.coordinates[0],e.coordinates[1],e.coordinates[0],e.coordinates[1]];case"MultiPoint":case"LineString":return y(e.coordinates);case"MultiLineString":case"Polygon":return h(e.coordinates);case"MultiPolygon":return function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++)for(var l=s[a],u=0;u<l.length;u++){var c=l[u],f=c[0],p=c[1];(null===e||f<e)&&(e=f),(null===o||f>o)&&(o=f),(null===n||p<n)&&(n=p),(null===r||p>r)&&(r=p)}return[e,n,o,r]}(e.coordinates);case"Feature":return e.geometry?t(e.geometry):null;case"FeatureCollection":return v(e);case"GeometryCollection":return m(e);default:throw new Error("Unknown type: "+e.type)}return null},L=function(t,e){if(t&&t.length){if(1===t.length)return c(t[0],e);if(c(t[0],e)){for(var o=1;o<t.length;o++)if(c(t[o],e))return!1;return!0}return!1}return!1},M=function t(e,o){var n,r,i;if("Feature"===o.type&&(o=o.geometry),"Point"===o.type&&"Point"===e.type)return f(e.coordinates,o.coordinates);if("MultiLineString"===o.type&&"Point"===e.type)for(r=0;r<e.coordinates.length;r++){if(t(e,{type:"LineString",coordinates:o.coordinates[r]}))return!0}if(("LineString"===o.type||"MultiPoint"===o.type)&&"Point"===e.type)for(r=0;r<o.coordinates.length;r++){if(e.coordinates.length!==o.coordinates[r].length)return!1;if(f(e.coordinates,o.coordinates[r]))return!0}if("Polygon"===o.type){if("Polygon"===e.type){if(o.coordinates.length===e.coordinates.length)for(r=0;r<e.coordinates.length;r++)if(g(e.coordinates[r],o.coordinates[r]))return!0;return!(!e.coordinates.length||!L(o.coordinates,e.coordinates[0][0]))&&!u(d(e.coordinates),d(o.coordinates))}if("Point"===e.type)return L(o.coordinates,e.coordinates);if("LineString"===e.type||"MultiPoint"===e.type){if(!e.coordinates||0===e.coordinates.length)return!1;for(r=0;r<e.coordinates.length;r++)if(!1===L(o.coordinates,e.coordinates[r]))return!1;return!0}if("MultiLineString"===e.type){for(r=0;r<e.coordinates.length;r++){if(!1===t({type:"LineString",coordinates:e.coordinates[r]},o))return i++,!1}return!0}if("MultiPolygon"===e.type){for(r=0;r<e.coordinates.length;r++){if(!1===t({type:"Polygon",coordinates:e.coordinates[r]},o))return!1}return!0}}if("MultiPolygon"===o.type){if("Point"===e.type){if(o.coordinates.length)for(r=0;r<o.coordinates.length;r++)if(n=o.coordinates[r],L(n,e.coordinates)&&!1===u([e.coordinates],o.coordinates))return!0;return!1}if("Polygon"===e.type){for(r=0;r<e.coordinates.length;r++)if(o.coordinates[r].length===e.coordinates.length)for(var s=0;s<e.coordinates.length;s++)if(g(e.coordinates[s],o.coordinates[r][s]))return!0;if(!1===u(e.coordinates,o.coordinates)&&o.coordinates.length){for(r=0;r<o.coordinates.length;r++)n=o.coordinates[r],i=!1!==L(n,e.coordinates[0][0]);return i}}else if("LineString"===e.type||"MultiPoint"===e.type)for(r=0;r<o.coordinates.length;r++){return!!t(e,{type:"Polygon",coordinates:o.coordinates[r]})}else{if("MultiLineString"===e.type){for(r=0;r<e.coordinates.length;r++){if(!1===t({type:"LineString",coordinates:e.coordinates[r]},o))return!1}return!0}if("MultiPolygon"===e.type){for(r=0;r<o.coordinates.length;r++){if(!1===t(e,{type:"Polygon",coordinates:o.coordinates[r]}))return!1}return!0}}}return!1},b=function(t,e){return M(e,t)},P=function t(e,o){return"Feature"===o.type&&(o=o.geometry),!(!M(e,o)&&!M(o,e))||("Point"!==e.type&&"MultiPoint"!==e.type&&"Point"!==o.type&&"MultiPoint"!==o.type?u(e.coordinates,o.coordinates):"Feature"===e.type?t(e.geometry,o):(function(){var t=Array.prototype.slice.apply(arguments);"undefined"!=typeof console&&console.warn&&console.warn.apply(console,t)}("Type "+e.type+" to "+o.type+" intersection is not supported by intersects"),!1))},S=6378137,E=6356752.3142,w=1/298.257223563,D=function(t,e,o){for(var n,r=o||64,i={type:"Polygon",coordinates:[[]]},s=0;s<r;s++)n=360*s/r,i.coordinates[0].push(C(t,n,e));return i.coordinates=d(i.coordinates),i},C=function(t,e,o){for(var n,r,i,s=S,a=E,l=w,u=t[0],c=t[1],f=o,p=Math.PI,d=e*p/180,g=Math.sin(d),h=Math.cos(d),y=(1-l)*Math.tan(c*p/180),v=1/Math.sqrt(1+y*y),m=y*v,A=Math.atan2(y,h),L=v*g,M=1-L*L,b=M*(s*s-a*a)/(a*a),P=1+b/16384*(4096+b*(b*(320-175*b)-768)),D=b/1024*(256+b*(b*(74-47*b)-128)),C=f/(a*P),I=2*Math.PI;Math.abs(C-I)>1e-12;)n=Math.cos(2*A+C),I=C,C=f/(a*P)+D*(r=Math.sin(C))*(n+D/4*((i=Math.cos(C))*(2*n*n-1)-D/6*n*(4*r*r-3)*(4*n*n-3)));var B=m*r-v*i*h,U=Math.atan2(m*i+v*r*h,(1-l)*Math.sqrt(L*L+B*B)),k=l/16*M*(4+l*(4-3*M));return[u+180*(Math.atan2(r*g,v*i-m*r*h)-(1-k)*l*L*(C+k*r*(n+k*i*(2*n*n-1))))/p,180*U/p]};function I(t,o){return function(t,e,o){var n=o||64,r=e||250;if(!t||t.length<2||!r||!n)throw new Error("Terraformer: missing parameter for Terraformer.Circle");return{type:"Feature",geometry:D(t,r,n),properties:{radius:r,center:t,steps:n}}}(e.GeoJSON.latLngToCoords(t),o).geometry}function B(t,o){return void 0===o&&(o={}),t instanceof e.Circle?I(t.getLatLng(),t.getRadius()):t instanceof e.CircleMarker?null!=o.zoom&&null!=o.crs?I(t.getLatLng(),function(t,o,n){var r=t.getLatLng(),i=o.latLngToPoint(r,n),s=t.getRadius()/Math.SQRT2,a=e.point([i.x-s,i.y-s]),l=o.pointToLatLng(a,n);return o.distance(r,l)}(t,o.crs,o.zoom)):(console.warn("Zoom and CRS is required for calculating CircleMarker polygon, falling back to center point only"),t.toGeoJSON().geometry):t instanceof e.Marker||t instanceof e.Polyline?t.toGeoJSON().geometry:void 0}function U(t,o,n){void 0===n&&(n={});var r=t.toGeoJSON().geometry,i=t.getBounds();return o.filter((function(t){var o,s,a;return t instanceof e.Polyline?s=t.getBounds():(o=B(t,n),a=A(o),s=e.latLngBounds([a[1],a[0]],[a[3],a[2]])),!!i.intersects(s)&&(o||(o=B(t,n)),n.intersect?function(t,e){return"Point"===e.type?b(t,e):b(t,e)||P(t,e)}(r,o):function(t,e){return b(t,e)}(r,o))}))}function k(t,e){void 0===e&&(e={});var o=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}k(".leaflet-lasso-active {\n cursor: crosshair;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.leaflet-lasso-active .leaflet-interactive {\n cursor: crosshair;\n pointer-events: none;\n}");var O="leaflet-lasso-active",R=function(t){function o(o,n){void 0===n&&(n={});var r=t.call(this,o)||this;return r.options={polygon:{color:"#00C3FF",weight:2},intersect:!1},r.onDocumentMouseMoveBound=r.onDocumentMouseMove.bind(r),r.onDocumentMouseUpBound=r.onDocumentMouseUp.bind(r),r.map=o,e.Util.setOptions(r,n),r}return n(o,t),o.prototype.setOptions=function(t){this.options=r(r({},this.options),t)},o.prototype.toggle=function(){this.enabled()?this.disable():this.enable()},o.prototype.addHooks=function(){this.map.getPane("mapPane"),this.map.on("mousedown",this.onMapMouseDown,this),this.map.getContainer().classList.add(O),this.map.dragging.disable(),this.map.fire("lasso.enabled")},o.prototype.removeHooks=function(){this.polygon&&(this.map.removeLayer(this.polygon),this.polygon=void 0),this.map.off("mousedown",this.onMapMouseDown,this),document.removeEventListener("mousemove",this.onDocumentMouseMoveBound),document.removeEventListener("mouseup",this.onDocumentMouseUpBound),this.map.getContainer().classList.remove(O),document.body.classList.remove(O),this.map.dragging.enable(),this.map.fire("lasso.disabled")},o.prototype.onMapMouseDown=function(t){var e=t;1===e.originalEvent.buttons?e.originalEvent.target.closest(".leaflet-control-container")||(this.polygon=new s([e.latlng],this.options.polygon).addTo(this.map),document.body.classList.add(O),document.addEventListener("mousemove",this.onDocumentMouseMoveBound),document.addEventListener("mouseup",this.onDocumentMouseUpBound)):this.disable()},o.prototype.onDocumentMouseMove=function(t){if(this.polygon){var e=t;if(1!==e.buttons)return console.warn("mouseup event was missed"),void this.finish();this.polygon.addLatLng(this.map.mouseEventToLatLng(e))}},o.prototype.onDocumentMouseUp=function(){this.finish()},o.prototype.finish=function(){var t=this;if(this.polygon){var o=[];this.map.eachLayer((function(n){n!==t.polygon&&n!==t.polygon.polyline&&n!==t.polygon.polygon&&(n instanceof e.Marker||n instanceof e.Path?o.push(n):e.MarkerCluster&&n instanceof e.MarkerCluster&&o.push.apply(o,n.getAllChildMarkers()))}));var n=U(this.polygon.polygon,o,{zoom:this.map.getZoom(),crs:this.map.options.crs,intersect:this.options.intersect});this.map.fire("lasso.finished",{latLngs:this.polygon.getLatLngs(),layers:n}),this.disable()}},o}(e.Handler);k(".leaflet-control-lasso {\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsSAAALEgHS3X78AAAD6UlEQVR4nO1b7XHbMAwFfP0fdYKqE8QbRJ0gGUEjaAR3A4/gbuBOUHWCKhs4E1SegD06jzmYpWhJpiRKNu58Tix+AA8gCQIQK6Xolml109LfAbgDcAfg5gH4NPQEzJwSkf4kRLR2NKmJqNLfSqlqaH7+4y/0McjML0SUQdinHkO8ApCSiPZKqToogxYFAQBC50T03NDkN74raFzSGtahreSLo+9PALG7mlEXaQD6fMD0BgIp8TkQ0ZaINChpl7ExZoZxK2vcGr8nfXl2ztm5g1twI/Q6KHPvVlFg/DMgJgEAWpWCay3lIYX2zJ1bQFQhAO+i9b2l8VEEd/BSWEooBgUAm5REPvg67AGCrZDdIABgQ6qF1oOu8QBAbK4FwTd4bq23SbXeks/OIPg0f7V5TQRCpz3BNdhamH30wgu+CwFC66VqD5IIByRas/eAYDbGqi8AW+FszEp4ocC6y1KQneW6z+YmvJDDLIVDVwBKdNzPVXghi/FbLjprp4AIM2fi6loMcusal8zN8eXirOp885jNrn/BAlKxnL17GWPj+As8viqlDguwAG3V+hR7JKJvSqmyqd1KmMnrUoQHGaEzX6OVaLAfg6sRyUSeUt+UKxGobDSTmZKR5yIAj/h79IhsDPSRFxg6+ho9AAukpI1IgydGxiY4dSRON+/SXgwAyE1sHbkF79JmeEuaPs91H4DWf+Ffk1nSgDwQ0RH5iUbZqgXcAI0MG/FbKn7f+i5DZo14PabISR/lb0qpjWETXq252LmSsidaCYfh8s0pbnKZuFHuEzNvmNl5MiR9YmmRLYHaxb8VJ3SG+UzD3ZyvwyI/UEPozMoZFE2xTjOADId1yuhGBMLO0raSUSE74HsGgDoPiZULsIISPkFqtUlEuOx0YsiHadeIakTC57bGPW0zAVRiP+yVXJhY+M6JHLFcCtfDvUAoahCseoXW0Wz0Oy1310O5WUQLgmX2ZddEzkffhoc2CJMUQ3h4kzt+v7S4ke/CRKWYaBtBYURmF2tcMda7bC0absWEk5TG4ISyS3Suury1BqAB+XIMIDCv7eAEsUTvHtDQoak8bhPSexSlcXadYBlqHu8p0BMIZRVIti9QeD/Hc/S1hVawgKDuufQDriqVZeYcAjeVyL4BGBc1lcaSKY8dolaYmTXgf0ykKFStcCIKpM33Q8vuR1EcXeEuMkhoDnyWCKB81wGUQV+aEhFaJ/mSlgPwYvyHZ8QN9SlS38RbY3hnYQ/NHyH8KVq0+DdGdCgMS+sRe1ImX8xYvAUw8wGb7Q9c88/2l1sAIEPBlPM0ur85GgEPk9IdgAh4mJTuAETAw3RERP8Ab2Uzgrad13wAAAAASUVORK5CYII=');\n background-size: 22px;\n}");var T=function(t){function o(o){void 0===o&&(o={});var n=t.call(this)||this;return n.options={position:"topright"},e.Util.setOptions(n,o),n}return n(o,t),o.prototype.setOptions=function(t){this.options=r(r({},this.options),t),this.lasso&&this.lasso.setOptions(this.options)},o.prototype.onAdd=function(t){this.lasso=new R(t,this.options);var o=e.DomUtil.create("div","leaflet-bar leaflet-control"),n=e.DomUtil.create("a","leaflet-control-lasso",o);return n.href="#",n.title="Toggle Lasso",n.setAttribute("role","button"),n.setAttribute("aria-label",n.title),e.DomEvent.addListener(n,"click",this.toggle,this),e.DomEvent.disableClickPropagation(n),o},o.prototype.enabled=function(){return!!this.lasso&&this.lasso.enabled()},o.prototype.enable=function(){this.lasso&&this.lasso.enable()},o.prototype.disable=function(){this.lasso&&this.lasso.disable()},o.prototype.toggle=function(){this.lasso&&this.lasso.toggle()},o}(e.Control);void 0!==window.L&&(window.L.Lasso=R,window.L.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(R.bind.apply(R,i([void 0],t)))},window.L.Control.Lasso=T,window.L.control.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(T.bind.apply(T,i([void 0],t)))}),t.ACTIVE_CLASS=O,t.DISABLED_EVENT="lasso.disabled",t.ENABLED_EVENT="lasso.enabled",t.FINISHED_EVENT="lasso.finished",t.LassoControl=T,t.LassoHandler=R,Object.defineProperty(t,"__esModule",{value:!0})}));
*/var g=function(t,e){if(t.length!==e.length)return!1;for(var o=t.slice().sort(p),n=e.slice().sort(p),r=0;r<o.length;r++){if(o[r].length!==n[r].length)return!1;for(var i=0;i<o.length;i++)if(o[r][i]!==n[r][i])return!1}return!0},h=function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++){var l=s[a],u=l[0],c=l[1];(null===e||u<e)&&(e=u),(null===o||u>o)&&(o=u),(null===n||c<n)&&(n=c),(null===r||c>r)&&(r=c)}return[e,n,o,r]},y=function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++){var s=t[i],a=s[0],l=s[1];(null===e||a<e)&&(e=a),(null===o||a>o)&&(o=a),(null===n||l<n)&&(n=l),(null===r||l>r)&&(r=l)}return[e,n,o,r]},v=function(t){for(var e=[],o=t.features.length-1;o>=0;o--){var n=A(t.features[o].geometry);e.push([n[0],n[1]]),e.push([n[2],n[3]])}return y(e)},m=function(t){for(var e=[],o=t.geometries.length-1;o>=0;o--){var n=A(t.geometries[o]);e.push([n[0],n[1]]),e.push([n[2],n[3]])}return y(e)},A=function t(e){if(e.type)switch(e.type){case"Point":return[e.coordinates[0],e.coordinates[1],e.coordinates[0],e.coordinates[1]];case"MultiPoint":case"LineString":return y(e.coordinates);case"MultiLineString":case"Polygon":return h(e.coordinates);case"MultiPolygon":return function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++)for(var l=s[a],u=0;u<l.length;u++){var c=l[u],f=c[0],p=c[1];(null===e||f<e)&&(e=f),(null===o||f>o)&&(o=f),(null===n||p<n)&&(n=p),(null===r||p>r)&&(r=p)}return[e,n,o,r]}(e.coordinates);case"Feature":return e.geometry?t(e.geometry):null;case"FeatureCollection":return v(e);case"GeometryCollection":return m(e);default:throw new Error("Unknown type: "+e.type)}return null},L=function(t,e){if(t&&t.length){if(1===t.length)return c(t[0],e);if(c(t[0],e)){for(var o=1;o<t.length;o++)if(c(t[o],e))return!1;return!0}return!1}return!1},M=function t(e,o){var n,r,i;if("Feature"===o.type&&(o=o.geometry),"Point"===o.type&&"Point"===e.type)return f(e.coordinates,o.coordinates);if("MultiLineString"===o.type&&"Point"===e.type)for(r=0;r<e.coordinates.length;r++){if(t(e,{type:"LineString",coordinates:o.coordinates[r]}))return!0}if(("LineString"===o.type||"MultiPoint"===o.type)&&"Point"===e.type)for(r=0;r<o.coordinates.length;r++){if(e.coordinates.length!==o.coordinates[r].length)return!1;if(f(e.coordinates,o.coordinates[r]))return!0}if("Polygon"===o.type){if("Polygon"===e.type){if(o.coordinates.length===e.coordinates.length)for(r=0;r<e.coordinates.length;r++)if(g(e.coordinates[r],o.coordinates[r]))return!0;return!(!e.coordinates.length||!L(o.coordinates,e.coordinates[0][0]))&&!u(d(e.coordinates),d(o.coordinates))}if("Point"===e.type)return L(o.coordinates,e.coordinates);if("LineString"===e.type||"MultiPoint"===e.type){if(!e.coordinates||0===e.coordinates.length)return!1;for(r=0;r<e.coordinates.length;r++)if(!1===L(o.coordinates,e.coordinates[r]))return!1;return!0}if("MultiLineString"===e.type){for(r=0;r<e.coordinates.length;r++){if(!1===t({type:"LineString",coordinates:e.coordinates[r]},o))return i++,!1}return!0}if("MultiPolygon"===e.type){for(r=0;r<e.coordinates.length;r++){if(!1===t({type:"Polygon",coordinates:e.coordinates[r]},o))return!1}return!0}}if("MultiPolygon"===o.type){if("Point"===e.type){if(o.coordinates.length)for(r=0;r<o.coordinates.length;r++)if(n=o.coordinates[r],L(n,e.coordinates)&&!1===u([e.coordinates],o.coordinates))return!0;return!1}if("Polygon"===e.type){for(r=0;r<e.coordinates.length;r++)if(o.coordinates[r].length===e.coordinates.length)for(var s=0;s<e.coordinates.length;s++)if(g(e.coordinates[s],o.coordinates[r][s]))return!0;if(!1===u(e.coordinates,o.coordinates)&&o.coordinates.length){for(r=0;r<o.coordinates.length;r++)n=o.coordinates[r],i=!1!==L(n,e.coordinates[0][0]);return i}}else if("LineString"===e.type||"MultiPoint"===e.type)for(r=0;r<o.coordinates.length;r++){return!!t(e,{type:"Polygon",coordinates:o.coordinates[r]})}else{if("MultiLineString"===e.type){for(r=0;r<e.coordinates.length;r++){if(!1===t({type:"LineString",coordinates:e.coordinates[r]},o))return!1}return!0}if("MultiPolygon"===e.type){for(r=0;r<o.coordinates.length;r++){if(!1===t(e,{type:"Polygon",coordinates:o.coordinates[r]}))return!1}return!0}}}return!1},b=function(t,e){return M(e,t)},P=function t(e,o){return"Feature"===o.type&&(o=o.geometry),!(!M(e,o)&&!M(o,e))||("Point"!==e.type&&"MultiPoint"!==e.type&&"Point"!==o.type&&"MultiPoint"!==o.type?u(e.coordinates,o.coordinates):"Feature"===e.type?t(e.geometry,o):(function(){var t=Array.prototype.slice.apply(arguments);"undefined"!=typeof console&&console.warn&&console.warn.apply(console,t)}("Type "+e.type+" to "+o.type+" intersection is not supported by intersects"),!1))},S=6378137,E=6356752.3142,w=1/298.257223563,D=function(t,e,o){for(var n,r=o||64,i={type:"Polygon",coordinates:[[]]},s=0;s<r;s++)n=360*s/r,i.coordinates[0].push(C(t,n,e));return i.coordinates=d(i.coordinates),i},C=function(t,e,o){for(var n,r,i,s=S,a=E,l=w,u=t[0],c=t[1],f=o,p=Math.PI,d=e*p/180,g=Math.sin(d),h=Math.cos(d),y=(1-l)*Math.tan(c*p/180),v=1/Math.sqrt(1+y*y),m=y*v,A=Math.atan2(y,h),L=v*g,M=1-L*L,b=M*(s*s-a*a)/(a*a),P=1+b/16384*(4096+b*(b*(320-175*b)-768)),D=b/1024*(256+b*(b*(74-47*b)-128)),C=f/(a*P),I=2*Math.PI;Math.abs(C-I)>1e-12;)n=Math.cos(2*A+C),I=C,C=f/(a*P)+D*(r=Math.sin(C))*(n+D/4*((i=Math.cos(C))*(2*n*n-1)-D/6*n*(4*r*r-3)*(4*n*n-3)));var B=m*r-v*i*h,U=Math.atan2(m*i+v*r*h,(1-l)*Math.sqrt(L*L+B*B)),k=l/16*M*(4+l*(4-3*M));return[u+180*(Math.atan2(r*g,v*i-m*r*h)-(1-k)*l*L*(C+k*r*(n+k*i*(2*n*n-1))))/p,180*U/p]};function I(t,o){return function(t,e,o){var n=o||64,r=e||250;if(!t||t.length<2||!r||!n)throw new Error("Terraformer: missing parameter for Terraformer.Circle");return{type:"Feature",geometry:D(t,r,n),properties:{radius:r,center:t,steps:n}}}(e.GeoJSON.latLngToCoords(t),o).geometry}function B(t,o){return void 0===o&&(o={}),t instanceof e.Circle?I(t.getLatLng(),t.getRadius()):t instanceof e.CircleMarker?null!=o.zoom&&null!=o.crs?I(t.getLatLng(),function(t,o,n){var r=t.getLatLng(),i=o.latLngToPoint(r,n),s=t.getRadius()/Math.SQRT2,a=e.point([i.x-s,i.y-s]),l=o.pointToLatLng(a,n);return o.distance(r,l)}(t,o.crs,o.zoom)):(console.warn("Zoom and CRS is required for calculating CircleMarker polygon, falling back to center point only"),t.toGeoJSON().geometry):t instanceof e.Marker||t instanceof e.Polyline?t.toGeoJSON().geometry:void 0}function U(t,o,n){void 0===n&&(n={});var r=t.toGeoJSON().geometry,i=t.getBounds();return o.filter((function(t){var o,s,a;return t instanceof e.Polyline?s=t.getBounds():(o=B(t,n),a=A(o),s=e.latLngBounds([a[1],a[0]],[a[3],a[2]])),!!(n.intersect?i.intersects(s):i.contains(s))&&(o||(o=B(t,n)),n.intersect?function(t,e){return"Point"===e.type?b(t,e):P(t,e)}(r,o):function(t,e){return b(t,e)}(r,o))}))}function k(t,e){void 0===e&&(e={});var o=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}k(".leaflet-lasso-active {\n cursor: crosshair;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.leaflet-lasso-active .leaflet-interactive {\n cursor: crosshair;\n pointer-events: none;\n}");var O="leaflet-lasso-active",R=function(t){function o(o,n){void 0===n&&(n={});var r=t.call(this,o)||this;return r.options={polygon:{color:"#00C3FF",weight:2},intersect:!1},r.onDocumentMouseMoveBound=r.onDocumentMouseMove.bind(r),r.onDocumentMouseUpBound=r.onDocumentMouseUp.bind(r),r.map=o,e.Util.setOptions(r,n),r}return n(o,t),o.prototype.setOptions=function(t){this.options=r(r({},this.options),t)},o.prototype.toggle=function(){this.enabled()?this.disable():this.enable()},o.prototype.addHooks=function(){this.map.getPane("mapPane"),this.map.on("mousedown",this.onMapMouseDown,this),this.map.getContainer().classList.add(O),this.map.dragging.disable(),this.map.fire("lasso.enabled")},o.prototype.removeHooks=function(){this.polygon&&(this.map.removeLayer(this.polygon),this.polygon=void 0),this.map.off("mousedown",this.onMapMouseDown,this),document.removeEventListener("mousemove",this.onDocumentMouseMoveBound),document.removeEventListener("mouseup",this.onDocumentMouseUpBound),this.map.getContainer().classList.remove(O),document.body.classList.remove(O),this.map.dragging.enable(),this.map.fire("lasso.disabled")},o.prototype.onMapMouseDown=function(t){var e=t;1===e.originalEvent.buttons?e.originalEvent.target.closest(".leaflet-control-container")||(this.polygon=new s([e.latlng],this.options.polygon).addTo(this.map),document.body.classList.add(O),document.addEventListener("mousemove",this.onDocumentMouseMoveBound),document.addEventListener("mouseup",this.onDocumentMouseUpBound)):this.disable()},o.prototype.onDocumentMouseMove=function(t){if(this.polygon){var e=t;if(1!==e.buttons)return console.warn("mouseup event was missed"),void this.finish();this.polygon.addLatLng(this.map.mouseEventToLatLng(e))}},o.prototype.onDocumentMouseUp=function(){this.finish()},o.prototype.finish=function(){var t=this;if(this.polygon){var o=[];this.map.eachLayer((function(n){n!==t.polygon&&n!==t.polygon.polyline&&n!==t.polygon.polygon&&(n instanceof e.Marker||n instanceof e.Path?o.push(n):e.MarkerCluster&&n instanceof e.MarkerCluster&&o.push.apply(o,n.getAllChildMarkers()))}));var n=U(this.polygon.polygon,o,{zoom:this.map.getZoom(),crs:this.map.options.crs,intersect:this.options.intersect});this.map.fire("lasso.finished",{latLngs:this.polygon.getLatLngs(),layers:n}),this.disable()}},o}(e.Handler);k(".leaflet-control-lasso {\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsSAAALEgHS3X78AAAD6UlEQVR4nO1b7XHbMAwFfP0fdYKqE8QbRJ0gGUEjaAR3A4/gbuBOUHWCKhs4E1SegD06jzmYpWhJpiRKNu58Tix+AA8gCQIQK6Xolml109LfAbgDcAfg5gH4NPQEzJwSkf4kRLR2NKmJqNLfSqlqaH7+4y/0McjML0SUQdinHkO8ApCSiPZKqToogxYFAQBC50T03NDkN74raFzSGtahreSLo+9PALG7mlEXaQD6fMD0BgIp8TkQ0ZaINChpl7ExZoZxK2vcGr8nfXl2ztm5g1twI/Q6KHPvVlFg/DMgJgEAWpWCay3lIYX2zJ1bQFQhAO+i9b2l8VEEd/BSWEooBgUAm5REPvg67AGCrZDdIABgQ6qF1oOu8QBAbK4FwTd4bq23SbXeks/OIPg0f7V5TQRCpz3BNdhamH30wgu+CwFC66VqD5IIByRas/eAYDbGqi8AW+FszEp4ocC6y1KQneW6z+YmvJDDLIVDVwBKdNzPVXghi/FbLjprp4AIM2fi6loMcusal8zN8eXirOp885jNrn/BAlKxnL17GWPj+As8viqlDguwAG3V+hR7JKJvSqmyqd1KmMnrUoQHGaEzX6OVaLAfg6sRyUSeUt+UKxGobDSTmZKR5yIAj/h79IhsDPSRFxg6+ho9AAukpI1IgydGxiY4dSRON+/SXgwAyE1sHbkF79JmeEuaPs91H4DWf+Ffk1nSgDwQ0RH5iUbZqgXcAI0MG/FbKn7f+i5DZo14PabISR/lb0qpjWETXq252LmSsidaCYfh8s0pbnKZuFHuEzNvmNl5MiR9YmmRLYHaxb8VJ3SG+UzD3ZyvwyI/UEPozMoZFE2xTjOADId1yuhGBMLO0raSUSE74HsGgDoPiZULsIISPkFqtUlEuOx0YsiHadeIakTC57bGPW0zAVRiP+yVXJhY+M6JHLFcCtfDvUAoahCseoXW0Wz0Oy1310O5WUQLgmX2ZddEzkffhoc2CJMUQ3h4kzt+v7S4ke/CRKWYaBtBYURmF2tcMda7bC0absWEk5TG4ISyS3Suury1BqAB+XIMIDCv7eAEsUTvHtDQoak8bhPSexSlcXadYBlqHu8p0BMIZRVIti9QeD/Hc/S1hVawgKDuufQDriqVZeYcAjeVyL4BGBc1lcaSKY8dolaYmTXgf0ykKFStcCIKpM33Q8vuR1EcXeEuMkhoDnyWCKB81wGUQV+aEhFaJ/mSlgPwYvyHZ8QN9SlS38RbY3hnYQ/NHyH8KVq0+DdGdCgMS+sRe1ImX8xYvAUw8wGb7Q9c88/2l1sAIEPBlPM0ur85GgEPk9IdgAh4mJTuAETAw3RERP8Ab2Uzgrad13wAAAAASUVORK5CYII=');\n background-size: 22px;\n}");var T=function(t){function o(o){void 0===o&&(o={});var n=t.call(this)||this;return n.options={position:"topright"},e.Util.setOptions(n,o),n}return n(o,t),o.prototype.setOptions=function(t){this.options=r(r({},this.options),t),this.lasso&&this.lasso.setOptions(this.options)},o.prototype.onAdd=function(t){this.lasso=new R(t,this.options);var o=e.DomUtil.create("div","leaflet-bar leaflet-control"),n=e.DomUtil.create("a","leaflet-control-lasso",o);return n.href="#",n.title="Toggle Lasso",n.setAttribute("role","button"),n.setAttribute("aria-label",n.title),e.DomEvent.addListener(n,"click",this.toggle,this),e.DomEvent.disableClickPropagation(n),o},o.prototype.enabled=function(){return!!this.lasso&&this.lasso.enabled()},o.prototype.enable=function(){this.lasso&&this.lasso.enable()},o.prototype.disable=function(){this.lasso&&this.lasso.disable()},o.prototype.toggle=function(){this.lasso&&this.lasso.toggle()},o}(e.Control);void 0!==window.L&&(window.L.Lasso=R,window.L.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(R.bind.apply(R,i([void 0],t)))},window.L.Control.Lasso=T,window.L.control.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(T.bind.apply(T,i([void 0],t)))}),t.ACTIVE_CLASS=O,t.DISABLED_EVENT="lasso.disabled",t.ENABLED_EVENT="lasso.enabled",t.FINISHED_EVENT="lasso.finished",t.LassoControl=T,t.LassoHandler=R,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=leaflet-lasso.umd.min.js.map
{
"name": "leaflet-lasso",
"version": "2.1.2",
"version": "2.1.3",
"description": "Leaflet plugin for lasso selection",

@@ -5,0 +5,0 @@ "keywords": [

# leaflet-lasso
![](https://img.shields.io/npm/dm/leaflet-lasso)
![](https://img.shields.io/david/zakjan/leaflet-lasso)
![](https://img.shields.io/bundlephobia/min/leaflet-lasso)
[![](https://img.shields.io/npm/dm/leaflet-lasso)](https://www.npmjs.com/package/leaflet-lasso)
[![](https://img.shields.io/david/zakjan/leaflet-lasso)](https://www.npmjs.com/package/leaflet-lasso)
[![](https://img.shields.io/bundlephobia/min/leaflet-lasso)](https://www.npmjs.com/package/leaflet-lasso)

@@ -38,3 +38,3 @@ True lasso selection plugin for Leaflet. [Demo](http://zakjan.github.io/leaflet-lasso/)

```
<script src="https://unpkg.com/leaflet-lasso@2.1.2/dist/leaflet-lasso.umd.min.js"></script>
<script src="https://unpkg.com/leaflet-lasso@2.1.3/dist/leaflet-lasso.umd.min.js"></script>
```

@@ -41,0 +41,0 @@

@@ -49,8 +49,5 @@ import * as L from 'leaflet';

function polygonIntersects(polygon: GeoJSON.Polygon, layerGeometry: GeoJSON.GeometryObject) {
if (layerGeometry.type === "Point") {
return contains(polygon, layerGeometry);
}
// try contains first (fast), then intersects (slower)
return contains(polygon, layerGeometry) || intersects(polygon, layerGeometry);
return layerGeometry.type === "Point" ?
contains(polygon, layerGeometry) :
intersects(polygon, layerGeometry);
}

@@ -73,7 +70,10 @@

if (!polygonBounds.intersects(layerBounds)) {
const boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
// check full geometry (slower)
// check full geometry (slow)
if (!layerGeometry) {

@@ -83,5 +83,6 @@ layerGeometry = layerToGeoJSONGeometry(layer, options);

return options.intersect ?
const geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -88,0 +89,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc