@turf/length 7.1.0 → 7.3.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/README.md CHANGED
@@ -11,7 +11,7 @@ Takes a [GeoJSON][1] and measures its length in the specified units, [(Multi)Poi
11
11
  * `geojson` **[Feature][3]<([LineString][4] | [MultiLineString][5])>** GeoJSON to measure
12
12
  * `options` **[Object][6]** Optional parameters (optional, default `{}`)
13
13
 
14
- * `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`)
14
+ * `options.units` **Units** Supports all valid Turf [Units][7]. (optional, default `kilometers`)
15
15
 
16
16
  ### Examples
17
17
 
@@ -38,7 +38,7 @@ Returns **[number][8]** length of GeoJSON
38
38
 
39
39
  [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
40
40
 
41
- [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
41
+ [7]: https://turfjs.org/docs/api/types/Units
42
42
 
43
43
  [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
44
44
 
@@ -11,9 +11,9 @@ function length(geojson, options = {}) {
11
11
  0
12
12
  );
13
13
  }
14
- var turf_length_default = length;
14
+ var index_default = length;
15
15
 
16
16
 
17
17
 
18
- exports.default = turf_length_default; exports.length = length;
18
+ exports.default = index_default; exports.length = length;
19
19
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,gBAAgB;AAEzB,SAAS,qBAAqB;AAkB9B,SAAS,OACP,SACA,UAEI,CAAC,GACG;AAER,SAAO;AAAA,IACL;AAAA,IACA,CAAC,eAAe,YAAY;AAC1B,YAAM,SAAS,QAAS,SAAS;AACjC,aAAO,gBAAiB,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,IACA;AAAA,EACF;AACF;AAGA,IAAO,sBAAQ","sourcesContent":["import { Feature, FeatureCollection, GeometryCollection } from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { Units } from \"@turf/helpers\";\nimport { segmentReduce } from \"@turf/meta\";\n\n/**\n * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.\n *\n * @name length\n * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers\n * @returns {number} length of GeoJSON\n * @example\n * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);\n * var length = turf.length(line, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [line];\n * line.properties.distance = length;\n */\nfunction length(\n geojson: Feature<any> | FeatureCollection<any> | GeometryCollection,\n options: {\n units?: Units;\n } = {}\n): number {\n // Calculate distance from 2-vertex line segments\n return segmentReduce(\n geojson,\n (previousValue, segment) => {\n const coords = segment!.geometry.coordinates;\n return previousValue! + distance(coords[0], coords[1], options);\n },\n 0\n );\n}\n\nexport { length };\nexport default length;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-length/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACCA,0CAAyB;AAEzB,kCAA8B;AAkB9B,SAAS,MAAA,CACP,OAAA,EACA,QAAA,EAEI,CAAC,CAAA,EACG;AAER,EAAA,OAAO,iCAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAC,aAAA,EAAe,OAAA,EAAA,GAAY;AAC1B,MAAA,MAAM,OAAA,EAAS,OAAA,CAAS,QAAA,CAAS,WAAA;AACjC,MAAA,OAAO,cAAA,EAAiB,gCAAA,MAAS,CAAO,CAAC,CAAA,EAAG,MAAA,CAAO,CAAC,CAAA,EAAG,OAAO,CAAA;AAAA,IAChE,CAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AAGA,IAAO,cAAA,EAAQ,MAAA;ADzBf;AACE;AACA;AACF,yDAAC","file":"/home/runner/work/turf/turf/packages/turf-length/dist/cjs/index.cjs","sourcesContent":[null,"import { Feature, FeatureCollection, GeometryCollection } from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { Units } from \"@turf/helpers\";\nimport { segmentReduce } from \"@turf/meta\";\n\n/**\n * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.\n *\n * @function\n * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units=kilometers] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}.\n * @returns {number} length of GeoJSON\n * @example\n * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);\n * var length = turf.length(line, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [line];\n * line.properties.distance = length;\n */\nfunction length(\n geojson: Feature<any> | FeatureCollection<any> | GeometryCollection,\n options: {\n units?: Units;\n } = {}\n): number {\n // Calculate distance from 2-vertex line segments\n return segmentReduce(\n geojson,\n (previousValue, segment) => {\n const coords = segment!.geometry.coordinates;\n return previousValue! + distance(coords[0], coords[1], options);\n },\n 0\n );\n}\n\nexport { length };\nexport default length;\n"]}
@@ -4,10 +4,10 @@ import { Units } from '@turf/helpers';
4
4
  /**
5
5
  * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.
6
6
  *
7
- * @name length
7
+ * @function
8
8
  * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure
9
9
  * @param {Object} [options={}] Optional parameters
10
- * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers
10
+ * @param {Units} [options.units=kilometers] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}.
11
11
  * @returns {number} length of GeoJSON
12
12
  * @example
13
13
  * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);
@@ -4,10 +4,10 @@ import { Units } from '@turf/helpers';
4
4
  /**
5
5
  * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.
6
6
  *
7
- * @name length
7
+ * @function
8
8
  * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure
9
9
  * @param {Object} [options={}] Optional parameters
10
- * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers
10
+ * @param {Units} [options.units=kilometers] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}.
11
11
  * @returns {number} length of GeoJSON
12
12
  * @example
13
13
  * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);
package/dist/esm/index.js CHANGED
@@ -11,9 +11,9 @@ function length(geojson, options = {}) {
11
11
  0
12
12
  );
13
13
  }
14
- var turf_length_default = length;
14
+ var index_default = length;
15
15
  export {
16
- turf_length_default as default,
16
+ index_default as default,
17
17
  length
18
18
  };
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, GeometryCollection } from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { Units } from \"@turf/helpers\";\nimport { segmentReduce } from \"@turf/meta\";\n\n/**\n * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.\n *\n * @name length\n * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers\n * @returns {number} length of GeoJSON\n * @example\n * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);\n * var length = turf.length(line, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [line];\n * line.properties.distance = length;\n */\nfunction length(\n geojson: Feature<any> | FeatureCollection<any> | GeometryCollection,\n options: {\n units?: Units;\n } = {}\n): number {\n // Calculate distance from 2-vertex line segments\n return segmentReduce(\n geojson,\n (previousValue, segment) => {\n const coords = segment!.geometry.coordinates;\n return previousValue! + distance(coords[0], coords[1], options);\n },\n 0\n );\n}\n\nexport { length };\nexport default length;\n"],"mappings":";AACA,SAAS,gBAAgB;AAEzB,SAAS,qBAAqB;AAkB9B,SAAS,OACP,SACA,UAEI,CAAC,GACG;AAER,SAAO;AAAA,IACL;AAAA,IACA,CAAC,eAAe,YAAY;AAC1B,YAAM,SAAS,QAAS,SAAS;AACjC,aAAO,gBAAiB,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,IACA;AAAA,EACF;AACF;AAGA,IAAO,sBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, GeometryCollection } from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { Units } from \"@turf/helpers\";\nimport { segmentReduce } from \"@turf/meta\";\n\n/**\n * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.\n *\n * @function\n * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units=kilometers] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}.\n * @returns {number} length of GeoJSON\n * @example\n * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);\n * var length = turf.length(line, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [line];\n * line.properties.distance = length;\n */\nfunction length(\n geojson: Feature<any> | FeatureCollection<any> | GeometryCollection,\n options: {\n units?: Units;\n } = {}\n): number {\n // Calculate distance from 2-vertex line segments\n return segmentReduce(\n geojson,\n (previousValue, segment) => {\n const coords = segment!.geometry.coordinates;\n return previousValue! + distance(coords[0], coords[1], options);\n },\n 0\n );\n}\n\nexport { length };\nexport default length;\n"],"mappings":";AACA,SAAS,gBAAgB;AAEzB,SAAS,qBAAqB;AAkB9B,SAAS,OACP,SACA,UAEI,CAAC,GACG;AAER,SAAO;AAAA,IACL;AAAA,IACA,CAAC,eAAe,YAAY;AAC1B,YAAM,SAAS,QAAS,SAAS;AACjC,aAAO,gBAAiB,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,IACA;AAAA,EACF;AACF;AAGA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turf/length",
3
- "version": "7.1.0",
4
- "description": "turf length module",
3
+ "version": "7.3.0",
4
+ "description": " Calculates the length of a line, perfect for paths or routes.",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
7
7
  "Denis Carriere <@DenisCarriere>",
@@ -58,22 +58,22 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/benchmark": "^2.1.5",
61
- "@types/tape": "^4.2.32",
61
+ "@types/tape": "^5.8.1",
62
62
  "benchmark": "^2.1.4",
63
63
  "load-json-file": "^7.0.1",
64
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",
69
- "write-json-file": "^5.0.0"
65
+ "tape": "^5.9.0",
66
+ "tsup": "^8.4.0",
67
+ "tsx": "^4.19.4",
68
+ "typescript": "^5.8.3",
69
+ "write-json-file": "^6.0.0"
70
70
  },
71
71
  "dependencies": {
72
- "@turf/distance": "^7.1.0",
73
- "@turf/helpers": "^7.1.0",
74
- "@turf/meta": "^7.1.0",
72
+ "@turf/distance": "7.3.0",
73
+ "@turf/helpers": "7.3.0",
74
+ "@turf/meta": "7.3.0",
75
75
  "@types/geojson": "^7946.0.10",
76
- "tslib": "^2.6.2"
76
+ "tslib": "^2.8.1"
77
77
  },
78
- "gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
78
+ "gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
79
79
  }