three-conic-polygon-geometry
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -10,2 +10,3 @@ 'use strict'; | ||
var earcut = _interopDefault(require('earcut')); | ||
var turfPointInPolygon = _interopDefault(require('@turf/boolean-point-in-polygon')); | ||
var d3Geo = require('d3-geo'); | ||
@@ -134,3 +135,3 @@ var d3Array = require('d3-array'); | ||
includeSides = includeSides !== undefined ? includeSides : true; | ||
curvatureResolution = curvatureResolution || 10; // in angular degrees | ||
curvatureResolution = curvatureResolution || 5; // in angular degrees | ||
// pre-calculate contour and triangulation | ||
@@ -230,3 +231,3 @@ | ||
if (!innerPoints.length) { | ||
// earcut triangulation more performant if it's only using the polygon perimeter | ||
// earcut triangulation slightly more performant if it's only using the polygon perimeter | ||
var _earcut$flatten = earcut.flatten(contourGeoJson), | ||
@@ -241,4 +242,2 @@ _vertices = _earcut$flatten.vertices, | ||
var delaunay = Delaunator.from(points); | ||
var maxDistance = Math.hypot(curvatureResolution, curvatureResolution) * 1.1; // with small margin of error | ||
var boundariesGeojson = { | ||
@@ -257,15 +256,4 @@ type: 'Polygon', | ||
return points[indice]; | ||
}); // exclude triangles longer than the max distance | ||
}); // exclude edge triangles outside polygon perimeter or through holes | ||
var largestSide = Math.max.apply(Math, _toConsumableArray([[0, 1], [1, 2], [2, 0]].map(function (_ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 2), | ||
i0 = _ref4[0], | ||
i1 = _ref4[1]; | ||
return Math.hypot.apply(Math, _toConsumableArray([0, 1].map(function (cIdx) { | ||
return triangle[i1][cIdx] - triangle[i0][cIdx]; | ||
}))); | ||
}))); | ||
if (largestSide > maxDistance) return "continue"; // exclude edge triangles outside polygon perimeter or through holes | ||
if (inds.some(function (ind) { | ||
@@ -279,3 +267,3 @@ return ind < edgePnts.length; | ||
}); | ||
if (!d3Geo.geoContains(boundariesGeojson, triangleCentroid)) return "continue"; | ||
if (!pointInside(triangleCentroid, boundariesGeojson)) return "continue"; | ||
} | ||
@@ -314,2 +302,6 @@ | ||
function pointInside(pnt, polygonGeoJson) { | ||
return turfPointInPolygon(pnt, polygonGeoJson); | ||
} | ||
function interpolateContourPoints(polygonGeoJson, maxDistance) { | ||
@@ -376,3 +368,3 @@ // add interpolated points for segments that are further apart than the max distance | ||
var pnt = [lng, lat]; | ||
d3Geo.geoContains(boundariesGeojson, pnt) && pnts.push(pnt); | ||
pointInside(pnt, boundariesGeojson) && pnts.push(pnt); | ||
lat += maxDistance; | ||
@@ -379,0 +371,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Version 1.3.3 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],n):n((t=t||self).THREE=t.THREE||{},t.THREE)}(this,(function(t,n){"use strict";function e(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(r=(u=s.next()).done)&&(e.push(u.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,n)||i(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,n){if(t){if("string"==typeof t)return o(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,n):void 0}}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}const u=Math.pow(2,-52),s=new Uint32Array(512);class a{static from(t,n=p,e=d){const r=t.length,i=new Float64Array(2*r);for(let o=0;o<r;o++){const r=t[o];i[2*o]=n(r),i[2*o+1]=e(r)}return new a(i)}constructor(t){const n=t.length>>1;if(n>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const e=Math.max(2*n-5,0);this._triangles=new Uint32Array(3*e),this._halfedges=new Int32Array(3*e),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:e,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let s=1/0,a=1/0,l=-1/0,c=-1/0;for(let n=0;n<o;n++){const e=t[2*n],r=t[2*n+1];e<s&&(s=e),r<a&&(a=r),e>l&&(l=e),r>c&&(c=r),this._ids[n]=n}const v=(s+l)/2,p=(a+c)/2;let d,g,m,_=1/0;for(let n=0;n<o;n++){const e=f(v,p,t[2*n],t[2*n+1]);e<_&&(d=n,_=e)}const w=t[2*d],M=t[2*d+1];_=1/0;for(let n=0;n<o;n++){if(n===d)continue;const e=f(w,M,t[2*n],t[2*n+1]);e<_&&e>0&&(g=n,_=e)}let b=t[2*g],S=t[2*g+1],A=1/0;for(let n=0;n<o;n++){if(n===d||n===g)continue;const e=y(w,M,b,S,t[2*n],t[2*n+1]);e<A&&(m=n,A=e)}let Z=t[2*m],P=t[2*m+1];if(A===1/0){for(let n=0;n<o;n++)this._dists[n]=t[2*n]-t[0]||t[2*n+1]-t[1];x(this._ids,this._dists,0,o-1);const n=new Uint32Array(o);let e=0;for(let t=0,r=-1/0;t<o;t++){const i=this._ids[t];this._dists[i]>r&&(n[e++]=i,r=this._dists[i])}return this.hull=n.subarray(0,e),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(h(w,M,b,S,Z,P)){const t=g,n=b,e=S;g=m,b=Z,S=P,m=t,Z=n,P=e}const E=function(t,n,e,r,i,o){const u=e-t,s=r-n,a=i-t,f=o-n,l=u*u+s*s,h=a*a+f*f,c=.5/(u*f-s*a);return{x:t+(f*l-s*h)*c,y:n+(u*h-a*l)*c}}(w,M,b,S,Z,P);this._cx=E.x,this._cy=E.y;for(let n=0;n<o;n++)this._dists[n]=f(t[2*n],t[2*n+1],E.x,E.y);x(this._ids,this._dists,0,o-1),this._hullStart=d;let z=3;e[d]=n[m]=g,e[g]=n[d]=m,e[m]=n[g]=d,r[d]=0,r[g]=1,r[m]=2,i.fill(-1),i[this._hashKey(w,M)]=d,i[this._hashKey(b,S)]=g,i[this._hashKey(Z,P)]=m,this.trianglesLen=0,this._addTriangle(d,g,m,-1,-1,-1);for(let o,s,a=0;a<this._ids.length;a++){const f=this._ids[a],l=t[2*f],c=t[2*f+1];if(a>0&&Math.abs(l-o)<=u&&Math.abs(c-s)<=u)continue;if(o=l,s=c,f===d||f===g||f===m)continue;let y=0;for(let t=0,n=this._hashKey(l,c);t<this._hashSize&&(y=i[(n+t)%this._hashSize],-1===y||y===e[y]);t++);y=n[y];let x,v=y;for(;x=e[v],!h(l,c,t[2*v],t[2*v+1],t[2*x],t[2*x+1]);)if(v=x,v===y){v=-1;break}if(-1===v)continue;let p=this._addTriangle(v,f,e[v],-1,-1,r[v]);r[f]=this._legalize(p+2),r[v]=p,z++;let _=e[v];for(;x=e[_],h(l,c,t[2*_],t[2*_+1],t[2*x],t[2*x+1]);)p=this._addTriangle(_,f,x,r[f],-1,r[_]),r[f]=this._legalize(p+2),e[_]=_,z--,_=x;if(v===y)for(;x=n[v],h(l,c,t[2*x],t[2*x+1],t[2*v],t[2*v+1]);)p=this._addTriangle(x,f,v,-1,r[v],r[x]),this._legalize(p+2),r[x]=p,e[v]=v,z--,v=x;this._hullStart=n[f]=v,e[v]=n[_]=f,e[f]=_,i[this._hashKey(l,c)]=f,i[this._hashKey(t[2*v],t[2*v+1])]=v}this.hull=new Uint32Array(z);for(let t=0,n=this._hullStart;t<z;t++)this.hull[t]=n,n=e[n];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(function(t,n){const e=t/(Math.abs(t)+Math.abs(n));return(n>0?3-e:1+e)/4}(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:e,coords:r}=this;let i=0,o=0;for(;;){const u=e[t],a=t-t%3;if(o=a+(t+2)%3,-1===u){if(0===i)break;t=s[--i];continue}const f=u-u%3,l=a+(t+1)%3,h=f+(u+2)%3,y=n[o],x=n[t],v=n[l],p=n[h];if(c(r[2*y],r[2*y+1],r[2*x],r[2*x+1],r[2*v],r[2*v+1],r[2*p],r[2*p+1])){n[t]=p,n[u]=y;const r=e[h];if(-1===r){let n=this._hullStart;do{if(this._hullTri[n]===h){this._hullTri[n]=t;break}n=this._hullPrev[n]}while(n!==this._hullStart)}this._link(t,r),this._link(u,e[o]),this._link(o,h);const a=f+(u+1)%3;i<s.length&&(s[i++]=a)}else{if(0===i)break;t=s[--i]}}return o}_link(t,n){this._halfedges[t]=n,-1!==n&&(this._halfedges[n]=t)}_addTriangle(t,n,e,r,i,o){const u=this.trianglesLen;return this._triangles[u]=t,this._triangles[u+1]=n,this._triangles[u+2]=e,this._link(u,r),this._link(u+1,i),this._link(u+2,o),this.trianglesLen+=3,u}}function f(t,n,e,r){const i=t-e,o=n-r;return i*i+o*o}function l(t,n,e,r,i,o){const u=(r-n)*(i-t),s=(e-t)*(o-n);return Math.abs(u-s)>=33306690738754716e-32*Math.abs(u+s)?u-s:0}function h(t,n,e,r,i,o){return(l(i,o,t,n,e,r)||l(t,n,e,r,i,o)||l(e,r,i,o,t,n))<0}function c(t,n,e,r,i,o,u,s){const a=t-u,f=n-s,l=e-u,h=r-s,c=i-u,y=o-s,x=l*l+h*h,v=c*c+y*y;return a*(h*v-x*y)-f*(l*v-x*c)+(a*a+f*f)*(l*y-h*c)<0}function y(t,n,e,r,i,o){const u=e-t,s=r-n,a=i-t,f=o-n,l=u*u+s*s,h=a*a+f*f,c=.5/(u*f-s*a),y=(f*l-s*h)*c,x=(u*h-a*l)*c;return y*y+x*x}function x(t,n,e,r){if(r-e<=20)for(let i=e+1;i<=r;i++){const r=t[i],o=n[r];let u=i-1;for(;u>=e&&n[t[u]]>o;)t[u+1]=t[u--];t[u+1]=r}else{let i=e+1,o=r;v(t,e+r>>1,i),n[t[e]]>n[t[r]]&&v(t,e,r),n[t[i]]>n[t[r]]&&v(t,i,r),n[t[e]]>n[t[i]]&&v(t,e,i);const u=t[i],s=n[u];for(;;){do{i++}while(n[t[i]]<s);do{o--}while(n[t[o]]>s);if(o<i)break;v(t,i,o)}t[e+1]=t[o],t[o]=u,r-i+1>=o-e?(x(t,n,i,r),x(t,n,e,o-1)):(x(t,n,e,o-1),x(t,n,i,r))}}function v(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function p(t){return t[0]}function d(t){return t[1]}var g=_,m=_;function _(t,n,e){e=e||2;var r,i,o,u,s,a,f,l=n&&n.length,h=l?n[0]*e:t.length,c=w(t,0,h,e,!0),y=[];if(!c||c.next===c.prev)return y;if(l&&(c=function(t,n,e,r){var i,o,u,s,a,f=[];for(i=0,o=n.length;i<o;i++)u=n[i]*r,s=i<o-1?n[i+1]*r:t.length,(a=w(t,u,s,r,!1))===a.next&&(a.steiner=!0),f.push(k(a));for(f.sort(E),i=0;i<f.length;i++)z(f[i],e),e=M(e,e.next);return e}(t,n,c,e)),t.length>80*e){r=o=t[0],i=u=t[1];for(var x=e;x<h;x+=e)(s=t[x])<r&&(r=s),(a=t[x+1])<i&&(i=a),s>o&&(o=s),a>u&&(u=a);f=0!==(f=Math.max(o-r,u-i))?1/f:0}return b(c,y,e,r,i,f),y}function w(t,n,e,r,i){var o,u;if(i===q(t,n,e,r)>0)for(o=n;o<e;o+=r)u=K(o,t[o],t[o+1],u);else for(o=e-r;o>=n;o-=r)u=K(o,t[o],t[o+1],u);return u&&H(u,u.next)&&(R(u),u=u.next),u}function M(t,n){if(!t)return t;n||(n=t);var e,r=t;do{if(e=!1,r.steiner||!H(r,r.next)&&0!==O(r.prev,r,r.next))r=r.next;else{if(R(r),(r=n=r.prev)===r.next)break;e=!0}}while(e||r!==n);return n}function b(t,n,e,r,i,o,u){if(t){!u&&o&&function(t,n,e,r){var i=t;do{null===i.z&&(i.z=T(i.x,i.y,n,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var n,e,r,i,o,u,s,a,f=1;do{for(e=t,t=null,o=null,u=0;e;){for(u++,r=e,s=0,n=0;n<f&&(s++,r=r.nextZ);n++);for(a=f;s>0||a>0&&r;)0!==s&&(0===a||!r||e.z<=r.z)?(i=e,e=e.nextZ,s--):(i=r,r=r.nextZ,a--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;e=r}o.nextZ=null,f*=2}while(u>1)}(i)}(t,r,i,o);for(var s,a,f=t;t.prev!==t.next;)if(s=t.prev,a=t.next,o?A(t,r,i,o):S(t))n.push(s.i/e),n.push(t.i/e),n.push(a.i/e),R(t),t=a.next,f=a.next;else if((t=a)===f){u?1===u?b(t=Z(M(t),n,e),n,e,r,i,o,2):2===u&&P(t,n,e,r,i,o):b(M(t),n,e,r,i,o,1);break}}}function S(t){var n=t.prev,e=t,r=t.next;if(O(n,e,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(B(n.x,n.y,e.x,e.y,r.x,r.y,i.x,i.y)&&O(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function A(t,n,e,r){var i=t.prev,o=t,u=t.next;if(O(i,o,u)>=0)return!1;for(var s=i.x<o.x?i.x<u.x?i.x:u.x:o.x<u.x?o.x:u.x,a=i.y<o.y?i.y<u.y?i.y:u.y:o.y<u.y?o.y:u.y,f=i.x>o.x?i.x>u.x?i.x:u.x:o.x>u.x?o.x:u.x,l=i.y>o.y?i.y>u.y?i.y:u.y:o.y>u.y?o.y:u.y,h=T(s,a,n,e,r),c=T(f,l,n,e,r),y=t.prevZ,x=t.nextZ;y&&y.z>=h&&x&&x.z<=c;){if(y!==t.prev&&y!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,y.x,y.y)&&O(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x!==t.prev&&x!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,x.x,x.y)&&O(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=h;){if(y!==t.prev&&y!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,y.x,y.y)&&O(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=c;){if(x!==t.prev&&x!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,x.x,x.y)&&O(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Z(t,n,e){var r=t;do{var i=r.prev,o=r.next.next;!H(i,o)&&U(i,r,r.next,o)&&L(i,o)&&L(o,i)&&(n.push(i.i/e),n.push(r.i/e),n.push(o.i/e),R(r),R(r.next),r=t=o),r=r.next}while(r!==t);return M(r)}function P(t,n,e,r,i,o){var u=t;do{for(var s=u.next.next;s!==u.prev;){if(u.i!==s.i&&I(u,s)){var a=C(u,s);return u=M(u,u.next),a=M(a,a.next),b(u,n,e,r,i,o),void b(a,n,e,r,i,o)}s=s.next}u=u.next}while(u!==t)}function E(t,n){return t.x-n.x}function z(t,n){if(n=function(t,n){var e,r=n,i=t.x,o=t.y,u=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>u){if(u=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}e=r.x<r.next.x?r:r.next}}r=r.next}while(r!==n);if(!e)return null;if(i===u)return e;var a,f=e,l=e.x,h=e.y,c=1/0;r=e;do{i>=r.x&&r.x>=l&&i!==r.x&&B(o<h?i:u,o,l,h,o<h?u:i,o,r.x,r.y)&&(a=Math.abs(o-r.y)/(i-r.x),L(r,t)&&(a<c||a===c&&(r.x>e.x||r.x===e.x&&G(e,r)))&&(e=r,c=a)),r=r.next}while(r!==f);return e}(t,n)){var e=C(n,t);M(n,n.next),M(e,e.next)}}function G(t,n){return O(t.prev,t,n.prev)<0&&O(n.next,t,t.next)<0}function T(t,n,e,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-e)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-r)*i)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function k(t){var n=t,e=t;do{(n.x<e.x||n.x===e.x&&n.y<e.y)&&(e=n),n=n.next}while(n!==t);return e}function B(t,n,e,r,i,o,u,s){return(i-u)*(n-s)-(t-u)*(o-s)>=0&&(t-u)*(r-s)-(e-u)*(n-s)>=0&&(e-u)*(o-s)-(i-u)*(r-s)>=0}function I(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==n.i&&e.next.i!==n.i&&U(e,e.next,t,n))return!0;e=e.next}while(e!==t);return!1}(t,n)&&(L(t,n)&&L(n,t)&&function(t,n){var e=t,r=!1,i=(t.x+n.x)/2,o=(t.y+n.y)/2;do{e.y>o!=e.next.y>o&&e.next.y!==e.y&&i<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next}while(e!==t);return r}(t,n)&&(O(t.prev,t,n.prev)||O(t,n.prev,n))||H(t,n)&&O(t.prev,t,t.next)>0&&O(n.prev,n,n.next)>0)}function O(t,n,e){return(n.y-t.y)*(e.x-n.x)-(n.x-t.x)*(e.y-n.y)}function H(t,n){return t.x===n.x&&t.y===n.y}function U(t,n,e,r){var i=F(O(t,n,e)),o=F(O(t,n,r)),u=F(O(e,r,t)),s=F(O(e,r,n));return i!==o&&u!==s||(!(0!==i||!j(t,e,n))||(!(0!==o||!j(t,r,n))||(!(0!==u||!j(e,t,r))||!(0!==s||!j(e,n,r)))))}function j(t,n,e){return n.x<=Math.max(t.x,e.x)&&n.x>=Math.min(t.x,e.x)&&n.y<=Math.max(t.y,e.y)&&n.y>=Math.min(t.y,e.y)}function F(t){return t>0?1:t<0?-1:0}function L(t,n){return O(t.prev,t,t.next)<0?O(t,n,t.next)>=0&&O(t,t.prev,n)>=0:O(t,n,t.prev)<0||O(t,t.next,n)<0}function C(t,n){var e=new N(t.i,t.x,t.y),r=new N(n.i,n.x,n.y),i=t.next,o=n.prev;return t.next=n,n.prev=t,e.next=i,i.prev=e,r.next=e,e.prev=r,o.next=r,r.prev=o,r}function K(t,n,e,r){var i=new N(t,n,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function R(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function N(t,n,e){this.i=t,this.x=n,this.y=e,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function q(t,n,e,r){for(var i=0,o=n,u=e-r;o<e;o+=r)i+=(t[u]-t[o])*(t[o+1]+t[u+1]),u=o;return i}function J(){return new V}function V(){this.reset()}_.deviation=function(t,n,e,r){var i=n&&n.length,o=i?n[0]*e:t.length,u=Math.abs(q(t,0,o,e));if(i)for(var s=0,a=n.length;s<a;s++){var f=n[s]*e,l=s<a-1?n[s+1]*e:t.length;u-=Math.abs(q(t,f,l,e))}var h=0;for(s=0;s<r.length;s+=3){var c=r[s]*e,y=r[s+1]*e,x=r[s+2]*e;h+=Math.abs((t[c]-t[x])*(t[y+1]-t[c+1])-(t[c]-t[y])*(t[x+1]-t[c+1]))}return 0===u&&0===h?0:Math.abs((h-u)/u)},_.flatten=function(t){for(var n=t[0][0].length,e={vertices:[],holes:[],dimensions:n},r=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var u=0;u<n;u++)e.vertices.push(t[i][o][u]);i>0&&(r+=t[i-1].length,e.holes.push(r))}return e},g.default=m,V.prototype={constructor:V,reset:function(){this.s=this.t=0},add:function(t){D($,t,this.t),D(this,$.s,this.s),this.s?this.t+=$.t:this.s=$.t},valueOf:function(){return this.s}};var $=new V;function D(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Q=Math.PI,W=Q/2,X=Q/4,Y=2*Q,tt=180/Q,nt=Q/180,et=Math.abs,rt=Math.atan2,it=Math.cos,ot=Math.sin,ut=Math.sign||function(t){return t>0?1:t<0?-1:0},st=Math.sqrt;function at(t){return t>1?W:t<-1?-W:Math.asin(t)}function ft(t){return(t=ot(t/2))*t}function lt(){}function ht(t,n){t&&yt.hasOwnProperty(t.type)&&yt[t.type](t,n)}var ct={Feature:function(t,n){ht(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)ht(e[r].geometry,n)}},yt={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){xt(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)xt(e[r],n,0)},Polygon:function(t,n){vt(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)vt(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)ht(e[r],n)}};function xt(t,n,e){var r,i=-1,o=t.length-e;for(n.lineStart();++i<o;)r=t[i],n.point(r[0],r[1],r[2]);n.lineEnd()}function vt(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)xt(t[e],n,1);n.polygonEnd()}function pt(t){var n=t[0],e=t[1],r=it(e);return[r*it(n),r*ot(n),ot(e)]}function dt(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function gt(t){var n=st(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var mt=J();function _t(t){return et(t[0])<=Q?t[0]:ut(t[0])*((et(t[0])+Q)%Y-Q)}var wt,Mt,bt,St=J(),At={sphere:lt,point:lt,lineStart:function(){At.point=Pt,At.lineEnd=Zt},lineEnd:lt,polygonStart:lt,polygonEnd:lt};function Zt(){At.point=At.lineEnd=lt}function Pt(t,n){wt=t*=nt,Mt=ot(n*=nt),bt=it(n),At.point=Et}function Et(t,n){t*=nt;var e=ot(n*=nt),r=it(n),i=et(t-wt),o=it(i),u=r*ot(i),s=bt*e-Mt*r*o,a=Mt*e+bt*r*o;St.add(rt(st(u*u+s*s),a)),wt=t,Mt=e,bt=r}function zt(t){return St.reset(),function(t,n){t&&ct.hasOwnProperty(t.type)?ct[t.type](t,n):ht(t,n)}(t,At),+St}var Gt=[null,null],Tt={type:"LineString",coordinates:Gt};function kt(t,n){return Gt[0]=t,Gt[1]=n,zt(Tt)}var Bt={Feature:function(t,n){return Ot(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)if(Ot(e[r].geometry,n))return!0;return!1}},It={Sphere:function(){return!0},Point:function(t,n){return Ht(t.coordinates,n)},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(Ht(e[r],n))return!0;return!1},LineString:function(t,n){return Ut(t.coordinates,n)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(Ut(e[r],n))return!0;return!1},Polygon:function(t,n){return jt(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(jt(e[r],n))return!0;return!1},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)if(Ot(e[r],n))return!0;return!1}};function Ot(t,n){return!(!t||!It.hasOwnProperty(t.type))&&It[t.type](t,n)}function Ht(t,n){return 0===kt(t,n)}function Ut(t,n){for(var e,r,i,o=0,u=t.length;o<u;o++){if(0===(r=kt(t[o],n)))return!0;if(o>0&&(i=kt(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))<1e-12*i)return!0;e=r}return!1}function jt(t,n){return!!function(t,n){var e=_t(n),r=n[1],i=ot(r),o=[ot(e),-it(e),0],u=0,s=0;mt.reset(),1===i?r=W+1e-6:-1===i&&(r=-W-1e-6);for(var a=0,f=t.length;a<f;++a)if(h=(l=t[a]).length)for(var l,h,c=l[h-1],y=_t(c),x=c[1]/2+X,v=ot(x),p=it(x),d=0;d<h;++d,y=m,v=w,p=M,c=g){var g=l[d],m=_t(g),_=g[1]/2+X,w=ot(_),M=it(_),b=m-y,S=b>=0?1:-1,A=S*b,Z=A>Q,P=v*w;if(mt.add(rt(P*S*ot(A),p*M+P*it(A))),u+=Z?b+S*Y:b,Z^y>=e^m>=e){var E=dt(pt(c),pt(g));gt(E);var z=dt(o,E);gt(z);var G=(Z^b>=0?-1:1)*at(z[2]);(r>G||r===G&&(E[0]||E[1]))&&(s+=Z^b>=0?1:-1)}}return(u<-1e-6||u<1e-6&&mt<-1e-6)^1&s}(t.map(Ft),Lt(n))}function Ft(t){return(t=t.map(Lt)).pop(),t}function Lt(t){return[t[0]*nt,t[1]*nt]}function Ct(t,n){return(t&&Bt.hasOwnProperty(t.type)?Bt[t.type]:Ot)(t,n)}function Kt(t,n){let e,r;if(void 0===n)for(const n of t)null!=n&&(void 0===e?n>=n&&(e=r=n):(e>n&&(e=n),r<n&&(r=n)));else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(void 0===e?o>=o&&(e=r=o):(e>o&&(e=o),r<o&&(r=o)))}return[e,r]}function Rt(t){return Array.from(function*(t){for(const n of t)yield*n}(t))}var Nt=window.THREE?window.THREE:{BufferGeometry:n.BufferGeometry,Float32BufferAttribute:n.Float32BufferAttribute,Geometry:n.Geometry},qt=(new Nt.BufferGeometry).setAttribute?"setAttribute":"addAttribute";function Jt(t,n,e,r,i,o,u){Nt.Geometry.call(this),this.type="ConicPolygonGeometry",this.parameters={polygonGeoJson:t,startHeight:n,endHeight:e,closedBottom:r,closedTop:i,includeSides:o,curvatureResolution:u},this.fromBufferGeometry(new Vt(t,n,e,r,i,o)),this.mergeVertices()}function Vt(t,n,i,o,u,s,f){var l=this;Nt.BufferGeometry.call(this),this.type="ConicPolygonBufferGeometry",this.parameters={polygonGeoJson:t,startHeight:n,endHeight:i,closedBottom:o,closedTop:u,includeSides:s,curvatureResolution:f},n=n||0,i=i||1,o=void 0===o||o,u=void 0===u||u,s=void 0===s||s;var h=function(t,n){return t.map((function(t){var e,r=[];return t.forEach((function(t){if(e){var i=180*kt(t,e)/Math.PI;if(i>n)for(var o=(f=t,l=(a=e)[0]*nt,h=a[1]*nt,c=f[0]*nt,y=f[1]*nt,x=it(h),v=ot(h),p=it(y),d=ot(y),g=x*it(l),m=x*ot(l),_=p*it(c),w=p*ot(c),M=2*at(st(ft(y-h)+x*p*ft(c-l))),b=ot(M),(S=M?function(t){var n=ot(t*=M)/b,e=ot(M-t)/b,r=e*g+n*_,i=e*m+n*w,o=e*v+n*d;return[rt(i,r)*tt,rt(o,st(r*r+i*i))*tt]}:function(){return[l*tt,h*tt]}).distance=M,S),u=1/Math.ceil(i/n),s=u;s<1;)r.push(o(s)),s+=u}var a,f,l,h,c,y,x,v,p,d,g,m,_,w,M,b,S;r.push(e=t)})),r}))}(t,f=f||10),c=(u||o)&&function(){var n=Rt(h),i=function(t,n){var r=e(Kt(t[0],(function(t){return t[0]})),2),i=r[0],o=r[1],u=e(Kt(t[0],(function(t){return t[1]})),2),s=u[0],a=u[1];if(Math.min(o-i,a-s)<n)return[];var f,l=s+(a-s)%n/2,h=[],c={type:"Polygon",coordinates:t},y=i+(o-i)%n/2;for(;y<o;){for(f=l;f<a;){var x=[y,f];Ct(c,x)&&h.push(x),f+=n}y+=n}return h}(t,f),o=[].concat(r(n),r(i)),u=[];if(i.length)!function(){for(var i=a.from(o),s=1.1*Math.hypot(f,f),l={type:"Polygon",coordinates:t},h=function(t,a){var f,h=[0,1,2].map((function(n){return i.triangles[t+n]})),c=h.map((function(t){return o[t]}));if(Math.max.apply(Math,r([[0,1],[1,2],[2,0]].map((function(t){var n=e(t,2),i=n[0],o=n[1];return Math.hypot.apply(Math,r([0,1].map((function(t){return c[o][t]-c[i][t]}))))}))))>s)return"continue";if(h.some((function(t){return t<n.length}))){var y=[0,1].map((function(t){return function(t,n){let e=0,r=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(++e,r+=n);else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(o=+o)>=o&&(++e,r+=o)}if(e)return r/e}(c,(function(n){return n[t]}))}));if(!Ct(l,y))return"continue"}(f=u).push.apply(f,r(h))},c=0,y=i.triangles.length;c<y;c+=3)h(c)}();else{var s=g.flatten(h),l=s.vertices,c=s.holes;u=g(l,void 0===c?[]:c,2)}return{points:o,indices:u}}(),y=[],x=[],v=0,p=function(t){var n=Math.round(y.length/3),e=x.length;y=y.concat(t.vertices),x=x.concat(n?t.indices.map((function(t){return t+n})):t.indices),l.addGroup(e,x.length-e,v++)};function d(t,n){var r=t.map((function(t){return t.map((function(t){var r=e(t,2),i=r[0];return function(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-t)*Math.PI/180,i=(90-n)*Math.PI/180;return[e*Math.sin(r)*Math.cos(i),e*Math.cos(r),e*Math.sin(r)*Math.sin(i)]}(r[1],i,n)}))}));return g.flatten(r)}function m(t){return{indices:c.indices,vertices:d([c.points],t).vertices}}s&&p(function(){for(var t=d(h,n),e=t.vertices,r=t.holes,o=d(h,i).vertices,u=Rt([o,e]),s=Math.round(o.length/3),a=new Set(r),f=0,l=[],c=0;c<s;c++){var y=c+1;if(y===s)y=f;else if(a.has(y)){var x=y;y=f,f=x}l.push(c,c+s,y+s),l.push(y+s,y,c)}return{indices:l,vertices:u}}()),o&&p(m(n)),u&&p(m(i)),this.setIndex(x),this[qt]("position",new Nt.Float32BufferAttribute(y,3)),this.computeFaceNormals(),this.computeVertexNormals()}Jt.prototype=Object.create(Nt.Geometry.prototype),Jt.prototype.constructor=Jt,Vt.prototype=Object.create(Nt.BufferGeometry.prototype),Vt.prototype.constructor=Vt,t.ConicPolygonBufferGeometry=Vt,t.ConicPolygonGeometry=Jt,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
// Version 1.3.4 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],e):e((t=t||self).THREE=t.THREE||{},t.THREE)}(this,(function(t,e){"use strict";function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}const a=Math.pow(2,-52),s=new Uint32Array(512);class u{static from(t,e=p,r=x){const n=t.length,i=new Float64Array(2*n);for(let o=0;o<n;o++){const n=t[o];i[2*o]=e(n),i[2*o+1]=r(n)}return new u(i)}constructor(t){const e=t.length>>1;if(e>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const r=Math.max(2*e-5,0);this._triangles=new Uint32Array(3*r),this._halfedges=new Int32Array(3*r),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:r,_hullTri:n,_hullHash:i}=this,o=t.length>>1;let s=1/0,u=1/0,f=-1/0,c=-1/0;for(let e=0;e<o;e++){const r=t[2*e],n=t[2*e+1];r<s&&(s=r),n<u&&(u=n),r>f&&(f=r),n>c&&(c=n),this._ids[e]=e}const v=(s+f)/2,p=(u+c)/2;let x,g,m,w=1/0;for(let e=0;e<o;e++){const r=l(v,p,t[2*e],t[2*e+1]);r<w&&(x=e,w=r)}const b=t[2*x],_=t[2*x+1];w=1/0;for(let e=0;e<o;e++){if(e===x)continue;const r=l(b,_,t[2*e],t[2*e+1]);r<w&&r>0&&(g=e,w=r)}let E=t[2*g],M=t[2*g+1],A=1/0;for(let e=0;e<o;e++){if(e===x||e===g)continue;const r=y(b,_,E,M,t[2*e],t[2*e+1]);r<A&&(m=e,A=r)}let P=t[2*m],S=t[2*m+1];if(A===1/0){for(let e=0;e<o;e++)this._dists[e]=t[2*e]-t[0]||t[2*e+1]-t[1];d(this._ids,this._dists,0,o-1);const e=new Uint32Array(o);let r=0;for(let t=0,n=-1/0;t<o;t++){const i=this._ids[t];this._dists[i]>n&&(e[r++]=i,n=this._dists[i])}return this.hull=e.subarray(0,r),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(h(b,_,E,M,P,S)){const t=g,e=E,r=M;g=m,E=P,M=S,m=t,P=e,S=r}const T=function(t,e,r,n,i,o){const a=r-t,s=n-e,u=i-t,l=o-e,f=a*a+s*s,h=u*u+l*l,c=.5/(a*l-s*u);return{x:t+(l*f-s*h)*c,y:e+(a*h-u*f)*c}}(b,_,E,M,P,S);this._cx=T.x,this._cy=T.y;for(let e=0;e<o;e++)this._dists[e]=l(t[2*e],t[2*e+1],T.x,T.y);d(this._ids,this._dists,0,o-1),this._hullStart=x;let R=3;r[x]=e[m]=g,r[g]=e[x]=m,r[m]=e[g]=x,n[x]=0,n[g]=1,n[m]=2,i.fill(-1),i[this._hashKey(b,_)]=x,i[this._hashKey(E,M)]=g,i[this._hashKey(P,S)]=m,this.trianglesLen=0,this._addTriangle(x,g,m,-1,-1,-1);for(let o,s,u=0;u<this._ids.length;u++){const l=this._ids[u],f=t[2*l],c=t[2*l+1];if(u>0&&Math.abs(f-o)<=a&&Math.abs(c-s)<=a)continue;if(o=f,s=c,l===x||l===g||l===m)continue;let y=0;for(let t=0,e=this._hashKey(f,c);t<this._hashSize&&(y=i[(e+t)%this._hashSize],-1===y||y===r[y]);t++);y=e[y];let d,v=y;for(;d=r[v],!h(f,c,t[2*v],t[2*v+1],t[2*d],t[2*d+1]);)if(v=d,v===y){v=-1;break}if(-1===v)continue;let p=this._addTriangle(v,l,r[v],-1,-1,n[v]);n[l]=this._legalize(p+2),n[v]=p,R++;let w=r[v];for(;d=r[w],h(f,c,t[2*w],t[2*w+1],t[2*d],t[2*d+1]);)p=this._addTriangle(w,l,d,n[l],-1,n[w]),n[l]=this._legalize(p+2),r[w]=w,R--,w=d;if(v===y)for(;d=e[v],h(f,c,t[2*d],t[2*d+1],t[2*v],t[2*v+1]);)p=this._addTriangle(d,l,v,-1,n[v],n[d]),this._legalize(p+2),n[d]=p,r[v]=v,R--,v=d;this._hullStart=e[l]=v,r[v]=e[w]=l,r[l]=w,i[this._hashKey(f,c)]=l,i[this._hashKey(t[2*v],t[2*v+1])]=v}this.hull=new Uint32Array(R);for(let t=0,e=this._hullStart;t<R;t++)this.hull[t]=e,e=r[e];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(function(t,e){const r=t/(Math.abs(t)+Math.abs(e));return(e>0?3-r:1+r)/4}(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:r,coords:n}=this;let i=0,o=0;for(;;){const a=r[t],u=t-t%3;if(o=u+(t+2)%3,-1===a){if(0===i)break;t=s[--i];continue}const l=a-a%3,f=u+(t+1)%3,h=l+(a+2)%3,y=e[o],d=e[t],v=e[f],p=e[h];if(c(n[2*y],n[2*y+1],n[2*d],n[2*d+1],n[2*v],n[2*v+1],n[2*p],n[2*p+1])){e[t]=p,e[a]=y;const n=r[h];if(-1===n){let e=this._hullStart;do{if(this._hullTri[e]===h){this._hullTri[e]=t;break}e=this._hullPrev[e]}while(e!==this._hullStart)}this._link(t,n),this._link(a,r[o]),this._link(o,h);const u=l+(a+1)%3;i<s.length&&(s[i++]=u)}else{if(0===i)break;t=s[--i]}}return o}_link(t,e){this._halfedges[t]=e,-1!==e&&(this._halfedges[e]=t)}_addTriangle(t,e,r,n,i,o){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=r,this._link(a,n),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a}}function l(t,e,r,n){const i=t-r,o=e-n;return i*i+o*o}function f(t,e,r,n,i,o){const a=(n-e)*(i-t),s=(r-t)*(o-e);return Math.abs(a-s)>=33306690738754716e-32*Math.abs(a+s)?a-s:0}function h(t,e,r,n,i,o){return(f(i,o,t,e,r,n)||f(t,e,r,n,i,o)||f(r,n,i,o,t,e))<0}function c(t,e,r,n,i,o,a,s){const u=t-a,l=e-s,f=r-a,h=n-s,c=i-a,y=o-s,d=f*f+h*h,v=c*c+y*y;return u*(h*v-d*y)-l*(f*v-d*c)+(u*u+l*l)*(f*y-h*c)<0}function y(t,e,r,n,i,o){const a=r-t,s=n-e,u=i-t,l=o-e,f=a*a+s*s,h=u*u+l*l,c=.5/(a*l-s*u),y=(l*f-s*h)*c,d=(a*h-u*f)*c;return y*y+d*d}function d(t,e,r,n){if(n-r<=20)for(let i=r+1;i<=n;i++){const n=t[i],o=e[n];let a=i-1;for(;a>=r&&e[t[a]]>o;)t[a+1]=t[a--];t[a+1]=n}else{let i=r+1,o=n;v(t,r+n>>1,i),e[t[r]]>e[t[n]]&&v(t,r,n),e[t[i]]>e[t[n]]&&v(t,i,n),e[t[r]]>e[t[i]]&&v(t,r,i);const a=t[i],s=e[a];for(;;){do{i++}while(e[t[i]]<s);do{o--}while(e[t[o]]>s);if(o<i)break;v(t,i,o)}t[r+1]=t[o],t[o]=a,n-i+1>=o-r?(d(t,e,i,n),d(t,e,r,o-1)):(d(t,e,r,o-1),d(t,e,i,n))}}function v(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function p(t){return t[0]}function x(t){return t[1]}var g=w,m=w;function w(t,e,r){r=r||2;var n,i,o,a,s,u,l,f=e&&e.length,h=f?e[0]*r:t.length,c=b(t,0,h,r,!0),y=[];if(!c||c.next===c.prev)return y;if(f&&(c=function(t,e,r,n){var i,o,a,s,u,l=[];for(i=0,o=e.length;i<o;i++)a=e[i]*n,s=i<o-1?e[i+1]*n:t.length,(u=b(t,a,s,n,!1))===u.next&&(u.steiner=!0),l.push(G(u));for(l.sort(T),i=0;i<l.length;i++)R(l[i],r),r=_(r,r.next);return r}(t,e,c,r)),t.length>80*r){n=o=t[0],i=a=t[1];for(var d=r;d<h;d+=r)(s=t[d])<n&&(n=s),(u=t[d+1])<i&&(i=u),s>o&&(o=s),u>a&&(a=u);l=0!==(l=Math.max(o-n,a-i))?1/l:0}return E(c,y,r,n,i,l),y}function b(t,e,r,n,i){var o,a;if(i===D(t,e,r,n)>0)for(o=e;o<r;o+=n)a=N(o,t[o],t[o+1],a);else for(o=r-n;o>=e;o-=n)a=N(o,t[o],t[o+1],a);return a&&z(a,a.next)&&(H(a),a=a.next),a}function _(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!z(n,n.next)&&0!==I(n.prev,n,n.next))n=n.next;else{if(H(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function E(t,e,r,n,i,o,a){if(t){!a&&o&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=Z(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,o,a,s,u,l=1;do{for(r=t,t=null,o=null,a=0;r;){for(a++,n=r,s=0,e=0;e<l&&(s++,n=n.nextZ);e++);for(u=l;s>0||u>0&&n;)0!==s&&(0===u||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,u--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;r=n}o.nextZ=null,l*=2}while(a>1)}(i)}(t,n,i,o);for(var s,u,l=t;t.prev!==t.next;)if(s=t.prev,u=t.next,o?A(t,n,i,o):M(t))e.push(s.i/r),e.push(t.i/r),e.push(u.i/r),H(t),t=u.next,l=u.next;else if((t=u)===l){a?1===a?E(t=P(_(t),e,r),e,r,n,i,o,2):2===a&&S(t,e,r,n,i,o):E(_(t),e,r,n,i,o,1);break}}}function M(t){var e=t.prev,r=t,n=t.next;if(I(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(k(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&I(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function A(t,e,r,n){var i=t.prev,o=t,a=t.next;if(I(i,o,a)>=0)return!1;for(var s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,u=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,l=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,f=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=Z(s,u,e,r,n),c=Z(l,f,e,r,n),y=t.prevZ,d=t.nextZ;y&&y.z>=h&&d&&d.z<=c;){if(y!==t.prev&&y!==t.next&&k(i.x,i.y,o.x,o.y,a.x,a.y,y.x,y.y)&&I(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,d!==t.prev&&d!==t.next&&k(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&I(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;y&&y.z>=h;){if(y!==t.prev&&y!==t.next&&k(i.x,i.y,o.x,o.y,a.x,a.y,y.x,y.y)&&I(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;d&&d.z<=c;){if(d!==t.prev&&d!==t.next&&k(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&I(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function P(t,e,r){var n=t;do{var i=n.prev,o=n.next.next;!z(i,o)&&C(i,n,n.next,o)&&q(i,o)&&q(o,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(o.i/r),H(n),H(n.next),n=t=o),n=n.next}while(n!==t);return _(n)}function S(t,e,r,n,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&O(a,s)){var u=B(a,s);return a=_(a,a.next),u=_(u,u.next),E(a,e,r,n,i,o),void E(u,e,r,n,i,o)}s=s.next}a=a.next}while(a!==t)}function T(t,e){return t.x-e.x}function R(t,e){if(e=function(t,e){var r,n=e,i=t.x,o=t.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!r)return null;if(i===a)return r;var u,l=r,f=r.x,h=r.y,c=1/0;n=r;do{i>=n.x&&n.x>=f&&i!==n.x&&k(o<h?i:a,o,f,h,o<h?a:i,o,n.x,n.y)&&(u=Math.abs(o-n.y)/(i-n.x),q(n,t)&&(u<c||u===c&&(n.x>r.x||n.x===r.x&&F(r,n)))&&(r=n,c=u)),n=n.next}while(n!==l);return r}(t,e)){var r=B(e,t);_(e,e.next),_(r,r.next)}}function F(t,e){return I(t.prev,t,e.prev)<0&&I(e.next,t,t.next)<0}function Z(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function G(t){var e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next}while(e!==t);return r}function k(t,e,r,n,i,o,a,s){return(i-a)*(e-s)-(t-a)*(o-s)>=0&&(t-a)*(n-s)-(r-a)*(e-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function O(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&C(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(q(t,e)&&q(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(I(t.prev,t,e.prev)||I(t,e.prev,e))||z(t,e)&&I(t.prev,t,t.next)>0&&I(e.prev,e,e.next)>0)}function I(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function z(t,e){return t.x===e.x&&t.y===e.y}function C(t,e,r,n){var i=L(I(t,e,r)),o=L(I(t,e,n)),a=L(I(r,n,t)),s=L(I(r,n,e));return i!==o&&a!==s||(!(0!==i||!j(t,r,e))||(!(0!==o||!j(t,n,e))||(!(0!==a||!j(r,t,n))||!(0!==s||!j(r,e,n)))))}function j(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function L(t){return t>0?1:t<0?-1:0}function q(t,e){return I(t.prev,t,t.next)<0?I(t,e,t.next)>=0&&I(t,t.prev,e)>=0:I(t,e,t.prev)<0||I(t,t.next,e)<0}function B(t,e){var r=new U(t.i,t.x,t.y),n=new U(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function N(t,e,r,n){var i=new U(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function H(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function U(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function D(t,e,r,n){for(var i=0,o=e,a=r-n;o<r;o+=n)i+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return i}function K(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function J(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}w.deviation=function(t,e,r,n){var i=e&&e.length,o=i?e[0]*r:t.length,a=Math.abs(D(t,0,o,r));if(i)for(var s=0,u=e.length;s<u;s++){var l=e[s]*r,f=s<u-1?e[s+1]*r:t.length;a-=Math.abs(D(t,l,f,r))}var h=0;for(s=0;s<n.length;s+=3){var c=n[s]*r,y=n[s+1]*r,d=n[s+2]*r;h+=Math.abs((t[c]-t[d])*(t[y+1]-t[c+1])-(t[c]-t[y])*(t[d+1]-t[c+1]))}return 0===a&&0===h?0:Math.abs((h-a)/a)},w.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},n=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var a=0;a<e;a++)r.vertices.push(t[i][o][a]);i>0&&(n+=t[i-1].length,r.holes.push(n))}return r},g.default=m;var V=J((function(t,e){function r(t,e,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function n(t,e,n){return void 0===n&&(n={}),r({type:"Point",coordinates:t},e,n)}function i(t,e,n){void 0===n&&(n={});for(var i=0,o=t;i<o.length;i++){var a=o[i];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return r({type:"Polygon",coordinates:t},e,n)}function o(t,e,n){if(void 0===n&&(n={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:t},e,n)}function a(t,e){void 0===e&&(e={});var r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function s(t,e,n){return void 0===n&&(n={}),r({type:"MultiLineString",coordinates:t},e,n)}function u(t,e,n){return void 0===n&&(n={}),r({type:"MultiPoint",coordinates:t},e,n)}function l(t,e,n){return void 0===n&&(n={}),r({type:"MultiPolygon",coordinates:t},e,n)}function f(t,r){void 0===r&&(r="kilometers");var n=e.factors[r];if(!n)throw new Error(r+" units is invalid");return t*n}function h(t,r){void 0===r&&(r="kilometers");var n=e.factors[r];if(!n)throw new Error(r+" units is invalid");return t/n}function c(t){return 180*(t%(2*Math.PI))/Math.PI}function y(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)&&!/^\s*$/.test(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.earthRadius=6371008.8,e.factors={centimeters:100*e.earthRadius,centimetres:100*e.earthRadius,degrees:e.earthRadius/111325,feet:3.28084*e.earthRadius,inches:39.37*e.earthRadius,kilometers:e.earthRadius/1e3,kilometres:e.earthRadius/1e3,meters:e.earthRadius,metres:e.earthRadius,miles:e.earthRadius/1609.344,millimeters:1e3*e.earthRadius,millimetres:1e3*e.earthRadius,nauticalmiles:e.earthRadius/1852,radians:1,yards:e.earthRadius/1.0936},e.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e.earthRadius,yards:1/1.0936},e.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},e.feature=r,e.geometry=function(t,e,r){switch(t){case"Point":return n(e).geometry;case"LineString":return o(e).geometry;case"Polygon":return i(e).geometry;case"MultiPoint":return u(e).geometry;case"MultiLineString":return s(e).geometry;case"MultiPolygon":return l(e).geometry;default:throw new Error(t+" is invalid")}},e.point=n,e.points=function(t,e,r){return void 0===r&&(r={}),a(t.map((function(t){return n(t,e)})),r)},e.polygon=i,e.polygons=function(t,e,r){return void 0===r&&(r={}),a(t.map((function(t){return i(t,e)})),r)},e.lineString=o,e.lineStrings=function(t,e,r){return void 0===r&&(r={}),a(t.map((function(t){return o(t,e)})),r)},e.featureCollection=a,e.multiLineString=s,e.multiPoint=u,e.multiPolygon=l,e.geometryCollection=function(t,e,n){return void 0===n&&(n={}),r({type:"GeometryCollection",geometries:t},e,n)},e.round=function(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(t*r)/r},e.radiansToLength=f,e.lengthToRadians=h,e.lengthToDegrees=function(t,e){return c(h(t,e))},e.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},e.radiansToDegrees=c,e.degreesToRadians=function(t){return t%360*Math.PI/180},e.convertLength=function(t,e,r){if(void 0===e&&(e="kilometers"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("length must be a positive number");return f(h(t,e),r)},e.convertArea=function(t,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=e.areaFactors[r];if(!i)throw new Error("invalid original units");var o=e.areaFactors[n];if(!o)throw new Error("invalid final units");return t/i*o},e.isNumber=y,e.isObject=function(t){return!!t&&t.constructor===Object},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!y(t))throw new Error("bbox must only contain numbers")}))},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")},e.radians2degrees=function(){throw new Error("method has been renamed to `radiansToDegrees`")},e.degrees2radians=function(){throw new Error("method has been renamed to `degreesToRadians`")},e.distanceToDegrees=function(){throw new Error("method has been renamed to `lengthToDegrees`")},e.distanceToRadians=function(){throw new Error("method has been renamed to `lengthToRadians`")},e.radiansToDistance=function(){throw new Error("method has been renamed to `radiansToLength`")},e.bearingToAngle=function(){throw new Error("method has been renamed to `bearingToAzimuth`")},e.convertDistance=function(){throw new Error("method has been renamed to `convertLength`")}})),$=J((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getCoord=function(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")},e.getCoords=function(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")},e.containsNumber=function t(e){if(e.length>1&&V.isNumber(e[0])&&V.isNumber(e[1]))return!0;if(Array.isArray(e[0])&&e[0].length)return t(e[0]);throw new Error("coordinates must only contain numbers")},e.geojsonType=function(t,e,r){if(!e||!r)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+t.type)},e.featureOf=function(t,e,r){if(!t)throw new Error("No feature passed");if(!r)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+r+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+t.geometry.type)},e.collectionOf=function(t,e,r){if(!t)throw new Error("No featureCollection passed");if(!r)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+r+", FeatureCollection required");for(var n=0,i=t.features;n<i.length;n++){var o=i[n];if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+r+", Feature with geometry required");if(!o.geometry||o.geometry.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+o.geometry.type)}},e.getGeom=function(t){return"Feature"===t.type?t.geometry:t},e.getType=function(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}})),Q=K(J((function(t,e){function r(t,e,r){var n=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var i=0,o=e.length-1;i<e.length;o=i++){var a=e[i][0],s=e[i][1],u=e[o][0],l=e[o][1];if(t[1]*(a-u)+s*(u-t[0])+l*(t[0]-a)==0&&(a-t[0])*(u-t[0])<=0&&(s-t[1])*(l-t[1])<=0)return!r;s>t[1]!=l>t[1]&&t[0]<(u-a)*(t[1]-s)/(l-s)+a&&(n=!n)}return n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var i=$.getCoord(t),o=$.getGeom(e),a=o.type,s=e.bbox,u=o.coordinates;if(s&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(i,s))return!1;"Polygon"===a&&(u=[u]);for(var l=!1,f=0;f<u.length&&!l;f++)if(r(i,u[f][0],n.ignoreBoundary)){for(var h=!1,c=1;c<u[f].length&&!h;)r(i,u[f][c],!n.ignoreBoundary)&&(h=!0),c++;h||(l=!0)}return l}})));function W(){this.reset()}W.prototype={constructor:W,reset:function(){this.s=this.t=0},add:function(t){Y(X,t,this.t),Y(this,X.s,this.s),this.s?this.t+=X.t:this.s=X.t},valueOf:function(){return this.s}};var X=new W;function Y(t,e,r){var n=t.s=e+r,i=n-e,o=n-i;t.t=e-o+(r-i)}var tt=Math.PI,et=tt/2,rt=180/tt,nt=tt/180,it=Math.abs,ot=Math.atan2,at=Math.cos,st=Math.sin,ut=Math.sqrt;function lt(t){return(t=st(t/2))*t}function ft(){}function ht(t,e){t&&yt.hasOwnProperty(t.type)&&yt[t.type](t,e)}var ct={Feature:function(t,e){ht(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n<i;)ht(r[n].geometry,e)}},yt={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)t=r[n],e.point(t[0],t[1],t[2])},LineString:function(t,e){dt(t.coordinates,e,0)},MultiLineString:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)dt(r[n],e,0)},Polygon:function(t,e){vt(t.coordinates,e)},MultiPolygon:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)vt(r[n],e)},GeometryCollection:function(t,e){for(var r=t.geometries,n=-1,i=r.length;++n<i;)ht(r[n],e)}};function dt(t,e,r){var n,i=-1,o=t.length-r;for(e.lineStart();++i<o;)n=t[i],e.point(n[0],n[1],n[2]);e.lineEnd()}function vt(t,e){var r=-1,n=t.length;for(e.polygonStart();++r<n;)dt(t[r],e,1);e.polygonEnd()}var pt,xt,gt,mt=new W,wt={sphere:ft,point:ft,lineStart:function(){wt.point=_t,wt.lineEnd=bt},lineEnd:ft,polygonStart:ft,polygonEnd:ft};function bt(){wt.point=wt.lineEnd=ft}function _t(t,e){pt=t*=nt,xt=st(e*=nt),gt=at(e),wt.point=Et}function Et(t,e){t*=nt;var r=st(e*=nt),n=at(e),i=it(t-pt),o=at(i),a=n*st(i),s=gt*r-xt*n*o,u=xt*r+gt*n*o;mt.add(ot(ut(a*a+s*s),u)),pt=t,xt=r,gt=n}function Mt(t){return mt.reset(),function(t,e){t&&ct.hasOwnProperty(t.type)?ct[t.type](t,e):ht(t,e)}(t,wt),+mt}var At=[null,null],Pt={type:"LineString",coordinates:At};function St(t,e){var r,n=t[0]*nt,i=t[1]*nt,o=e[0]*nt,a=e[1]*nt,s=at(i),u=st(i),l=at(a),f=st(a),h=s*at(n),c=s*st(n),y=l*at(o),d=l*st(o),v=2*((r=ut(lt(a-i)+s*l*lt(o-n)))>1?et:r<-1?-et:Math.asin(r)),p=st(v),x=v?function(t){var e=st(t*=v)/p,r=st(v-t)/p,n=r*h+e*y,i=r*c+e*d,o=r*u+e*f;return[ot(i,n)*rt,ot(o,ut(n*n+i*i))*rt]}:function(){return[n*rt,i*rt]};return x.distance=v,x}function Tt(t,e){let r,n;if(void 0===e)for(const e of t)null!=e&&(void 0===r?e>=e&&(r=n=e):(r>e&&(r=e),n<e&&(n=e)));else{let i=-1;for(let o of t)null!=(o=e(o,++i,t))&&(void 0===r?o>=o&&(r=n=o):(r>o&&(r=o),n<o&&(n=o)))}return[r,n]}function Rt(t){return Array.from(function*(t){for(const e of t)yield*e}(t))}var Ft=window.THREE?window.THREE:{BufferGeometry:e.BufferGeometry,Float32BufferAttribute:e.Float32BufferAttribute,Geometry:e.Geometry},Zt=(new Ft.BufferGeometry).setAttribute?"setAttribute":"addAttribute";function Gt(t,e,r,n,i,o,a){Ft.Geometry.call(this),this.type="ConicPolygonGeometry",this.parameters={polygonGeoJson:t,startHeight:e,endHeight:r,closedBottom:n,closedTop:i,includeSides:o,curvatureResolution:a},this.fromBufferGeometry(new kt(t,e,r,n,i,o)),this.mergeVertices()}function kt(t,e,i,o,a,s,l){var f=this;Ft.BufferGeometry.call(this),this.type="ConicPolygonBufferGeometry",this.parameters={polygonGeoJson:t,startHeight:e,endHeight:i,closedBottom:o,closedTop:a,includeSides:s,curvatureResolution:l},e=e||0,i=i||1,o=void 0===o||o,a=void 0===a||a,s=void 0===s||s;var h=function(t,e){return t.map((function(t){var r,n=[];return t.forEach((function(t){if(r){var i=180*(u=t,l=r,At[0]=u,At[1]=l,Mt(Pt))/Math.PI;if(i>e)for(var o=St(r,t),a=1/Math.ceil(i/e),s=a;s<1;)n.push(o(s)),s+=a}var u,l;n.push(r=t)})),n}))}(t,l=l||5),c=(a||o)&&function(){var e=Rt(h),i=function(t,e){var n=r(Tt(t[0],(function(t){return t[0]})),2),i=n[0],o=n[1],a=r(Tt(t[0],(function(t){return t[1]})),2),s=a[0],u=a[1];if(Math.min(o-i,u-s)<e)return[];var l,f=s+(u-s)%e/2,h=[],c={type:"Polygon",coordinates:t},y=i+(o-i)%e/2;for(;y<o;){for(l=f;l<u;){var d=[y,l];Ot(d,c)&&h.push(d),l+=e}y+=e}return h}(t,l),o=[].concat(n(e),n(i)),a=[];if(i.length)!function(){for(var r=u.from(o),i={type:"Polygon",coordinates:t},s=function(t,s){var u,l=[0,1,2].map((function(e){return r.triangles[t+e]})),f=l.map((function(t){return o[t]}));if(l.some((function(t){return t<e.length}))&&!Ot([0,1].map((function(t){return function(t,e){let r=0,n=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++r,n+=e);else{let i=-1;for(let o of t)null!=(o=e(o,++i,t))&&(o=+o)>=o&&(++r,n+=o)}if(r)return n/r}(f,(function(e){return e[t]}))})),i))return"continue";(u=a).push.apply(u,n(l))},l=0,f=r.triangles.length;l<f;l+=3)s(l)}();else{var s=g.flatten(h),f=s.vertices,c=s.holes;a=g(f,void 0===c?[]:c,2)}return{points:o,indices:a}}(),y=[],d=[],v=0,p=function(t){var e=Math.round(y.length/3),r=d.length;y=y.concat(t.vertices),d=d.concat(e?t.indices.map((function(t){return t+e})):t.indices),f.addGroup(r,d.length-r,v++)};function x(t,e){var n=t.map((function(t){return t.map((function(t){var n=r(t,2),i=n[0];return function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=(90-t)*Math.PI/180,i=(90-e)*Math.PI/180;return[r*Math.sin(n)*Math.cos(i),r*Math.cos(n),r*Math.sin(n)*Math.sin(i)]}(n[1],i,e)}))}));return g.flatten(n)}function m(t){return{indices:c.indices,vertices:x([c.points],t).vertices}}s&&p(function(){for(var t=x(h,e),r=t.vertices,n=t.holes,o=x(h,i).vertices,a=Rt([o,r]),s=Math.round(o.length/3),u=new Set(n),l=0,f=[],c=0;c<s;c++){var y=c+1;if(y===s)y=l;else if(u.has(y)){var d=y;y=l,l=d}f.push(c,c+s,y+s),f.push(y+s,y,c)}return{indices:f,vertices:a}}()),o&&p(m(e)),a&&p(m(i)),this.setIndex(d),this[Zt]("position",new Ft.Float32BufferAttribute(y,3)),this.computeFaceNormals(),this.computeVertexNormals()}function Ot(t,e){return Q(t,e)}Gt.prototype=Object.create(Ft.Geometry.prototype),Gt.prototype.constructor=Gt,kt.prototype=Object.create(Ft.BufferGeometry.prototype),kt.prototype.constructor=kt,t.ConicPolygonBufferGeometry=kt,t.ConicPolygonGeometry=Gt,Object.defineProperty(t,"__esModule",{value:!0})})); |
import { BufferGeometry, Float32BufferAttribute, Geometry } from 'three'; | ||
import Delaunator from 'delaunator'; | ||
import earcut from 'earcut'; | ||
import { geoDistance, geoInterpolate, geoContains } from 'd3-geo'; | ||
import turfPointInPolygon from '@turf/boolean-point-in-polygon'; | ||
import { geoDistance, geoInterpolate } from 'd3-geo'; | ||
import { merge, extent, mean } from 'd3-array'; | ||
@@ -127,3 +128,3 @@ | ||
includeSides = includeSides !== undefined ? includeSides : true; | ||
curvatureResolution = curvatureResolution || 10; // in angular degrees | ||
curvatureResolution = curvatureResolution || 5; // in angular degrees | ||
// pre-calculate contour and triangulation | ||
@@ -223,3 +224,3 @@ | ||
if (!innerPoints.length) { | ||
// earcut triangulation more performant if it's only using the polygon perimeter | ||
// earcut triangulation slightly more performant if it's only using the polygon perimeter | ||
var _earcut$flatten = earcut.flatten(contourGeoJson), | ||
@@ -234,4 +235,2 @@ _vertices = _earcut$flatten.vertices, | ||
var delaunay = Delaunator.from(points); | ||
var maxDistance = Math.hypot(curvatureResolution, curvatureResolution) * 1.1; // with small margin of error | ||
var boundariesGeojson = { | ||
@@ -250,15 +249,4 @@ type: 'Polygon', | ||
return points[indice]; | ||
}); // exclude triangles longer than the max distance | ||
}); // exclude edge triangles outside polygon perimeter or through holes | ||
var largestSide = Math.max.apply(Math, _toConsumableArray([[0, 1], [1, 2], [2, 0]].map(function (_ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 2), | ||
i0 = _ref4[0], | ||
i1 = _ref4[1]; | ||
return Math.hypot.apply(Math, _toConsumableArray([0, 1].map(function (cIdx) { | ||
return triangle[i1][cIdx] - triangle[i0][cIdx]; | ||
}))); | ||
}))); | ||
if (largestSide > maxDistance) return "continue"; // exclude edge triangles outside polygon perimeter or through holes | ||
if (inds.some(function (ind) { | ||
@@ -272,3 +260,3 @@ return ind < edgePnts.length; | ||
}); | ||
if (!geoContains(boundariesGeojson, triangleCentroid)) return "continue"; | ||
if (!pointInside(triangleCentroid, boundariesGeojson)) return "continue"; | ||
} | ||
@@ -307,2 +295,6 @@ | ||
function pointInside(pnt, polygonGeoJson) { | ||
return turfPointInPolygon(pnt, polygonGeoJson); | ||
} | ||
function interpolateContourPoints(polygonGeoJson, maxDistance) { | ||
@@ -369,3 +361,3 @@ // add interpolated points for segments that are further apart than the max distance | ||
var pnt = [lng, lat]; | ||
geoContains(boundariesGeojson, pnt) && pnts.push(pnt); | ||
pointInside(pnt, boundariesGeojson) && pnts.push(pnt); | ||
lat += maxDistance; | ||
@@ -372,0 +364,0 @@ } |
{ | ||
"name": "three-conic-polygon-geometry", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "ThreeJS geometry for drawing polygons on a sphere", | ||
@@ -42,2 +42,3 @@ "unpkg": "dist/three-conic-polygon-geometry.min.js", | ||
"dependencies": { | ||
"@turf/boolean-point-in-polygon": "^6.0.1", | ||
"d3-array": "^2.4.0", | ||
@@ -56,3 +57,3 @@ "d3-geo": "^1.12.1", | ||
"@babel/preset-env": "^7.10.4", | ||
"@rollup/plugin-commonjs": "^14.0.0", | ||
"@rollup/plugin-commonjs": "^13.0.2", | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
@@ -59,0 +60,0 @@ "@types/three": ">=0.72.0", |
@@ -54,3 +54,3 @@ ThreeJS Conic Polygon Geometry | ||
* <b>includeSides</b>: Whether to include the side surfaces of the cone. Default is `true`. | ||
* <b>curvatureResolution</b>: The resolution in angular degrees of the sphere curvature. The finer the resolution, the more the polygon is fragmented into smaller faces to approximate the spheric surface, at the cost of performance. Default is `10`. | ||
* <b>curvatureResolution</b>: The resolution in angular degrees of the sphere curvature. The finer the resolution, the more the polygon is fragmented into smaller faces to approximate the spheric surface, at the cost of performance. Default is `5`. | ||
@@ -57,0 +57,0 @@ ### Properties |
@@ -17,3 +17,4 @@ import { | ||
import earcut from 'earcut'; | ||
import { geoContains, geoDistance, geoInterpolate } from 'd3-geo'; | ||
import turfPointInPolygon from '@turf/boolean-point-in-polygon'; | ||
import { geoDistance, geoInterpolate } from 'd3-geo'; | ||
import { extent, mean, merge as flatten } from 'd3-array'; | ||
@@ -68,3 +69,3 @@ | ||
includeSides = includeSides !== undefined ? includeSides : true; | ||
curvatureResolution = curvatureResolution || 10; // in angular degrees | ||
curvatureResolution = curvatureResolution || 5; // in angular degrees | ||
@@ -153,3 +154,3 @@ // pre-calculate contour and triangulation | ||
if (!innerPoints.length) { // earcut triangulation more performant if it's only using the polygon perimeter | ||
if (!innerPoints.length) { // earcut triangulation slightly more performant if it's only using the polygon perimeter | ||
const { vertices, holes = [] } = earcut.flatten(contourGeoJson); | ||
@@ -160,3 +161,2 @@ indices = earcut(vertices, holes, 2); | ||
const maxDistance = Math.hypot(curvatureResolution, curvatureResolution) * 1.1; // with small margin of error | ||
const boundariesGeojson = {type: 'Polygon', coordinates: polygonGeoJson}; | ||
@@ -167,12 +167,6 @@ for (let i = 0, len = delaunay.triangles.length; i < len; i += 3) { | ||
// exclude triangles longer than the max distance | ||
const largestSide = Math.max(...[[0, 1], [1, 2], [2, 0]].map(([i0, i1]) => | ||
Math.hypot(...[0, 1].map(cIdx => triangle[i1][cIdx] - triangle[i0][cIdx])) | ||
)); | ||
if (largestSide > maxDistance) continue; | ||
// exclude edge triangles outside polygon perimeter or through holes | ||
if (inds.some(ind => ind < edgePnts.length)) { | ||
const triangleCentroid = [0, 1].map(coordIdx => mean(triangle, p => p[coordIdx])); | ||
if (!geoContains(boundariesGeojson, triangleCentroid)) continue; | ||
if (!pointInside(triangleCentroid, boundariesGeojson)) continue; | ||
} | ||
@@ -203,2 +197,6 @@ | ||
function pointInside(pnt, polygonGeoJson) { | ||
return turfPointInPolygon(pnt, polygonGeoJson); | ||
} | ||
function interpolateContourPoints(polygonGeoJson, maxDistance) { | ||
@@ -253,3 +251,3 @@ // add interpolated points for segments that are further apart than the max distance | ||
const pnt = [lng, lat]; | ||
geoContains(boundariesGeojson, pnt) && pnts.push(pnt); | ||
pointInside(pnt, boundariesGeojson) && pnts.push(pnt); | ||
lat += maxDistance; | ||
@@ -256,0 +254,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
941544
3557
6
15
+ Added@turf/boolean-point-in-polygon@6.5.0(transitive)
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/invariant@6.5.0(transitive)