UNPKG

terra-route

Version:

A library for routing along GeoJSON LineString networks

3 lines (2 loc) 18 kB
var t=function(t,e){var r=function(t){return t*Math.PI/180},n=r(t[1]),i=r(t[0]),a=r(e[1]),s=a-n,o=r(e[0])-i,h=Math.sin(s/2)*Math.sin(s/2)+Math.cos(n)*Math.cos(a)*Math.sin(o/2)*Math.sin(o/2);return 2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h))*6371e3/1e3};function e(t){var e=1/298.257223563,r=e*(2-e),n=Math.PI/180,i=Math.cos(t*n),a=1/(1-r*(1-i*i)),s=Math.sqrt(a),o=6378.137*n,h=o*s*i,u=o*s*a*(1-r);return function(t,e){for(var r=t[0]-e[0];r<-180;)r+=360;for(;r>180;)r-=360;var n=r*h,i=(t[1]-e[1])*u;return Math.sqrt(n*n+i*i)}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function n(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(null,arguments)}function a(t,e,r){r[t]=!0;for(var i,s=n(e[t]);!(i=s()).done;){var o=i.value;r[o]||a(o,e,r)}}function s(t,e){var r=function(t,e){var r=t[0],n=e[0];return r<n||r===n&&t[1]<=e[1]?[t,e]:[e,t]}(t,e);return JSON.stringify([r[0],r[1]])}function o(t){for(var e,r=new Map,i=n(t.features);!(e=i()).done;)for(var a=e.value.geometry.coordinates,o=0;o<a.length-1;o++){var h=a[o],u=a[o+1],f=s(h,u);r.has(f)||r.set(f,{type:"Feature",geometry:{type:"LineString",coordinates:[h,u]},properties:{}})}return{type:"FeatureCollection",features:Array.from(r.values())}}function h(e){for(var r=e.geometry.coordinates,n=0,i=0;i<r.length-1;i++)n+=t(r[i],r[i+1]);return n}function u(t,e){var r=t.length,n=e.length;if(r>n)return!1;for(var i=0;i<=n-r;i++){for(var a=!0,s=0;s<r;s++)if(e[i+s][0]!==t[s][0]||e[i+s][1]!==t[s][1]){a=!1;break}if(a)return!0}for(var o=[].concat(t).reverse(),h=0;h<=n-r;h++){for(var u=!0,f=0;f<r;f++)if(e[h+f][0]!==o[f][0]||e[h+f][1]!==o[f][1]){u=!1;break}if(u)return!0}return!1}function f(t){var e=o(t),r=new Map;function n(t){return t.join(",")}for(var i=0;i<e.features.length;i++){var a=e.features[i].geometry.coordinates;if(!(a.length<2)){var s=n(a[0]),h=n(a[a.length-1]);r.set(s,(r.get(s)||0)+1),r.set(h,(r.get(h)||0)+1)}}for(var u=new Map,f=new Map,c=0;c<e.features.length;c++){var d=e.features[c],v=d.geometry.coordinates;if(!(v.length<2)){var l=n(v[0]),g=n(v[v.length-1]),p=r.get(l)||0,y=r.get(g)||0,m=v.map(n).join(";");1===p||1===y?u.has(m)||u.set(m,d):f.has(m)||f.set(m,d)}}return{leafEdges:{type:"FeatureCollection",features:Array.from(u.values())},nonLeafEdges:{type:"FeatureCollection",features:Array.from(f.values())}}}function c(t,e,r,i,a){for(var s,o=n(t.geometry.coordinates);!(s=o()).done;)if(!d(s.value,e,r,i,a))return!1;return!0}function d(t,e,r,n,i){var a=t[0],s=t[1];return a>=e&&a<=n&&s>=r&&s<=i}var v=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],l=/*#__PURE__*/function(){function t(t,e,r,n){if(void 0===e&&(e=64),void 0===r&&(r=Float64Array),this.data=void 0,this.ids=void 0,this.coords=void 0,this._pos=void 0,this._finished=void 0,this.numItems=void 0,this.nodeSize=void 0,this.ArrayType=void 0,this.IndexArrayType=void 0,isNaN(t)||t<0)throw new Error("Unexpected numItems value: "+t+".");this.numItems=t,this.nodeSize=Math.min(Math.max(e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;var i=v.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-s%8)%8;if(i<0)throw new Error("Unexpected typed array class: "+r+".");n?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+a+s+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=this.nodeSize,new Uint32Array(this.data,4,1)[0]=this.numItems)}var e=t.prototype;return e.add=function(t,e){var r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r},e.finish=function(){var t=this._pos>>1;if(t!==this.numItems)throw new Error("Added "+t+" items when expected "+this.numItems+".");return g(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this},t}();function g(t,e,r,n,i,a){if(!(i-n<=r)){var s=n+i>>1;p(t,e,s,n,i,a),g(t,e,r,n,s-1,1-a),g(t,e,r,s+1,i,1-a)}}function p(t,e,r,n,i,a){for(;i>n;){if(i-n>600){var s=i-n+1,o=r-n+1,h=Math.log(s),u=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*u*(s-u)/s)*(o-s/2<0?-1:1);p(t,e,r,Math.max(n,Math.floor(r-o*u/s+f)),Math.min(i,Math.floor(r+(s-o)*u/s+f)),a)}var c=e[2*r+a],d=n,v=i;for(y(t,e,n,r),e[2*i+a]>c&&y(t,e,n,i);d<v;){for(y(t,e,d,v),d++,v--;e[2*d+a]<c;)d++;for(;e[2*v+a]>c;)v--}e[2*n+a]===c?y(t,e,n,v):y(t,e,++v,i),v<=r&&(n=v+1),r<=v&&(i=v-1)}}function y(t,e,r,n){m(t,r,n),m(e,2*r,2*n),m(e,2*r+1,2*n+1)}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}var w=/*#__PURE__*/function(){function t(t,e){if(void 0===t&&(t=[]),void 0===e&&(e=function(t,e){return t<e?-1:t>e?1:0}),this.data=void 0,this.length=void 0,this.compare=void 0,this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}var e=t.prototype;return e.push=function(t){this.data.push(t),this._up(this.length++)},e.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},e.peek=function(){return this.data[0]},e._up=function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i}e[t]=n},e._down=function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t<n;){var a=1+(t<<1),s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],i)>=0)break;e[t]=e[a],t=a}e[t]=i},t}(),M=Math.PI/180;function x(t,e,r,n){var i=n.minLng,a=n.maxLng,s=n.minLat,o=n.maxLat;if(t>=i&&t<=a)return e<s?A((e-s)*M):e>o?A((e-o)*M):0;var h=Math.min(A((t-i)*M),A((t-a)*M)),u=function(t,e){var r=1-2*e;return r<=0?t>0?90:-90:Math.atan(Math.tan(t*M)/r)/M}(e,h);return u>s&&u<o?I(h,r,e,u):Math.min(I(h,r,e,s),I(h,r,e,o))}function S(t,e){return t.dist-e.dist}function A(t){var e=Math.sin(t/2);return e*e}function I(t,e,r,n){return e*Math.cos(n*M)*t+A((r-n)*M)}function k(t,e,r,n,i){return I(A((t-r)*M),i,e,n)}var L=/*#__PURE__*/function(){function e(t){this.network=void 0,this.network=t}var r=e.prototype;return r.setNetwork=function(t){this.network=t},r.getNetwork=function(){return this.network},r.getNetworkInBoundingBox=function(t){return function(t,e){var r=e[0],i=e[1],a=e[2],s=e[3];if(r>=a||i>=s)throw new Error("Invalid bounding box: min values must be less than max values");for(var o,h=[],u=n(t.features);!(o=u()).done;){var f=o.value;c(f,r,i,a,s)&&h.push(f)}return{type:"FeatureCollection",features:h}}(this.network,t)},r.getNetworkWithoutDuplicatesOrSubsections=function(){return function(t){for(var e=t.features,r=new Set,n=0;n<e.length;n++)for(var i=e[n].geometry.coordinates,a=0;a<e.length;a++)if(n!==a){var s=e[a].geometry.coordinates;if(u(i,s)&&(i.length<s.length||i.length===s.length&&n>a)){r.add(n);break}}return{type:"FeatureCollection",features:e.filter(function(t,e){return!r.has(e)})}}(this.network)},r.getConnectedComponents=function(){return function(t){var e=t.features,r=new Map,i=new Map;function a(t){return t[0]+","+t[1]}for(var s=0;s<e.length;s++)for(var o,h=n(e[s].geometry.coordinates);!(o=h()).done;){var u=a(o.value);i.has(u)||i.set(u,new Set),i.get(u).add(s)}for(var f=0;f<e.length;f++){r.set(f,new Set);for(var c,d=n(e[f].geometry.coordinates);!(c=d()).done;){var v=a(c.value),l=i.get(v);if(l)for(var g,p=n(l);!(g=p()).done;){var y=g.value;y!==f&&r.get(f).add(y)}}}var m=new Set,w=[];function M(t,i){for(var a=[t];a.length>0;){var s=a.pop();if(!m.has(s)){m.add(s),i.push(e[s]);var o=r.get(s);if(o)for(var h,u=n(o);!(h=u()).done;){var f=h.value;m.has(f)||a.push(f)}}}}for(var x=0;x<e.length;x++)if(!m.has(x)){var S=[];M(x,S),w.push({type:"FeatureCollection",features:S})}return w.sort(function(t,e){return t.features.length-e.features.length}),w}(this.network)},r.getConnectedComponentCount=function(){return function(t){for(var e,r=t.features,i=r.length,s=new Map,o=0;o<i;o++)for(var h,u=n(r[o].geometry.coordinates);!(h=u()).done;){var f=(e=h.value)[0]+","+e[1];s.has(f)||s.set(f,[]),s.get(f).push(o)}for(var c,d=Array.from({length:i},function(){return[]}),v=n(s.values());!(c=v()).done;)for(var l=c.value,g=0;g<l.length;g++)for(var p=g+1;p<l.length;p++){var y=l[g],m=l[p];d[y].push(m),d[m].push(y)}for(var w=new Array(i).fill(!1),M=0,x=0;x<i;x++)w[x]||(a(x,d,w),M++);return M}(this.network)},r.getNodeAndEdgeCount=function(){return function(t){for(var e,r=new Set,i=new Set,a=n(t.features);!(e=a()).done;){for(var s,o=e.value.geometry.coordinates,h=n(o);!(s=h()).done;)r.add(JSON.stringify(s.value));for(var u=0;u<o.length-1;u++){var f=(c=o[u+1],(d=JSON.stringify(o[u]))<(v=JSON.stringify(c))?d+"|"+v:v+"|"+d);i.add(f)}}var c,d,v;return{nodeCount:r.size,edgeCount:i.size}}(this.network)},r.getNodes=function(){return{type:"FeatureCollection",features:function(t){for(var e,r=new Set,i=[],a=n(t.features);!(e=a()).done;)for(var s,o=n(e.value.geometry.coordinates);!(s=o()).done;){var h=s.value,u=h.join(",");r.has(u)||(r.add(u),i.push({type:"Feature",geometry:{type:"Point",coordinates:h},properties:{}}))}return i}(this.network)}},r.getNodeCount=function(){return this.getNodeAndEdgeCount().nodeCount},r.getEdges=function(){return o(this.network)},r.getLongestEdgeLength=function(){var t=this.getLongestEdge();return t?h(t):-1},r.getShortestEdgeLength=function(){var t=this.getShortestEdge();return t?h(t):-1},r.getLongestEdge=function(){var t=this.getEdges().features;if(0===t.length)return null;var e=t.sort(function(t,e){return h(t)-h(e)});return e[e.length-1]},r.getShortestEdge=function(){var t=this.getEdges().features;return 0===t.length?null:t.sort(function(t,e){return h(t)-h(e)})[0]},r.getEdgeCount=function(){return this.getNodeAndEdgeCount().edgeCount},r.getLeafEdges=function(){return f(this.network).leafEdges},r.getPrunedEdges=function(t){if(t&&t>0){for(var e=this.network,r=0;r<t;r++)e=f(e).nonLeafEdges;return e}return f(this.network).nonLeafEdges},r.getUnifiedNetwork=function(e){return function(e,r){if(e.features.length<2)return e;for(var a,s=new Set,o=new Map,h=[],u=new Map,f=n(e.features);!(a=f()).done;)for(var c,d=n(a.value.geometry.coordinates);!(c=d()).done;){var v=c.value,g=v[0]+","+v[1];u.has(g)||(u.set(g,h.length),h.push(v))}for(var p=new l(h.length),y=0,m=h;y<m.length;y++){var I=m[y];p.add(I[0],I[1])}function L(e,i,a){for(var o,u=null,f=Infinity,c=n(function(t,e,r,n,i){void 0===n&&(n=Infinity),void 0===i&&(i=Infinity);var a=1,s=[];void 0===n&&(n=Infinity),void 0!==i&&(a=A(i/6371));for(var o=new w([],S),h={left:0,right:t.ids.length-1,axis:0,dist:0,minLng:-180,minLat:-90,maxLng:180,maxLat:90},u=Math.cos(r*M);h;){var f=h.right,c=h.left;if(f-c<=t.nodeSize)for(var d=c;d<=f;d++){var v=t.ids[d],l=k(e,r,t.coords[2*d],t.coords[2*d+1],u);o.push({id:v,dist:l})}else{var g=c+f>>1,p=t.coords[2*g],y=t.coords[2*g+1],m=t.ids[g],I=k(e,r,p,y,u);o.push({id:m,dist:I});var L=(h.axis+1)%2,C={left:c,right:g-1,axis:L,minLng:h.minLng,minLat:h.minLat,maxLng:0===h.axis?p:h.maxLng,maxLat:1===h.axis?y:h.maxLat,dist:0},E={left:g+1,right:f,axis:L,minLng:0===h.axis?p:h.minLng,minLat:1===h.axis?y:h.minLat,maxLng:h.maxLng,maxLat:h.maxLat,dist:0};C.dist=x(e,r,u,C),E.dist=x(e,r,u,E),o.push(C),o.push(E)}for(;o.length&&null!=o.peek().id;){var b=o.pop();if(b.dist>a)return s;if(s.push(b.id),s.length===n)return s}h=o.pop()}return s}(p,e[0],e[1],Infinity,r/1e3));!(o=c()).done;){var d=h[o.value],v=d[0]+","+d[1];if(s.has(v)&&!i.includes(d)&&!a.has(v)){var l=1e3*t(d,e);l<=r&&l<f&&(u=d,f=l)}}return null!==u?u:(s.add(e[0]+","+e[1]),e)}p.finish();var C=e.features.map(function(t){for(var e,r=[],a=[],s=new Set,h=n(t.geometry.coordinates);!(e=h()).done;){var u=e.value,f=u[0]+","+u[1];if(!o.has(f)){var c=L(u,r,s);s.has(c[0]+","+c[1])?o.set(f,u):o.set(f,c)}var d=o.get(f),v=d[0]+","+d[1];s.has(v)||(a.push(d),s.add(v)),r.push(u)}return i({},t,{geometry:i({},t.geometry,{coordinates:a})})});return i({},e,{features:C})}(this.network,e)},e}(),C=/*#__PURE__*/function(){function t(){this.keys=[],this.values=[],this.idxs=[],this.length=0,this.insertCounter=0}var e=t.prototype;return e.insert=function(t,e){var r=this.length;this.length=r+1;for(var n=t,i=e,a=this.insertCounter++;r>0;){var s=r-1>>>2,o=this.keys[s],h=this.idxs[s];if(n>o||n===o&&a>h)break;this.keys[r]=o,this.values[r]=this.values[s],this.idxs[r]=h,r=s}this.keys[r]=n,this.values[r]=i,this.idxs[r]=a},e.extractMin=function(){var t=this.length;if(0===t)return null;var e=this.values[0],r=t-1;return this.length=r,r>0&&(this.keys[0]=this.keys[r],this.values[0]=this.values[r],this.idxs[0]=this.idxs[r],this.bubbleDown(0)),e},e.size=function(){return this.length},e.bubbleDown=function(t){for(var e=this.length,r=this.keys,n=this.values,i=this.idxs,a=r[t],s=n[t],o=i[t];;){var h=1+(t<<2);if(h>=e)break;var u=h,f=r[h],c=i[h],d=n[h],v=h+1;if(v<e){var l=r[v],g=i[v];(l<f||l===f&&g<c)&&(u=v,f=l,c=g,d=n[v])}var p=h+2;if(p<e){var y=r[p],m=i[p];(y<f||y===f&&m<c)&&(u=p,f=y,c=m,d=n[p])}var w=h+3;if(w<e){var M=r[w],x=i[w];(M<f||M===f&&x<c)&&(u=w,f=M,c=x,d=n[w])}if(!(f<a||f===a&&c<o))break;r[t]=f,n[t]=d,i[t]=c,t=u}r[t]=a,n[t]=s,i[t]=o},t}(),E=/*#__PURE__*/function(){function e(e){var r,n;this.network=null,this.distanceMeasurement=void 0,this.heapConstructor=void 0,this.coordinateIndexMap=new Map,this.coordinates=[],this.adjacencyList=[],this.csrOffsets=null,this.csrIndices=null,this.csrDistances=null,this.csrNodeCount=0,this.gScoreScratch=null,this.cameFromScratch=null,this.visitedScratch=null,this.hScratch=null,this.scratchCapacity=0,this.distanceMeasurement=null!=(r=null==e?void 0:e.distanceMeasurement)?r:t,this.heapConstructor=null!=(n=null==e?void 0:e.heap)?n:C}var r=e.prototype;return r.buildRouteGraph=function(t){this.network=t,this.coordinateIndexMap=new Map,this.coordinates=[],this.adjacencyList=[],this.csrOffsets=null,this.csrIndices=null,this.csrDistances=null,this.csrNodeCount=0;for(var e=this.coordinateIndexMap,r=this.coordinates,n=this.distanceMeasurement,i=t.features,a=[],s=0,o=i.length;s<o;s++)for(var h=i[s].geometry.coordinates,u=0,f=h.length-1;u<f;u++){var c,d,v=h[u],l=h[u+1],g=v[0],p=v[1],y=l[0],m=l[1],w=e.get(g);void 0===w&&(w=new Map,e.set(g,w));var M=w.get(p);void 0===M&&(M=r.length,r.push(v),w.set(p,M));var x=e.get(y);void 0===x&&(x=new Map,e.set(y,x));var S=x.get(m);void 0===S&&(S=r.length,r.push(l),x.set(m,S)),a[M]=(null!=(c=a[M])?c:0)+1,a[S]=(null!=(d=a[S])?d:0)+1}var A=this.coordinates.length;this.csrNodeCount=A;for(var I=new Int32Array(A+1),k=0;k<A;k++){var L,C=null!=(L=a[k])?L:0;I[k+1]=I[k]+C}for(var E=I[A],b=new Int32Array(E),N=new Float64Array(E),O=I.slice(),F=0,_=i.length;F<_;F++)for(var T=i[F].geometry.coordinates,U=0,j=T.length-1;U<j;U++){var P=T[U],z=T[U+1],D=P[1],q=z[0],B=z[1],R=this.coordinateIndexMap.get(P[0]).get(D),J=this.coordinateIndexMap.get(q).get(B),Y=n(P,z),G=O[R]++;b[G]=J,N[G]=Y,b[G=O[J]++]=R,N[G]=Y}this.csrOffsets=I,this.csrIndices=b,this.csrDistances=N,this.adjacencyList=new Array(A)},r.getRoute=function(t,e){if(null===this.network)throw new Error("Network not built. Please call buildRouteGraph(network) first.");var r=this.getOrCreateIndex(t.geometry.coordinates),n=this.getOrCreateIndex(e.geometry.coordinates);if(r===n)return null;var i=this.coordinates,a=this.adjacencyList,s=this.distanceMeasurement,o=i.length;this.ensureScratch(o);var h=this.gScoreScratch,u=this.cameFromScratch,f=this.visitedScratch,c=this.hScratch;h.fill(Number.POSITIVE_INFINITY,0,o),u.fill(-1,0,o),f.fill(0,0,o),c.fill(-1,0,o);var d=new this.heapConstructor,v=i[n],l=c[r];for(l<0&&(l=s(i[r],v),c[r]=l),d.insert(l,r),h[r]=0;d.size()>0;){var g=d.extractMin();if(0===f[g]){if(g===n)break;if(f[g]=1,this.csrOffsets&&g<this.csrNodeCount)for(var p=this.csrOffsets,y=this.csrIndices,m=this.csrDistances,w=p[g+1],M=p[g];M<w;M++){var x=y[M],S=h[g]+m[M];if(S<h[x]){h[x]=S,u[x]=g;var A=c[x];A<0&&(A=s(i[x],v),c[x]=A),d.insert(S+A,x)}}else{var I=a[g];if(!I||0===I.length)continue;for(var k=0,L=I.length;k<L;k++){var C=I[k],E=C.node,b=h[g]+C.distance;if(b<h[E]){h[E]=b,u[E]=g;var N=c[E];N<0&&(N=s(i[E],v),c[E]=N),d.insert(b+N,E)}}}}}if(u[n]<0)return null;for(var O=[],F=n;F!==r;)O.push(i[F]),F=u[F];return O.push(i[r]),O.reverse(),{type:"Feature",geometry:{type:"LineString",coordinates:O},properties:{}}},r.getOrCreateIndex=function(t){var e=t[0],r=t[1],n=this.coordinateIndexMap.get(e);void 0===n&&(n=new Map,this.coordinateIndexMap.set(e,n));var i=n.get(r);if(void 0===i&&(i=this.coordinates.length,this.coordinates.push(t),n.set(r,i),this.adjacencyList[i]=[],this.csrOffsets)){var a=this.csrNodeCount;if(i===a){var s=new Int32Array(a+2);s.set(this.csrOffsets,0),s[a+1]=s[a],this.csrOffsets=s,this.csrNodeCount=a+1}}return i},r.ensureScratch=function(t){if(!(this.scratchCapacity>=t&&this.gScoreScratch&&this.cameFromScratch&&this.visitedScratch&&this.hScratch)){var e=0|t;this.gScoreScratch=new Float64Array(e),this.cameFromScratch=new Int32Array(e),this.visitedScratch=new Uint8Array(e),this.hScratch=new Float64Array(e),this.scratchCapacity=e}},e}();export{L as LineStringGraph,E as TerraRoute,e as createCheapRuler,t as haversineDistance}; //# sourceMappingURL=terra-route.module.js.map