New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.0 to 2.1.1

6

CHANGELOG.md
# Changelog
## 2.1.1
- improved performance for lots of complex polygons by checking the bounds first, then checking the full geometries
## 2.1.0
- switched from `terraform` to `@terraform/spatial` dependency -> half bundle size, thanks to @jgravois! 🎉 (60 kB -> 33 kB, 24 kB -> 14 kB minified)
- switched from `terraformer` to `@terraformer/spatial` dependency -> half bundle size, thanks to @jgravois! 🎉 (60 kB -> 33 kB, 24 kB -> 14 kB minified)
- updated `leaflet` imports to not require `esModuleInterop`
- bundled TS typings with `rollup-plugin-dts`

@@ -88,2 +88,7 @@ 'use strict';

function geoJSONGeometryToBounds(geometry) {
var bounds = spatial.calculateBounds(geometry);
var leafletBounds = L.latLngBounds([bounds[1], bounds[0]], [bounds[3], bounds[2]]);
return leafletBounds;
}
function getCircleMarkerRadius(circleMarker, crs, zoom) {

@@ -133,10 +138,29 @@ var latLng = circleMarker.getLatLng();

if (options === void 0) { options = {}; }
var polygonGeometry = polygon.toGeoJSON().geometry;
var polygonBounds = polygon.getBounds();
var selectedLayers = layers.filter(function (layer) {
var layerGeometry = layerToGeoJSONGeometry(layer, options);
if (!layerGeometry) {
// check bounds first (fast)
var layerGeometry;
var layerBounds;
if (layer instanceof L.Polyline) {
layerBounds = layer.getBounds();
}
else {
layerGeometry = layerToGeoJSONGeometry(layer, options);
layerBounds = geoJSONGeometryToBounds(layerGeometry);
}
var boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
return options.intersect ?
polygonIntersects(polygon, layerGeometry) :
polygonContains(polygon, layerGeometry);
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
var geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -267,3 +291,2 @@ return selectedLayers;

}
var polygon = this.polygon.toGeoJSON().geometry;
var layers = [];

@@ -281,3 +304,3 @@ this.map.eachLayer(function (layer) {

});
var selectedFeatures = getLayersInPolygon(polygon, layers, {
var selectedFeatures = getLayersInPolygon(this.polygon.polygon, layers, {
zoom: this.map.getZoom(),

@@ -284,0 +307,0 @@ crs: this.map.options.crs,

41

dist/leaflet-lasso.esm.js

@@ -1,3 +0,3 @@

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

@@ -84,2 +84,7 @@ /*! *****************************************************************************

function geoJSONGeometryToBounds(geometry) {
var bounds = calculateBounds(geometry);
var leafletBounds = latLngBounds([bounds[1], bounds[0]], [bounds[3], bounds[2]]);
return leafletBounds;
}
function getCircleMarkerRadius(circleMarker, crs, zoom) {

@@ -129,10 +134,29 @@ var latLng = circleMarker.getLatLng();

if (options === void 0) { options = {}; }
var polygonGeometry = polygon.toGeoJSON().geometry;
var polygonBounds = polygon.getBounds();
var selectedLayers = layers.filter(function (layer) {
var layerGeometry = layerToGeoJSONGeometry(layer, options);
if (!layerGeometry) {
// check bounds first (fast)
var layerGeometry;
var layerBounds;
if (layer instanceof Polyline) {
layerBounds = layer.getBounds();
}
else {
layerGeometry = layerToGeoJSONGeometry(layer, options);
layerBounds = geoJSONGeometryToBounds(layerGeometry);
}
var boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
return options.intersect ?
polygonIntersects(polygon, layerGeometry) :
polygonContains(polygon, layerGeometry);
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
var geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -263,3 +287,2 @@ return selectedLayers;

}
var polygon = this.polygon.toGeoJSON().geometry;
var layers = [];

@@ -277,3 +300,3 @@ this.map.eachLayer(function (layer) {

});
var selectedFeatures = getLayersInPolygon(polygon, layers, {
var selectedFeatures = getLayersInPolygon(this.polygon.polygon, layers, {
zoom: this.map.getZoom(),

@@ -280,0 +303,0 @@ crs: this.map.options.crs,

@@ -234,2 +234,231 @@ (function (global, factory) {

/*
Internal: Calculate an bounding box from an nested array of positions
[
[
[ [lng, lat],[lng, lat],[lng, lat] ]
]
[
[lng, lat],[lng, lat],[lng, lat]
]
[
[lng, lat],[lng, lat],[lng, lat]
]
]
*/
var calculateBoundsFromNestedArrays = function calculateBoundsFromNestedArrays(array) {
var x1 = null;
var x2 = null;
var y1 = null;
var y2 = null;
for (var i = 0; i < array.length; i++) {
var inner = array[i];
for (var j = 0; j < inner.length; j++) {
var lonlat = inner[j];
var lon = lonlat[0];
var lat = lonlat[1];
if (x1 === null) {
x1 = lon;
} else if (lon < x1) {
x1 = lon;
}
if (x2 === null) {
x2 = lon;
} else if (lon > x2) {
x2 = lon;
}
if (y1 === null) {
y1 = lat;
} else if (lat < y1) {
y1 = lat;
}
if (y2 === null) {
y2 = lat;
} else if (lat > y2) {
y2 = lat;
}
}
}
return [x1, y1, x2, y2];
};
/*
Internal: Calculate a bounding box from an array of arrays of arrays
[
[ [lng, lat],[lng, lat],[lng, lat] ]
[ [lng, lat],[lng, lat],[lng, lat] ]
[ [lng, lat],[lng, lat],[lng, lat] ]
]
*/
var calculateBoundsFromNestedArrayOfArrays = function calculateBoundsFromNestedArrayOfArrays(array) {
var x1 = null;
var x2 = null;
var y1 = null;
var y2 = null;
for (var i = 0; i < array.length; i++) {
var inner = array[i]; // return calculateBoundsFromNestedArrays(inner); // more DRY?
for (var j = 0; j < inner.length; j++) {
var innerinner = inner[j];
for (var k = 0; k < innerinner.length; k++) {
var lonlat = innerinner[k];
var lon = lonlat[0];
var lat = lonlat[1];
if (x1 === null) {
x1 = lon;
} else if (lon < x1) {
x1 = lon;
}
if (x2 === null) {
x2 = lon;
} else if (lon > x2) {
x2 = lon;
}
if (y1 === null) {
y1 = lat;
} else if (lat < y1) {
y1 = lat;
}
if (y2 === null) {
y2 = lat;
} else if (lat > y2) {
y2 = lat;
}
}
}
}
return [x1, y1, x2, y2];
};
/*
Internal: Calculate a bounding box from an array of positions
[
[lng, lat],[lng, lat],[lng, lat]
]
*/
var calculateBoundsFromArray = function calculateBoundsFromArray(array) {
var x1 = null;
var x2 = null;
var y1 = null;
var y2 = null;
for (var i = 0; i < array.length; i++) {
var lonlat = array[i];
var lon = lonlat[0];
var lat = lonlat[1];
if (x1 === null) {
x1 = lon;
} else if (lon < x1) {
x1 = lon;
}
if (x2 === null) {
x2 = lon;
} else if (lon > x2) {
x2 = lon;
}
if (y1 === null) {
y1 = lat;
} else if (lat < y1) {
y1 = lat;
}
if (y2 === null) {
y2 = lat;
} else if (lat > y2) {
y2 = lat;
}
}
return [x1, y1, x2, y2];
};
/*
Internal: Calculate an bounding box for a feature collection
*/
var calculateBoundsForFeatureCollection = function calculateBoundsForFeatureCollection(featureCollection) {
var extents = [];
for (var i = featureCollection.features.length - 1; i >= 0; i--) {
var extent = calculateBounds(featureCollection.features[i].geometry);
extents.push([extent[0], extent[1]]);
extents.push([extent[2], extent[3]]);
}
return calculateBoundsFromArray(extents);
};
/*
Internal: Calculate an bounding box for a geometry collection
*/
var calculateBoundsForGeometryCollection = function calculateBoundsForGeometryCollection(geometryCollection) {
var extents = [];
for (var i = geometryCollection.geometries.length - 1; i >= 0; i--) {
var extent = calculateBounds(geometryCollection.geometries[i]);
extents.push([extent[0], extent[1]]);
extents.push([extent[2], extent[3]]);
}
return calculateBoundsFromArray(extents);
};
var calculateBounds = function calculateBounds(geojson) {
if (geojson.type) {
switch (geojson.type) {
case 'Point':
return [geojson.coordinates[0], geojson.coordinates[1], geojson.coordinates[0], geojson.coordinates[1]];
case 'MultiPoint':
return calculateBoundsFromArray(geojson.coordinates);
case 'LineString':
return calculateBoundsFromArray(geojson.coordinates);
case 'MultiLineString':
return calculateBoundsFromNestedArrays(geojson.coordinates);
case 'Polygon':
return calculateBoundsFromNestedArrays(geojson.coordinates);
case 'MultiPolygon':
return calculateBoundsFromNestedArrayOfArrays(geojson.coordinates);
case 'Feature':
return geojson.geometry ? calculateBounds(geojson.geometry) : null;
case 'FeatureCollection':
return calculateBoundsForFeatureCollection(geojson);
case 'GeometryCollection':
return calculateBoundsForGeometryCollection(geojson);
default:
throw new Error('Unknown type: ' + geojson.type);
}
}
return null;
};
var polygonContainsPoint = function polygonContainsPoint(polygon, point) {

@@ -572,2 +801,7 @@ if (polygon && polygon.length) {

function geoJSONGeometryToBounds(geometry) {
var bounds = calculateBounds(geometry);
var leafletBounds = L.latLngBounds([bounds[1], bounds[0]], [bounds[3], bounds[2]]);
return leafletBounds;
}
function getCircleMarkerRadius(circleMarker, crs, zoom) {

@@ -617,10 +851,29 @@ var latLng = circleMarker.getLatLng();

if (options === void 0) { options = {}; }
var polygonGeometry = polygon.toGeoJSON().geometry;
var polygonBounds = polygon.getBounds();
var selectedLayers = layers.filter(function (layer) {
var layerGeometry = layerToGeoJSONGeometry(layer, options);
if (!layerGeometry) {
// check bounds first (fast)
var layerGeometry;
var layerBounds;
if (layer instanceof L.Polyline) {
layerBounds = layer.getBounds();
}
else {
layerGeometry = layerToGeoJSONGeometry(layer, options);
layerBounds = geoJSONGeometryToBounds(layerGeometry);
}
var boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
return options.intersect ?
polygonIntersects(polygon, layerGeometry) :
polygonContains(polygon, layerGeometry);
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
var geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -751,3 +1004,2 @@ return selectedLayers;

}
var polygon = this.polygon.toGeoJSON().geometry;
var layers = [];

@@ -765,3 +1017,3 @@ this.map.eachLayer(function (layer) {

});
var selectedFeatures = getLayersInPolygon(polygon, layers, {
var selectedFeatures = getLayersInPolygon(this.polygon.polygon, layers, {
zoom: this.map.getZoom(),

@@ -768,0 +1020,0 @@ crs: this.map.options.crs,

@@ -1,2 +0,2 @@

!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],o):o((t=t||self).LeafletLasso={},t.L)}(this,(function(t,o){"use strict";
!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";
/*! *****************************************************************************

@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. All rights reserved.

and limitations under the License.
***************************************************************************** */var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var e in o)o.hasOwnProperty(e)&&(t[e]=o[e])})(t,o)};function n(t,o){function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var o,e=1,n=arguments.length;e<n;e++)for(var r in o=arguments[e])Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r]);return t}).apply(this,arguments)};function i(){for(var t=0,o=0,e=arguments.length;o<e;o++)t+=arguments[o].length;var n=Array(t),r=0;for(o=0;o<e;o++)for(var i=arguments[o],s=0,a=i.length;s<a;s++,r++)n[r]=i[s];return n}var s=function(t){function e(e,n){var i=t.call(this)||this;return i.polyline=o.polyline(e,n),i.polygon=o.polygon(e,r(r({},n),{weight:0})),i}return n(e,t),e.prototype.onAdd=function(t){return this.polyline.addTo(t),this.polygon.addTo(t),this},e.prototype.onRemove=function(){return this.polyline.remove(),this.polygon.remove(),this},e.prototype.addLatLng=function(t){return this.polyline.addLatLng(t),this.polygon.addLatLng(t),this},e.prototype.getLatLngs=function(){return this.polygon.getLatLngs()[0]},e.prototype.toGeoJSON=function(){return this.polygon.toGeoJSON()},e}(o.Layer),a=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},l=function(t,o,e,n){var r=(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]),i=(o[0]-t[0])*(t[1]-e[1])-(o[1]-t[1])*(t[0]-e[0]),s=(n[1]-e[1])*(o[0]-t[0])-(n[0]-e[0])*(o[1]-t[1]);if(0!==s){var a=r/s,l=i/s;if(a>=0&&a<=1&&l>=0&&l<=1)return!0}return!1},u=function t(o,e){if(a(o[0][0])){if(a(e[0][0])){for(var n=0;n<o.length-1;n++)for(var r=0;r<e.length-1;r++)if(l(o[n],o[n+1],e[r],e[r+1]))return!0}else for(var i=0;i<e.length;i++)if(t(o,e[i]))return!0}else for(var s=0;s<o.length;s++)if(t(o[s],e))return!0;return!1},c=function(t,o){for(var e=!1,n=-1,r=t.length,i=r-1;++n<r;i=n)(t[n][1]<=o[1]&&o[1]<t[i][1]||t[i][1]<=o[1]&&o[1]<t[n][1])&&o[0]<(t[i][0]-t[n][0])*(o[1]-t[n][1])/(t[i][1]-t[n][1])+t[n][0]&&(e=!e);return e},p=function(t,o){for(var e=0;e<t.length;e++)if(t[e]!==o[e])return!1;return!0},f=function(t,o){return t[0]>o[0]?-1:t[0]<o[0]?1:t[1]>o[1]?-1:t[1]<o[1]?1:0},d=function(t){for(var o=[],e=0;e<t.length;e++){var n=t[e].slice();!1===p(n[0],n[n.length-1])&&n.push(n[0]),o.push(n)}return o};
***************************************************************************** */var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};function n(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function i(){for(var t=0,e=0,o=arguments.length;e<o;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<o;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,r++)n[r]=i[s];return n}var s=function(t){function o(o,n){var i=t.call(this)||this;return i.polyline=e.polyline(o,n),i.polygon=e.polygon(o,r(r({},n),{weight:0})),i}return n(o,t),o.prototype.onAdd=function(t){return this.polyline.addTo(t),this.polygon.addTo(t),this},o.prototype.onRemove=function(){return this.polyline.remove(),this.polygon.remove(),this},o.prototype.addLatLng=function(t){return this.polyline.addLatLng(t),this.polygon.addLatLng(t),this},o.prototype.getLatLngs=function(){return this.polygon.getLatLngs()[0]},o.prototype.toGeoJSON=function(){return this.polygon.toGeoJSON()},o}(e.Layer),a=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},l=function(t,e,o,n){var r=(n[0]-o[0])*(t[1]-o[1])-(n[1]-o[1])*(t[0]-o[0]),i=(e[0]-t[0])*(t[1]-o[1])-(e[1]-t[1])*(t[0]-o[0]),s=(n[1]-o[1])*(e[0]-t[0])-(n[0]-o[0])*(e[1]-t[1]);if(0!==s){var a=r/s,l=i/s;if(a>=0&&a<=1&&l>=0&&l<=1)return!0}return!1},u=function t(e,o){if(a(e[0][0])){if(a(o[0][0])){for(var n=0;n<e.length-1;n++)for(var r=0;r<o.length-1;r++)if(l(e[n],e[n+1],o[r],o[r+1]))return!0}else for(var i=0;i<o.length;i++)if(t(e,o[i]))return!0}else for(var s=0;s<e.length;s++)if(t(e[s],o))return!0;return!1},c=function(t,e){for(var o=!1,n=-1,r=t.length,i=r-1;++n<r;i=n)(t[n][1]<=e[1]&&e[1]<t[i][1]||t[i][1]<=e[1]&&e[1]<t[n][1])&&e[0]<(t[i][0]-t[n][0])*(e[1]-t[n][1])/(t[i][1]-t[n][1])+t[n][0]&&(o=!o);return o},f=function(t,e){for(var o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0},p=function(t,e){return t[0]>e[0]?-1:t[0]<e[0]?1:t[1]>e[1]?-1:t[1]<e[1]?1:0},d=function(t){for(var e=[],o=0;o<t.length;o++){var n=t[o].slice();!1===f(n[0],n[n.length-1])&&n.push(n[0]),e.push(n)}return e};
/* @preserve

@@ -21,3 +21,3 @@ * @terraformer/spatial - v2.0.6 - MIT

* Mon May 18 2020 14:30:36 GMT-0700 (Pacific Daylight Time)
*/var h=function(t,o){if(t.length!==o.length)return!1;for(var e=t.slice().sort(f),n=o.slice().sort(f),r=0;r<e.length;r++){if(e[r].length!==n[r].length)return!1;for(var i=0;i<e.length;i++)if(e[r][i]!==n[r][i])return!1}return!0},g=function(t,o){if(t&&t.length){if(1===t.length)return c(t[0],o);if(c(t[0],o)){for(var e=1;e<t.length;e++)if(c(t[e],o))return!1;return!0}return!1}return!1},y=function t(o,e){var n,r,i;if("Feature"===e.type&&(e=e.geometry),"Point"===e.type&&"Point"===o.type)return p(o.coordinates,e.coordinates);if("MultiLineString"===e.type&&"Point"===o.type)for(r=0;r<o.coordinates.length;r++){if(t(o,{type:"LineString",coordinates:e.coordinates[r]}))return!0}if(("LineString"===e.type||"MultiPoint"===e.type)&&"Point"===o.type)for(r=0;r<e.coordinates.length;r++){if(o.coordinates.length!==e.coordinates[r].length)return!1;if(p(o.coordinates,e.coordinates[r]))return!0}if("Polygon"===e.type){if("Polygon"===o.type){if(e.coordinates.length===o.coordinates.length)for(r=0;r<o.coordinates.length;r++)if(h(o.coordinates[r],e.coordinates[r]))return!0;return!(!o.coordinates.length||!g(e.coordinates,o.coordinates[0][0]))&&!u(d(o.coordinates),d(e.coordinates))}if("Point"===o.type)return g(e.coordinates,o.coordinates);if("LineString"===o.type||"MultiPoint"===o.type){if(!o.coordinates||0===o.coordinates.length)return!1;for(r=0;r<o.coordinates.length;r++)if(!1===g(e.coordinates,o.coordinates[r]))return!1;return!0}if("MultiLineString"===o.type){for(r=0;r<o.coordinates.length;r++){if(!1===t({type:"LineString",coordinates:o.coordinates[r]},e))return i++,!1}return!0}if("MultiPolygon"===o.type){for(r=0;r<o.coordinates.length;r++){if(!1===t({type:"Polygon",coordinates:o.coordinates[r]},e))return!1}return!0}}if("MultiPolygon"===e.type){if("Point"===o.type){if(e.coordinates.length)for(r=0;r<e.coordinates.length;r++)if(n=e.coordinates[r],g(n,o.coordinates)&&!1===u([o.coordinates],e.coordinates))return!0;return!1}if("Polygon"===o.type){for(r=0;r<o.coordinates.length;r++)if(e.coordinates[r].length===o.coordinates.length)for(var s=0;s<o.coordinates.length;s++)if(h(o.coordinates[s],e.coordinates[r][s]))return!0;if(!1===u(o.coordinates,e.coordinates)&&e.coordinates.length){for(r=0;r<e.coordinates.length;r++)n=e.coordinates[r],i=!1!==g(n,o.coordinates[0][0]);return i}}else if("LineString"===o.type||"MultiPoint"===o.type)for(r=0;r<e.coordinates.length;r++){return!!t(o,{type:"Polygon",coordinates:e.coordinates[r]})}else{if("MultiLineString"===o.type){for(r=0;r<o.coordinates.length;r++){if(!1===t({type:"LineString",coordinates:o.coordinates[r]},e))return!1}return!0}if("MultiPolygon"===o.type){for(r=0;r<e.coordinates.length;r++){if(!1===t(o,{type:"Polygon",coordinates:e.coordinates[r]}))return!1}return!0}}}return!1},m=function(t,o){return y(o,t)},v=function t(o,e){return"Feature"===e.type&&(e=e.geometry),!(!y(o,e)&&!y(e,o))||("Point"!==o.type&&"MultiPoint"!==o.type&&"Point"!==e.type&&"MultiPoint"!==e.type?u(o.coordinates,e.coordinates):"Feature"===o.type?t(o.geometry,e):(function(){var t=Array.prototype.slice.apply(arguments);"undefined"!=typeof console&&console.warn&&console.warn.apply(console,t)}("Type "+o.type+" to "+e.type+" intersection is not supported by intersects"),!1))},A=6378137,L=6356752.3142,M=1/298.257223563,b=function(t,o,e){for(var n,r=e||64,i={type:"Polygon",coordinates:[[]]},s=0;s<r;s++)n=360*s/r,i.coordinates[0].push(S(t,n,o));return i.coordinates=d(i.coordinates),i},S=function(t,o,e){for(var n,r,i,s=A,a=L,l=M,u=t[0],c=t[1],p=e,f=Math.PI,d=o*f/180,h=Math.sin(d),g=Math.cos(d),y=(1-l)*Math.tan(c*f/180),m=1/Math.sqrt(1+y*y),v=y*m,b=Math.atan2(y,g),S=m*h,P=1-S*S,E=P*(s*s-a*a)/(a*a),w=1+E/16384*(4096+E*(E*(320-175*E)-768)),D=E/1024*(256+E*(E*(74-47*E)-128)),C=p/(a*w),I=2*Math.PI;Math.abs(C-I)>1e-12;)n=Math.cos(2*b+C),I=C,C=p/(a*w)+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=v*r-m*i*g,O=Math.atan2(v*i+m*r*g,(1-l)*Math.sqrt(S*S+B*B)),U=l/16*P*(4+l*(4-3*P));return[u+180*(Math.atan2(r*h,m*i-v*r*g)-(1-U)*l*S*(C+U*r*(n+U*i*(2*n*n-1))))/f,180*O/f]};function P(t,e){return function(t,o,e){var n=e||64,r=o||250;if(!t||t.length<2||!r||!n)throw new Error("Terraformer: missing parameter for Terraformer.Circle");return{type:"Feature",geometry:b(t,r,n),properties:{radius:r,center:t,steps:n}}}(o.GeoJSON.latLngToCoords(t),e).geometry}function E(t,e){return void 0===e&&(e={}),t instanceof o.Circle?P(t.getLatLng(),t.getRadius()):t instanceof o.CircleMarker?null!=e.zoom&&null!=e.crs?P(t.getLatLng(),function(t,e,n){var r=t.getLatLng(),i=e.latLngToPoint(r,n),s=t.getRadius()/Math.SQRT2,a=o.point([i.x-s,i.y-s]),l=e.pointToLatLng(a,n);return e.distance(r,l)}(t,e.crs,e.zoom)):(console.warn("Zoom and CRS is required for calculating CircleMarker polygon, falling back to center point only"),t.toGeoJSON().geometry):t instanceof o.Marker||t instanceof o.Polyline?t.toGeoJSON().geometry:void 0}function w(t,o,e){return void 0===e&&(e={}),o.filter((function(o){var n=E(o,e);return!!n&&(e.intersect?function(t,o){return"Point"===o.type?m(t,o):v(t,o)}(t,n):function(t,o){return m(t,o)}(t,n))}))}function D(t,o){void 0===o&&(o={});var e=o.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===e&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}D(".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 C="leaflet-lasso-active",I=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,e)||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=e,o.Util.setOptions(r,n),r}return n(e,t),e.prototype.setOptions=function(t){this.options=r(r({},this.options),t)},e.prototype.toggle=function(){this.enabled()?this.disable():this.enable()},e.prototype.addHooks=function(){this.map.getPane("mapPane"),this.map.on("mousedown",this.onMapMouseDown,this),this.map.getContainer().classList.add(C),this.map.dragging.disable(),this.map.fire("lasso.enabled")},e.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(C),document.body.classList.remove(C),this.map.dragging.enable(),this.map.fire("lasso.disabled")},e.prototype.onMapMouseDown=function(t){var o=t;1===o.originalEvent.buttons?o.originalEvent.target.closest(".leaflet-control-container")||(this.polygon=new s([o.latlng],this.options.polygon).addTo(this.map),document.body.classList.add(C),document.addEventListener("mousemove",this.onDocumentMouseMoveBound),document.addEventListener("mouseup",this.onDocumentMouseUpBound)):this.disable()},e.prototype.onDocumentMouseMove=function(t){if(this.polygon){var o=t;if(1!==o.buttons)return console.warn("mouseup event was missed"),void this.finish();this.polygon.addLatLng(this.map.mouseEventToLatLng(o))}},e.prototype.onDocumentMouseUp=function(){this.finish()},e.prototype.finish=function(){var t=this;if(this.polygon){var e=this.polygon.toGeoJSON().geometry,n=[];this.map.eachLayer((function(e){e!==t.polygon&&e!==t.polygon.polyline&&e!==t.polygon.polygon&&(e instanceof o.Marker||e instanceof o.Path?n.push(e):o.MarkerCluster&&e instanceof o.MarkerCluster&&n.push.apply(n,e.getAllChildMarkers()))}));var r=w(e,n,{zoom:this.map.getZoom(),crs:this.map.options.crs,intersect:this.options.intersect});this.map.fire("lasso.finished",{latLngs:this.polygon.getLatLngs(),layers:r}),this.disable()}},e}(o.Handler);D(".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 B=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options={position:"topright"},o.Util.setOptions(n,e),n}return n(e,t),e.prototype.setOptions=function(t){this.options=r(r({},this.options),t),this.lasso&&this.lasso.setOptions(this.options)},e.prototype.onAdd=function(t){this.lasso=new I(t,this.options);var e=o.DomUtil.create("div","leaflet-bar leaflet-control"),n=o.DomUtil.create("a","leaflet-control-lasso",e);return n.href="#",n.title="Toggle Lasso",n.setAttribute("role","button"),n.setAttribute("aria-label",n.title),o.DomEvent.addListener(n,"click",this.toggle,this),o.DomEvent.disableClickPropagation(n),e},e.prototype.enabled=function(){return!!this.lasso&&this.lasso.enabled()},e.prototype.enable=function(){this.lasso&&this.lasso.enable()},e.prototype.disable=function(){this.lasso&&this.lasso.disable()},e.prototype.toggle=function(){this.lasso&&this.lasso.toggle()},e}(o.Control);void 0!==window.L&&(window.L.Lasso=I,window.L.lasso=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return new(I.bind.apply(I,i([void 0],t)))},window.L.Control.Lasso=B,window.L.control.lasso=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return new(B.bind.apply(B,i([void 0],t)))}),t.ACTIVE_CLASS=C,t.DISABLED_EVENT="lasso.disabled",t.ENABLED_EVENT="lasso.enabled",t.FINISHED_EVENT="lasso.finished",t.LassoControl=B,t.LassoHandler=I,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.0",
"version": "2.1.1",
"description": "Leaflet plugin for lasso selection",

@@ -17,2 +17,3 @@ "keywords": [

"build": "rimraf dist && rollup -c",
"dev": "rollup -c -w",
"test": "jest",

@@ -19,0 +20,0 @@ "prepublishOnly": "npm run build"

# 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)
True lasso selection plugin for Leaflet. [Demo](http://zakjan.github.io/leaflet-lasso/)

@@ -29,3 +33,2 @@

npm install leaflet-lasso
import "leaflet-lasso"
```

@@ -36,3 +39,3 @@

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

@@ -42,2 +45,6 @@

```
import "leaflet-lasso";
```
For detailed API, please see exported TypeScript typings.

@@ -44,0 +51,0 @@

@@ -135,3 +135,3 @@ import * as L from 'leaflet';

[center.lat + latSmallDelta * scale * ratio, center.lng - lngSmallDelta * scale * inversedRatio],
]).toGeoJSON().geometry;
]).polygon;
}

@@ -168,3 +168,3 @@

[markers[4].getLatLng().lat + latSmallDelta, markers[4].getLatLng().lng - lngSmallDelta],
]).toGeoJSON().geometry;
]).polygon;
const expectedResult = [markers[1], markers[3], markers[4], markers[5], markers[7]];

@@ -171,0 +171,0 @@ const result = getLayersInPolygon(lassoPolygon, layers, { zoom: zoom, crs: crs });

import * as L from 'leaflet';
import * as GeoJSON from 'geojson';
import { toCircle, contains, intersects } from '@terraformer/spatial';
import { calculateBounds, toCircle, contains, intersects } from '@terraformer/spatial';
function geoJSONGeometryToBounds(geometry: GeoJSON.GeometryObject) {
const bounds = calculateBounds(geometry);
const leafletBounds = L.latLngBounds([bounds[1], bounds[0]], [bounds[3], bounds[2]]);
return leafletBounds;
}
function getCircleMarkerRadius(circleMarker: L.CircleMarker, crs: L.CRS, zoom: number) {

@@ -48,12 +54,33 @@ const latLng = circleMarker.getLatLng();

export function getLayersInPolygon(polygon: GeoJSON.Polygon, layers: L.Layer[], options: { zoom?: number, crs?: L.CRS, intersect?: boolean } = {}) {
export function getLayersInPolygon(polygon: L.Polygon, layers: L.Layer[], options: { zoom?: number, crs?: L.CRS, intersect?: boolean } = {}) {
const polygonGeometry = polygon.toGeoJSON().geometry as GeoJSON.Polygon;
const polygonBounds = polygon.getBounds();
const selectedLayers = layers.filter(layer => {
const layerGeometry = layerToGeoJSONGeometry(layer, options);
if (!layerGeometry) {
// check bounds first (fast)
let layerGeometry;
let layerBounds;
if (layer instanceof L.Polyline) {
layerBounds = layer.getBounds();
} else {
layerGeometry = layerToGeoJSONGeometry(layer, options);
layerBounds = geoJSONGeometryToBounds(layerGeometry);
}
const boundsResult = options.intersect ?
polygonBounds.intersects(layerBounds) :
polygonBounds.contains(layerBounds);
if (!boundsResult) {
return false;
}
return options.intersect ?
polygonIntersects(polygon, layerGeometry) :
polygonContains(polygon, layerGeometry);
// check full geometry (slow)
if (!layerGeometry) {
layerGeometry = layerToGeoJSONGeometry(layer, options);
}
const geometryResult = options.intersect ?
polygonIntersects(polygonGeometry, layerGeometry) :
polygonContains(polygonGeometry, layerGeometry);
return geometryResult;
});

@@ -60,0 +87,0 @@

@@ -135,3 +135,2 @@ import * as L from 'leaflet';

const polygon = this.polygon.toGeoJSON().geometry as GeoJSON.Polygon;
const layers: L.Layer[] = [];

@@ -150,3 +149,3 @@ this.map.eachLayer(layer => {

const selectedFeatures = getLayersInPolygon(polygon, layers, {
const selectedFeatures = getLayersInPolygon(this.polygon.polygon, layers, {
zoom: this.map.getZoom(),

@@ -153,0 +152,0 @@ crs: this.map.options.crs,

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

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