qd-changjing/public/leaflet/libs/turf/5.1.6/turf.min.js

8 lines
557 KiB
JavaScript
Raw Permalink Normal View History

2022-07-05 16:56:29 +08:00
/*!
* Copyright (c) 2018 TurfJS
* turf.(https://github.com/Turfjs/turf/blob/master/)
* license: MIT
* version: v5.1.6
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.turf={})}(this,function(t){"use strict";function e(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.bbox,i=n.id;if(void 0===t)throw new Error("geometry is required");if(e&&e.constructor!==Object)throw new Error("properties must be an Object");r&&N(r),i&&C(i);var o={type:"Feature"};return i&&(o.id=i),r&&(o.bbox=r),o.properties=e||{},o.geometry=t,o}function n(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var i=n.bbox;if(!t)throw new Error("type is required");if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");i&&N(i);var s;switch(t){case"Point":s=r(e).geometry;break;case"LineString":s=a(e).geometry;break;case"Polygon":s=o(e).geometry;break;case"MultiPoint":s=l(e).geometry;break;case"MultiLineString":s=h(e).geometry;break;case"MultiPolygon":s=p(e).geometry;break;default:throw new Error(t+" is invalid")}return i&&(s.bbox=i),s}function r(t,n,r){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!b(t[0])||!b(t[1]))throw new Error("coordinates must contain numbers");return e({type:"Point",coordinates:t},n,r)}function i(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return c(t.map(function(t){return r(t,e)}),n)}function o(t,n,r){if(!t)throw new Error("coordinates is required");for(var i=0;i<t.length;i++){var o=t[i];if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<o[o.length-1].length;s++){if(0===i&&0===s&&!b(o[0][0])||!b(o[0][1]))throw new Error("coordinates must contain numbers");if(o[o.length-1][s]!==o[0][s])throw new Error("First and last Position are not equivalent.")}}return e({type:"Polygon",coordinates:t},n,r)}function s(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return c(t.map(function(t){return o(t,e)}),n)}function a(t,n,r){if(!t)throw new Error("coordinates is required");if(t.length<2)throw new Error("coordinates must be an array of two or more positions");if(!b(t[0][1])||!b(t[0][1]))throw new Error("coordinates must contain numbers");return e({type:"LineString",coordinates:t},n,r)}function u(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return c(t.map(function(t){return a(t,e)}),n)}function c(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.bbox,r=e.id;if(!t)throw new Error("No features passed");if(!Array.isArray(t))throw new Error("features must be an Array");n&&N(n),r&&C(r);var i={type:"FeatureCollection"};return r&&(i.id=r),n&&(i.bbox=n),i.features=t,i}function h(t,n,r){if(!t)throw new Error("coordinates is required");return e({type:"MultiLineString",coordinates:t},n,r)}function l(t,n,r){if(!t)throw new Error("coordinates is required");return e({type:"MultiPoint",coordinates:t},n,r)}function p(t,n,r){if(!t)throw new Error("coordinates is required");return e({type:"MultiPolygon",coordinates:t},n,r)}function f(t,n,r){if(!t)throw new Error("geometries is required");if(!Array.isArray(t))throw new Error("geometries must be an Array");return e({type:"GeometryCollection",geometries:t},n,r)}function g(t,e){if(void 0===t||null===t||isNaN(t))throw new Error("num is required");if(e&&!(e>=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function d(t,e){if(void 0===t||null===t)throw new Error("radians is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");var n=qo[e||"kilometers"];if(!n)throw new Error(e+" units is invalid");return t*n}function y(t,e){if(void 0===t||null===t)throw new Error("distance is required");if(e&&"string"!=typeof e)throw new