New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mapbox-gl-draw-geodesic

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-gl-draw-geodesic - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

5

CHANGELOG.md
# Changelog
## 2.1.1
- fix computing geodesic lines crossing antimeridian
## 2.1.0
- add center point, change radius handles from NSEW points to movable point
## 2.0.0
- updated patching method of original modes, to be compatible with other patches

13

dist/mapbox-gl-draw-geodesic.js

@@ -548,10 +548,13 @@ (function (global, factory) {

let crossed = false;
let worldOffset = 0;
const geodesicCoordinates = geodesicSegments.map(geodesicSegment => {
if (geodesicSegment.geometry.type === geojsonTypes.MULTI_LINE_STRING) {
crossed = !crossed;
const direction = geodesicSegment.geometry.coordinates[0][0][0] > geodesicSegment.geometry.coordinates[1][0][0];
return [...geodesicSegment.geometry.coordinates[0].map(x => [x[0] + (direction ? 0 : 360), x[1]]), ...geodesicSegment.geometry.coordinates[1].map(x => [x[0] + (direction ? 360 : 0), x[1]])];
const prevWorldOffset = worldOffset;
const nextWorldOffset = worldOffset + (geodesicSegment.geometry.coordinates[0][0][0] > geodesicSegment.geometry.coordinates[1][0][0] ? 1 : -1);
const geodesicCoordinates = [...geodesicSegment.geometry.coordinates[0].map(x => [x[0] + prevWorldOffset * 360, x[1]]), ...geodesicSegment.geometry.coordinates[1].map(x => [x[0] + nextWorldOffset * 360, x[1]])];
worldOffset = nextWorldOffset;
return geodesicCoordinates;
} else {
return geodesicSegment.geometry.coordinates.map(x => [x[0] + (crossed ? 360 : 0), x[1]]);
const geodesicCoordinates = geodesicSegment.geometry.coordinates.map(x => [x[0] + worldOffset * 360, x[1]]);
return geodesicCoordinates;
}

@@ -558,0 +561,0 @@ }).flat();

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).MapboxDrawGeodesic={})}(this,(function(t){"use strict";var e=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t};const r="add",o="none",n="Feature",i="Polygon",s="LineString",c="Point",a="Multi",p="MultiLineString",u="draw.create",h="midpoint",l="vertex",f="true",y="false";function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function O(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?g(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):g(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}const b=O(O({},{DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"}),{},{DRAW_CIRCLE:"draw_circle"}),d="circleRadius",m="circleHandleBearing";function w(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var j=w((function(t){var e=t.exports=function(t,r){if(r||(r=16),void 0===t&&(t=128),t<=0)return"0";for(var o=Math.log(Math.pow(2,t))/Math.log(r),n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,t/n))/Math.log(r)*n;var i=o-Math.floor(o),s="";for(n=0;n<Math.floor(o);n++){s=Math.floor(Math.random()*r).toString(r)+s}if(i){var c=Math.pow(r,i);s=Math.floor(Math.random()*c).toString(r)+s}var a=parseInt(s,r);return a!==1/0&&a>=Math.pow(2,t)?e(t,r):s};e.rack=function(t,r,o){var n=function(n){var s=0;do{if(s++>10){if(!o)throw new Error("too many ID collisions, use more bits");t+=o}var c=e(t,r)}while(Object.hasOwnProperty.call(i,c));return i[c]=n,c},i=n.hats={};return n.get=function(t){return n.hats[t]},n.set=function(t,e){return n.hats[t]=e,n},n.bits=t||128,n.base=r||16,n}}));function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function P(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?M(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):M(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function v(t,e,r={}){if(!(e>0))throw new Error("Radius has to be greater then 0");return{id:j(),type:n,properties:P({[d]:e},r),geometry:{type:i,coordinates:[[t,t,t,t]]}}}function E(t){return t.geometry.type===i&&"number"==typeof t.properties[d]&&t.properties[d]>0}function D(t){if(!E(t))throw new Error("GeoJSON is not a circle");return t.geometry.coordinates[0][0]}function S(t){if(!E(t))throw new Error("GeoJSON is not a circle");return t.properties[d]}var x=w((function(t){var e=Math.PI/180,r=180/Math.PI,o=function(t,r){this.lon=t,this.lat=r,this.x=e*t,this.y=e*r};o.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)},o.prototype.antipode=function(){var t=-1*this.lat,e=this.lon<0?180+this.lon:-1*(180-this.lon);return new o(e,t)};var n=function(){this.coords=[],this.length=0};n.prototype.move_to=function(t){this.length++,this.coords.push(t)};var i=function(t){this.properties=t||{},this.geometries=[]};i.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(1==this.geometries.length)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var t=[],e=0;e<this.geometries.length;e++)t.push(this.geometries[e].coords);return{geometry:{type:"MultiLineString",coordinates:t},type:"Feature",properties:this.properties}},i.prototype.wkt=function(){for(var t="",e="LINESTRING(",r=function(t){e+=t[0]+" "+t[1]+","},o=0;o<this.geometries.length;o++){if(0===this.geometries[o].coords.length)return"LINESTRING(empty)";this.geometries[o].coords.forEach(r),t+=e.substring(0,e.length-1)+")"}return t};var s=function(t,e,r){if(!t||void 0===t.x||void 0===t.y)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!e||void 0===e.x||void 0===e.y)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new o(t.x,t.y),this.end=new o(e.x,e.y),this.properties=r||{};var n=this.start.x-this.end.x,i=this.start.y-this.end.y,s=Math.pow(Math.sin(i/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(n/2),2);if(this.g=2*Math.asin(Math.sqrt(s)),this.g==Math.PI)throw new Error("it appears "+t.view()+" and "+e.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+t+" and "+e)};s.prototype.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),o=Math.sin(t*this.g)/Math.sin(this.g),n=e*Math.cos(this.start.y)*Math.cos(this.start.x)+o*Math.cos(this.end.y)*Math.cos(this.end.x),i=e*Math.cos(this.start.y)*Math.sin(this.start.x)+o*Math.cos(this.end.y)*Math.sin(this.end.x),s=e*Math.sin(this.start.y)+o*Math.sin(this.end.y),c=r*Math.atan2(s,Math.sqrt(Math.pow(n,2)+Math.pow(i,2)));return[r*Math.atan2(i,n),c]},s.prototype.Arc=function(t,e){var r=[];if(!t||t<=2)r.push([this.start.lon,this.start.lat]),r.push([this.end.lon,this.end.lat]);else for(var o=1/(t-1),s=0;s<t;++s){var c=o*s,a=this.interpolate(c);r.push(a)}for(var p=!1,u=0,h=e&&e.offset?e.offset:10,l=180-h,f=-180+h,y=360-h,g=1;g<r.length;++g){var O=r[g-1][0],b=r[g][0],d=Math.abs(b-O);d>y&&(b>l&&O<f||O>l&&b<f)?p=!0:d>u&&(u=d)}var m=[];if(p&&u<h){var w=[];m.push(w);for(var j=0;j<r.length;++j){var M=parseFloat(r[j][0]);if(j>0&&Math.abs(M-r[j-1][0])>y){var P=parseFloat(r[j-1][0]),v=parseFloat(r[j-1][1]),E=parseFloat(r[j][0]),D=parseFloat(r[j][1]);if(P>-180&&P<f&&180==E&&j+1<r.length&&r[j-1][0]>-180&&r[j-1][0]<f){w.push([-180,r[j][1]]),j++,w.push([r[j][0],r[j][1]]);continue}if(P>l&&P<180&&-180==E&&j+1<r.length&&r[j-1][0]>l&&r[j-1][0]<180){w.push([180,r[j][1]]),j++,w.push([r[j][0],r[j][1]]);continue}if(P<f&&E>l){var S=P;P=E,E=S;var x=v;v=D,D=x}if(P>l&&E<f&&(E+=360),P<=180&&E>=180&&P<E){var _=(180-P)/(E-P),C=_*D+(1-_)*v;w.push([r[j-1][0]>l?180:-180,C]),(w=[]).push([r[j-1][0]>l?-180:180,C]),m.push(w)}else w=[],m.push(w);w.push([M,r[j][1]])}else w.push([r[j][0],r[j][1]])}}else{var I=[];m.push(I);for(var L=0;L<r.length;++L)I.push([r[L][0],r[L][1]])}for(var T=new i(this.properties),N=0;N<m.length;++N){var F=new n;T.geometries.push(F);for(var R=m[N],G=0;G<R.length;++G)F.move_to(R[G])}return T},t.exports.Coord=o,t.exports.Arc=i,t.exports.GreatCircle=s}));function _(t,e){return t[0]===e[0]&&t[1]===e[1]}function C(t,e=32){var r;const o=(r=t).slice(0,-1).map((t,e)=>[t,r[e+1]]).filter(t=>!_(t[0],t[1])).map(t=>new x.GreatCircle({x:t[0][0],y:t[0][1]},{x:t[1][0],y:t[1][1]}).Arc(e,{offset:90}).json());let n=!1;const i=o.map(t=>{if(t.geometry.type===p){n=!n;const e=t.geometry.coordinates[0][0][0]>t.geometry.coordinates[1][0][0];return[...t.geometry.coordinates[0].map(t=>[t[0]+(e?0:360),t[1]]),...t.geometry.coordinates[1].map(t=>[t[0]+(e?360:0),t[1]])]}return t.geometry.coordinates.map(t=>[t[0]+(n?360:0),t[1]])}).flat();return i.filter((t,e)=>e===i.length-1||!_(t,i[e+1]))}function I(t){return t/180*Math.PI}function L(t){return t/Math.PI*180}function T(t,e){const r=I(t[1]),o=I(t[0]),n=I(e[1]),i=n-r,s=I(e[0])-o,c=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2);return 6371.0088*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function N(t,e){const r=I(t[1]),o=I(t[0]),n=I(e[1]),i=I(e[0])-o,s=Math.cos(r)*Math.sin(n)-Math.sin(r)*Math.cos(n)*Math.cos(i),c=Math.sin(i)*Math.cos(n);return(L(Math.atan2(c,s))+360)%360}function F(t,e,r){const o=I(t[1]),n=I(t[0]),i=e/6371.0088,s=I(r),c=Math.sin(o)*Math.cos(i)+Math.cos(o)*Math.sin(i)*Math.cos(s),a=Math.asin(c),p=Math.sin(s)*Math.sin(i)*Math.cos(o),u=Math.cos(i)-Math.sin(o)*c;return[L(n+Math.atan2(p,u)),L(a)]}function R(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function G(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?R(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):R(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function k(t,e){const r=e.split(".").map(t=>parseInt(t,10)).reduce((t,e)=>t[e],t);return JSON.parse(JSON.stringify(r))}function A(t,e){e=G({steps:32},e);const r=t.properties,o=t.geometry.type,p=t.geometry.coordinates,u=r.parent||r.id,g=e.ctx.store.get(u),O=g.toGeoJSON();if(o===c)return r.meta!==l&&r.meta!==h||!E(O)?r.meta===h?function(){const e=r.coord_path,o=e.split(".").map(t=>parseInt(t,10)),n=o.map((t,e)=>t+(e===o.length-1?-1:0)).join("."),i=e,s=k(O.geometry.coordinates,n),c=k(O.geometry.coordinates,i),a=function(t,e){const r=I(t[1]),o=I(t[0]),n=I(e[1]),i=I(e[0])-o,s=Math.cos(n)*Math.cos(i),c=Math.cos(n)*Math.sin(i),a=Math.atan2(Math.sin(r)+Math.sin(n),Math.sqrt((Math.cos(r)+s)*(Math.cos(r)+s)+c*c));return[L(o+Math.atan2(c,Math.cos(r)+s)),L(a)]}(s,c);return[G(G({},t),{},{properties:G(G({},r),{},{lng:a[0],lat:a[1]}),geometry:G(G({},t.geometry),{},{coordinates:a})})]}():[t]:[];if(o===s)return function(){const r=C(p,e.steps);return[G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:r})})]}();if(o===i)return E(O)?function(){const o=D(O),i=S(O),s=g[m]||45,a=function(t,e,r,o){const n=[];for(let i=0;i<o;++i)n.push(F(t,e,r+360*-i/o));return n.push(n[0]),n}(o,i,s,4*e.steps),p=G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:[a]})});if(r.active===f){const t=F(o,i,s),a=[o,t].map((t,o)=>function(t,e,r,o){return{type:n,properties:{meta:l,parent:t,coord_path:r,active:o?f:y},geometry:{type:c,coordinates:e}}}(r.id,t,"0.".concat(o),function(t){if(!e.selectedPaths)return!1;return-1!==e.selectedPaths.indexOf(t)}("0.".concat(o))));return[p,...a]}return[p]}():function(){const e=p.map(t=>C(t));return[G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:e})})]}();if(0===o.indexOf(a))return function(){const i=o.replace(a,""),s=p.map(t=>A({type:n,properties:r,geometry:{type:i,coordinates:t}},e)).flat().map(t=>t.geometry.coordinates);return[G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:s})})]}()}function W(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function J(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?W(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):W(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}function q(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function V(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?q(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):q(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}var Z={enable(t){setTimeout(()=>{t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()},0)},disable(t){setTimeout(()=>{t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()},0)}};const U={enable(t){setTimeout(()=>{t.map&&t.map.dragPan&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("dragPan")&&t.map.dragPan.enable()},0)},disable(t){setTimeout(()=>{t.map&&t.map.doubleClickZoom&&t.map.dragPan.disable()},0)}},Y={};function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function H(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?B(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):B(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}function K(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function z(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?K(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):K(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}function Q(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function X(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?Q(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):Q(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.dragVertex=function(e,r,o){const n=e.feature.toGeoJSON();if(E(n))if("0.1"===e.selectedCoordPaths[0]){const t=D(n),o=[r.lngLat.lng,r.lngLat.lat],i=T(t,o),s=N(t,o);e.feature.properties[d]=i,e.feature[m]=s,e.feature.changed()}else t.dragFeature.call(this,e,r,o);else t.dragVertex.call(this,e,r,o)},r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx,selectedPaths:e.selectedCoordPaths}).forEach(o)})},r}Y.onSetup=function(t){return this.clearSelectedFeatures(),Z.disable(this),U.disable(this),this.updateUIClasses({mouse:r}),this.setActionableState(),{}},Y.onMouseDown=Y.onTouchStart=function(t,e){const r=[e.lngLat.lng,e.lngLat.lat],o=this.newFeature(v(r,Number.EPSILON));this.addFeature(o),t.circle=o},Y.onDrag=Y.onTouchMove=function(t,e){if(t.circle){const r=D(t.circle.toGeoJSON()),o=[e.lngLat.lng,e.lngLat.lat],n=T(r,o),i=N(r,o);t.circle.properties[d]=n,t.circle[m]=i,t.circle.changed()}},Y.onMouseUp=Y.onTouchEnd=function(t,e){return this.map.fire(u,{features:[t.circle.toGeoJSON()]}),this.changeMode(b.SIMPLE_SELECT,{featureIds:[t.circle.id]})},Y.onKeyUp=function(t,e){!function(t){return 27===t.keyCode}(e)?function(t){return 13===t.keyCode}(e)&&this.changeMode(b.SIMPLE_SELECT,{featureIds:[t.circle.id]}):(t.circle&&this.deleteFeature([t.circle.id],{silent:!0}),this.changeMode(b.SIMPLE_SELECT))},Y.onStop=function(){this.updateUIClasses({mouse:o}),Z.enable(this),U.enable(this),this.activateUIButton()},Y.toDisplayFeatures=function(t,e,r){if(t.circle){const r=e.properties.id===t.circle.id;e.properties.active=r?f:y}(t=>{A(t,{ctx:this._ctx}).forEach(r)})(e)};const $={};function tt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function et(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?tt(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):tt(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}$.onSetup=function(){return this.setActionableState(),{}},$.toDisplayFeatures=function(t,e,r){(t=>{A(t,{ctx:this._ctx}).forEach(r)})(e)},t.createCircle=v,t.enable=function(t){return et(et({},t),{},{[b.DRAW_LINE_STRING]:J(t[b.DRAW_LINE_STRING]),[b.DRAW_POLYGON]:V(t[b.DRAW_POLYGON]),[b.DRAW_CIRCLE]:Y,[b.DRAW_POINT]:H(t[b.DRAW_POINT]),[b.SIMPLE_SELECT]:z(t[b.SIMPLE_SELECT]),[b.DIRECT_SELECT]:X(t[b.DIRECT_SELECT]),[b.STATIC]:$})},t.getCircleCenter=D,t.getCircleRadius=S,t.isCircle=E,t.setCircleCenter=function(t,e){if(!E(t))throw new Error("GeoJSON is not a circle");t.geometry.coordinates=[[e,e,e,e]]},t.setCircleRadius=function(t,e){if(!E(t))throw new Error("GeoJSON is not a circle");t.properties[d]=e},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).MapboxDrawGeodesic={})}(this,(function(t){"use strict";var e=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t};const r="add",o="none",n="Feature",i="Polygon",s="LineString",c="Point",a="Multi",p="MultiLineString",u="draw.create",h="midpoint",l="vertex",f="true",y="false";function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function O(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?g(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):g(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}const b=O(O({},{DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"}),{},{DRAW_CIRCLE:"draw_circle"}),d="circleRadius",m="circleHandleBearing";function w(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var j=w((function(t){var e=t.exports=function(t,r){if(r||(r=16),void 0===t&&(t=128),t<=0)return"0";for(var o=Math.log(Math.pow(2,t))/Math.log(r),n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,t/n))/Math.log(r)*n;var i=o-Math.floor(o),s="";for(n=0;n<Math.floor(o);n++){s=Math.floor(Math.random()*r).toString(r)+s}if(i){var c=Math.pow(r,i);s=Math.floor(Math.random()*c).toString(r)+s}var a=parseInt(s,r);return a!==1/0&&a>=Math.pow(2,t)?e(t,r):s};e.rack=function(t,r,o){var n=function(n){var s=0;do{if(s++>10){if(!o)throw new Error("too many ID collisions, use more bits");t+=o}var c=e(t,r)}while(Object.hasOwnProperty.call(i,c));return i[c]=n,c},i=n.hats={};return n.get=function(t){return n.hats[t]},n.set=function(t,e){return n.hats[t]=e,n},n.bits=t||128,n.base=r||16,n}}));function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function P(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?M(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):M(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function v(t,e,r={}){if(!(e>0))throw new Error("Radius has to be greater then 0");return{id:j(),type:n,properties:P({[d]:e},r),geometry:{type:i,coordinates:[[t,t,t,t]]}}}function E(t){return t.geometry.type===i&&"number"==typeof t.properties[d]&&t.properties[d]>0}function D(t){if(!E(t))throw new Error("GeoJSON is not a circle");return t.geometry.coordinates[0][0]}function S(t){if(!E(t))throw new Error("GeoJSON is not a circle");return t.properties[d]}var x=w((function(t){var e=Math.PI/180,r=180/Math.PI,o=function(t,r){this.lon=t,this.lat=r,this.x=e*t,this.y=e*r};o.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)},o.prototype.antipode=function(){var t=-1*this.lat,e=this.lon<0?180+this.lon:-1*(180-this.lon);return new o(e,t)};var n=function(){this.coords=[],this.length=0};n.prototype.move_to=function(t){this.length++,this.coords.push(t)};var i=function(t){this.properties=t||{},this.geometries=[]};i.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(1==this.geometries.length)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var t=[],e=0;e<this.geometries.length;e++)t.push(this.geometries[e].coords);return{geometry:{type:"MultiLineString",coordinates:t},type:"Feature",properties:this.properties}},i.prototype.wkt=function(){for(var t="",e="LINESTRING(",r=function(t){e+=t[0]+" "+t[1]+","},o=0;o<this.geometries.length;o++){if(0===this.geometries[o].coords.length)return"LINESTRING(empty)";this.geometries[o].coords.forEach(r),t+=e.substring(0,e.length-1)+")"}return t};var s=function(t,e,r){if(!t||void 0===t.x||void 0===t.y)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!e||void 0===e.x||void 0===e.y)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new o(t.x,t.y),this.end=new o(e.x,e.y),this.properties=r||{};var n=this.start.x-this.end.x,i=this.start.y-this.end.y,s=Math.pow(Math.sin(i/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(n/2),2);if(this.g=2*Math.asin(Math.sqrt(s)),this.g==Math.PI)throw new Error("it appears "+t.view()+" and "+e.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+t+" and "+e)};s.prototype.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),o=Math.sin(t*this.g)/Math.sin(this.g),n=e*Math.cos(this.start.y)*Math.cos(this.start.x)+o*Math.cos(this.end.y)*Math.cos(this.end.x),i=e*Math.cos(this.start.y)*Math.sin(this.start.x)+o*Math.cos(this.end.y)*Math.sin(this.end.x),s=e*Math.sin(this.start.y)+o*Math.sin(this.end.y),c=r*Math.atan2(s,Math.sqrt(Math.pow(n,2)+Math.pow(i,2)));return[r*Math.atan2(i,n),c]},s.prototype.Arc=function(t,e){var r=[];if(!t||t<=2)r.push([this.start.lon,this.start.lat]),r.push([this.end.lon,this.end.lat]);else for(var o=1/(t-1),s=0;s<t;++s){var c=o*s,a=this.interpolate(c);r.push(a)}for(var p=!1,u=0,h=e&&e.offset?e.offset:10,l=180-h,f=-180+h,y=360-h,g=1;g<r.length;++g){var O=r[g-1][0],b=r[g][0],d=Math.abs(b-O);d>y&&(b>l&&O<f||O>l&&b<f)?p=!0:d>u&&(u=d)}var m=[];if(p&&u<h){var w=[];m.push(w);for(var j=0;j<r.length;++j){var M=parseFloat(r[j][0]);if(j>0&&Math.abs(M-r[j-1][0])>y){var P=parseFloat(r[j-1][0]),v=parseFloat(r[j-1][1]),E=parseFloat(r[j][0]),D=parseFloat(r[j][1]);if(P>-180&&P<f&&180==E&&j+1<r.length&&r[j-1][0]>-180&&r[j-1][0]<f){w.push([-180,r[j][1]]),j++,w.push([r[j][0],r[j][1]]);continue}if(P>l&&P<180&&-180==E&&j+1<r.length&&r[j-1][0]>l&&r[j-1][0]<180){w.push([180,r[j][1]]),j++,w.push([r[j][0],r[j][1]]);continue}if(P<f&&E>l){var S=P;P=E,E=S;var x=v;v=D,D=x}if(P>l&&E<f&&(E+=360),P<=180&&E>=180&&P<E){var _=(180-P)/(E-P),C=_*D+(1-_)*v;w.push([r[j-1][0]>l?180:-180,C]),(w=[]).push([r[j-1][0]>l?-180:180,C]),m.push(w)}else w=[],m.push(w);w.push([M,r[j][1]])}else w.push([r[j][0],r[j][1]])}}else{var I=[];m.push(I);for(var L=0;L<r.length;++L)I.push([r[L][0],r[L][1]])}for(var T=new i(this.properties),N=0;N<m.length;++N){var F=new n;T.geometries.push(F);for(var R=m[N],G=0;G<R.length;++G)F.move_to(R[G])}return T},t.exports.Coord=o,t.exports.Arc=i,t.exports.GreatCircle=s}));function _(t,e){return t[0]===e[0]&&t[1]===e[1]}function C(t,e=32){var r;const o=(r=t).slice(0,-1).map((t,e)=>[t,r[e+1]]).filter(t=>!_(t[0],t[1])).map(t=>new x.GreatCircle({x:t[0][0],y:t[0][1]},{x:t[1][0],y:t[1][1]}).Arc(e,{offset:90}).json());let n=0;const i=o.map(t=>{if(t.geometry.type===p){const e=n,r=n+(t.geometry.coordinates[0][0][0]>t.geometry.coordinates[1][0][0]?1:-1),o=[...t.geometry.coordinates[0].map(t=>[t[0]+360*e,t[1]]),...t.geometry.coordinates[1].map(t=>[t[0]+360*r,t[1]])];return n=r,o}return t.geometry.coordinates.map(t=>[t[0]+360*n,t[1]])}).flat();return i.filter((t,e)=>e===i.length-1||!_(t,i[e+1]))}function I(t){return t/180*Math.PI}function L(t){return t/Math.PI*180}function T(t,e){const r=I(t[1]),o=I(t[0]),n=I(e[1]),i=n-r,s=I(e[0])-o,c=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2);return 6371.0088*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function N(t,e){const r=I(t[1]),o=I(t[0]),n=I(e[1]),i=I(e[0])-o,s=Math.cos(r)*Math.sin(n)-Math.sin(r)*Math.cos(n)*Math.cos(i),c=Math.sin(i)*Math.cos(n);return(L(Math.atan2(c,s))+360)%360}function F(t,e,r){const o=I(t[1]),n=I(t[0]),i=e/6371.0088,s=I(r),c=Math.sin(o)*Math.cos(i)+Math.cos(o)*Math.sin(i)*Math.cos(s),a=Math.asin(c),p=Math.sin(s)*Math.sin(i)*Math.cos(o),u=Math.cos(i)-Math.sin(o)*c;return[L(n+Math.atan2(p,u)),L(a)]}function R(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function G(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?R(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):R(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function k(t,e){const r=e.split(".").map(t=>parseInt(t,10)).reduce((t,e)=>t[e],t);return JSON.parse(JSON.stringify(r))}function A(t,e){e=G({steps:32},e);const r=t.properties,o=t.geometry.type,p=t.geometry.coordinates,u=r.parent||r.id,g=e.ctx.store.get(u),O=g.toGeoJSON();if(o===c)return r.meta!==l&&r.meta!==h||!E(O)?r.meta===h?function(){const e=r.coord_path,o=e.split(".").map(t=>parseInt(t,10)),n=o.map((t,e)=>t+(e===o.length-1?-1:0)).join("."),i=e,s=k(O.geometry.coordinates,n),c=k(O.geometry.coordinates,i),a=function(t,e){const r=I(t[1]),o=I(t[0]),n=I(e[1]),i=I(e[0])-o,s=Math.cos(n)*Math.cos(i),c=Math.cos(n)*Math.sin(i),a=Math.atan2(Math.sin(r)+Math.sin(n),Math.sqrt((Math.cos(r)+s)*(Math.cos(r)+s)+c*c));return[L(o+Math.atan2(c,Math.cos(r)+s)),L(a)]}(s,c);return[G(G({},t),{},{properties:G(G({},r),{},{lng:a[0],lat:a[1]}),geometry:G(G({},t.geometry),{},{coordinates:a})})]}():[t]:[];if(o===s)return function(){const r=C(p,e.steps);return[G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:r})})]}();if(o===i)return E(O)?function(){const o=D(O),i=S(O),s=g[m]||45,a=function(t,e,r,o){const n=[];for(let i=0;i<o;++i)n.push(F(t,e,r+360*-i/o));return n.push(n[0]),n}(o,i,s,4*e.steps),p=G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:[a]})});if(r.active===f){const t=F(o,i,s),a=[o,t].map((t,o)=>function(t,e,r,o){return{type:n,properties:{meta:l,parent:t,coord_path:r,active:o?f:y},geometry:{type:c,coordinates:e}}}(r.id,t,"0.".concat(o),function(t){if(!e.selectedPaths)return!1;return-1!==e.selectedPaths.indexOf(t)}("0.".concat(o))));return[p,...a]}return[p]}():function(){const e=p.map(t=>C(t));return[G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:e})})]}();if(0===o.indexOf(a))return function(){const i=o.replace(a,""),s=p.map(t=>A({type:n,properties:r,geometry:{type:i,coordinates:t}},e)).flat().map(t=>t.geometry.coordinates);return[G(G({},t),{},{geometry:G(G({},t.geometry),{},{coordinates:s})})]}()}function W(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function J(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?W(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):W(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}function q(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function V(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?q(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):q(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}var Z={enable(t){setTimeout(()=>{t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()},0)},disable(t){setTimeout(()=>{t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()},0)}};const U={enable(t){setTimeout(()=>{t.map&&t.map.dragPan&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("dragPan")&&t.map.dragPan.enable()},0)},disable(t){setTimeout(()=>{t.map&&t.map.doubleClickZoom&&t.map.dragPan.disable()},0)}},Y={};function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function H(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?B(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):B(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}function K(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function z(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?K(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):K(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx}).forEach(o)})},r}function Q(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function X(t){const r=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?Q(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):Q(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({},t);return r.dragVertex=function(e,r,o){const n=e.feature.toGeoJSON();if(E(n))if("0.1"===e.selectedCoordPaths[0]){const t=D(n),o=[r.lngLat.lng,r.lngLat.lat],i=T(t,o),s=N(t,o);e.feature.properties[d]=i,e.feature[m]=s,e.feature.changed()}else t.dragFeature.call(this,e,r,o);else t.dragVertex.call(this,e,r,o)},r.toDisplayFeatures=function(e,r,o){t.toDisplayFeatures.call(this,e,r,t=>{A(t,{ctx:this._ctx,selectedPaths:e.selectedCoordPaths}).forEach(o)})},r}Y.onSetup=function(t){return this.clearSelectedFeatures(),Z.disable(this),U.disable(this),this.updateUIClasses({mouse:r}),this.setActionableState(),{}},Y.onMouseDown=Y.onTouchStart=function(t,e){const r=[e.lngLat.lng,e.lngLat.lat],o=this.newFeature(v(r,Number.EPSILON));this.addFeature(o),t.circle=o},Y.onDrag=Y.onTouchMove=function(t,e){if(t.circle){const r=D(t.circle.toGeoJSON()),o=[e.lngLat.lng,e.lngLat.lat],n=T(r,o),i=N(r,o);t.circle.properties[d]=n,t.circle[m]=i,t.circle.changed()}},Y.onMouseUp=Y.onTouchEnd=function(t,e){return this.map.fire(u,{features:[t.circle.toGeoJSON()]}),this.changeMode(b.SIMPLE_SELECT,{featureIds:[t.circle.id]})},Y.onKeyUp=function(t,e){!function(t){return 27===t.keyCode}(e)?function(t){return 13===t.keyCode}(e)&&this.changeMode(b.SIMPLE_SELECT,{featureIds:[t.circle.id]}):(t.circle&&this.deleteFeature([t.circle.id],{silent:!0}),this.changeMode(b.SIMPLE_SELECT))},Y.onStop=function(){this.updateUIClasses({mouse:o}),Z.enable(this),U.enable(this),this.activateUIButton()},Y.toDisplayFeatures=function(t,e,r){if(t.circle){const r=e.properties.id===t.circle.id;e.properties.active=r?f:y}(t=>{A(t,{ctx:this._ctx}).forEach(r)})(e)};const $={};function tt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function et(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?tt(Object(o),!0).forEach((function(r){e(t,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):tt(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}$.onSetup=function(){return this.setActionableState(),{}},$.toDisplayFeatures=function(t,e,r){(t=>{A(t,{ctx:this._ctx}).forEach(r)})(e)},t.createCircle=v,t.enable=function(t){return et(et({},t),{},{[b.DRAW_LINE_STRING]:J(t[b.DRAW_LINE_STRING]),[b.DRAW_POLYGON]:V(t[b.DRAW_POLYGON]),[b.DRAW_CIRCLE]:Y,[b.DRAW_POINT]:H(t[b.DRAW_POINT]),[b.SIMPLE_SELECT]:z(t[b.SIMPLE_SELECT]),[b.DIRECT_SELECT]:X(t[b.DIRECT_SELECT]),[b.STATIC]:$})},t.getCircleCenter=D,t.getCircleRadius=S,t.isCircle=E,t.setCircleCenter=function(t,e){if(!E(t))throw new Error("GeoJSON is not a circle");t.geometry.coordinates=[[e,e,e,e]]},t.setCircleRadius=function(t,e){if(!E(t))throw new Error("GeoJSON is not a circle");t.properties[d]=e},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=mapbox-gl-draw-geodesic.min.js.map
{
"name": "mapbox-gl-draw-geodesic",
"version": "2.1.0",
"version": "2.1.1",
"description": "Geodesic plugin for Mapbox GL Draw",

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

@@ -32,3 +32,3 @@ # mapbox-gl-draw-geodesic

```
<script src="https://unpkg.com/mapbox-gl-draw-geodesic@2.1.0/dist/mapbox-gl-draw-geodesic.min.js"></script>
<script src="https://unpkg.com/mapbox-gl-draw-geodesic@2.1.1/dist/mapbox-gl-draw-geodesic.min.js"></script>
```

@@ -35,0 +35,0 @@

@@ -28,13 +28,16 @@ import arc from 'arc';

// fix Mapbox rendering by merging them together, adding 360 to longitudes on the right side
let crossed = false;
let worldOffset = 0;
const geodesicCoordinates = geodesicSegments.map(geodesicSegment => {
if (geodesicSegment.geometry.type === Constants.geojsonTypes.MULTI_LINE_STRING) {
crossed = !crossed;
const direction = geodesicSegment.geometry.coordinates[0][0][0] > geodesicSegment.geometry.coordinates[1][0][0];
return [
...geodesicSegment.geometry.coordinates[0].map(x => [x[0] + (direction ? 0 : 360), x[1]]),
...geodesicSegment.geometry.coordinates[1].map(x => [x[0] + (direction ? 360 : 0), x[1]])
const prevWorldOffset = worldOffset;
const nextWorldOffset = worldOffset + (geodesicSegment.geometry.coordinates[0][0][0] > geodesicSegment.geometry.coordinates[1][0][0] ? 1 : -1);
const geodesicCoordinates = [
...geodesicSegment.geometry.coordinates[0].map(x => [x[0] + prevWorldOffset * 360, x[1]]),
...geodesicSegment.geometry.coordinates[1].map(x => [x[0] + nextWorldOffset * 360, x[1]])
];
worldOffset = nextWorldOffset;
return geodesicCoordinates;
} else {
return geodesicSegment.geometry.coordinates.map(x => [x[0] + (crossed ? 360 : 0), x[1]]);
const geodesicCoordinates = geodesicSegment.geometry.coordinates.map(x => [x[0] + worldOffset * 360, x[1]]);
return geodesicCoordinates;
}

@@ -41,0 +44,0 @@ }).flat();

@@ -6,2 +6,4 @@ import createGeodesicLine from './create_geodesic_line';

const ANTIMERIDIAN_COORDINATES = COORDINATES.map((x) => [x[0] + 180, x[1]]);
const COORDINATES2 = [[50, 42.5], [50, -42.5], [-50, -42.5], [-50, 42.5], [50, 42.5]];
const ANTIMERIDIAN_COORDINATES2 = COORDINATES2.map((x) => [x[0] + 180, x[1]]);

@@ -11,3 +13,3 @@ describe('createGeodesicLine', () => {

const expectedResult = [
[-40.00000000000001, 37.50000000000001],
[-40, 37.5],
[-29.640181847974322, 41.04294366518809],

@@ -19,10 +21,10 @@ [-18.284925381704838, 43.56424149208077],

[29.640181847974315, 41.04294366518808],
[40.00000000000001, 37.50000000000001],
[40, 37.5],
[40, 36.42857142857143],
[40.00000000000001, 35.357142857142854],
[40, 35.357142857142854],
[40, 34.285714285714285],
[40, 33.214285714285715],
[40.00000000000001, 32.142857142857146],
[39.99999999999999, 31.071428571428566],
[40.00000000000001, 29.999999999999996],
[40, 32.142857142857146],
[40, 31.071428571428566],
[40, 30],
[27.167509670543375, 22.299081916471977],

@@ -34,10 +36,10 @@ [15.748721276100815, 13.700764508258576],

[-27.167509670543375, -22.299081916471977],
[-40.00000000000001, -29.999999999999996],
[-40.00000000000001, -31.071428571428566],
[-40, -30],
[-40, -31.071428571428566],
[-40, -32.142857142857146],
[-40.00000000000001, -33.214285714285715],
[-40, -33.214285714285715],
[-40, -34.285714285714285],
[-40.00000000000001, -35.357142857142854],
[-40, -35.357142857142854],
[-40, -36.42857142857143],
[-40.00000000000001, -37.50000000000001],
[-40, -37.5],
[-29.640181847974322, -41.04294366518809],

@@ -49,3 +51,3 @@ [-18.284925381704838, -43.56424149208077],

[29.640181847974315, -41.04294366518808],
[40.00000000000001, -37.50000000000001]
[40, -37.5]
];

@@ -58,3 +60,3 @@ const result = createGeodesicLine(COORDINATES, STEPS);

const expectedResult = [
[140, 37.49999999999999],
[140, 37.5],
[150.3598181520257, 41.04294366518809],

@@ -67,10 +69,10 @@ [161.71507461829515, 43.564241492080775],

[209.6401818479743, 41.04294366518809],
[219.99999999999997, 37.5],
[220, 37.5],
[220, 36.42857142857143],
[219.99999999999997, 35.357142857142854],
[220, 35.357142857142854],
[220, 34.285714285714285],
[219.99999999999997, 33.214285714285715],
[220, 33.214285714285715],
[220, 32.142857142857146],
[219.99999999999997, 31.071428571428566],
[220, 29.999999999999993],
[220, 31.071428571428566],
[220, 30],
[207.16750967054335, 22.299081916471977],

@@ -83,3 +85,3 @@ [195.74872127610078, 13.700764508258574],

[152.83249032945662, -22.299081916471977],
[140, -29.999999999999993],
[140, -30],
[140, -31.071428571428566],

@@ -91,3 +93,3 @@ [140, -32.142857142857146],

[140, -36.42857142857143],
[140, -37.49999999999999],
[140, -37.5],
[150.3598181520257, -41.04294366518809],

@@ -100,3 +102,3 @@ [161.71507461829515, -43.564241492080775],

[209.6401818479743, -41.04294366518809],
[219.99999999999997, -37.5]
[220, -37.5]
];

@@ -106,2 +108,75 @@ const result = createGeodesicLine(ANTIMERIDIAN_COORDINATES, STEPS);

});
it('returns a line', () => {
const expectedResult = [
[50, 42.5],
[50, 30.357142857142858],
[50, 18.214285714285708],
[50, 6.071428571428576],
[50, -6.071428571428571],
[50, -18.214285714285705],
[50, -30.357142857142858],
[50, -42.5],
[38.51500296240567, -48.12306182163198],
[24.61000064951651, -52.34744377816024],
[8.512108836214836, -54.65219948187882],
[-8.512108836214829, -54.65219948187882],
[-24.610000649516508, -52.34744377816025],
[-38.51500296240567, -48.12306182163198],
[-50, -42.5],
[-50, -30.357142857142858],
[-50, -18.214285714285708],
[-50, -6.071428571428576],
[-50, 6.071428571428571],
[-50, 18.214285714285705],
[-50, 30.357142857142858],
[-50, 42.5],
[-38.51500296240567, 48.12306182163198],
[-24.61000064951651, 52.34744377816024],
[-8.512108836214836, 54.65219948187882],
[8.512108836214829, 54.65219948187882],
[24.610000649516508, 52.34744377816025],
[38.51500296240567, 48.12306182163198],
[50, 42.5]
];
const result = createGeodesicLine(COORDINATES2, STEPS);
expect(result).toBeDeepCloseTo(expectedResult);
});
it('returns a line crossing antimeridian', () => {
const expectedResult = [
[-130, 42.5],
[-130, 30.357142857142858],
[-130, 18.214285714285708],
[-130, 6.071428571428576],
[-130, -6.071428571428571],
[-130, -18.214285714285708],
[-130, -30.35714285714285],
[-130, -42.5],
[-141.48499703759435, -48.12306182163198],
[-155.3899993504835, -52.34744377816024],
[-171.48789116378518, -54.65219948187882],
[-180, -54.65219948187882],
[-188.51210883621482, -54.65219948187882],
[-204.61000064951648, -52.34744377816025],
[-218.51500296240565, -48.12306182163198],
[-230, -42.5],
[-230, -30.357142857142858],
[-230, -18.214285714285708],
[-230, -6.071428571428576],
[-230, 6.071428571428571],
[-230, 18.214285714285705],
[-230, 30.357142857142858],
[-230, 42.5],
[-218.51500296240567, 48.12306182163198],
[-204.6100006495165, 52.34744377816024],
[-188.51210883621482, 54.65219948187882],
[-180, 54.65219948187882],
[-171.48789116378518, 54.65219948187882],
[-155.38999935048352, 52.34744377816024],
[-141.48499703759435, 48.12306182163198],
[-130, 42.5]
];
const result = createGeodesicLine(ANTIMERIDIAN_COORDINATES2, STEPS);
expect(result).toBeDeepCloseTo(expectedResult);
});
});

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