UNPKG

limitatio

Version:

calculates Roman centuriation given a central survey point

1 lines 45 kB
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.limitatio=r()}(this,function(){"use strict";var i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e,r){return e(r={exports:{}},r.exports),r.exports}var E=r(function(e,i){function u(e,r,t){void 0===t&&(t={});var n={type:"Feature"};return(0===t.id||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=r||{},n.geometry=e,n}function n(e,r,t){return void 0===t&&(t={}),u({type:"Point",coordinates:e},r,t)}function o(e,r,t){void 0===t&&(t={});for(var n=0,o=e;n<o.length;n++){var i=o[n];if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<i[i.length-1].length;a++)if(i[i.length-1][a]!==i[0][a])throw new Error("First and last Position are not equivalent.")}return u({type:"Polygon",coordinates:e},r,t)}function a(e,r,t){if(void 0===t&&(t={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return u({type:"LineString",coordinates:e},r,t)}function s(e,r){void 0===r&&(r={});var t={type:"FeatureCollection"};return r.id&&(t.id=r.id),r.bbox&&(t.bbox=r.bbox),t.features=e,t}function l(e,r,t){return void 0===t&&(t={}),u({type:"MultiLineString",coordinates:e},r,t)}function f(e,r,t){return void 0===t&&(t={}),u({type:"MultiPoint",coordinates:e},r,t)}function c(e,r,t){return void 0===t&&(t={}),u({type:"MultiPolygon",coordinates:e},r,t)}function h(e,r){void 0===r&&(r="kilometers");var t=i.factors[r];if(!t)throw new Error(r+" units is invalid");return e*t}function d(e,r){void 0===r&&(r="kilometers");var t=i.factors[r];if(!t)throw new Error(r+" units is invalid");return e/t}function t(e){return 180*(e%(2*Math.PI))/Math.PI}function r(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}Object.defineProperty(i,"__esModule",{value:!0}),i.earthRadius=6371008.8,i.factors={centimeters:100*i.earthRadius,centimetres:100*i.earthRadius,degrees:i.earthRadius/111325,feet:3.28084*i.earthRadius,inches:39.37*i.earthRadius,kilometers:i.earthRadius/1e3,kilometres:i.earthRadius/1e3,meters:i.earthRadius,metres:i.earthRadius,miles:i.earthRadius/1609.344,millimeters:1e3*i.earthRadius,millimetres:1e3*i.earthRadius,nauticalmiles:i.earthRadius/1852,radians:1,yards:i.earthRadius/1.0936},i.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/i.earthRadius,yards:1/1.0936},i.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:3.86e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046},i.feature=u,i.geometry=function(e,r,t){switch(void 0===t&&(t={}),e){case"Point":return n(r).geometry;case"LineString":return a(r).geometry;case"Polygon":return o(r).geometry;case"MultiPoint":return f(r).geometry;case"MultiLineString":return l(r).geometry;case"MultiPolygon":return c(r).geometry;default:throw new Error(e+" is invalid")}},i.point=n,i.points=function(e,r,t){return void 0===t&&(t={}),s(e.map(function(e){return n(e,r)}),t)},i.polygon=o,i.polygons=function(e,r,t){return void 0===t&&(t={}),s(e.map(function(e){return o(e,r)}),t)},i.lineString=a,i.lineStrings=function(e,r,t){return void 0===t&&(t={}),s(e.map(function(e){return a(e,r)}),t)},i.featureCollection=s,i.multiLineString=l,i.multiPoint=f,i.multiPolygon=c,i.geometryCollection=function(e,r,t){return void 0===t&&(t={}),u({type:"GeometryCollection",geometries:e},r,t)},i.round=function(e,r){if(void 0===r&&(r=0),r&&!(0<=r))throw new Error("precision must be a positive number");var t=Math.pow(10,r||0);return Math.round(e*t)/t},i.radiansToLength=h,i.lengthToRadians=d,i.lengthToDegrees=function(e,r){return t(d(e,r))},i.bearingToAzimuth=function(e){var r=e%360;return r<0&&(r+=360),r},i.radiansToDegrees=t,i.degreesToRadians=function(e){return e%360*Math.PI/180},i.convertLength=function(e,r,t){if(void 0===r&&(r="kilometers"),void 0===t&&(t="kilometers"),!(0<=e))throw new Error("length must be a positive number");return h(d(e,r),t)},i.convertArea=function(e,r,t){if(void 0===r&&(r="meters"),void 0===t&&(t="kilometers"),!(0<=e))throw new Error("area must be a positive number");var n=i.areaFactors[r];if(!n)throw new Error("invalid original units");var o=i.areaFactors[t];if(!o)throw new Error("invalid final units");return e/n*o},i.isNumber=r,i.isObject=function(e){return!!e&&e.constructor===Object},i.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!r(e))throw new Error("bbox must only contain numbers")})},i.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")},i.radians2degrees=function(){throw new Error("method has been renamed to `radiansToDegrees`")},i.degrees2radians=function(){throw new Error("method has been renamed to `degreesToRadians`")},i.distanceToDegrees=function(){throw new Error("method has been renamed to `lengthToDegrees`")},i.distanceToRadians=function(){throw new Error("method has been renamed to `lengthToRadians`")},i.radiansToDistance=function(){throw new Error("method has been renamed to `radiansToLength`")},i.bearingToAngle=function(){throw new Error("method has been renamed to `bearingToAzimuth`")},i.convertDistance=function(){throw new Error("method has been renamed to `convertLength`")}});e(E);E.earthRadius,E.factors,E.unitsFactors,E.areaFactors;var f=E.feature,A=(E.geometry,E.point),L=(E.points,E.polygon,E.polygons,E.lineString),O=(E.lineStrings,E.featureCollection),t=(E.multiLineString,E.multiPoint,E.multiPolygon,E.geometryCollection,E.round,E.radiansToLength,E.lengthToRadians,E.lengthToDegrees,E.bearingToAzimuth,E.radiansToDegrees,E.degreesToRadians,E.convertLength,E.convertArea,E.isNumber),l=E.isObject;E.validateBBox,E.validateId,E.radians2degrees,E.degrees2radians,E.distanceToDegrees,E.distanceToRadians,E.radiansToDistance,E.bearingToAngle,E.convertDistance;var n=Object.freeze({getCoord:function(e){if(!e)throw new Error("coord is required");if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates;if(Array.isArray(e)&&2<=e.length&&void 0===e[0].length&&void 0===e[1].length)return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")},getCoords:function(e){if(!e)throw new Error("coords is required");if("Feature"===e.type&&null!==e.geometry)return e.geometry.coordinates;if(e.coordinates)return e.coordinates;if(Array.isArray(e))return e;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")},containsNumber:function e(r){if(1<r.length&&t(r[0])&&t(r[1]))return!0;if(Array.isArray(r[0])&&r[0].length)return e(r[0]);throw new Error("coordinates must only contain numbers")},geojsonType:function(e,r,t){if(!r||!t)throw new Error("type and name required");if(!e||e.type!==r)throw new Error("Invalid input to "+t+": must be a "+r+", given "+e.type)},featureOf:function(e,r,t){if(!e)throw new Error("No feature passed");if(!t)throw new Error(".featureOf() requires a name");if(!e||"Feature"!==e.type||!e.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!e.geometry||e.geometry.type!==r)throw new Error("Invalid input to "+t+": must be a "+r+", given "+e.geometry.type)},collectionOf:function(e,r,t){if(!e)throw new Error("No featureCollection passed");if(!t)throw new Error(".collectionOf() requires a name");if(!e||"FeatureCollection"!==e.type)throw new Error("Invalid input to "+t+", FeatureCollection required");for(var n=0;n<e.features.length;n++){var o=e.features[n];if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!o.geometry||o.geometry.type!==r)throw new Error("Invalid input to "+t+": must be a "+r+", given "+o.geometry.type)}},getGeom:function(e){if(!e)throw new Error("geojson is required");if(void 0!==e.geometry)return e.geometry;if(e.coordinates||e.geometries)return e;throw new Error("geojson must be a valid Feature or Geometry Object")},getGeomType:function(){throw new Error("invariant.getGeomType has been deprecated in v5.0 in favor of invariant.getType")},getType:function(e,r){if(!e)throw new Error((r||"geojson")+" is required");if(e.geometry&&e.geometry.type)return e.geometry.type;if(e.type)return e.type;throw new Error((r||"geojson")+" is invalid")}}),w=n,o=r(function(e,r){function g(e,r,t){var n=!1;r[0][0]===r[r.length-1][0]&&r[0][1]===r[r.length-1][1]&&(r=r.slice(0,r.length-1));for(var o=0,i=r.length-1;o<r.length;i=o++){var a=r[o][0],u=r[o][1],s=r[i][0],l=r[i][1];if(e[1]*(a-s)+u*(s-e[0])+l*(e[0]-a)==0&&(a-e[0])*(s-e[0])<=0&&(u-e[1])*(l-e[1])<=0)return!t;u>e[1]!=l>e[1]&&e[0]<(s-a)*(e[1]-u)/(l-u)+a&&(n=!n)}return n}Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,r,t){if(void 0===t&&(t={}),!e)throw new Error("point is required");if(!r)throw new Error("polygon is required");var n,o,i=w.getCoord(e),a=w.getGeom(r),u=a.type,s=r.bbox,l=a.coordinates;if(s&&0==(n=i,(o=s)[0]<=n[0]&&o[1]<=n[1]&&o[2]>=n[0]&&o[3]>=n[1]))return!1;"Polygon"===u&&(l=[l]);for(var f=!1,c=0;c<l.length&&!f;c++)if(g(i,l[c][0],t.ignoreBoundary)){for(var h=!1,d=1;d<l[c].length&&!h;)g(i,l[c][d],!t.ignoreBoundary)&&(h=!0),d++;h||(f=!0)}return f}});function x(e,r,t){if(null!==e)for(var n,o,i,a,u,s,l,f,c=0,h=0,d=e.type,g="FeatureCollection"===d,m="Feature"===d,y=g?e.features.length:1,p=0;p<y;p++){u=(f=!!(l=g?e.features[p].geometry:m?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var v=0;v<u;v++){var w=0,b=0;if(null!==(a=f?l.geometries[v]:l)){s=a.coordinates;var M=a.type;switch(c=!t||"Polygon"!==M&&"MultiPolygon"!==M?0:1,M){case null:break;case"Point":if(!1===r(s,h,p,w,b))return!1;h++,w++;break;case"LineString":case"MultiPoint":for(n=0;n<s.length;n++){if(!1===r(s[n],h,p,w,b))return!1;h++,"MultiPoint"===M&&w++}"LineString"===M&&w++;break;case"Polygon":case"MultiLineString":for(n=0;n<s.length;n++){for(o=0;o<s[n].length-c;o++){if(!1===r(s[n][o],h,p,w,b))return!1;h++}"MultiLineString"===M&&w++,"Polygon"===M&&b++}"Polygon"===M&&w++;break;case"MultiPolygon":for(n=0;n<s.length;n++){for("MultiPolygon"===M&&(b=0),o=0;o<s[n].length;o++){for(i=0;i<s[n][o].length-c;i++){if(!1===r(s[n][o][i],h,p,w,b))return!1;h++}b++}w++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===x(a.geometries[n],r,t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function a(e,r){var t;switch(e.type){case"FeatureCollection":for(t=0;t<e.features.length&&!1!==r(e.features[t].properties,t);t++);break;case"Feature":r(e.properties,0)}}function u(e,r){if("Feature"===e.type)r(e,0);else if("FeatureCollection"===e.type)for(var t=0;t<e.features.length&&!1!==r(e.features[t],t);t++);}function s(e,r){var t,n,o,i,a,u,s,l,f,c,h=0,d="FeatureCollection"===e.type,g="Feature"===e.type,m=d?e.features.length:1;for(t=0;t<m;t++){for(u=d?e.features[t].geometry:g?e.geometry:e,l=d?e.features[t].properties:g?e.properties:{},f=d?e.features[t].bbox:g?e.bbox:void 0,c=d?e.features[t].id:g?e.id:void 0,a=(s=!!u&&"GeometryCollection"===u.type)?u.geometries.length:1,o=0;o<a;o++)if(null!==(i=s?u.geometries[o]:u))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===r(i,h,l,f,c))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===r(i.geometries[n],h,l,f,c))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===r(null,h,l,f,c))return!1;h++}}function h(e,l){s(e,function(e,r,t,n,o){var i,a=null===e?null:e.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==l(f(e,t,{bbox:n,id:o}),r,0)&&void 0}switch(a){case"MultiPoint":i="Point";break;case"MultiLineString":i="LineString";break;case"MultiPolygon":i="Polygon"}for(var u=0;u<e.coordinates.length;u++){var s=e.coordinates[u];if(!1===l(f({type:i,coordinates:s},t),r,u))return!1}})}function c(e,c){h(e,function(a,u,s){var l=0;if(a.geometry){var f,e=a.geometry.type;if("Point"!==e&&"MultiPoint"!==e)return!1!==x(a,function(e,r,t,n,o){if(void 0!==f){var i=L([f,e],a.properties);if(!1===c(i,u,s,o,l))return!1;l++,f=e}else f=e})&&void 0}})}function d(e,a){if(!e)throw new Error("geojson is required");h(e,function(e,r,t){if(null!==e.geometry){var n=e.geometry.type,o=e.geometry.coordinates;switch(n){case"LineString":if(!1===a(e,r,t,0,0))return!1;break;case"Polygon":for(var i=0;i<o.length;i++)if(!1===a(L(o[i],e.properties),r,t,i))return!1}}})}e(o);var g=Object.freeze({coordEach:x,coordReduce:function(e,i,a,r){var u=a;return x(e,function(e,r,t,n,o){u=0===r&&void 0===a?e:i(u,e,r,t,n,o)},r),u},propEach:a,propReduce:function(e,t,n){var o=n;return a(e,function(e,r){o=0===r&&void 0===n?e:t(o,e,r)}),o},featureEach:u,featureReduce:function(e,t,n){var o=n;return u(e,function(e,r){o=0===r&&void 0===n?e:t(o,e,r)}),o},coordAll:function(e){var r=[];return x(e,function(e){r.push(e)}),r},geomEach:s,geomReduce:function(e,i,a){var u=a;return s(e,function(e,r,t,n,o){u=0===r&&void 0===a?e:i(u,e,r,t,n,o)}),u},flattenEach:h,flattenReduce:function(e,n,o){var i=o;return h(e,function(e,r,t){i=0===r&&0===t&&void 0===o?e:n(i,e,r,t)}),i},segmentEach:c,segmentReduce:function(e,i,a){var u=a,s=!1;return c(e,function(e,r,t,n,o){u=!1===s&&void 0===a?e:i(u,e,r,t,n,o),s=!0}),u},lineEach:d,lineReduce:function(e,o,i){var a=i;return d(e,function(e,r,t,n){a=0===r&&void 0===i?e:o(a,e,r,t,n)}),a},findSegment:function(e,r){if(!l(r=r||{}))throw new Error("options is invalid");var t,n=r.featureIndex||0,o=r.multiFeatureIndex||0,i=r.geometryIndex||0,a=r.segmentIndex||0,u=r.properties;switch(e.type){case"FeatureCollection":n<0&&(n=e.features.length+n),u=u||e.features[n].properties,t=e.features[n].geometry;break;case"Feature":u=u||e.properties,t=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":t=e;break;default:throw new Error("geojson is invalid")}if(null===t)return null;var s=t.coordinates;switch(t.type){case"Point":case"MultiPoint":return null;case"LineString":return a<0&&(a=s.length+a-1),L([s[a],s[a+1]],u,r);case"Polygon":return i<0&&(i=s.length+i),a<0&&(a=s[i].length+a-1),L([s[i][a],s[i][a+1]],u,r);case"MultiLineString":return o<0&&(o=s.length+o),a<0&&(a=s[o].length+a-1),L([s[o][a],s[o][a+1]],u,r);case"MultiPolygon":return o<0&&(o=s.length+o),i<0&&(i=s[o].length+i),a<0&&(a=s[o][i].length-a-1),L([s[o][i][a],s[o][i][a+1]],u,r)}throw new Error("geojson is invalid")},findPoint:function(e,r){if(!l(r=r||{}))throw new Error("options is invalid");var t,n=r.featureIndex||0,o=r.multiFeatureIndex||0,i=r.geometryIndex||0,a=r.coordIndex||0,u=r.properties;switch(e.type){case"FeatureCollection":n<0&&(n=e.features.length+n),u=u||e.features[n].properties,t=e.features[n].geometry;break;case"Feature":u=u||e.properties,t=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":t=e;break;default:throw new Error("geojson is invalid")}if(null===t)return null;var s=t.coordinates;switch(t.type){case"Point":return A(s,u,r);case"MultiPoint":return o<0&&(o=s.length+o),A(s[o],u,r);case"LineString":return a<0&&(a=s.length+a),A(s[a],u,r);case"Polygon":return i<0&&(i=s.length+i),a<0&&(a=s[i].length+a),A(s[i][a],u,r);case"MultiLineString":return o<0&&(o=s.length+o),a<0&&(a=s[o].length+a),A(s[o][a],u,r);case"MultiPolygon":return o<0&&(o=s.length+o),i<0&&(i=s[o].length+i),a<0&&(a=s[o][i].length-a),A(s[o][i][a],u,r)}throw new Error("geojson is invalid")}}),m=g,y=r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){if(!e)throw new Error("geojson is required");var r=[];return m.flattenEach(e,function(e){!function(n,o){var e=[],r=n.geometry;if(null!==r){switch(r.type){case"Polygon":e=w.getCoords(r);break;case"LineString":e=[w.getCoords(r)]}e.forEach(function(e){var r,l,f,t=(r=e,l=n.properties,f=[],r.reduce(function(e,r){var t,n,o,i,a,u,s=E.lineString([e,r],l);return s.bbox=(n=r,o=(t=e)[0],i=t[1],a=n[0],u=n[1],[o<a?o:a,i<u?i:u,a<o?o:a,u<i?i:u]),f.push(s),r}),f);t.forEach(function(e){e.id=o.length,o.push(e)})})}}(e,r)}),E.featureCollection(r)}});e(y);var p=r(function(e,r){e.exports=function(){function y(e,r,t){var n=e[r];e[r]=e[t],e[t]=n}function i(e,r){return e<r?-1:r<e?1:0}return function(e,r,t,n,o){!function e(r,t,n,o,i){for(;n<o;){if(600<o-n){var a=o-n+1,u=t-n+1,s=Math.log(a),l=.5*Math.exp(2*s/3),f=.5*Math.sqrt(s*l*(a-l)/a)*(u-a/2<0?-1:1),c=Math.max(n,Math.floor(t-u*l/a+f)),h=Math.min(o,Math.floor(t+(a-u)*l/a+f));e(r,t,c,h,i)}var d=r[t],g=n,m=o;for(y(r,n,t),0<i(r[o],d)&&y(r,n,o);g<m;){for(y(r,g,m),g++,m--;i(r[g],d)<0;)g++;for(;0<i(r[m],d);)m--}0===i(r[n],d)?y(r,n,m):y(r,++m,o),m<=t&&(n=m+1),t<=m&&(o=m-1)}}(e,r,t||0,n||e.length-1,o||i)}}()}),v=M,b=M;function M(e,r){if(!(this instanceof M))return new M(e,r);this._maxEntries=Math.max(4,e||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),r&&this._initFormat(r),this.clear()}function P(e,r,t){if(!t)return r.indexOf(e);for(var n=0;n<r.length;n++)if(t(e,r[n]))return n;return-1}function k(e,r){_(e,0,e.children.length,r,e)}function _(e,r,t,n,o){o||(o=C(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(var i,a=r;a<t;a++)i=e.children[a],S(o,e.leaf?n(i):i);return o}function S(e,r){return e.minX=Math.min(e.minX,r.minX),e.minY=Math.min(e.minY,r.minY),e.maxX=Math.max(e.maxX,r.maxX),e.maxY=Math.max(e.maxY,r.maxY),e}function F(e,r){return e.minX-r.minX}function j(e,r){return e.minY-r.minY}function q(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function I(e){return e.maxX-e.minX+(e.maxY-e.minY)}function B(e,r){return e.minX<=r.minX&&e.minY<=r.minY&&r.maxX<=e.maxX&&r.maxY<=e.maxY}function T(e,r){return r.minX<=e.maxX&&r.minY<=e.maxY&&r.maxX>=e.minX&&r.maxY>=e.minY}function C(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function R(e,r,t,n,o){for(var i,a=[r,t];a.length;)(t=a.pop())-(r=a.pop())<=n||(i=r+Math.ceil((t-r)/n/2)*n,p(e,i,r,t,o),a.push(r,i,i,t))}M.prototype={all:function(){return this._all(this.data,[])},search:function(e){var r=this.data,t=[],n=this.toBBox;if(!T(e,r))return t;for(var o,i,a,u,s=[];r;){for(o=0,i=r.children.length;o<i;o++)a=r.children[o],T(e,u=r.leaf?n(a):a)&&(r.leaf?t.push(a):B(e,u)?this._all(a,t):s.push(a));r=s.pop()}return t},collides:function(e){var r=this.data,t=this.toBBox;if(!T(e,r))return!1;for(var n,o,i,a,u=[];r;){for(n=0,o=r.children.length;n<o;n++)if(i=r.children[n],T(e,a=r.leaf?t(i):i)){if(r.leaf||B(e,a))return!0;u.push(i)}r=u.pop()}return!1},load:function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var r=0,t=e.length;r<t;r++)this.insert(e[r]);return this}var n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var o=this.data;this.data=n,n=o}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},insert:function(e){return e&&this._insert(e,this.data.height-1),this},clear:function(){return this.data=C([]),this},remove:function(e,r){if(!e)return this;for(var t,n,o,i,a=this.data,u=this.toBBox(e),s=[],l=[];a||s.length;){if(a||(a=s.pop(),n=s[s.length-1],t=l.pop(),i=!0),a.leaf&&-1!==(o=P(e,a.children,r)))return a.children.splice(o,1),s.push(a),this._condense(s),this;i||a.leaf||!B(a,u)?n?(t++,a=n.children[t],i=!1):a=null:(s.push(a),l.push(t),t=0,a=(n=a).children[0])}return this},toBBox:function(e){return e},compareMinX:F,compareMinY:j,toJSON:function(){return this.data},fromJSON:function(e){return this.data=e,this},_all:function(e,r){for(var t=[];e;)e.leaf?r.push.apply(r,e.children):t.push.apply(t,e.children),e=t.pop();return r},_build:function(e,r,t,n){var o,i=t-r+1,a=this._maxEntries;if(i<=a)return k(o=C(e.slice(r,t+1)),this.toBBox),o;n||(n=Math.ceil(Math.log(i)/Math.log(a)),a=Math.ceil(i/Math.pow(a,n-1))),(o=C([])).leaf=!1,o.height=n;var u,s,l,f,c=Math.ceil(i/a),h=c*Math.ceil(Math.sqrt(a));for(R(e,r,t,h,this.compareMinX),u=r;u<=t;u+=h)for(R(e,u,l=Math.min(u+h-1,t),c,this.compareMinY),s=u;s<=l;s+=c)f=Math.min(s+c-1,l),o.children.push(this._build(e,s,f,n-1));return k(o,this.toBBox),o},_chooseSubtree:function(e,r,t,n){for(var o,i,a,u,s,l,f,c,h,d;n.push(r),!r.leaf&&n.length-1!==t;){for(f=c=1/0,o=0,i=r.children.length;o<i;o++)s=q(a=r.children[o]),h=e,d=a,(l=(Math.max(d.maxX,h.maxX)-Math.min(d.minX,h.minX))*(Math.max(d.maxY,h.maxY)-Math.min(d.minY,h.minY))-s)<c?(c=l,f=s<f?s:f,u=a):l===c&&s<f&&(f=s,u=a);r=u||r.children[0]}return r},_insert:function(e,r,t){var n=this.toBBox,o=t?e:n(e),i=[],a=this._chooseSubtree(o,this.data,r,i);for(a.children.push(e),S(a,o);0<=r&&i[r].children.length>this._maxEntries;)this._split(i,r),r--;this._adjustParentBBoxes(o,i,r)},_split:function(e,r){var t=e[r],n=t.children.length,o=this._minEntries;this._chooseSplitAxis(t,o,n);var i=this._chooseSplitIndex(t,o,n),a=C(t.children.splice(i,t.children.length-i));a.height=t.height,a.leaf=t.leaf,k(t,this.toBBox),k(a,this.toBBox),r?e[r-1].children.push(a):this._splitRoot(t,a)},_splitRoot:function(e,r){this.data=C([e,r]),this.data.height=e.height+1,this.data.leaf=!1,k(this.data,this.toBBox)},_chooseSplitIndex:function(e,r,t){var n,o,i,a,u,s,l,f,c,h,d,g,m,y;for(s=l=1/0,n=r;n<=t-r;n++)o=_(e,0,n,this.toBBox),i=_(e,n,t,this.toBBox),c=o,h=i,void 0,d=Math.max(c.minX,h.minX),g=Math.max(c.minY,h.minY),m=Math.min(c.maxX,h.maxX),y=Math.min(c.maxY,h.maxY),a=Math.max(0,m-d)*Math.max(0,y-g),u=q(o)+q(i),a<s?(s=a,f=n,l=u<l?u:l):a===s&&u<l&&(l=u,f=n);return f},_chooseSplitAxis:function(e,r,t){var n=e.leaf?this.compareMinX:F,o=e.leaf?this.compareMinY:j;this._allDistMargin(e,r,t,n)<this._allDistMargin(e,r,t,o)&&e.children.sort(n)},_allDistMargin:function(e,r,t,n){e.children.sort(n);var o,i,a=this.toBBox,u=_(e,0,r,a),s=_(e,t-r,t,a),l=I(u)+I(s);for(o=r;o<t-r;o++)i=e.children[o],S(u,e.leaf?a(i):i),l+=I(u);for(o=t-r-1;r<=o;o--)i=e.children[o],S(s,e.leaf?a(i):i),l+=I(s);return l},_adjustParentBBoxes:function(e,r,t){for(var n=t;0<=n;n--)S(r[n],e)},_condense:function(e){for(var r,t=e.length-1;0<=t;t--)0===e[t].children.length?0<t?(r=e[t-1].children).splice(r.indexOf(e[t]),1):this.clear():k(e[t],this.toBBox)},_initFormat:function(e){var r=["return a"," - b",";"];this.compareMinX=new Function("a","b",r.join(e[0])),this.compareMinY=new Function("a","b",r.join(e[1])),this.toBBox=new Function("a","return {minX: a"+e[0]+", minY: a"+e[1]+", maxX: a"+e[2]+", maxY: a"+e[3]+"};")}},v.default=b;var X=r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){var r=[1/0,1/0,-1/0,-1/0];return m.coordEach(e,function(e){r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r}});e(X);var Y=X.default,G=m.featureEach,N=(m.coordEach,E.polygon,E.featureCollection);function D(e){var r=v(e);return r.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:Y(e),v.prototype.insert.call(this,e)},r.load=function(e){var r=[];return Array.isArray(e)?e.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:Y(e),r.push(e)}):G(e,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:Y(e),r.push(e)}),v.prototype.load.call(this,r)},r.remove=function(e,r){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:Y(e),v.prototype.remove.call(this,e,r)},r.clear=function(){return v.prototype.clear.call(this)},r.search=function(e){var r=v.prototype.search.call(this,this.toBBox(e));return N(r)},r.collides=function(e){return v.prototype.collides.call(this,this.toBBox(e))},r.all=function(){var e=v.prototype.all.call(this);return N(e)},r.toJSON=function(){return v.prototype.toJSON.call(this)},r.fromJSON=function(e){return v.prototype.fromJSON.call(this,e)},r.toBBox=function(e){var r;if(e.bbox)r=e.bbox;else if(Array.isArray(e)&&4===e.length)r=e;else if(Array.isArray(e)&&6===e.length)r=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)r=Y(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");r=Y(e)}return{minX:r[0],minY:r[1],maxX:r[2],maxY:r[3]}},r}var J=D,U=D;J.default=U;var z=r(function(e,r){var t=i&&i.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var n=t(y),u=t(J);function s(e,r){var t=w.getCoords(e),n=w.getCoords(r);if(2!==t.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=t[0][0],i=t[0][1],a=t[1][0],u=t[1][1],s=n[0][0],l=n[0][1],f=n[1][0],c=n[1][1],h=(c-l)*(a-o)-(f-s)*(u-i),d=(f-s)*(i-l)-(c-l)*(o-s),g=(a-o)*(i-l)-(u-i)*(o-s);if(0===h)return null;var m=d/h,y=g/h;if(0<=m&&m<=1&&0<=y&&y<=1){var p=o+m*(a-o),v=i+m*(u-i);return E.point([p,v])}return null}r.default=function(e,r){var o={},i=[];if("LineString"===e.type&&(e=E.feature(e)),"LineString"===r.type&&(r=E.feature(r)),"Feature"===e.type&&"Feature"===r.type&&null!==e.geometry&&null!==r.geometry&&"LineString"===e.geometry.type&&"LineString"===r.geometry.type&&2===e.geometry.coordinates.length&&2===r.geometry.coordinates.length){var t=s(e,r);return t&&i.push(t),E.featureCollection(i)}var a=u.default();return a.load(n.default(r)),m.featureEach(n.default(e),function(n){m.featureEach(a.search(n),function(e){var r=s(n,e);if(r){var t=w.getCoords(r).join(",");o[t]||(o[t]=!0,i.push(r))}})}),E.featureCollection(i)}});e(z);var H=r(function(e,r){function n(e,r){void 0===r&&(r={});var t=w.getGeom(e);t.type;return a(t.coordinates,r.properties?r.properties:"Feature"===e.type?e.properties:{})}function o(e,r){void 0===r&&(r={});var t=w.getGeom(e),n=(t.type,t.coordinates),o=r.properties?r.properties:"Feature"===e.type?e.properties:{},i=[];return n.forEach(function(e){i.push(a(e,o))}),E.featureCollection(i)}function a(e,r){return 1<e.length?E.multiLineString(e,r):E.lineString(e[0],r)}Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,r){void 0===r&&(r={});var t=w.getGeom(e);switch(r.properties||"Feature"!==e.type||(r.properties=e.properties),t.type){case"Polygon":return n(t,r);case"MultiPolygon":return o(t,r);default:throw new Error("invalid poly")}},r.polygonToLine=n,r.multiPolygonToLine=o,r.coordsToLine=a});e(H);H.polygonToLine,H.multiPolygonToLine,H.coordsToLine;var K=r(function(e,r){var t=i&&i.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=t(o),l=t(z),f=t(H);function a(e,r){for(var t=0;t<e.coordinates.length-1;t++)if(n(e.coordinates[t],e.coordinates[t+1],r.coordinates))return!0;return!1}function u(e,r){for(var t=0,n=r.coordinates;t<n.length;t++){var o=n[t];if(s.default(o,e))return!0}return 0<l.default(r,f.default(e)).features.length}function n(e,r,t){var n=t[0]-e[0],o=t[1]-e[1],i=r[0]-e[0],a=r[1]-e[1];return 0==n*a-o*i&&(Math.abs(i)>=Math.abs(a)?0<i?e[0]<=t[0]&&t[0]<=r[0]:r[0]<=t[0]&&t[0]<=e[0]:0<a?e[1]<=t[1]&&t[1]<=r[1]:r[1]<=t[1]&&t[1]<=e[1])}r.default=function(e,t){var n=!0;return m.flattenEach(e,function(r){m.flattenEach(t,function(e){if(!1===n)return!1;n=function(e,r){switch(e.type){case"Point":switch(r.type){case"Point":return o=e.coordinates,i=r.coordinates,!(o[0]===i[0]&&o[1]===i[1]);case"LineString":return!a(r,e);case"Polygon":return!s.default(e,r)}break;case"LineString":switch(r.type){case"Point":return!a(e,r);case"LineString":return t=e,n=r,!(0<l.default(t,n).features.length);case"Polygon":return!u(r,e)}break;case"Polygon":switch(r.type){case"Point":return!s.default(r,e);case"LineString":return!u(e,r);case"Polygon":return!function(e,r){for(var t=0,n=e.coordinates[0];t<n.length;t++){var o=n[t];if(s.default(o,r))return!0}for(var i=0,a=r.coordinates[0];i<a.length;i++){var u=a[i];if(s.default(u,e))return!0}return 0<l.default(f.default(e),f.default(r)).features.length}(r,e)}}var t,n,o,i;return!1}(r.geometry,e.geometry)})}),n}});e(K);var Q=r(function(e,r){var t=i&&i.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var o=t(K);r.default=function(e,t){var n=!1;return m.flattenEach(e,function(r){m.flattenEach(t,function(e){if(!0===n)return!0;n=!o.default(r.geometry,e.geometry)})}),n}});e(Q);var V=r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,r,t){void 0===t&&(t={});var n=w.getCoord(e),o=w.getCoord(r),i=E.degreesToRadians(o[1]-n[1]),a=E.degreesToRadians(o[0]-n[0]),u=E.degreesToRadians(n[1]),s=E.degreesToRadians(o[1]),l=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(s);return E.radiansToLength(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),t.units)}}),W=e(V),Z=(V.distance,r(function(e,r){var t=i&&i.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var b=t(Q),M=t(V);r.default=function(e,r,t){void 0===t&&(t={});for(var n=[],o=e[0],i=e[1],a=e[2],u=e[3],s=r/M.default([o,i],[a,i],t)*(a-o),l=r/M.default([o,i],[o,u],t)*(u-i),f=a-o,c=u-i,h=Math.floor(f/s),d=Math.floor(c/l),g=(c-d*l)/2,m=o+(f-h*s)/2,y=0;y<h;y++){for(var p=i+g,v=0;v<d;v++){var w=E.polygon([[[m,p],[m,p+l],[m+s,p+l],[m+s,p],[m,p]]],t.properties);t.mask?b.default(t.mask,w)&&n.push(w):n.push(w),p+=l}m+=s}return E.featureCollection(n)}})),$=e(Z);Z.grid;function ee(e,r,t){if(!(n=t=t||{})||n.constructor!==Object)throw new Error("options is invalid");var n,o=t.bbox,i=t.id;if(void 0===e)throw new Error("geometry is required");if(r&&r.constructor!==Object)throw new Error("properties must be an Object");o&&function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!re(e))throw new Error("bbox must only contain numbers")})}(o),i&&function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}(i);var a={type:"Feature"};return i&&(a.id=i),o&&(a.bbox=o),a.properties=r||{},a.geometry=e,a}function re(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function te(e,r){var t=0,n=0,o=0;return function e(r,t,n){if(null!==r)for(var o,i,a,u,s,l,f,c,h=0,d=0,g=r.type,m="FeatureCollection"===g,y="Feature"===g,p=m?r.features.length:1,v=0;v<p;v++){s=(c=!!(f=m?r.features[v].geometry:y?r.geometry:r)&&"GeometryCollection"===f.type)?f.geometries.length:1;for(var w=0;w<s;w++){var b=0,M=0;if(null!==(u=c?f.geometries[w]:f)){l=u.coordinates;var E=u.type;switch(h=!n||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(l,d,v,b,M))return!1;d++,b++;break;case"LineString":case"MultiPoint":for(o=0;o<l.length;o++){if(!1===t(l[o],d,v,b,M))return!1;d++,"MultiPoint"===E&&b++}"LineString"===E&&b++;break;case"Polygon":case"MultiLineString":for(o=0;o<l.length;o++){for(i=0;i<l[o].length-h;i++){if(!1===t(l[o][i],d,v,b,M))return!1;d++}"MultiLineString"===E&&b++,"Polygon"===E&&M++}"Polygon"===E&&b++;break;case"MultiPolygon":for(o=0;o<l.length;o++){for("MultiPolygon"===E&&(M=0),i=0;i<l[o].length;i++){for(a=0;a<l[o][i].length-h;a++){if(!1===t(l[o][i][a],d,v,b,M))return!1;d++}M++}b++}break;case"GeometryCollection":for(o=0;o<u.geometries.length;o++)if(!1===e(u.geometries[o],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}(e,function(e){t+=e[0],n+=e[1],o++},!0),function(e,r,t){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!re(e[0])||!re(e[1]))throw new Error("coordinates must contain numbers");return ee({type:"Point",coordinates:e},r,t)}([t/o,n/o],r)}function ne(e){if(null==e)throw new Error("degrees is required");return e%360*Math.PI/180}function oe(e){if(!e)throw new Error("coord is required");if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates;if(Array.isArray(e)&&2<=e.length&&void 0===e[0].length&&void 0===e[1].length)return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ie(e,r,t){if(!(n=t=t||{})||n.constructor!==Object)throw new Error("options is invalid");var n,o,i=t.final;if(!e)throw new Error("start point is required");if(!r)throw new Error("end point is required");return 180<(o=i?ae(oe(r),oe(e)):ae(oe(e),oe(r)))?-(360-o):o}function ae(e,r){var t=ne(e[1]),n=ne(r[1]),o=ne(r[0]-e[0]);o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI);var i=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(t/2+Math.PI/4));return(function(e){if(null==e)throw new Error("radians is required");return e%(2*Math.PI)*180/Math.PI}(Math.atan2(o,i))+360)%360}var ue=6371008.8,se={meters:ue,metres:ue,millimeters:1e3*ue,millimetres:1e3*ue,centimeters:100*ue,centimetres:100*ue,kilometers:ue/1e3,kilometres:ue/1e3,miles:ue/1609.344,nauticalmiles:ue/1852,inches:39.37*ue,yards:ue/1.0936,feet:3.28084*ue,radians:1,degrees:ue/111325};function le(e,r,t){if(null==e)throw new Error("length is required");if(!(0<=e))throw new Error("length must be a positive number");return function(e,r){if(null==e)throw new Error("radians is required");if(r&&"string"!=typeof r)throw new Error("units must be a string");var t=se[r||"kilometers"];if(!t)throw new Error(r+" units is invalid");return e*t}(function(e,r){if(null==e)throw new Error("distance is required");if(r&&"string"!=typeof r)throw new Error("units must be a string");var t=se[r||"kilometers"];if(!t)throw new Error(r+" units is invalid");return e/t}(e,r),t||"kilometers")}function fe(e){if(!e)throw new Error("coord is required");if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates;if(Array.isArray(e)&&2<=e.length&&void 0===e[0].length&&void 0===e[1].length)return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ce(e,r,t){if(!(n=t=t||{})||n.constructor!==Object)throw new Error("options is invalid");var n,o=t.units;if(!e)throw new Error("from point is required");if(!r)throw new Error("to point is required");var i=fe(e),a=fe(r);return a[0]+=180<a[0]-i[0]?-360:180<i[0]-a[0]?360:0,le(function(e,r,t){var n=t=void 0===t?ue:Number(t),o=e[1]*Math.PI/180,i=r[1]*Math.PI/180,a=i-o,u=Math.abs(r[0]-e[0])*Math.PI/180;u>Math.PI&&(u-=2*Math.PI);var s=Math.log(Math.tan(i/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),l=1e-11<Math.abs(s)?a/s:Math.cos(o);return Math.sqrt(a*a+l*l*u*u)*n}(i,a),"meters",o)}var he=6371008.8,de={meters:he,metres:he,millimeters:1e3*he,millimetres:1e3*he,centimeters:100*he,centimetres:100*he,kilometers:he/1e3,kilometres:he/1e3,miles:he/1609.344,nauticalmiles:he/1852,inches:39.37*he,yards:he/1.0936,feet:3.28084*he,radians:1,degrees:he/111325};function ge(e,r,t){if(!ve(t=t||{}))throw new Error("options is invalid");var n=t.bbox,o=t.id;if(void 0===e)throw new Error("geometry is required");if(r&&r.constructor!==Object)throw new Error("properties must be an Object");n&&function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!pe(e))throw new Error("bbox must only contain numbers")})}(n),o&&function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}(o);var i={type:"Feature"};return o&&(i.id=o),n&&(i.bbox=n),i.properties=r||{},i.geometry=e,i}function me(e){if(null==e)throw new Error("degrees is required");return e%360*Math.PI/180}function ye(e,r,t){if(null==e)throw new Error("length is required");if(!(0<=e))throw new Error("length must be a positive number");return function(e,r){if(null==e)throw new Error("radians is required");if(r&&"string"!=typeof r)throw new Error("units must be a string");var t=de[r||"kilometers"];if(!t)throw new Error(r+" units is invalid");return e*t}(function(e,r){if(null==e)throw new Error("distance is required");if(r&&"string"!=typeof r)throw new Error("units must be a string");var t=de[r||"kilometers"];if(!t)throw new Error(r+" units is invalid");return e/t}(e,r),t||"kilometers")}function pe(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ve(e){return!!e&&e.constructor===Object}function we(e,r,t,n){if(!ve(n=n||{}))throw new Error("options is invalid");var o=n.units,i=n.properties;if(!e)throw new Error("origin is required");if(null==r)throw new Error("distance is required");if(null==t)throw new Error("bearing is required");if(!(0<=r))throw new Error("distance must be greater than 0");var a=ye(r,o,"meters"),u=function(e){if(!e)throw new Error("coord is required");if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates;if(Array.isArray(e)&&2<=e.length&&void 0===e[0].length&&void 0===e[1].length)return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}(e),s=function(e,r,t,n){n=void 0===n?he:Number(n);var o=r/n,i=e[0]*Math.PI/180,a=me(e[1]),u=me(t),s=o*Math.cos(u),l=a+s;Math.abs(l)>Math.PI/2&&(l=0<l?Math.PI-l:-Math.PI-l);var f=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),c=1e-11<Math.abs(f)?s/f:Math.cos(a),h=o*Math.sin(u)/c;return[(180*(i+h)/Math.PI+540)%360-180,180*l/Math.PI]}(u,a,t);return s[0]+=180<s[0]-u[0]?-360:180<u[0]-s[0]?360:0,function(e,r,t){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!pe(e[0])||!pe(e[1]))throw new Error("coordinates must contain numbers");return ge({type:"Point",coordinates:e},r,t)}(s,i)}function be(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Me(e);case"FeatureCollection":return r=e,t={type:"FeatureCollection"},Object.keys(r).forEach(function(e){switch(e){case"type":case"features":return;default:t[e]=r[e]}}),t.features=r.features.map(function(e){return Me(e)}),t;case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ee(e);default:throw new Error("unknown GeoJSON type")}var r,t}function Me(r){var t={type:"Feature"};return Object.keys(r).forEach(function(e){switch(e){case"type":case"properties":case"geometry":return;default:t[e]=r[e]}}),t.properties=function t(n){var o={};if(!n)return o;Object.keys(n).forEach(function(e){var r=n[e];"object"==typeof r?null===r?o[e]=null:r.length?o[e]=r.map(function(e){return e}):o[e]=t(r):o[e]=r});return o}(r.properties),t.geometry=Ee(r.geometry),t}function Ee(e){var r={type:e.type};return e.bbox&&(r.bbox=e.bbox),"GeometryCollection"===e.type?r.geometries=e.geometries.map(function(e){return Ee(e)}):r.coordinates=function r(e){if("object"!=typeof e[0])return e.slice();return e.map(function(e){return r(e)})}(e.coordinates),r}function xe(e,o,r){if(!(t=r=r||{})||t.constructor!==Object)throw new Error("options is invalid");var t,i=r.pivot,n=r.mutate;if(!e)throw new Error("geojson is required");if(null==o||isNaN(o))throw new Error("angle is required");return 0===o||(i||(i=te(e)),!1!==n&&void 0!==n||(e=be(e)),function e(r,t,n){if(null!==r)for(var o,i,a,u,s,l,f,c,h=0,d=0,g=r.type,m="FeatureCollection"===g,y="Feature"===g,p=m?r.features.length:1,v=0;v<p;v++){s=(c=!!(f=m?r.features[v].geometry:y?r.geometry:r)&&"GeometryCollection"===f.type)?f.geometries.length:1;for(var w=0;w<s;w++){var b=0,M=0;if(null!==(u=c?f.geometries[w]:f)){l=u.coordinates;var E=u.type;switch(h=!n||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(l,d,v,b,M))return!1;d++,b++;break;case"LineString":case"MultiPoint":for(o=0;o<l.length;o++){if(!1===t(l[o],d,v,b,M))return!1;d++,"MultiPoint"===E&&b++}"LineString"===E&&b++;break;case"Polygon":case"MultiLineString":for(o=0;o<l.length;o++){for(i=0;i<l[o].length-h;i++){if(!1===t(l[o][i],d,v,b,M))return!1;d++}"MultiLineString"===E&&b++,"Polygon"===E&&M++}"Polygon"===E&&b++;break;case"MultiPolygon":for(o=0;o<l.length;o++){for("MultiPolygon"===E&&(M=0),i=0;i<l[o].length;i++){for(a=0;a<l[o][i].length-h;a++){if(!1===t(l[o][i][a],d,v,b,M))return!1;d++}M++}b++}break;case"GeometryCollection":for(o=0;o<u.geometries.length;o++)if(!1===e(u.geometries[o],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}(e,function(e){var r=ie(i,e)+o,t=ce(i,e),n=function(e){if(!e)throw new Error("coords is required");if("Feature"===e.type&&null!==e.geometry)return e.geometry.coordinates;if(e.coordinates)return e.coordinates;if(Array.isArray(e))return e;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(we(i,t,r));e[0]=n[0],e[1]=n[1]})),e}var Pe=_e,ke=_e;function _e(e,r){return new Fe(e,r)}var Se=_e.units={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254};function Fe(e,r){if(void 0===e)throw new Error("No latitude given.");if(r&&!Se[r])throw new Error("Unknown unit "+r+". Use one of: "+Object.keys(Se).join(", "));var t=r?Se[r]:1,n=Math.cos(e*Math.PI/180),o=2*n*n-1,i=2*n*o-n,a=2*n*i-o,u=2*n*a-i;this.kx=t*(111.41513*n-.09455*i+12e-5*u),this.ky=t*(111.13209-.56605*o+.0012*a)}function Ae(e,r){return e[0]===r[0]&&e[1]===r[1]}function Le(e,r,t){var n=r[0]-e[0],o=r[1]-e[1];return[e[0]+n*t,e[1]+o*t]}_e.fromTile=function(e,r,t){var n=Math.PI*(1-2*(e+.5)/Math.pow(2,r));return new Fe(180*Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Math.PI,t)},Fe.prototype={distance:function(e,r){var t=(e[0]-r[0])*this.kx,n=(e[1]-r[1])*this.ky;return Math.sqrt(t*t+n*n)},bearing:function(e,r){var t=(r[0]-e[0])*this.kx,n=(r[1]-e[1])*this.ky;if(!t&&!n)return 0;var o=180*Math.atan2(t,n)/Math.PI;return 180<o&&(o-=360),o},destination:function(e,r,t){var n=(90-t)*Math.PI/180;return this.offset(e,Math.cos(n)*r,Math.sin(n)*r)},offset:function(e,r,t){return[e[0]+r/this.kx,e[1]+t/this.ky]},lineDistance:function(e){for(var r=0,t=0;t<e.length-1;t++)r+=this.distance(e[t],e[t+1]);return r},area:function(e){for(var r=0,t=0;t<e.length;t++)for(var n=e[t],o=0,i=n.length,a=i-1;o<i;a=o++)r+=(n[o][0]-n[a][0])*(n[o][1]+n[a][1])*(t?-1:1);return Math.abs(r)/2*this.kx*this.ky},along:function(e,r){var t=0;if(r<=0)return e[0];for(var n=0;n<e.length-1;n++){var o=e[n],i=e[n+1],a=this.distance(o,i);if(r<(t+=a))return Le(o,i,(r-(t-a))/a)}return e[e.length-1]},pointOnLine:function(e,r){for(var t,n,o,i,a=1/0,u=0;u<e.length-1;u++){var s=e[u][0],l=e[u][1],f=(e[u+1][0]-s)*this.kx,c=(e[u+1][1]-l)*this.ky;if(0!==f||0!==c){var h=((r[0]-s)*this.kx*f+(r[1]-l)*this.ky*c)/(f*f+c*c);1<h?(s=e[u+1][0],l=e[u+1][1]):0<h&&(s+=f/this.kx*h,l+=c/this.ky*h)}var d=(f=(r[0]-s)*this.kx)*f+(c=(r[1]-l)*this.ky)*c;d<a&&(a=d,t=s,n=l,o=u,i=h)}return{point:[t,n],index:o,t:Math.max(0,Math.min(1,i))}},lineSlice:function(e,r,t){var n=this.pointOnLine(t,e),o=this.pointOnLine(t,r);if(n.index>o.index||n.index===o.index&&n.t>o.t){var i=n;n=o,o=i}var a=[n.point],u=n.index+1,s=o.index;!Ae(t[u],a[0])&&u<=s&&a.push(t[u]);for(var l=u+1;l<=s;l++)a.push(t[l]);return Ae(t[s],o.point)||a.push(o.point),a},lineSliceAlong:function(e,r,t){for(var n=0,o=[],i=0;i<t.length-1;i++){var a=t[i],u=t[i+1],s=this.distance(a,u);if(e<(n+=s)&&0===o.length&&o.push(Le(a,u,(e-(n-s))/s)),r<=n)return o.push(Le(a,u,(r-(n-s))/s)),o;e<n&&o.push(u)}return o},bufferPoint:function(e,r){var t=r/this.ky,n=r/this.kx;return[e[0]-n,e[1]-t,e[0]+n,e[1]+t]},bufferBBox:function(e,r){var t=r/this.ky,n=r/this.kx;return[e[0]-n,e[1]-t,e[2]+n,e[3]+t]},insideBBox:function(e,r){return e[0]>=r[0]&&e[0]<=r[2]&&e[1]>=r[1]&&e[1]<=r[3]}},Pe.default=ke;var Oe=35.5,je=.296;return function(e,r){var t,n,o,i,a,u,s,l,f,c,h,d,g,m,y,p,v,w,b,M=e.geometry.coordinates,E=Pe(M[1],"meters"),x=E.destination(M,10*Oe,-90),P=E.destination(M,10*Oe,90),k=E.destination(M,10*Oe,0),_=E.destination(M,10*Oe,180),S=[x[0],_[1],P[0],k[1]],F=[];return F=(F=F.concat((t=A([S[0],S[1]]),n=A([S[0],S[3]]),a=W(t,n,{units:"meters"}),o=A([S[0],S[1]]),i=A([S[2],S[1]]),u=W(o,i,{units:"meters"}),s=u<a?u:a,l=Math.floor(s/20*1e3)/1e3,xe($(S,2*l.toFixed(3),{units:"meters"}),r)).features)).concat((f=L([k,_],{name:"cardo maximus",width:20*je}),c=L([x,P],{name:"decumanus maximus",width:40*je}),h=[x[0],_[1]],d=[x[0],k[1]],g=[P[0],k[1]],m=[P[0],_[1]],y={name:"limite quintarius",width:8*je},p=L([h,d],y),v=L([m,g],y),w=L([d,g],y),b=L([h,m],y),xe(O([f,c,p,v,w,b]),r)).features),O(F)}});