node-red-contrib-web-worldmap 4.8.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +6 -2
- package/examples/{feedback.json → Feedback.json} +1 -9
- package/examples/MouseCoordinates.json +159 -0
- package/examples/sidcEdgeIcon.json +158 -0
- package/node_modules/@turf/bezier-spline/README.md +15 -21
- package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs +165 -0
- package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs.map +1 -0
- package/node_modules/@turf/bezier-spline/dist/{es/index.js → cjs/index.d.cts} +9 -30
- package/node_modules/@turf/bezier-spline/dist/{js → esm}/index.d.ts +5 -3
- package/node_modules/@turf/bezier-spline/dist/esm/index.js +165 -0
- package/node_modules/@turf/bezier-spline/dist/esm/index.js.map +1 -0
- package/node_modules/@turf/bezier-spline/package.json +33 -25
- package/node_modules/@turf/helpers/README.md +231 -219
- package/node_modules/@turf/helpers/dist/cjs/index.cjs +308 -0
- package/node_modules/@turf/helpers/dist/cjs/index.cjs.map +1 -0
- package/node_modules/@turf/helpers/dist/{es/index.js → cjs/index.d.cts} +103 -303
- package/node_modules/@turf/helpers/dist/{js → esm}/index.d.ts +67 -53
- package/node_modules/@turf/helpers/dist/esm/index.js +308 -0
- package/node_modules/@turf/helpers/dist/esm/index.js.map +1 -0
- package/node_modules/@turf/helpers/package.json +32 -22
- package/node_modules/@turf/invariant/README.md +47 -58
- package/node_modules/@turf/invariant/dist/cjs/index.cjs +127 -0
- package/node_modules/@turf/invariant/dist/cjs/index.cjs.map +1 -0
- package/node_modules/@turf/invariant/dist/cjs/index.d.cts +108 -0
- package/node_modules/@turf/invariant/dist/{js → esm}/index.d.ts +12 -9
- package/node_modules/@turf/invariant/dist/esm/index.js +127 -0
- package/node_modules/@turf/invariant/dist/esm/index.js.map +1 -0
- package/node_modules/@turf/invariant/package.json +31 -22
- package/node_modules/@types/geojson/LICENSE +21 -0
- package/node_modules/@types/geojson/README.md +15 -0
- package/node_modules/@types/geojson/index.d.ts +165 -0
- package/node_modules/@types/geojson/package.json +45 -0
- package/node_modules/body-parser/HISTORY.md +7 -0
- package/node_modules/body-parser/README.md +11 -0
- package/node_modules/body-parser/lib/types/urlencoded.js +30 -7
- package/node_modules/body-parser/package.json +2 -2
- package/node_modules/encodeurl/README.md +19 -38
- package/node_modules/encodeurl/index.js +1 -1
- package/node_modules/encodeurl/package.json +7 -7
- package/node_modules/express/History.md +27 -0
- package/node_modules/express/Readme.md +100 -6
- package/node_modules/express/lib/response.js +11 -10
- package/node_modules/express/package.json +11 -11
- package/node_modules/finalhandler/HISTORY.md +15 -0
- package/node_modules/finalhandler/README.md +2 -2
- package/node_modules/finalhandler/index.js +7 -2
- package/node_modules/finalhandler/package.json +8 -7
- package/node_modules/merge-descriptors/README.md +4 -3
- package/node_modules/merge-descriptors/index.js +3 -3
- package/node_modules/merge-descriptors/package.json +14 -7
- package/node_modules/mime-db/HISTORY.md +14 -0
- package/node_modules/mime-db/README.md +27 -24
- package/node_modules/mime-db/db.json +646 -62
- package/node_modules/mime-db/package.json +9 -13
- package/node_modules/mime-types/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/mime-types/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-types/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-types/node_modules/mime-db/db.json +8519 -0
- package/node_modules/mime-types/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-types/node_modules/mime-db/package.json +60 -0
- package/node_modules/object-inspect/CHANGELOG.md +15 -0
- package/node_modules/object-inspect/index.js +4 -1
- package/node_modules/object-inspect/package.json +14 -9
- package/node_modules/object-inspect/readme.markdown +9 -11
- package/node_modules/path-to-regexp/index.js +57 -40
- package/node_modules/path-to-regexp/package.json +2 -2
- package/node_modules/qs/.editorconfig +3 -0
- package/node_modules/qs/.eslintrc +2 -2
- package/node_modules/qs/CHANGELOG.md +59 -5
- package/node_modules/qs/README.md +133 -49
- package/node_modules/qs/dist/qs.js +56 -2020
- package/node_modules/qs/lib/parse.js +46 -13
- package/node_modules/qs/lib/stringify.js +53 -28
- package/node_modules/qs/lib/utils.js +47 -34
- package/node_modules/qs/package.json +26 -12
- package/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/node_modules/qs/test/parse.js +347 -32
- package/node_modules/qs/test/stringify.js +436 -47
- package/node_modules/send/HISTORY.md +5 -0
- package/node_modules/send/index.js +1 -2
- package/node_modules/send/node_modules/encodeurl/LICENSE +22 -0
- package/node_modules/send/node_modules/encodeurl/README.md +128 -0
- package/node_modules/send/node_modules/encodeurl/index.js +60 -0
- package/node_modules/send/node_modules/encodeurl/package.json +40 -0
- package/node_modules/send/package.json +1 -1
- package/node_modules/serve-static/HISTORY.md +16 -0
- package/node_modules/serve-static/index.js +1 -2
- package/node_modules/serve-static/package.json +3 -3
- package/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/tslib/README.md +164 -0
- package/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/tslib/modules/index.d.ts +37 -0
- package/node_modules/tslib/modules/index.js +68 -0
- package/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/tslib/package.json +47 -0
- package/node_modules/tslib/tslib.d.ts +453 -0
- package/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/tslib/tslib.es6.js +379 -0
- package/node_modules/tslib/tslib.es6.mjs +378 -0
- package/node_modules/tslib/tslib.html +1 -0
- package/node_modules/tslib/tslib.js +429 -0
- package/package.json +5 -5
- package/worldmap/index.html +1 -1
- package/worldmap/leaflet/leaflet.mousecoordinate.js +3 -3
- package/worldmap/worldmap.js +148 -44
- package/worldmap.html +1 -1
- package/worldmap.js +23 -4
- package/node_modules/@turf/bezier-spline/dist/es/lib/spline.js +0 -158
- package/node_modules/@turf/bezier-spline/dist/es/package.json +0 -1
- package/node_modules/@turf/bezier-spline/dist/js/index.js +0 -65
- package/node_modules/@turf/bezier-spline/dist/js/lib/spline.d.ts +0 -62
- package/node_modules/@turf/bezier-spline/dist/js/lib/spline.js +0 -160
- package/node_modules/@turf/helpers/dist/es/lib/geojson.js +0 -7
- package/node_modules/@turf/helpers/dist/es/package.json +0 -1
- package/node_modules/@turf/helpers/dist/js/index.js +0 -724
- package/node_modules/@turf/helpers/dist/js/lib/geojson.d.ts +0 -193
- package/node_modules/@turf/helpers/dist/js/lib/geojson.js +0 -9
- package/node_modules/@turf/invariant/dist/es/index.js +0 -223
- package/node_modules/@turf/invariant/dist/es/package.json +0 -1
- package/node_modules/@turf/invariant/dist/js/index.js +0 -233
- package/node_modules/path-to-regexp/History.md +0 -36
- /package/node_modules/{encodeurl → send/node_modules/encodeurl}/HISTORY.md +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n BBox,\n Feature,\n FeatureCollection,\n Geometry,\n GeometryCollection,\n GeometryObject,\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n Position,\n GeoJsonProperties,\n} from \"geojson\";\n\nimport { Id } from \"./lib/geojson.js\";\nexport * from \"./lib/geojson.js\";\n\n// TurfJS Combined Types\nexport type Coord = Feature<Point> | Point | Position;\n\n// TurfJS String Types\nexport type Units =\n | \"meters\"\n | \"metres\"\n | \"millimeters\"\n | \"millimetres\"\n | \"centimeters\"\n | \"centimetres\"\n | \"kilometers\"\n | \"kilometres\"\n | \"miles\"\n | \"nauticalmiles\"\n | \"inches\"\n | \"yards\"\n | \"feet\"\n | \"radians\"\n | \"degrees\";\nexport type AreaUnits =\n | Exclude<Units, \"radians\" | \"degrees\">\n | \"acres\"\n | \"hectares\";\nexport type Grid = \"point\" | \"square\" | \"hex\" | \"triangle\";\nexport type Corners = \"sw\" | \"se\" | \"nw\" | \"ne\" | \"center\" | \"centroid\";\n\nexport type Lines = LineString | MultiLineString | Polygon | MultiPolygon;\nexport type AllGeoJSON =\n | Feature\n | FeatureCollection\n | Geometry\n | GeometryCollection;\n\n/**\n * @module helpers\n */\n\n/**\n * The Earth radius in kilometers. Used by Turf modules that model the Earth as a sphere. The {@link https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius mean radius} was selected because it is {@link https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended recommended } by the Haversine formula (used by turf/distance) to reduce error.\n * @memberof helpers\n * @type {number}\n */\nexport const earthRadius = 6371008.8;\n\n/**\n * Unit of measurement factors based on earthRadius.\n *\n * Keys are the name of the unit, values are the number of that unit in a single radian\n *\n * @memberof helpers\n * @type {Object}\n */\nexport const factors: Record<Units, number> = {\n centimeters: earthRadius * 100,\n centimetres: earthRadius * 100,\n degrees: 360 / (2 * Math.PI),\n feet: earthRadius * 3.28084,\n inches: earthRadius * 39.37,\n kilometers: earthRadius / 1000,\n kilometres: earthRadius / 1000,\n meters: earthRadius,\n metres: earthRadius,\n miles: earthRadius / 1609.344,\n millimeters: earthRadius * 1000,\n millimetres: earthRadius * 1000,\n nauticalmiles: earthRadius / 1852,\n radians: 1,\n yards: earthRadius * 1.0936,\n};\n\n/**\n\n * Area of measurement factors based on 1 square meter.\n *\n * @memberof helpers\n * @type {Object}\n */\nexport const areaFactors: Record<AreaUnits, number> = {\n acres: 0.000247105,\n centimeters: 10000,\n centimetres: 10000,\n feet: 10.763910417,\n hectares: 0.0001,\n inches: 1550.003100006,\n kilometers: 0.000001,\n kilometres: 0.000001,\n meters: 1,\n metres: 1,\n miles: 3.86e-7,\n nauticalmiles: 2.9155334959812285e-7,\n millimeters: 1000000,\n millimetres: 1000000,\n yards: 1.195990046,\n};\n\n/**\n * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.\n *\n * @name feature\n * @param {Geometry} geometry input geometry\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature} a GeoJSON Feature\n * @example\n * var geometry = {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * };\n *\n * var feature = turf.feature(geometry);\n *\n * //=feature\n */\nexport function feature<\n G extends GeometryObject = Geometry,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n geom: G | null,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<G, P> {\n const feat: any = { type: \"Feature\" };\n if (options.id === 0 || options.id) {\n feat.id = options.id;\n }\n if (options.bbox) {\n feat.bbox = options.bbox;\n }\n feat.properties = properties || {};\n feat.geometry = geom;\n return feat;\n}\n\n/**\n * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.\n * For GeometryCollection type use `helpers.geometryCollection`\n *\n * @name geometry\n * @param {string} type Geometry Type\n * @param {Array<any>} coordinates Coordinates\n * @param {Object} [options={}] Optional Parameters\n * @returns {Geometry} a GeoJSON Geometry\n * @example\n * var type = \"Point\";\n * var coordinates = [110, 50];\n * var geometry = turf.geometry(type, coordinates);\n * // => geometry\n */\nexport function geometry(\n type:\n | \"Point\"\n | \"LineString\"\n | \"Polygon\"\n | \"MultiPoint\"\n | \"MultiLineString\"\n | \"MultiPolygon\",\n coordinates: any[],\n _options: Record<string, never> = {}\n) {\n switch (type) {\n case \"Point\":\n return point(coordinates).geometry;\n case \"LineString\":\n return lineString(coordinates).geometry;\n case \"Polygon\":\n return polygon(coordinates).geometry;\n case \"MultiPoint\":\n return multiPoint(coordinates).geometry;\n case \"MultiLineString\":\n return multiLineString(coordinates).geometry;\n case \"MultiPolygon\":\n return multiPolygon(coordinates).geometry;\n default:\n throw new Error(type + \" is invalid\");\n }\n}\n\n/**\n * Creates a {@link Point} {@link Feature} from a Position.\n *\n * @name point\n * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<Point>} a Point feature\n * @example\n * var point = turf.point([-75.343, 39.984]);\n *\n * //=point\n */\nexport function point<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<Point, P> {\n if (!coordinates) {\n throw new Error(\"coordinates is required\");\n }\n if (!Array.isArray(coordinates)) {\n throw new Error(\"coordinates must be an Array\");\n }\n if (coordinates.length < 2) {\n throw new Error(\"coordinates must be at least 2 numbers long\");\n }\n if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {\n throw new Error(\"coordinates must contain numbers\");\n }\n\n const geom: Point = {\n type: \"Point\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.\n *\n * @name points\n * @param {Array<Array<number>>} coordinates an array of Points\n * @param {Object} [properties={}] Translate these properties to each Feature\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]\n * associated with the FeatureCollection\n * @param {string|number} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<Point>} Point Feature\n * @example\n * var points = turf.points([\n * [-75, 39],\n * [-80, 45],\n * [-78, 50]\n * ]);\n *\n * //=points\n */\nexport function points<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<Point, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return point(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.\n *\n * @name polygon\n * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<Polygon>} Polygon Feature\n * @example\n * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });\n *\n * //=polygon\n */\nexport function polygon<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<Polygon, P> {\n for (const ring of coordinates) {\n if (ring.length < 4) {\n throw new Error(\n \"Each LinearRing of a Polygon must have 4 or more Positions.\"\n );\n }\n\n if (ring[ring.length - 1].length !== ring[0].length) {\n throw new Error(\"First and last Position are not equivalent.\");\n }\n\n for (let j = 0; j < ring[ring.length - 1].length; j++) {\n // Check if first point of Polygon contains two numbers\n if (ring[ring.length - 1][j] !== ring[0][j]) {\n throw new Error(\"First and last Position are not equivalent.\");\n }\n }\n }\n const geom: Polygon = {\n type: \"Polygon\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.\n *\n * @name polygons\n * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygon coordinates\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<Polygon>} Polygon FeatureCollection\n * @example\n * var polygons = turf.polygons([\n * [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],\n * [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],\n * ]);\n *\n * //=polygons\n */\nexport function polygons<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<Polygon, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return polygon(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Creates a {@link LineString} {@link Feature} from an Array of Positions.\n *\n * @name lineString\n * @param {Array<Array<number>>} coordinates an array of Positions\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<LineString>} LineString Feature\n * @example\n * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});\n * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});\n *\n * //=linestring1\n * //=linestring2\n */\nexport function lineString<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<LineString, P> {\n if (coordinates.length < 2) {\n throw new Error(\"coordinates must be an array of two or more positions\");\n }\n const geom: LineString = {\n type: \"LineString\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.\n *\n * @name lineStrings\n * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]\n * associated with the FeatureCollection\n * @param {string|number} [options.id] Identifier associated with the FeatureCollection\n * @returns {FeatureCollection<LineString>} LineString FeatureCollection\n * @example\n * var linestrings = turf.lineStrings([\n * [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],\n * [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]\n * ]);\n *\n * //=linestrings\n */\nexport function lineStrings<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<LineString, P> {\n return featureCollection(\n coordinates.map((coords) => {\n return lineString(coords, properties);\n }),\n options\n );\n}\n\n/**\n * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.\n *\n * @name featureCollection\n * @param {Feature[]} features input features\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {FeatureCollection} FeatureCollection of Features\n * @example\n * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});\n * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});\n * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});\n *\n * var collection = turf.featureCollection([\n * locationA,\n * locationB,\n * locationC\n * ]);\n *\n * //=collection\n */\nexport function featureCollection<\n G extends GeometryObject = Geometry,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n features: Array<Feature<G, P>>,\n options: { bbox?: BBox; id?: Id } = {}\n): FeatureCollection<G, P> {\n const fc: any = { type: \"FeatureCollection\" };\n if (options.id) {\n fc.id = options.id;\n }\n if (options.bbox) {\n fc.bbox = options.bbox;\n }\n fc.features = features;\n return fc;\n}\n\n/**\n * Creates a {@link Feature<MultiLineString>} based on a\n * coordinate array. Properties can be added optionally.\n *\n * @name multiLineString\n * @param {Array<Array<Array<number>>>} coordinates an array of LineStrings\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiLineString>} a MultiLineString feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);\n *\n * //=multiLine\n */\nexport function multiLineString<\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n coordinates: Position[][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiLineString, P> {\n const geom: MultiLineString = {\n type: \"MultiLineString\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature<MultiPoint>} based on a\n * coordinate array. Properties can be added optionally.\n *\n * @name multiPoint\n * @param {Array<Array<number>>} coordinates an array of Positions\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiPoint>} a MultiPoint feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiPt = turf.multiPoint([[0,0],[10,10]]);\n *\n * //=multiPt\n */\nexport function multiPoint<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiPoint, P> {\n const geom: MultiPoint = {\n type: \"MultiPoint\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature<MultiPolygon>} based on a\n * coordinate array. Properties can be added optionally.\n *\n * @name multiPolygon\n * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygons\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<MultiPolygon>} a multipolygon feature\n * @throws {Error} if no coordinates are passed\n * @example\n * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);\n *\n * //=multiPoly\n *\n */\nexport function multiPolygon<P extends GeoJsonProperties = GeoJsonProperties>(\n coordinates: Position[][][],\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<MultiPolygon, P> {\n const geom: MultiPolygon = {\n type: \"MultiPolygon\",\n coordinates,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Creates a {@link Feature<GeometryCollection>} based on a\n * coordinate array. Properties can be added optionally.\n *\n * @name geometryCollection\n * @param {Array<Geometry>} geometries an array of GeoJSON Geometries\n * @param {Object} [properties={}] an Object of key-value pairs to add as properties\n * @param {Object} [options={}] Optional Parameters\n * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature\n * @param {string|number} [options.id] Identifier associated with the Feature\n * @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature\n * @example\n * var pt = turf.geometry(\"Point\", [100, 0]);\n * var line = turf.geometry(\"LineString\", [[101, 0], [102, 1]]);\n * var collection = turf.geometryCollection([pt, line]);\n *\n * // => collection\n */\nexport function geometryCollection<\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n geometries: Array<\n Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon\n >,\n properties?: P,\n options: { bbox?: BBox; id?: Id } = {}\n): Feature<GeometryCollection, P> {\n const geom: GeometryCollection = {\n type: \"GeometryCollection\",\n geometries,\n };\n return feature(geom, properties, options);\n}\n\n/**\n * Round number to precision\n *\n * @param {number} num Number\n * @param {number} [precision=0] Precision\n * @returns {number} rounded number\n * @example\n * turf.round(120.4321)\n * //=120\n *\n * turf.round(120.4321, 2)\n * //=120.43\n */\nexport function round(num: number, precision = 0): number {\n if (precision && !(precision >= 0)) {\n throw new Error(\"precision must be a positive number\");\n }\n const multiplier = Math.pow(10, precision || 0);\n return Math.round(num * multiplier) / multiplier;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @name radiansToLength\n * @param {number} radians in radians across the sphere\n * @param {string} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} distance\n */\nexport function radiansToLength(\n radians: number,\n units: Units = \"kilometers\"\n): number {\n const factor = factors[units];\n if (!factor) {\n throw new Error(units + \" units is invalid\");\n }\n return radians * factor;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @name lengthToRadians\n * @param {number} distance in real units\n * @param {string} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} radians\n */\nexport function lengthToRadians(\n distance: number,\n units: Units = \"kilometers\"\n): number {\n const factor = factors[units];\n if (!factor) {\n throw new Error(units + \" units is invalid\");\n }\n return distance / factor;\n}\n\n/**\n * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet\n *\n * @name lengthToDegrees\n * @param {number} distance in real units\n * @param {string} [units=\"kilometers\"] can be degrees, radians, miles, inches, yards, metres,\n * meters, kilometres, kilometers.\n * @returns {number} degrees\n */\nexport function lengthToDegrees(distance: number, units?: Units): number {\n return radiansToDegrees(lengthToRadians(distance, units));\n}\n\n/**\n * Converts any bearing angle from the north line direction (positive clockwise)\n * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line\n *\n * @name bearingToAzimuth\n * @param {number} bearing angle, between -180 and +180 degrees\n * @returns {number} angle between 0 and 360 degrees\n */\nexport function bearingToAzimuth(bearing: number): number {\n let angle = bearing % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\n\n/**\n * Converts any azimuth angle from the north line direction (positive clockwise)\n * and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line\n *\n * @name azimuthToBearing\n * @param {number} angle between 0 and 360 degrees\n * @returns {number} bearing between -180 and +180 degrees\n */\nexport function azimuthToBearing(angle: number): number {\n angle = angle % 360;\n if (angle > 0) return angle > 180 ? angle - 360 : angle;\n return angle < -180 ? angle + 360 : angle;\n}\n\n/**\n * Converts an angle in radians to degrees\n *\n * @name radiansToDegrees\n * @param {number} radians angle in radians\n * @returns {number} degrees between 0 and 360 degrees\n */\nexport function radiansToDegrees(radians: number): number {\n const degrees = radians % (2 * Math.PI);\n return (degrees * 180) / Math.PI;\n}\n\n/**\n * Converts an angle in degrees to radians\n *\n * @name degreesToRadians\n * @param {number} degrees angle between 0 and 360 degrees\n * @returns {number} angle in radians\n */\nexport function degreesToRadians(degrees: number): number {\n const radians = degrees % 360;\n return (radians * Math.PI) / 180;\n}\n\n/**\n * Converts a length to the requested unit.\n * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet\n *\n * @param {number} length to be converted\n * @param {Units} [originalUnit=\"kilometers\"] of the length\n * @param {Units} [finalUnit=\"kilometers\"] returned unit\n * @returns {number} the converted length\n */\nexport function convertLength(\n length: number,\n originalUnit: Units = \"kilometers\",\n finalUnit: Units = \"kilometers\"\n): number {\n if (!(length >= 0)) {\n throw new Error(\"length must be a positive number\");\n }\n return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);\n}\n\n/**\n * Converts a area to the requested unit.\n * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares\n * @param {number} area to be converted\n * @param {Units} [originalUnit=\"meters\"] of the distance\n * @param {Units} [finalUnit=\"kilometers\"] returned unit\n * @returns {number} the converted area\n */\nexport function convertArea(\n area: number,\n originalUnit: AreaUnits = \"meters\",\n finalUnit: AreaUnits = \"kilometers\"\n): number {\n if (!(area >= 0)) {\n throw new Error(\"area must be a positive number\");\n }\n\n const startFactor = areaFactors[originalUnit];\n if (!startFactor) {\n throw new Error(\"invalid original units\");\n }\n\n const finalFactor = areaFactors[finalUnit];\n if (!finalFactor) {\n throw new Error(\"invalid final units\");\n }\n\n return (area / startFactor) * finalFactor;\n}\n\n/**\n * isNumber\n *\n * @param {*} num Number to validate\n * @returns {boolean} true/false\n * @example\n * turf.isNumber(123)\n * //=true\n * turf.isNumber('foo')\n * //=false\n */\nexport function isNumber(num: any): boolean {\n return !isNaN(num) && num !== null && !Array.isArray(num);\n}\n\n/**\n * isObject\n *\n * @param {*} input variable to validate\n * @returns {boolean} true/false, including false for Arrays and Functions\n * @example\n * turf.isObject({elevation: 10})\n * //=true\n * turf.isObject('foo')\n * //=false\n */\nexport function isObject(input: any): boolean {\n return input !== null && typeof input === \"object\" && !Array.isArray(input);\n}\n\n/**\n * Validate BBox\n *\n * @private\n * @param {Array<number>} bbox BBox to validate\n * @returns {void}\n * @throws {Error} if BBox is not valid\n * @example\n * validateBBox([-180, -40, 110, 50])\n * //=OK\n * validateBBox([-180, -40])\n * //=Error\n * validateBBox('Foo')\n * //=Error\n * validateBBox(5)\n * //=Error\n * validateBBox(null)\n * //=Error\n * validateBBox(undefined)\n * //=Error\n */\nexport function validateBBox(bbox: any): void {\n if (!bbox) {\n throw new Error(\"bbox is required\");\n }\n if (!Array.isArray(bbox)) {\n throw new Error(\"bbox must be an Array\");\n }\n if (bbox.length !== 4 && bbox.length !== 6) {\n throw new Error(\"bbox must be an Array of 4 or 6 numbers\");\n }\n bbox.forEach((num) => {\n if (!isNumber(num)) {\n throw new Error(\"bbox must only contain numbers\");\n }\n });\n}\n\n/**\n * Validate Id\n *\n * @private\n * @param {string|number} id Id to validate\n * @returns {void}\n * @throws {Error} if Id is not valid\n * @example\n * validateId([-180, -40, 110, 50])\n * //=Error\n * validateId([-180, -40])\n * //=Error\n * validateId('Foo')\n * //=OK\n * validateId(5)\n * //=OK\n * validateId(null)\n * //=Error\n * validateId(undefined)\n * //=Error\n */\nexport function validateId(id: any): void {\n if (!id) {\n throw new Error(\"id is required\");\n }\n if ([\"string\", \"number\"].indexOf(typeof id) === -1) {\n throw new Error(\"id must be a number or a string\");\n }\n}\n"],"mappings":";AA+DO,IAAM,cAAc;AAUpB,IAAM,UAAiC;AAAA,EAC5C,aAAa,cAAc;AAAA,EAC3B,aAAa,cAAc;AAAA,EAC3B,SAAS,OAAO,IAAI,KAAK;AAAA,EACzB,MAAM,cAAc;AAAA,EACpB,QAAQ,cAAc;AAAA,EACtB,YAAY,cAAc;AAAA,EAC1B,YAAY,cAAc;AAAA,EAC1B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,gBAAgB;AAAA,EAClC;AACA,MAAI,CAAC,UAAU,QAAQ,EAAE,QAAQ,OAAO,EAAE,MAAM,IAAI;AAClD,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "turf helpers module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -28,38 +28,48 @@
|
|
|
28
28
|
"turf",
|
|
29
29
|
"geojson"
|
|
30
30
|
],
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "dist/cjs/index.cjs",
|
|
33
|
+
"module": "dist/esm/index.js",
|
|
34
|
+
"types": "dist/esm/index.d.ts",
|
|
33
35
|
"exports": {
|
|
34
36
|
"./package.json": "./package.json",
|
|
35
37
|
".": {
|
|
36
|
-
"import":
|
|
37
|
-
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/esm/index.d.ts",
|
|
40
|
+
"default": "./dist/esm/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/cjs/index.d.cts",
|
|
44
|
+
"default": "./dist/cjs/index.cjs"
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
},
|
|
40
|
-
"types": "dist/js/index.d.ts",
|
|
41
48
|
"sideEffects": false,
|
|
42
49
|
"files": [
|
|
43
50
|
"dist"
|
|
44
51
|
],
|
|
45
52
|
"scripts": {
|
|
46
|
-
"bench": "
|
|
47
|
-
"build": "
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"test": "
|
|
52
|
-
"test:tape": "ts-node -r esm test.js",
|
|
53
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
53
|
+
"bench": "tsx bench.ts",
|
|
54
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
55
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
56
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
57
|
+
"test:tape": "tsx test.ts",
|
|
58
|
+
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
|
-
"@types/
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"@types/benchmark": "^2.1.5",
|
|
62
|
+
"@types/tape": "^4.2.32",
|
|
63
|
+
"benchmark": "^2.1.4",
|
|
64
|
+
"npm-run-all": "^4.1.5",
|
|
65
|
+
"tape": "^5.7.2",
|
|
66
|
+
"tsup": "^8.0.1",
|
|
67
|
+
"tsx": "^4.6.2",
|
|
68
|
+
"typescript": "^5.2.2"
|
|
63
69
|
},
|
|
64
|
-
"
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@types/geojson": "^7946.0.10",
|
|
72
|
+
"tslib": "^2.6.2"
|
|
73
|
+
},
|
|
74
|
+
"gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
|
|
65
75
|
}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
* `coord` **([Array][1]<[number][2]> | [Geometry][3]<[Point][4]> | [Feature][5]<[Point][4]>)** GeoJSON Point or an Array of numbers
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Examples
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
16
|
var pt = turf.point([10, 10]);
|
|
@@ -19,17 +19,17 @@ var coord = turf.getCoord(pt);
|
|
|
19
19
|
//= [10, 10]
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Returns **[Array][1]
|
|
22
|
+
Returns **[Array][1]<[number][2]>** coordinates
|
|
23
23
|
|
|
24
24
|
## getCoords
|
|
25
25
|
|
|
26
26
|
Unwrap coordinates from a Feature, Geometry Object or an Array
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
### Parameters
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
* `coords` **([Array][1]\<any> | [Geometry][3] | [Feature][5])** Feature, Geometry Object or an Array
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
### Examples
|
|
33
33
|
|
|
34
34
|
```javascript
|
|
35
35
|
var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);
|
|
@@ -38,15 +38,15 @@ var coords = turf.getCoords(poly);
|
|
|
38
38
|
//= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
Returns **[Array][1]
|
|
41
|
+
Returns **[Array][1]\<any>** coordinates
|
|
42
42
|
|
|
43
43
|
## containsNumber
|
|
44
44
|
|
|
45
45
|
Checks if coordinates contains a number
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### Parameters
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
* `coordinates` **[Array][1]\<any>** GeoJSON Coordinates
|
|
50
50
|
|
|
51
51
|
Returns **[boolean][6]** true if Array contains a number
|
|
52
52
|
|
|
@@ -54,52 +54,55 @@ Returns **[boolean][6]** true if Array contains a number
|
|
|
54
54
|
|
|
55
55
|
Enforce expectations about types of GeoJSON objects for Turf.
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
### Parameters
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
* `value` **[GeoJSON][7]** any GeoJSON object
|
|
60
|
+
* `type` **[string][8]** expected GeoJSON type
|
|
61
|
+
* `name` **[string][8]** name of calling function
|
|
62
62
|
|
|
63
|
+
<!---->
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
* Throws **[Error][9]** if value is not the expected type.
|
|
65
66
|
|
|
66
67
|
## featureOf
|
|
67
68
|
|
|
68
|
-
Enforce expectations about types of [Feature][
|
|
69
|
-
Internally this uses [geojsonType][
|
|
69
|
+
Enforce expectations about types of [Feature][5] inputs for Turf.
|
|
70
|
+
Internally this uses [geojsonType][10] to judge geometry types.
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
### Parameters
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
* `feature` **[Feature][5]** a feature with an expected geometry type
|
|
75
|
+
* `type` **[string][8]** expected GeoJSON type
|
|
76
|
+
* `name` **[string][8]** name of calling function
|
|
76
77
|
|
|
78
|
+
<!---->
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
* Throws **[Error][9]** error if value is not the expected type.
|
|
79
81
|
|
|
80
82
|
## collectionOf
|
|
81
83
|
|
|
82
|
-
Enforce expectations about types of [FeatureCollection][
|
|
83
|
-
Internally this uses [geojsonType][
|
|
84
|
+
Enforce expectations about types of [FeatureCollection][11] inputs for Turf.
|
|
85
|
+
Internally this uses [geojsonType][10] to judge geometry types.
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
### Parameters
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
* `featureCollection` **[FeatureCollection][11]** a FeatureCollection for which features will be judged
|
|
90
|
+
* `type` **[string][8]** expected GeoJSON type
|
|
91
|
+
* `name` **[string][8]** name of calling function
|
|
90
92
|
|
|
93
|
+
<!---->
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
* Throws **[Error][9]** if value is not the expected type.
|
|
93
96
|
|
|
94
97
|
## getGeom
|
|
95
98
|
|
|
96
99
|
Get Geometry from Feature or Geometry Object
|
|
97
100
|
|
|
98
|
-
|
|
101
|
+
### Parameters
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
* `geojson` **([Feature][5] | [Geometry][3])** GeoJSON Feature or Geometry Object
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
### Examples
|
|
103
106
|
|
|
104
107
|
```javascript
|
|
105
108
|
var point = {
|
|
@@ -114,26 +117,21 @@ var geom = turf.getGeom(point)
|
|
|
114
117
|
//={"type": "Point", "coordinates": [110, 40]}
|
|
115
118
|
```
|
|
116
119
|
|
|
117
|
-
|
|
120
|
+
* Throws **[Error][9]** if geojson is not a Feature or Geometry Object
|
|
118
121
|
|
|
119
122
|
Returns **([Geometry][3] | null)** GeoJSON Geometry Object
|
|
120
123
|
|
|
121
|
-
## getGeomType
|
|
122
|
-
|
|
123
|
-
Get Geometry Type from Feature or Geometry Object
|
|
124
|
-
|
|
125
|
-
- Throws **[Error][9]** **DEPRECATED** in v5.0.0 in favor of getType
|
|
126
|
-
|
|
127
124
|
## getType
|
|
128
125
|
|
|
129
126
|
Get GeoJSON object's type, Geometry type is prioritize.
|
|
130
127
|
|
|
131
|
-
|
|
128
|
+
### Parameters
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
* `geojson` **[GeoJSON][7]** GeoJSON object
|
|
131
|
+
* `_name` **[string][8]?** 
|
|
132
|
+
* `name` **[string][8]** name of the variable to display in error message (unused) (optional, default `"geojson"`)
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
### Examples
|
|
137
135
|
|
|
138
136
|
```javascript
|
|
139
137
|
var point = {
|
|
@@ -168,34 +166,25 @@ Returns **[string][8]** GeoJSON type
|
|
|
168
166
|
|
|
169
167
|
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
|
170
168
|
|
|
171
|
-
[10]:
|
|
172
|
-
|
|
173
|
-
[11]: #geojsontype
|
|
174
|
-
|
|
175
|
-
[12]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
169
|
+
[10]: #geojsontype
|
|
176
170
|
|
|
177
|
-
[
|
|
171
|
+
[11]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
178
172
|
|
|
179
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
180
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
181
|
-
./scripts/generate-readmes in the turf project. -->
|
|
173
|
+
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
182
174
|
|
|
183
175
|
---
|
|
184
176
|
|
|
185
|
-
This module is part of the [Turfjs project](
|
|
186
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
187
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
188
|
-
PRs and issues.
|
|
177
|
+
This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
|
|
189
178
|
|
|
190
179
|
### Installation
|
|
191
180
|
|
|
192
|
-
Install this module individually:
|
|
181
|
+
Install this single module individually:
|
|
193
182
|
|
|
194
183
|
```sh
|
|
195
184
|
$ npm install @turf/invariant
|
|
196
185
|
```
|
|
197
186
|
|
|
198
|
-
Or install the
|
|
187
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
199
188
|
|
|
200
189
|
```sh
|
|
201
190
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
|
+
var _helpers = require('@turf/helpers');
|
|
3
|
+
function getCoord(coord) {
|
|
4
|
+
if (!coord) {
|
|
5
|
+
throw new Error("coord is required");
|
|
6
|
+
}
|
|
7
|
+
if (!Array.isArray(coord)) {
|
|
8
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
9
|
+
return [...coord.geometry.coordinates];
|
|
10
|
+
}
|
|
11
|
+
if (coord.type === "Point") {
|
|
12
|
+
return [...coord.coordinates];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
16
|
+
return [...coord];
|
|
17
|
+
}
|
|
18
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
19
|
+
}
|
|
20
|
+
function getCoords(coords) {
|
|
21
|
+
if (Array.isArray(coords)) {
|
|
22
|
+
return coords;
|
|
23
|
+
}
|
|
24
|
+
if (coords.type === "Feature") {
|
|
25
|
+
if (coords.geometry !== null) {
|
|
26
|
+
return coords.geometry.coordinates;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
if (coords.coordinates) {
|
|
30
|
+
return coords.coordinates;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
throw new Error(
|
|
34
|
+
"coords must be GeoJSON Feature, Geometry Object or an Array"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
function containsNumber(coordinates) {
|
|
38
|
+
if (coordinates.length > 1 && _helpers.isNumber.call(void 0, coordinates[0]) && _helpers.isNumber.call(void 0, coordinates[1])) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(coordinates[0]) && coordinates[0].length) {
|
|
42
|
+
return containsNumber(coordinates[0]);
|
|
43
|
+
}
|
|
44
|
+
throw new Error("coordinates must only contain numbers");
|
|
45
|
+
}
|
|
46
|
+
function geojsonType(value, type, name) {
|
|
47
|
+
if (!type || !name) {
|
|
48
|
+
throw new Error("type and name required");
|
|
49
|
+
}
|
|
50
|
+
if (!value || value.type !== type) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
"Invalid input to " + name + ": must be a " + type + ", given " + value.type
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function featureOf(feature, type, name) {
|
|
57
|
+
if (!feature) {
|
|
58
|
+
throw new Error("No feature passed");
|
|
59
|
+
}
|
|
60
|
+
if (!name) {
|
|
61
|
+
throw new Error(".featureOf() requires a name");
|
|
62
|
+
}
|
|
63
|
+
if (!feature || feature.type !== "Feature" || !feature.geometry) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
"Invalid input to " + name + ", Feature with geometry required"
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (!feature.geometry || feature.geometry.type !== type) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
"Invalid input to " + name + ": must be a " + type + ", given " + feature.geometry.type
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function collectionOf(featureCollection, type, name) {
|
|
75
|
+
if (!featureCollection) {
|
|
76
|
+
throw new Error("No featureCollection passed");
|
|
77
|
+
}
|
|
78
|
+
if (!name) {
|
|
79
|
+
throw new Error(".collectionOf() requires a name");
|
|
80
|
+
}
|
|
81
|
+
if (!featureCollection || featureCollection.type !== "FeatureCollection") {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"Invalid input to " + name + ", FeatureCollection required"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
for (const feature of featureCollection.features) {
|
|
87
|
+
if (!feature || feature.type !== "Feature" || !feature.geometry) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
"Invalid input to " + name + ", Feature with geometry required"
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (!feature.geometry || feature.geometry.type !== type) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
"Invalid input to " + name + ": must be a " + type + ", given " + feature.geometry.type
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function getGeom(geojson) {
|
|
100
|
+
if (geojson.type === "Feature") {
|
|
101
|
+
return geojson.geometry;
|
|
102
|
+
}
|
|
103
|
+
return geojson;
|
|
104
|
+
}
|
|
105
|
+
function getType(geojson, _name) {
|
|
106
|
+
if (geojson.type === "FeatureCollection") {
|
|
107
|
+
return "FeatureCollection";
|
|
108
|
+
}
|
|
109
|
+
if (geojson.type === "GeometryCollection") {
|
|
110
|
+
return "GeometryCollection";
|
|
111
|
+
}
|
|
112
|
+
if (geojson.type === "Feature" && geojson.geometry !== null) {
|
|
113
|
+
return geojson.geometry.type;
|
|
114
|
+
}
|
|
115
|
+
return geojson.type;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
exports.collectionOf = collectionOf; exports.containsNumber = containsNumber; exports.featureOf = featureOf; exports.geojsonType = geojsonType; exports.getCoord = getCoord; exports.getCoords = getCoords; exports.getGeom = getGeom; exports.getType = getType;
|
|
127
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AAWA,SAAS,gBAAgB;AAczB,SAAS,SAAS,OAAoD;AACpE,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AAEA,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,QACE,MAAM,SAAS,aACf,MAAM,aAAa,QACnB,MAAM,SAAS,SAAS,SACxB;AACA,aAAO,CAAC,GAAG,MAAM,SAAS,WAAW;AAAA,IACvC;AACA,QAAI,MAAM,SAAS,SAAS;AAC1B,aAAO,CAAC,GAAG,MAAM,WAAW;AAAA,IAC9B;AAAA,EACF;AACA,MACE,MAAM,QAAQ,KAAK,KACnB,MAAM,UAAU,KAChB,CAAC,MAAM,QAAQ,MAAM,CAAC,CAAC,KACvB,CAAC,MAAM,QAAQ,MAAM,CAAC,CAAC,GACvB;AACA,WAAO,CAAC,GAAG,KAAK;AAAA,EAClB;AAEA,QAAM,IAAI,MAAM,oDAAoD;AACtE;AAcA,SAAS,UAQP,QAAuC;AACvC,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,SAAS,WAAW;AAC7B,QAAI,OAAO,a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B;AACtB,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,MAAI,CAAC,qBAAqB,kBAAkB,SAAS,qBAAqB;AACxE,UAAM,IAAI;AAAA,MACR,sBAAsB,OAAO;AAAA,IAC/B;AAAA,EACF;AACA,aAAW,WAAW,kBAAkB,UAAU;AAChD,QAAI,CAAC,WAAW,QAAQ,SAAS,aAAa,CAAC,QAAQ,UAAU;AAC/D,YAAM,IAAI;AAAA,QACR,sBAAsB,OAAO;AAAA,MAC/B;AAAA,IACF;AACA,QAAI,CAAC,QAAQ,YAAY,QAAQ,SAAS,SAAS,MAAM;AACvD,YAAM,IAAI;AAAA,QACR,sBACE,OACA,iBACA,OACA,aACA,QAAQ,SAAS;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AACF;AAoBA,SAAS,QAA4B,SAA4B;AAC/D,MAAI,QAAQ,SAAS,WAAW;AAC9B,WAAO,QAAQ;AAAA,EACjB;AACA,SAAO;AACT;AAoBA,SAAS,QACP,SACA,OACQ;AACR,MAAI,QAAQ,SAAS,qBAAqB;AACxC,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,SAAS,sBAAsB;AACzC,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,SAAS,aAAa,QAAQ,aAAa,MAAM;AAC3D,WAAO,QAAQ,SAAS;AAAA,EAC1B;AACA,SAAO,QAAQ;AACjB","sourcesContent":["import {\n Feature,\n FeatureCollection,\n Geometry,\n LineString,\n MultiPoint,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { isNumber } from \"@turf/helpers\";\n\n/**\n * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.\n *\n * @name getCoord\n * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers\n * @returns {Array<number>} coordinates\n * @example\n * var pt = turf.point([10, 10]);\n *\n * var coord = turf.getCoord(pt);\n * //= [10, 10]\n */\nfunction getCoord(coord: Feature<Point> | Point | number[]): number[] {\n if (!coord) {\n throw new Error(\"coord is required\");\n }\n\n if (!Array.isArray(coord)) {\n if (\n coord.type === \"Feature\" &&\n coord.geometry !== null &&\n coord.geometry.type === \"Point\"\n ) {\n return [...coord.geometry.coordinates];\n }\n if (coord.type === \"Point\") {\n return [...coord.coordinates];\n }\n }\n if (\n Array.isArray(coord) &&\n coord.length >= 2 &&\n !Array.isArray(coord[0]) &&\n !Array.isArray(coord[1])\n ) {\n return [...coord];\n }\n\n throw new Error(\"coord must be GeoJSON Point or an Array of numbers\");\n}\n\n/**\n * Unwrap coordinates from a Feature, Geometry Object or an Array\n *\n * @name getCoords\n * @param {Array<any>|Geometry|Feature} coords Feature, Geometry Object or an Array\n * @returns {Array<any>} coordinates\n * @example\n * var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);\n *\n * var coords = turf.getCoords(poly);\n * //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]\n */\nfunction getCoords<\n G extends\n | Point\n | LineString\n | Polygon\n | MultiPoint\n | MultiLineString\n | MultiPolygon,\n>(coords: any[] | Feature<G> | G): any[] {\n if (Array.isArray(coords)) {\n return coords;\n }\n\n // Feature\n if (coords.type === \"Feature\") {\n if (coords.geometry !== null) {\n return coords.geometry.coordinates;\n }\n } else {\n // Geometry\n if (coords.coordinates) {\n return coords.coordinates;\n }\n }\n\n throw new Error(\n \"coords must be GeoJSON Feature, Geometry Object or an Array\"\n );\n}\n\n/**\n * Checks if coordinates contains a number\n *\n * @name containsNumber\n * @param {Array<any>} coordinates GeoJSON Coordinates\n * @returns {boolean} true if Array contains a number\n */\nfunction containsNumber(coordinates: any[]): boolean {\n if (\n coordinates.length > 1 &&\n isNumber(coordinates[0]) &&\n isNumber(coordinates[1])\n ) {\n return true;\n }\n\n if (Array.isArray(coordinates[0]) && coordinates[0].length) {\n return containsNumber(coordinates[0]);\n }\n throw new Error(\"coordinates must only contain numbers\");\n}\n\n/**\n * Enforce expectations about types of GeoJSON objects for Turf.\n *\n * @name geojsonType\n * @param {GeoJSON} value any GeoJSON object\n * @param {string} type expected GeoJSON type\n * @param {string} name name of calling function\n * @throws {Error} if value is not the expected type.\n */\nfunction geojsonType(value: any, type: string, name: string): void {\n if (!type || !name) {\n throw new Error(\"type and name required\");\n }\n\n if (!value || value.type !== type) {\n throw new Error(\n \"Invalid input to \" +\n name +\n \": must be a \" +\n type +\n \", given \" +\n value.type\n );\n }\n}\n\n/**\n * Enforce expectations about types of {@link Feature} inputs for Turf.\n * Internally this uses {@link geojsonType} to judge geometry types.\n *\n * @name featureOf\n * @param {Feature} feature a feature with an expected geometry type\n * @param {string} type expected GeoJSON type\n * @param {string} name name of calling function\n * @throws {Error} error if value is not the expected type.\n */\nfunction featureOf(feature: Feature<any>, type: string, name: string): void {\n if (!feature) {\n throw new Error(\"No feature passed\");\n }\n if (!name) {\n throw new Error(\".featureOf() requires a name\");\n }\n if (!feature || feature.type !== \"Feature\" || !feature.geometry) {\n throw new Error(\n \"Invalid input to \" + name + \", Feature with geometry required\"\n );\n }\n if (!feature.geometry || feature.geometry.type !== type) {\n throw new Error(\n \"Invalid input to \" +\n name +\n \": must be a \" +\n type +\n \", given \" +\n feature.geometry.type\n );\n }\n}\n\n/**\n * Enforce expectations about types of {@link FeatureCollection} inputs for Turf.\n * Internally this uses {@link geojsonType} to judge geometry types.\n *\n * @name collectionOf\n * @param {FeatureCollection} featureCollection a FeatureCollection for which features will be judged\n * @param {string} type expected GeoJSON type\n * @param {string} name name of calling function\n * @throws {Error} if value is not the expected type.\n */\nfunction collectionOf(\n featureCollection: FeatureCollection<any>,\n type: string,\n name: string\n) {\n if (!featureCollection) {\n throw new Error(\"No featureCollection passed\");\n }\n if (!name) {\n throw new Error(\".collectionOf() requires a name\");\n }\n if (!featureCollection || featureCollection.type !== \"FeatureCollection\") {\n throw new Error(\n \"Invalid input to \" + name + \", FeatureCollection required\"\n );\n }\n for (const feature of featureCollection.features) {\n if (!feature || feature.type !== \"Feature\" || !feature.geometry) {\n throw new Error(\n \"Invalid input to \" + name + \", Feature with geometry required\"\n );\n }\n if (!feature.geometry || feature.geometry.type !== type) {\n throw new Error(\n \"Invalid input to \" +\n name +\n \": must be a \" +\n type +\n \", given \" +\n feature.geometry.type\n );\n }\n }\n}\n\n/**\n * Get Geometry from Feature or Geometry Object\n *\n * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object\n * @returns {Geometry|null} GeoJSON Geometry Object\n * @throws {Error} if geojson is not a Feature or Geometry Object\n * @example\n * var point = {\n * \"type\": \"Feature\",\n * \"properties\": {},\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 40]\n * }\n * }\n * var geom = turf.getGeom(point)\n * //={\"type\": \"Point\", \"coordinates\": [110, 40]}\n */\nfunction getGeom<G extends Geometry>(geojson: Feature<G> | G): G {\n if (geojson.type === \"Feature\") {\n return geojson.geometry;\n }\n return geojson;\n}\n\n/**\n * Get GeoJSON object's type, Geometry type is prioritize.\n *\n * @param {GeoJSON} geojson GeoJSON object\n * @param {string} [name=\"geojson\"] name of the variable to display in error message (unused)\n * @returns {string} GeoJSON type\n * @example\n * var point = {\n * \"type\": \"Feature\",\n * \"properties\": {},\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 40]\n * }\n * }\n * var geom = turf.getType(point)\n * //=\"Point\"\n */\nfunction getType(\n geojson: Feature<any> | FeatureCollection<any> | Geometry,\n _name?: string\n): string {\n if (geojson.type === \"FeatureCollection\") {\n return \"FeatureCollection\";\n }\n if (geojson.type === \"GeometryCollection\") {\n return \"GeometryCollection\";\n }\n if (geojson.type === \"Feature\" && geojson.geometry !== null) {\n return geojson.geometry.type;\n }\n return geojson.type;\n}\n\nexport {\n getCoord,\n getCoords,\n containsNumber,\n geojsonType,\n featureOf,\n collectionOf,\n getGeom,\n getType,\n};\n// No default export!\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Feature, Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, FeatureCollection, Geometry } from 'geojson';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
|
|
5
|
+
*
|
|
6
|
+
* @name getCoord
|
|
7
|
+
* @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
|
|
8
|
+
* @returns {Array<number>} coordinates
|
|
9
|
+
* @example
|
|
10
|
+
* var pt = turf.point([10, 10]);
|
|
11
|
+
*
|
|
12
|
+
* var coord = turf.getCoord(pt);
|
|
13
|
+
* //= [10, 10]
|
|
14
|
+
*/
|
|
15
|
+
declare function getCoord(coord: Feature<Point> | Point | number[]): number[];
|
|
16
|
+
/**
|
|
17
|
+
* Unwrap coordinates from a Feature, Geometry Object or an Array
|
|
18
|
+
*
|
|
19
|
+
* @name getCoords
|
|
20
|
+
* @param {Array<any>|Geometry|Feature} coords Feature, Geometry Object or an Array
|
|
21
|
+
* @returns {Array<any>} coordinates
|
|
22
|
+
* @example
|
|
23
|
+
* var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);
|
|
24
|
+
*
|
|
25
|
+
* var coords = turf.getCoords(poly);
|
|
26
|
+
* //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]
|
|
27
|
+
*/
|
|
28
|
+
declare function getCoords<G extends Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>(coords: any[] | Feature<G> | G): any[];
|
|
29
|
+
/**
|
|
30
|
+
* Checks if coordinates contains a number
|
|
31
|
+
*
|
|
32
|
+
* @name containsNumber
|
|
33
|
+
* @param {Array<any>} coordinates GeoJSON Coordinates
|
|
34
|
+
* @returns {boolean} true if Array contains a number
|
|
35
|
+
*/
|
|
36
|
+
declare function containsNumber(coordinates: any[]): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Enforce expectations about types of GeoJSON objects for Turf.
|
|
39
|
+
*
|
|
40
|
+
* @name geojsonType
|
|
41
|
+
* @param {GeoJSON} value any GeoJSON object
|
|
42
|
+
* @param {string} type expected GeoJSON type
|
|
43
|
+
* @param {string} name name of calling function
|
|
44
|
+
* @throws {Error} if value is not the expected type.
|
|
45
|
+
*/
|
|
46
|
+
declare function geojsonType(value: any, type: string, name: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Enforce expectations about types of {@link Feature} inputs for Turf.
|
|
49
|
+
* Internally this uses {@link geojsonType} to judge geometry types.
|
|
50
|
+
*
|
|
51
|
+
* @name featureOf
|
|
52
|
+
* @param {Feature} feature a feature with an expected geometry type
|
|
53
|
+
* @param {string} type expected GeoJSON type
|
|
54
|
+
* @param {string} name name of calling function
|
|
55
|
+
* @throws {Error} error if value is not the expected type.
|
|
56
|
+
*/
|
|
57
|
+
declare function featureOf(feature: Feature<any>, type: string, name: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Enforce expectations about types of {@link FeatureCollection} inputs for Turf.
|
|
60
|
+
* Internally this uses {@link geojsonType} to judge geometry types.
|
|
61
|
+
*
|
|
62
|
+
* @name collectionOf
|
|
63
|
+
* @param {FeatureCollection} featureCollection a FeatureCollection for which features will be judged
|
|
64
|
+
* @param {string} type expected GeoJSON type
|
|
65
|
+
* @param {string} name name of calling function
|
|
66
|
+
* @throws {Error} if value is not the expected type.
|
|
67
|
+
*/
|
|
68
|
+
declare function collectionOf(featureCollection: FeatureCollection<any>, type: string, name: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get Geometry from Feature or Geometry Object
|
|
71
|
+
*
|
|
72
|
+
* @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
|
|
73
|
+
* @returns {Geometry|null} GeoJSON Geometry Object
|
|
74
|
+
* @throws {Error} if geojson is not a Feature or Geometry Object
|
|
75
|
+
* @example
|
|
76
|
+
* var point = {
|
|
77
|
+
* "type": "Feature",
|
|
78
|
+
* "properties": {},
|
|
79
|
+
* "geometry": {
|
|
80
|
+
* "type": "Point",
|
|
81
|
+
* "coordinates": [110, 40]
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* var geom = turf.getGeom(point)
|
|
85
|
+
* //={"type": "Point", "coordinates": [110, 40]}
|
|
86
|
+
*/
|
|
87
|
+
declare function getGeom<G extends Geometry>(geojson: Feature<G> | G): G;
|
|
88
|
+
/**
|
|
89
|
+
* Get GeoJSON object's type, Geometry type is prioritize.
|
|
90
|
+
*
|
|
91
|
+
* @param {GeoJSON} geojson GeoJSON object
|
|
92
|
+
* @param {string} [name="geojson"] name of the variable to display in error message (unused)
|
|
93
|
+
* @returns {string} GeoJSON type
|
|
94
|
+
* @example
|
|
95
|
+
* var point = {
|
|
96
|
+
* "type": "Feature",
|
|
97
|
+
* "properties": {},
|
|
98
|
+
* "geometry": {
|
|
99
|
+
* "type": "Point",
|
|
100
|
+
* "coordinates": [110, 40]
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* var geom = turf.getType(point)
|
|
104
|
+
* //="Point"
|
|
105
|
+
*/
|
|
106
|
+
declare function getType(geojson: Feature<any> | FeatureCollection<any> | Geometry, _name?: string): string;
|
|
107
|
+
|
|
108
|
+
export { collectionOf, containsNumber, featureOf, geojsonType, getCoord, getCoords, getGeom, getType };
|