From 53a6c7732d6669d84afc9e33a8e9a31033092984 Mon Sep 17 00:00:00 2001 From: James Beard Date: Mon, 30 Dec 2024 16:04:07 +1100 Subject: [PATCH 1/2] Fixed disparities between jsdoc and function typedefs, mainly focused on Units and GeoJsonProperties. Also replaced a few more instances of Turf specific Id typedef, standardised wording of param descriptions (e.g. on Units, GeoJsonProperies). Updated example code to use const rather than var. --- packages/turf-bbox-polygon/README.md | 14 ++++---- packages/turf-bbox-polygon/index.ts | 18 +++++----- packages/turf-bezier-spline/README.md | 16 ++++----- packages/turf-bezier-spline/index.ts | 16 ++++----- packages/turf-boolean-intersects/README.md | 2 +- packages/turf-buffer/README.md | 24 ++++++------- packages/turf-buffer/index.js | 16 ++++----- packages/turf-center-mean/README.md | 26 ++++++++------ packages/turf-center-mean/index.ts | 27 +++++++++------ packages/turf-center-of-mass/README.md | 8 ++--- packages/turf-center-of-mass/index.ts | 8 ++--- packages/turf-center/README.md | 22 +++++++----- packages/turf-center/index.ts | 16 ++++----- packages/turf-centroid/README.md | 8 ++--- packages/turf-centroid/index.ts | 8 ++--- packages/turf-circle/README.md | 30 ++++++++-------- packages/turf-circle/index.ts | 26 +++++++------- packages/turf-clusters-dbscan/README.md | 22 ++++++------ packages/turf-clusters-dbscan/index.ts | 12 +++---- packages/turf-concave/README.md | 24 ++++++------- packages/turf-concave/index.ts | 14 ++++---- packages/turf-convex/README.md | 8 ++--- packages/turf-convex/index.ts | 8 ++--- packages/turf-destination/README.md | 22 ++++++------ packages/turf-destination/index.ts | 16 ++++----- packages/turf-distance/README.md | 18 +++++----- packages/turf-distance/index.ts | 12 +++---- packages/turf-ellipse/README.md | 22 ++++++------ packages/turf-ellipse/index.ts | 14 ++++---- packages/turf-great-circle/README.md | 20 +++++------ packages/turf-great-circle/index.js | 10 +++--- packages/turf-helpers/index.ts | 25 +++++++------- packages/turf-hex-grid/README.md | 24 ++++++------- packages/turf-hex-grid/index.ts | 14 ++++---- packages/turf-interpolate/README.md | 10 +++--- packages/turf-interpolate/index.js | 10 +++--- packages/turf-intersect/README.md | 10 +++--- packages/turf-intersect/index.ts | 10 +++--- packages/turf-isobands/lib/matrix-to-grid.js | 10 +++--- packages/turf-isolines/lib/matrix-to-grid.js | 10 +++--- packages/turf-length/README.md | 14 ++++---- packages/turf-length/index.ts | 8 ++--- packages/turf-line-arc/README.md | 22 ++++++------ packages/turf-line-arc/index.ts | 14 ++++---- packages/turf-line-chunk/README.md | 14 ++++---- packages/turf-line-chunk/index.js | 8 ++--- packages/turf-line-offset/README.md | 10 +++--- packages/turf-line-offset/index.js | 8 ++--- packages/turf-line-slice-along/README.md | 14 ++++---- packages/turf-line-slice-along/index.js | 12 +++---- packages/turf-line-to-polygon/README.md | 8 ++--- packages/turf-line-to-polygon/index.ts | 8 ++--- packages/turf-meta/README.md | 6 ++-- packages/turf-meta/index.d.ts | 10 +++--- packages/turf-meta/index.js | 6 ++-- .../turf-nearest-neighbor-analysis/README.md | 10 +++--- .../turf-nearest-neighbor-analysis/index.ts | 10 +++--- packages/turf-nearest-point-on-line/README.md | 12 +++---- packages/turf-nearest-point-on-line/index.ts | 10 +++--- packages/turf-nearest-point-to-line/README.md | 19 +++++------ packages/turf-nearest-point-to-line/index.ts | 17 +++++----- packages/turf-nearest-point/README.md | 16 ++++----- packages/turf-nearest-point/index.ts | 10 +++--- packages/turf-point-grid/README.md | 34 +++++++++---------- packages/turf-point-grid/index.ts | 20 +++++------ .../turf-point-to-line-distance/README.md | 29 ++++++++-------- packages/turf-point-to-line-distance/index.ts | 16 ++++----- .../turf-point-to-polygon-distance/README.md | 6 ++-- .../turf-point-to-polygon-distance/index.ts | 8 ++--- packages/turf-polygon-to-line/README.md | 12 +++---- packages/turf-polygon-to-line/index.ts | 12 +++---- packages/turf-rectangle-grid/README.md | 31 ++++++++--------- packages/turf-rectangle-grid/index.ts | 17 +++++----- packages/turf-rhumb-destination/README.md | 22 ++++++------ packages/turf-rhumb-destination/index.ts | 16 ++++----- packages/turf-rhumb-distance/README.md | 18 +++++----- packages/turf-rhumb-distance/index.ts | 12 +++---- packages/turf-sector/README.md | 24 ++++++------- packages/turf-sector/index.ts | 16 ++++----- packages/turf-square-grid/README.md | 29 +++++++--------- packages/turf-square-grid/index.ts | 15 ++++---- .../README.md | 2 +- .../index.ts | 2 +- packages/turf-triangle-grid/README.md | 12 +++---- packages/turf-triangle-grid/index.ts | 12 +++---- packages/turf-union/README.md | 8 ++--- packages/turf-union/index.ts | 8 ++--- 87 files changed, 619 insertions(+), 658 deletions(-) diff --git a/packages/turf-bbox-polygon/README.md b/packages/turf-bbox-polygon/README.md index 7e99be723f..5323f06904 100644 --- a/packages/turf-bbox-polygon/README.md +++ b/packages/turf-bbox-polygon/README.md @@ -8,24 +8,24 @@ Takes a bbox and returns an equivalent [polygon][1]. ### Parameters -* `bbox` **[BBox][2]** extent in \[minX, minY, maxX, maxY] order +* `bbox` **[BBox][2]** Extent in \[minX, minY, maxX, maxY] order * `options` **[Object][3]** Optional parameters (optional, default `{}`) - * `options.properties` **[GeoJsonProperties][4]** Translate properties to Polygon (optional, default `{}`) - * `options.id` **([string][5] | [number][6])** Translate Id to Polygon (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][4]** Properties to set on returned feature (optional, default `{}`) + * `options.id` **([string][5] | [number][6])** Id to set on returned feature (optional, default `{}`) ### Examples ```javascript -var bbox = [0, 0, 10, 10]; +const bbox = [0, 0, 10, 10]; -var poly = turf.bboxPolygon(bbox); +const poly = turf.bboxPolygon(bbox); //addToMap -var addToMap = [poly] +const addToMap = [poly] ``` -Returns **[Feature][4]<[Polygon][1]>** a Polygon representation of the bounding box +Returns **[Feature][4]<[Polygon][1]>** Polygon representing the bounding box [1]: https://tools.ietf.org/html/rfc7946#section-3.1.6 diff --git a/packages/turf-bbox-polygon/index.ts b/packages/turf-bbox-polygon/index.ts index 6ae88a4a4f..8c4b2e47fb 100644 --- a/packages/turf-bbox-polygon/index.ts +++ b/packages/turf-bbox-polygon/index.ts @@ -1,28 +1,28 @@ import { BBox, Feature, Polygon, GeoJsonProperties } from "geojson"; -import { polygon, Id } from "@turf/helpers"; +import { polygon } from "@turf/helpers"; /** * Takes a bbox and returns an equivalent {@link Polygon|polygon}. * * @function - * @param {BBox} bbox extent in [minX, minY, maxX, maxY] order + * @param {BBox} bbox Extent in [minX, minY, maxX, maxY] order * @param {Object} [options={}] Optional parameters - * @param {GeoJsonProperties} [options.properties={}] Translate properties to Polygon - * @param {string|number} [options.id={}] Translate Id to Polygon - * @returns {Feature} a Polygon representation of the bounding box + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @param {string|number} [options.id={}] Id to set on returned feature + * @returns {Feature} Polygon representing the bounding box * @example - * var bbox = [0, 0, 10, 10]; + * const bbox = [0, 0, 10, 10]; * - * var poly = turf.bboxPolygon(bbox); + * const poly = turf.bboxPolygon(bbox); * * //addToMap - * var addToMap = [poly] + * const addToMap = [poly] */ function bboxPolygon

( bbox: BBox, options: { properties?: P; - id?: Id; + id?: string | number; } = {} ): Feature { // Convert BBox positions to Numbers diff --git a/packages/turf-bezier-spline/README.md b/packages/turf-bezier-spline/README.md index 58a7e82c00..d711294c5d 100644 --- a/packages/turf-bezier-spline/README.md +++ b/packages/turf-bezier-spline/README.md @@ -12,17 +12,17 @@ The bezier spline implementation is by [Leszek Rybicki][3]. ### Parameters -* `line` **[Feature][4]<[LineString][1]>** input LineString +* `line` **[Feature][4]<[LineString][1]>** Input LineString * `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][5]** Translate properties to output (optional, default `{}`) - * `options.resolution` **[number][6]** time in milliseconds between points (optional, default `10000`) - * `options.sharpness` **[number][6]** a measure of how curvy the path should be between splines (optional, default `0.85`) + * `options.properties` **[GeoJsonProperties][4]** Properties to set on returned feature (optional, default `{}`) + * `options.resolution` **[number][6]** Time in milliseconds between points (optional, default `10000`) + * `options.sharpness` **[number][6]** Measure of how curvy the path should be between splines (optional, default `0.85`) ### Examples ```javascript -var line = turf.lineString([ +const line = turf.lineString([ [-76.091308, 18.427501], [-76.695556, 18.729501], [-76.552734, 19.40443], @@ -31,14 +31,14 @@ var line = turf.lineString([ [-73.157958, 20.210656] ]); -var curved = turf.bezierSpline(line); +const curved = turf.bezierSpline(line); //addToMap -var addToMap = [line, curved] +const addToMap = [line, curved] curved.properties = { stroke: '#0F0' }; ``` -Returns **[Feature][4]<[LineString][1]>** curved line +Returns **[Feature][4]<[LineString][1]>** Curved line [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4 diff --git a/packages/turf-bezier-spline/index.ts b/packages/turf-bezier-spline/index.ts index 99599877b0..e8b9cdb624 100644 --- a/packages/turf-bezier-spline/index.ts +++ b/packages/turf-bezier-spline/index.ts @@ -11,14 +11,14 @@ import { Spline } from "./lib/spline.js"; * The bezier spline implementation is by [Leszek Rybicki](http://leszek.rybicki.cc/). * * @function - * @param {Feature} line input LineString + * @param {Feature} line Input LineString * @param {Object} [options={}] Optional parameters - * @param {Object} [options.properties={}] Translate properties to output - * @param {number} [options.resolution=10000] time in milliseconds between points - * @param {number} [options.sharpness=0.85] a measure of how curvy the path should be between splines - * @returns {Feature} curved line + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @param {number} [options.resolution=10000] Time in milliseconds between points + * @param {number} [options.sharpness=0.85] Measure of how curvy the path should be between splines + * @returns {Feature} Curved line * @example - * var line = turf.lineString([ + * const line = turf.lineString([ * [-76.091308, 18.427501], * [-76.695556, 18.729501], * [-76.552734, 19.40443], @@ -27,10 +27,10 @@ import { Spline } from "./lib/spline.js"; * [-73.157958, 20.210656] * ]); * - * var curved = turf.bezierSpline(line); + * const curved = turf.bezierSpline(line); * * //addToMap - * var addToMap = [line, curved] + * const addToMap = [line, curved] * curved.properties = { stroke: '#0F0' }; */ function bezierSpline

( diff --git a/packages/turf-boolean-intersects/README.md b/packages/turf-boolean-intersects/README.md index 2ad0ceadb3..910856c889 100644 --- a/packages/turf-boolean-intersects/README.md +++ b/packages/turf-boolean-intersects/README.md @@ -12,7 +12,7 @@ Boolean-intersects returns (TRUE) if the intersection of the two geometries is N * `feature2` **([Geometry][1] | [Feature][2]\)** GeoJSON Feature or Geometry * `options` **[Object][3]** Optional parameters (optional, default `{}`) - * `options.ignoreSelfIntersections` **[boolean][4]** ignores self-intersections on input features (optional, default `false`) + * `options.ignoreSelfIntersections` **[boolean][4]** ignore self-intersections on input features (optional, default `true`) ### Examples diff --git a/packages/turf-buffer/README.md b/packages/turf-buffer/README.md index 664fbd028f..8aaeff2067 100644 --- a/packages/turf-buffer/README.md +++ b/packages/turf-buffer/README.md @@ -14,24 +14,24 @@ the input, or even be empty. ### Parameters -* `geojson` **([FeatureCollection][1] | [Geometry][2] | [Feature][3]\)** input to be buffered -* `radius` **[number][4]** distance to draw the buffer (negative values are allowed) +* `geojson` **([FeatureCollection][1] | [Geometry][2] | [Feature][3]\)** Input to be buffered +* `radius` **[number][4]** Distance to draw the buffer (negative values are allowed) * `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.units` **[string][6]** any of the options supported by turf units (optional, default `"kilometers"`) - * `options.steps` **[number][4]** number of steps (optional, default `8`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `"kilometers"`) + * `options.steps` **[number][4]** Number of steps (optional, default `8`) ### Examples ```javascript -var point = turf.point([-90.548630, 14.616599]); -var buffered = turf.buffer(point, 500, {units: 'miles'}); +const point = turf.point([-90.548630, 14.616599]); +const buffered = turf.buffer(point, 500, {units: 'miles'}); //addToMap -var addToMap = [point, buffered] +const addToMap = [point, buffered] ``` -Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][7] | [MultiPolygon][8])> | [undefined][9])** buffered features +Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][6] | [MultiPolygon][7])> | [undefined][8])** Buffered features [1]: https://tools.ietf.org/html/rfc7946#section-3.3 @@ -43,13 +43,11 @@ Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][7] | [MultiPolygon][ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[7]: https://tools.ietf.org/html/rfc7946#section-3.1.7 -[8]: https://tools.ietf.org/html/rfc7946#section-3.1.7 - -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined diff --git a/packages/turf-buffer/index.js b/packages/turf-buffer/index.js index 9ab9724032..0286d5495a 100644 --- a/packages/turf-buffer/index.js +++ b/packages/turf-buffer/index.js @@ -22,18 +22,18 @@ const { BufferOp, GeoJSONReader, GeoJSONWriter } = jsts; * the input, or even be empty. * * @function - * @param {FeatureCollection|Geometry|Feature} geojson input to be buffered - * @param {number} radius distance to draw the buffer (negative values are allowed) + * @param {FeatureCollection|Geometry|Feature} geojson Input to be buffered + * @param {number} radius Distance to draw the buffer (negative values are allowed) * @param {Object} [options={}] Optional parameters - * @param {string} [options.units="kilometers"] any of the options supported by turf units - * @param {number} [options.steps=8] number of steps - * @returns {FeatureCollection|Feature|undefined} buffered features + * @param {Units} [options.units="kilometers"] Units in which linear values are expressed + * @param {number} [options.steps=8] Number of steps + * @returns {FeatureCollection|Feature|undefined} Buffered features * @example - * var point = turf.point([-90.548630, 14.616599]); - * var buffered = turf.buffer(point, 500, {units: 'miles'}); + * const point = turf.point([-90.548630, 14.616599]); + * const buffered = turf.buffer(point, 500, {units: 'miles'}); * * //addToMap - * var addToMap = [point, buffered] + * const addToMap = [point, buffered] */ function buffer(geojson, radius, options) { // Optional params diff --git a/packages/turf-center-mean/README.md b/packages/turf-center-mean/README.md index 1efa4de049..7ff22cbafc 100644 --- a/packages/turf-center-mean/README.md +++ b/packages/turf-center-mean/README.md @@ -11,30 +11,30 @@ Takes a [Feature][1] or [FeatureCollection][2] and returns the mean center. Can * `geojson` **[GeoJSON][3]** GeoJSON to be centered * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][4]** Translate GeoJSON Properties to Point (optional, default `{}`) - * `options.bbox` **[Object][4]** Translate GeoJSON BBox to Point (optional, default `{}`) - * `options.id` **[Object][4]** Translate GeoJSON Id to Point (optional, default `{}`) - * `options.weight` **[string][5]?** the property name used to weight the center + * `options.properties` **[GeoJsonProperties][1]** Properties to set on returned feature (optional, default `{}`) + * `options.bbox` **[BBox][5]** TranslBBox to set on returned feature (optional, default `{}`) + * `options.id` **([string][6] | [number][7])** Id to set on returned feature (optional, default `{}`) + * `options.weight` **[string][6]?** Property name used to weight the center ### Examples ```javascript -var features = turf.featureCollection([ +const features = turf.featureCollection([ turf.point([-97.522259, 35.4691], {value: 10}), turf.point([-97.502754, 35.463455], {value: 3}), turf.point([-97.508269, 35.463245], {value: 5}) ]); -var options = {weight: "value"} -var mean = turf.centerMean(features, options); +const options = {weight: "value"} +const mean = turf.centerMean(features, options); //addToMap -var addToMap = [features, mean] +const addToMap = [features, mean] mean.properties['marker-size'] = 'large'; mean.properties['marker-color'] = '#000'; ``` -Returns **[Feature][1]<[Point][6]>** a Point feature at the mean center point of all input features +Returns **[Feature][1]<[Point][8]>** Point feature at the mean center point of all input features [1]: https://tools.ietf.org/html/rfc7946#section-3.2 @@ -44,9 +44,13 @@ Returns **[Feature][1]<[Point][6]>** a Point feature at the mean center point of [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[5]: https://tools.ietf.org/html/rfc7946#section-5 -[6]: https://tools.ietf.org/html/rfc7946#section-3.1.2 +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[8]: https://tools.ietf.org/html/rfc7946#section-3.1.2 diff --git a/packages/turf-center-mean/index.ts b/packages/turf-center-mean/index.ts index 3d8814f908..4412afd6e9 100644 --- a/packages/turf-center-mean/index.ts +++ b/packages/turf-center-mean/index.ts @@ -1,6 +1,6 @@ import { BBox, Feature, Point, GeoJsonProperties } from "geojson"; import { geomEach, coordEach } from "@turf/meta"; -import { isNumber, point, Id } from "@turf/helpers"; +import { isNumber, point } from "@turf/helpers"; /** * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted. @@ -8,29 +8,34 @@ import { isNumber, point, Id } from "@turf/helpers"; * @function * @param {GeoJSON} geojson GeoJSON to be centered * @param {Object} [options={}] Optional parameters - * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point - * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point - * @param {Object} [options.id={}] Translate GeoJSON Id to Point - * @param {string} [options.weight] the property name used to weight the center - * @returns {Feature} a Point feature at the mean center point of all input features + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @param {BBox} [options.bbox={}] TranslBBox to set on returned feature + * @param {string | number} [options.id={}] Id to set on returned feature + * @param {string} [options.weight] Property name used to weight the center + * @returns {Feature} Point feature at the mean center point of all input features * @example - * var features = turf.featureCollection([ + * const features = turf.featureCollection([ * turf.point([-97.522259, 35.4691], {value: 10}), * turf.point([-97.502754, 35.463455], {value: 3}), * turf.point([-97.508269, 35.463245], {value: 5}) * ]); * - * var options = {weight: "value"} - * var mean = turf.centerMean(features, options); + * const options = {weight: "value"} + * const mean = turf.centerMean(features, options); * * //addToMap - * var addToMap = [features, mean] + * const addToMap = [features, mean] * mean.properties['marker-size'] = 'large'; * mean.properties['marker-color'] = '#000'; */ function centerMean

( geojson: any, // To-Do include Typescript AllGeoJSON - options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {} + options: { + properties?: P; + bbox?: BBox; + id?: string | number; + weight?: string; + } = {} ): Feature { let sumXs = 0; let sumYs = 0; diff --git a/packages/turf-center-of-mass/README.md b/packages/turf-center-of-mass/README.md index 7d35fd2fcd..7829e4785a 100644 --- a/packages/turf-center-of-mass/README.md +++ b/packages/turf-center-of-mass/README.md @@ -11,17 +11,17 @@ Takes any [Feature][1] or a [FeatureCollection][2] and returns its [center of ma * `geojson` **[GeoJSON][5]** GeoJSON to be centered * `options` **[Object][6]** Optional Parameters (optional, default `{}`) - * `options.properties` **[Object][6]** Translate Properties to Feature (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][1]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); +const polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); -var center = turf.centerOfMass(polygon); +const center = turf.centerOfMass(polygon); //addToMap -var addToMap = [polygon, center] +const addToMap = [polygon, center] ``` Returns **[Feature][1]<[Point][7]>** the center of mass diff --git a/packages/turf-center-of-mass/index.ts b/packages/turf-center-of-mass/index.ts index 819bd5583a..6f5f027047 100644 --- a/packages/turf-center-of-mass/index.ts +++ b/packages/turf-center-of-mass/index.ts @@ -11,15 +11,15 @@ import { coordEach } from "@turf/meta"; * @function * @param {GeoJSON} geojson GeoJSON to be centered * @param {Object} [options={}] Optional Parameters - * @param {Object} [options.properties={}] Translate Properties to Feature + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} the center of mass * @example - * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); + * const polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); * - * var center = turf.centerOfMass(polygon); + * const center = turf.centerOfMass(polygon); * * //addToMap - * var addToMap = [polygon, center] + * const addToMap = [polygon, center] */ function centerOfMass

( geojson: any, diff --git a/packages/turf-center/README.md b/packages/turf-center/README.md index 1f138a456a..56c948e130 100644 --- a/packages/turf-center/README.md +++ b/packages/turf-center/README.md @@ -11,28 +11,28 @@ Takes a [Feature][1] or [FeatureCollection][2] and returns the absolute center p * `geojson` **[GeoJSON][3]** GeoJSON to be centered * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][4]** Translate GeoJSON Properties to Point (optional, default `{}`) - * `options.bbox` **[Object][4]** Translate GeoJSON BBox to Point (optional, default `{}`) - * `options.id` **[Object][4]** Translate GeoJSON Id to Point (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][1]** Properties to set on returned feature (optional, default `{}`) + * `options.bbox` **[BBox][5]** Bbox to set on returned feature (optional, default `{}`) + * `options.id` **([string][6] | [number][7])** Id to set on returned feature (optional, default `{}`) ### Examples ```javascript -var features = turf.points([ +const features = turf.points([ [-97.522259, 35.4691], [-97.502754, 35.463455], [-97.508269, 35.463245] ]); -var center = turf.center(features); +const center = turf.center(features); //addToMap -var addToMap = [features, center] +const addToMap = [features, center] center.properties['marker-size'] = 'large'; center.properties['marker-color'] = '#000'; ``` -Returns **[Feature][1]<[Point][5]>** a Point feature at the absolute center point of all input features +Returns **[Feature][1]<[Point][8]>** a Point feature at the absolute center point of all input features [1]: https://tools.ietf.org/html/rfc7946#section-3.2 @@ -42,7 +42,13 @@ Returns **[Feature][1]<[Point][5]>** a Point feature at the absolute center poin [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://tools.ietf.org/html/rfc7946#section-3.1.2 +[5]: https://tools.ietf.org/html/rfc7946#section-5 + +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[8]: https://tools.ietf.org/html/rfc7946#section-3.1.2 diff --git a/packages/turf-center/index.ts b/packages/turf-center/index.ts index f23c8697ca..b1735fb4e1 100644 --- a/packages/turf-center/index.ts +++ b/packages/turf-center/index.ts @@ -1,6 +1,6 @@ import { BBox, Feature, GeoJsonProperties, Point } from "geojson"; import { bbox } from "@turf/bbox"; -import { point, Id, AllGeoJSON } from "@turf/helpers"; +import { point, AllGeoJSON } from "@turf/helpers"; /** * Takes a {@link Feature} or {@link FeatureCollection} and returns the absolute center point of all features. @@ -8,27 +8,27 @@ import { point, Id, AllGeoJSON } from "@turf/helpers"; * @function * @param {GeoJSON} geojson GeoJSON to be centered * @param {Object} [options={}] Optional parameters - * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point - * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point - * @param {Object} [options.id={}] Translate GeoJSON Id to Point + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @param {BBox} [options.bbox={}] Bbox to set on returned feature + * @param {string | number} [options.id={}] Id to set on returned feature * @returns {Feature} a Point feature at the absolute center point of all input features * @example - * var features = turf.points([ + * const features = turf.points([ * [-97.522259, 35.4691], * [-97.502754, 35.463455], * [-97.508269, 35.463245] * ]); * - * var center = turf.center(features); + * const center = turf.center(features); * * //addToMap - * var addToMap = [features, center] + * const addToMap = [features, center] * center.properties['marker-size'] = 'large'; * center.properties['marker-color'] = '#000'; */ function center

( geojson: AllGeoJSON, - options: { properties?: P; bbox?: BBox; id?: Id } = {} + options: { properties?: P; bbox?: BBox; id?: string | number } = {} ): Feature { const ext = bbox(geojson); const x = (ext[0] + ext[2]) / 2; diff --git a/packages/turf-centroid/README.md b/packages/turf-centroid/README.md index 3e95e40643..1ea7c2b5a4 100644 --- a/packages/turf-centroid/README.md +++ b/packages/turf-centroid/README.md @@ -11,17 +11,17 @@ Computes the centroid as the mean of all vertices within the object. * `geojson` **[GeoJSON][1]** GeoJSON to be centered * `options` **[Object][2]** Optional Parameters (optional, default `{}`) - * `options.properties` **[Object][2]** an Object that is used as the [Feature][3]'s properties (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][3]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); +const polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); -var centroid = turf.centroid(polygon); +const centroid = turf.centroid(polygon); //addToMap -var addToMap = [polygon, centroid] +const addToMap = [polygon, centroid] ``` Returns **[Feature][3]<[Point][4]>** the centroid of the input object diff --git a/packages/turf-centroid/index.ts b/packages/turf-centroid/index.ts index 0a662e8066..d3356bdd9c 100644 --- a/packages/turf-centroid/index.ts +++ b/packages/turf-centroid/index.ts @@ -8,15 +8,15 @@ import { coordEach } from "@turf/meta"; * @function * @param {GeoJSON} geojson GeoJSON to be centered * @param {Object} [options={}] Optional Parameters - * @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} the centroid of the input object * @example - * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); + * const polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]); * - * var centroid = turf.centroid(polygon); + * const centroid = turf.centroid(polygon); * * //addToMap - * var addToMap = [polygon, centroid] + * const addToMap = [polygon, centroid] */ function centroid

( geojson: AllGeoJSON, diff --git a/packages/turf-circle/README.md b/packages/turf-circle/README.md index 89fdaa522c..97c9fa6aa5 100644 --- a/packages/turf-circle/README.md +++ b/packages/turf-circle/README.md @@ -8,41 +8,39 @@ Takes a [Point][1] and calculates the circle polygon given a radius in degrees, ### Parameters -* `center` **([Feature][2]<[Point][1]> | [Array][3]<[number][4]>)** center point -* `radius` **[number][4]** radius of the circle +* `center` **([Position][2] | [Point][1] | [Feature][3]<[Point][1]>)** Center point +* `radius` **[number][4]** Radius of the circle * `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.steps` **[number][4]** number of steps (optional, default `64`) - * `options.units` **[string][6]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) - * `options.properties` **[Object][5]** properties (optional, default `{}`) + * `options.steps` **[number][4]** Number of steps (optional, default `64`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.properties` **[GeoJsonProperties][3]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var center = [-75.343, 39.984]; -var radius = 5; -var options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}}; -var circle = turf.circle(center, radius, options); +const center = [-75.343, 39.984]; +const radius = 5; +const options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}}; +const circle = turf.circle(center, radius, options); //addToMap -var addToMap = [turf.point(center), circle] +const addToMap = [turf.point(center), circle] ``` -Returns **[Feature][2]<[Polygon][7]>** circle polygon +Returns **[Feature][3]<[Polygon][6]>** Circle polygon [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 -[2]: https://tools.ietf.org/html/rfc7946#section-3.2 +[2]: https://developer.mozilla.org/docs/Web/API/Position -[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[3]: https://tools.ietf.org/html/rfc7946#section-3.2 [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 diff --git a/packages/turf-circle/index.ts b/packages/turf-circle/index.ts index e9e0410e53..176c42f727 100644 --- a/packages/turf-circle/index.ts +++ b/packages/turf-circle/index.ts @@ -1,4 +1,4 @@ -import { GeoJsonProperties, Feature, Point, Polygon } from "geojson"; +import { GeoJsonProperties, Feature, Point, Polygon, Position } from "geojson"; import { destination } from "@turf/destination"; import { polygon, Units } from "@turf/helpers"; @@ -6,24 +6,24 @@ import { polygon, Units } from "@turf/helpers"; * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision. * * @function - * @param {Feature|number[]} center center point - * @param {number} radius radius of the circle + * @param {Position|Point|Feature} center Center point + * @param {number} radius Radius of the circle * @param {Object} [options={}] Optional parameters - * @param {number} [options.steps=64] number of steps - * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians - * @param {Object} [options.properties={}] properties - * @returns {Feature} circle polygon + * @param {number} [options.steps=64] Number of steps + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @returns {Feature} Circle polygon * @example - * var center = [-75.343, 39.984]; - * var radius = 5; - * var options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}}; - * var circle = turf.circle(center, radius, options); + * const center = [-75.343, 39.984]; + * const radius = 5; + * const options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}}; + * const circle = turf.circle(center, radius, options); * * //addToMap - * var addToMap = [turf.point(center), circle] + * const addToMap = [turf.point(center), circle] */ function circle

( - center: number[] | Point | Feature, + center: Position | Point | Feature, radius: number, options: { steps?: number; diff --git a/packages/turf-clusters-dbscan/README.md b/packages/turf-clusters-dbscan/README.md index 0b3c127918..9c16123046 100644 --- a/packages/turf-clusters-dbscan/README.md +++ b/packages/turf-clusters-dbscan/README.md @@ -27,12 +27,12 @@ Takes a set of [points][4] and partition them into clusters according to [DBSCAN ### Parameters -* `points` **[FeatureCollection][6]<[Point][4]>** to be clustered +* `points` **[FeatureCollection][6]<[Point][4]>** Points to be clustered * `maxDistance` **[number][3]** Maximum Distance between any point of the cluster to generate the clusters (kilometers by default, see options) * `options` **[Object][1]** Optional parameters (optional, default `{}`) - * `options.units` **[string][7]** in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`) - * `options.mutate` **[boolean][8]** Allows GeoJSON input to be mutated (optional, default `false`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `"kilometers"`) + * `options.mutate` **[boolean][7]** Allows GeoJSON input to be mutated (optional, default `false`) * `options.minPoints` **[number][3]** Minimum number of points to generate a single cluster, points which do not meet this requirement will be classified as an 'edge' or 'noise'. (optional, default `3`) @@ -40,15 +40,15 @@ Takes a set of [points][4] and partition them into clusters according to [DBSCAN ```javascript // create random points with random z-values in their properties -var points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]}); -var maxDistance = 100; -var clustered = turf.clustersDbscan(points, maxDistance); +const points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]}); +const maxDistance = 100; +const clustered = turf.clustersDbscan(points, maxDistance); //addToMap -var addToMap = [clustered]; +const addToMap = [clustered]; ``` -Returns **[FeatureCollection][6]<[Point][4], [DbscanProps][9]>** Clustered Points with an additional two properties associated to each Feature:* {number} cluster - the associated clusterId +Returns **[FeatureCollection][6]<[Point][4], [DbscanProps][8]>** Clustered Points with an additional two properties associated to each Feature:* {number} cluster - the associated clusterId * {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise') [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object @@ -63,11 +63,9 @@ Returns **[FeatureCollection][6]<[Point][4], [DbscanProps][9]>** Clustered Point [6]: https://tools.ietf.org/html/rfc7946#section-3.3 -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean - -[9]: #dbscanprops +[8]: #dbscanprops diff --git a/packages/turf-clusters-dbscan/index.ts b/packages/turf-clusters-dbscan/index.ts index ef87d5ec74..cb28e8732f 100644 --- a/packages/turf-clusters-dbscan/index.ts +++ b/packages/turf-clusters-dbscan/index.ts @@ -37,10 +37,10 @@ type IndexedPoint = { * Takes a set of {@link Point|points} and partition them into clusters according to {@link https://en.wikipedia.org/wiki/DBSCAN|DBSCAN's} data clustering algorithm. * * @function - * @param {FeatureCollection} points to be clustered + * @param {FeatureCollection} points Points to be clustered * @param {number} maxDistance Maximum Distance between any point of the cluster to generate the clusters (kilometers by default, see options) * @param {Object} [options={}] Optional parameters - * @param {string} [options.units="kilometers"] in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers + * @param {Units} [options.units="kilometers"] Units in which linear values are expressed * @param {boolean} [options.mutate=false] Allows GeoJSON input to be mutated * @param {number} [options.minPoints=3] Minimum number of points to generate a single cluster, * points which do not meet this requirement will be classified as an 'edge' or 'noise'. @@ -49,12 +49,12 @@ type IndexedPoint = { * - {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise') * @example * // create random points with random z-values in their properties - * var points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]}); - * var maxDistance = 100; - * var clustered = turf.clustersDbscan(points, maxDistance); + * const points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]}); + * const maxDistance = 100; + * const clustered = turf.clustersDbscan(points, maxDistance); * * //addToMap - * var addToMap = [clustered]; + * const addToMap = [clustered]; */ function clustersDbscan( points: FeatureCollection, diff --git a/packages/turf-concave/README.md b/packages/turf-concave/README.md index eb903ad4cc..3f4be28bbc 100644 --- a/packages/turf-concave/README.md +++ b/packages/turf-concave/README.md @@ -9,17 +9,17 @@ Internally, this uses [turf-tin][2] to generate geometries. ### Parameters -* `points` **[FeatureCollection][3]<[Point][1]>** input points +* `points` **[FeatureCollection][3]<[Point][1]>** Input points * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.maxEdge` **[number][5]** the length (in 'units') of an edge necessary for part of the + * `options.maxEdge` **[number][5]** Length of an edge necessary for part of the hull to become concave. (optional, default `Infinity`) - * `options.units` **[string][6]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var points = turf.featureCollection([ +const points = turf.featureCollection([ turf.point([-63.601226, 44.642643]), turf.point([-63.591442, 44.651436]), turf.point([-63.580799, 44.648749]), @@ -27,15 +27,15 @@ var points = turf.featureCollection([ turf.point([-63.587665, 44.64533]), turf.point([-63.595218, 44.64765]) ]); -var options = {units: 'miles', maxEdge: 1}; +const options = {units: 'miles', maxEdge: 1}; -var hull = turf.concave(points, options); +const hull = turf.concave(points, options); //addToMap -var addToMap = [points, hull] +const addToMap = [points, hull] ``` -Returns **([Feature][7]<([Polygon][8] | [MultiPolygon][9])> | null)** a concave hull (null value is returned if unable to compute hull) +Returns **([Feature][6]<([Polygon][7] | [MultiPolygon][8])> | null)** a concave hull (null value is returned if unable to compute hull) [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -47,13 +47,11 @@ Returns **([Feature][7]<([Polygon][8] | [MultiPolygon][9])> | null)** a concave [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[6]: https://tools.ietf.org/html/rfc7946#section-3.2 -[7]: https://tools.ietf.org/html/rfc7946#section-3.2 +[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6 -[8]: https://tools.ietf.org/html/rfc7946#section-3.1.6 - -[9]: https://tools.ietf.org/html/rfc7946#section-3.1.7 +[8]: https://tools.ietf.org/html/rfc7946#section-3.1.7 diff --git a/packages/turf-concave/index.ts b/packages/turf-concave/index.ts index fbfa28e926..b88d5465c6 100644 --- a/packages/turf-concave/index.ts +++ b/packages/turf-concave/index.ts @@ -17,14 +17,14 @@ import { dissolve } from "./lib/turf-dissolve.js"; * Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries. * * @function - * @param {FeatureCollection} points input points + * @param {FeatureCollection} points Input points * @param {Object} [options={}] Optional parameters - * @param {number} [options.maxEdge=Infinity] the length (in 'units') of an edge necessary for part of the + * @param {number} [options.maxEdge=Infinity] Length of an edge necessary for part of the * hull to become concave. - * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {Feature<(Polygon|MultiPolygon)>|null} a concave hull (null value is returned if unable to compute hull) * @example - * var points = turf.featureCollection([ + * const points = turf.featureCollection([ * turf.point([-63.601226, 44.642643]), * turf.point([-63.591442, 44.651436]), * turf.point([-63.580799, 44.648749]), @@ -32,12 +32,12 @@ import { dissolve } from "./lib/turf-dissolve.js"; * turf.point([-63.587665, 44.64533]), * turf.point([-63.595218, 44.64765]) * ]); - * var options = {units: 'miles', maxEdge: 1}; + * const options = {units: 'miles', maxEdge: 1}; * - * var hull = turf.concave(points, options); + * const hull = turf.concave(points, options); * * //addToMap - * var addToMap = [points, hull] + * const addToMap = [points, hull] */ function concave( points: FeatureCollection, diff --git a/packages/turf-convex/README.md b/packages/turf-convex/README.md index bf8763bf79..ab267793c6 100644 --- a/packages/turf-convex/README.md +++ b/packages/turf-convex/README.md @@ -16,12 +16,12 @@ the [convex-hull][4] module that implements a * `options` **[Object][7]** Optional parameters (optional, default `{}`) * `options.concavity` **[number][8]** 1 - thin shape. Infinity - convex hull. (optional, default `Infinity`) - * `options.properties` **[Object][7]** Translate Properties to Feature (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][1]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var points = turf.featureCollection([ +const points = turf.featureCollection([ turf.point([10.195312, 43.755225]), turf.point([10.404052, 43.8424511]), turf.point([10.579833, 43.659924]), @@ -30,10 +30,10 @@ var points = turf.featureCollection([ turf.point([10.195312, 43.755225]) ]); -var hull = turf.convex(points); +const hull = turf.convex(points); //addToMap -var addToMap = [points, hull] +const addToMap = [points, hull] ``` Returns **[Feature][1]<[Polygon][3]>** a convex hull diff --git a/packages/turf-convex/index.ts b/packages/turf-convex/index.ts index d7969ec59b..d16baa4944 100644 --- a/packages/turf-convex/index.ts +++ b/packages/turf-convex/index.ts @@ -14,10 +14,10 @@ import concaveman from "concaveman"; * @param {GeoJSON} geojson input Feature or FeatureCollection * @param {Object} [options={}] Optional parameters * @param {number} [options.concavity=Infinity] 1 - thin shape. Infinity - convex hull. - * @param {Object} [options.properties={}] Translate Properties to Feature + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} a convex hull * @example - * var points = turf.featureCollection([ + * const points = turf.featureCollection([ * turf.point([10.195312, 43.755225]), * turf.point([10.404052, 43.8424511]), * turf.point([10.579833, 43.659924]), @@ -26,10 +26,10 @@ import concaveman from "concaveman"; * turf.point([10.195312, 43.755225]) * ]); * - * var hull = turf.convex(points); + * const hull = turf.convex(points); * * //addToMap - * var addToMap = [points, hull] + * const addToMap = [points, hull] */ function convex

( geojson: AllGeoJSON, diff --git a/packages/turf-destination/README.md b/packages/turf-destination/README.md index c2f0f5880d..7323744507 100644 --- a/packages/turf-destination/README.md +++ b/packages/turf-destination/README.md @@ -15,26 +15,26 @@ This uses the [Haversine formula][2] to account for global curvature. * `bearing` **[number][4]** ranging from -180 to 180 * `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.units` **[string][6]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) - * `options.properties` **[Object][5]** Translate properties to Point (optional, default `{}`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.properties` **[GeoJsonProperties][6]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var point = turf.point([-75.343, 39.984]); -var distance = 50; -var bearing = 90; -var options = {units: 'miles'}; +const point = turf.point([-75.343, 39.984]); +const distance = 50; +const bearing = 90; +const options = {units: 'miles'}; -var destination = turf.destination(point, distance, bearing, options); +const destination = turf.destination(point, distance, bearing, options); //addToMap -var addToMap = [point, destination] +const addToMap = [point, destination] destination.properties['marker-color'] = '#f00'; point.properties['marker-color'] = '#0f0'; ``` -Returns **[Feature][7]<[Point][1]>** destination point +Returns **[Feature][6]<[Point][1]>** destination point [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -46,9 +46,7 @@ Returns **[Feature][7]<[Point][1]>** destination point [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[7]: https://tools.ietf.org/html/rfc7946#section-3.2 +[6]: https://tools.ietf.org/html/rfc7946#section-3.2 diff --git a/packages/turf-destination/index.ts b/packages/turf-destination/index.ts index a5352994cf..33e8123c92 100644 --- a/packages/turf-destination/index.ts +++ b/packages/turf-destination/index.ts @@ -21,19 +21,19 @@ import { getCoord } from "@turf/invariant"; * @param {number} distance distance from the origin point * @param {number} bearing ranging from -180 to 180 * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians - * @param {Object} [options.properties={}] Translate properties to Point + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} destination point * @example - * var point = turf.point([-75.343, 39.984]); - * var distance = 50; - * var bearing = 90; - * var options = {units: 'miles'}; + * const point = turf.point([-75.343, 39.984]); + * const distance = 50; + * const bearing = 90; + * const options = {units: 'miles'}; * - * var destination = turf.destination(point, distance, bearing, options); + * const destination = turf.destination(point, distance, bearing, options); * * //addToMap - * var addToMap = [point, destination] + * const addToMap = [point, destination] * destination.properties['marker-color'] = '#f00'; * point.properties['marker-color'] = '#0f0'; */ diff --git a/packages/turf-distance/README.md b/packages/turf-distance/README.md index f521aa5f8f..3399d594ab 100644 --- a/packages/turf-distance/README.md +++ b/packages/turf-distance/README.md @@ -13,24 +13,24 @@ This uses the [Haversine formula][2] to account for global curvature. * `to` **[Coord][1]** destination coordinate * `options` **[Object][3]** Optional parameters (optional, default `{}`) - * `options.units` **[string][4]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var from = turf.point([-75.343, 39.984]); -var to = turf.point([-75.534, 39.123]); -var options = {units: 'miles'}; +const from = turf.point([-75.343, 39.984]); +const to = turf.point([-75.534, 39.123]); +const options = {units: 'miles'}; -var distance = turf.distance(from, to, options); +const distance = turf.distance(from, to, options); //addToMap -var addToMap = [from, to]; +const addToMap = [from, to]; from.properties.distance = distance; to.properties.distance = distance; ``` -Returns **[number][5]** distance between the two coordinates +Returns **[number][4]** distance between the two coordinates [1]: https://tools.ietf.org/html/rfc7946#section-3.1.1 @@ -38,9 +38,7 @@ Returns **[number][5]** distance between the two coordinates [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/packages/turf-distance/index.ts b/packages/turf-distance/index.ts index b9f9771188..a3e1401520 100644 --- a/packages/turf-distance/index.ts +++ b/packages/turf-distance/index.ts @@ -12,17 +12,17 @@ import { radiansToLength, degreesToRadians, Coord, Units } from "@turf/helpers"; * @param {Coord} from origin coordinate * @param {Coord} to destination coordinate * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {number} distance between the two coordinates * @example - * var from = turf.point([-75.343, 39.984]); - * var to = turf.point([-75.534, 39.123]); - * var options = {units: 'miles'}; + * const from = turf.point([-75.343, 39.984]); + * const to = turf.point([-75.534, 39.123]); + * const options = {units: 'miles'}; * - * var distance = turf.distance(from, to, options); + * const distance = turf.distance(from, to, options); * * //addToMap - * var addToMap = [from, to]; + * const addToMap = [from, to]; * from.properties.distance = distance; * to.properties.distance = distance; */ diff --git a/packages/turf-ellipse/README.md b/packages/turf-ellipse/README.md index cb49376e9c..b54c68a91c 100644 --- a/packages/turf-ellipse/README.md +++ b/packages/turf-ellipse/README.md @@ -16,22 +16,22 @@ Takes a [Point][1] and calculates the ellipse polygon given two semi-axes expres * `options.angle` **[number][3]** angle of rotation in decimal degrees, positive clockwise (optional, default `0`) * `options.pivot` **[Coord][2]** point around which any rotation will be performed (optional, default `center`) * `options.steps` **[number][3]** number of steps (optional, default `64`) - * `options.units` **[string][5]** unit of measurement for axes (optional, default `'kilometers'`) - * `options.properties` **[Object][4]** properties (optional, default `{}`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var center = [-75, 40]; -var xSemiAxis = 5; -var ySemiAxis = 2; -var ellipse = turf.ellipse(center, xSemiAxis, ySemiAxis); +const center = [-75, 40]; +const xSemiAxis = 5; +const ySemiAxis = 2; +const ellipse = turf.ellipse(center, xSemiAxis, ySemiAxis); //addToMap -var addToMap = [turf.point(center), ellipse] +const addToMap = [turf.point(center), ellipse] ``` -Returns **[Feature][6]<[Polygon][7]>** ellipse polygon +Returns **[Feature][5]<[Polygon][6]>** ellipse polygon [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -41,11 +41,9 @@ Returns **[Feature][6]<[Polygon][7]>** ellipse polygon [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[5]: https://tools.ietf.org/html/rfc7946#section-3.2 -[6]: https://tools.ietf.org/html/rfc7946#section-3.2 - -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 diff --git a/packages/turf-ellipse/index.ts b/packages/turf-ellipse/index.ts index 06182b9721..38f1bfdbc0 100644 --- a/packages/turf-ellipse/index.ts +++ b/packages/turf-ellipse/index.ts @@ -21,17 +21,17 @@ import { GeoJsonProperties, Feature, Polygon } from "geojson"; * @param {number} [options.angle=0] angle of rotation in decimal degrees, positive clockwise * @param {Coord} [options.pivot=center] point around which any rotation will be performed * @param {number} [options.steps=64] number of steps - * @param {string} [options.units='kilometers'] unit of measurement for axes - * @param {Object} [options.properties={}] properties + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} ellipse polygon * @example - * var center = [-75, 40]; - * var xSemiAxis = 5; - * var ySemiAxis = 2; - * var ellipse = turf.ellipse(center, xSemiAxis, ySemiAxis); + * const center = [-75, 40]; + * const xSemiAxis = 5; + * const ySemiAxis = 2; + * const ellipse = turf.ellipse(center, xSemiAxis, ySemiAxis); * * //addToMap - * var addToMap = [turf.point(center), ellipse] + * const addToMap = [turf.point(center), ellipse] */ function ellipse( center: Coord, diff --git a/packages/turf-great-circle/README.md b/packages/turf-great-circle/README.md index 30eae73ae8..1f8c97ce51 100644 --- a/packages/turf-great-circle/README.md +++ b/packages/turf-great-circle/README.md @@ -15,24 +15,24 @@ then a `LineString` will be returned with duplicate coordinates the length of th * `end` **[Coord][3]** destination point feature * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][4]** line feature properties (optional, default `{}`) - * `options.npoints` **[number][5]** number of points (optional, default `100`) - * `options.offset` **[number][5]** offset controls the likelyhood that lines will + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) + * `options.npoints` **[number][6]** number of points (optional, default `100`) + * `options.offset` **[number][6]** offset controls the likelyhood that lines will be split which cross the dateline. The higher the number the more likely. (optional, default `10`) ### Examples ```javascript -var start = turf.point([-122, 48]); -var end = turf.point([-77, 39]); +const start = turf.point([-122, 48]); +const end = turf.point([-77, 39]); -var greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}}); +const greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}}); //addToMap -var addToMap = [start, end, greatCircle] +const addToMap = [start, end, greatCircle] ``` -Returns **[Feature][6]<([LineString][1] | [MultiLineString][2])>** great circle line feature +Returns **[Feature][5]<([LineString][1] | [MultiLineString][2])>** great circle line feature [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4 @@ -42,9 +42,9 @@ Returns **[Feature][6]<([LineString][1] | [MultiLineString][2])>** great circle [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[5]: https://tools.ietf.org/html/rfc7946#section-3.2 -[6]: https://tools.ietf.org/html/rfc7946#section-3.2 +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/packages/turf-great-circle/index.js b/packages/turf-great-circle/index.js index c7d36243e7..7d389b1f36 100644 --- a/packages/turf-great-circle/index.js +++ b/packages/turf-great-circle/index.js @@ -12,19 +12,19 @@ import { GreatCircle } from "./lib/arc.js"; * @param {Coord} start source point feature * @param {Coord} end destination point feature * @param {Object} [options={}] Optional parameters - * @param {Object} [options.properties={}] line feature properties + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @param {number} [options.npoints=100] number of points * @param {number} [options.offset=10] offset controls the likelyhood that lines will * be split which cross the dateline. The higher the number the more likely. * @returns {Feature} great circle line feature * @example - * var start = turf.point([-122, 48]); - * var end = turf.point([-77, 39]); + * const start = turf.point([-122, 48]); + * const end = turf.point([-77, 39]); * - * var greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}}); + * const greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}}); * * //addToMap - * var addToMap = [start, end, greatCircle] + * const addToMap = [start, end, greatCircle] */ function greatCircle(start, end, options) { // Optional parameters diff --git a/packages/turf-helpers/index.ts b/packages/turf-helpers/index.ts index 1348911fd1..dff233a0a0 100644 --- a/packages/turf-helpers/index.ts +++ b/packages/turf-helpers/index.ts @@ -15,7 +15,6 @@ import { GeoJsonProperties, } from "geojson"; -import { Id } from "./lib/geojson.js"; export * from "./lib/geojson.js"; /** @@ -178,7 +177,7 @@ export function feature< >( geom: G | null, properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { const feat: any = { type: "Feature" }; if (options.id === 0 || options.id) { @@ -254,7 +253,7 @@ export function geometry( export function point

( coordinates: Position, properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { if (!coordinates) { throw new Error("coordinates is required"); @@ -299,7 +298,7 @@ export function point

( export function points

( coordinates: Position[], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): FeatureCollection { return featureCollection( coordinates.map((coords) => { @@ -327,7 +326,7 @@ export function points

( export function polygon

( coordinates: Position[][], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { for (const ring of coordinates) { if (ring.length < 4) { @@ -375,7 +374,7 @@ export function polygon

( export function polygons

( coordinates: Position[][][], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): FeatureCollection { return featureCollection( coordinates.map((coords) => { @@ -405,7 +404,7 @@ export function polygons

( export function lineString

( coordinates: Position[], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { if (coordinates.length < 2) { throw new Error("coordinates must be an array of two or more positions"); @@ -439,7 +438,7 @@ export function lineString

( export function lineStrings

( coordinates: Position[][], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): FeatureCollection { return featureCollection( coordinates.map((coords) => { @@ -476,7 +475,7 @@ export function featureCollection< P extends GeoJsonProperties = GeoJsonProperties, >( features: Array>, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): FeatureCollection { const fc: any = { type: "FeatureCollection" }; if (options.id) { @@ -511,7 +510,7 @@ export function multiLineString< >( coordinates: Position[][], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { const geom: MultiLineString = { type: "MultiLineString", @@ -540,7 +539,7 @@ export function multiLineString< export function multiPoint

( coordinates: Position[], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { const geom: MultiPoint = { type: "MultiPoint", @@ -570,7 +569,7 @@ export function multiPoint

( export function multiPolygon

( coordinates: Position[][][], properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { const geom: MultiPolygon = { type: "MultiPolygon", @@ -604,7 +603,7 @@ export function geometryCollection< Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon >, properties?: P, - options: { bbox?: BBox; id?: Id } = {} + options: { bbox?: BBox; id?: string | number } = {} ): Feature { const geom: GeometryCollection = { type: "GeometryCollection", diff --git a/packages/turf-hex-grid/README.md b/packages/turf-hex-grid/README.md index c87c7a1c78..be1f067c20 100644 --- a/packages/turf-hex-grid/README.md +++ b/packages/turf-hex-grid/README.md @@ -15,22 +15,22 @@ described in [Hexagonal Grids][3]. radius of the circumcircle of the hexagons. * `options` **[Object][6]** Optional parameters (optional, default `{}`) - * `options.units` **[string][7]** used in calculating cell size, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) - * `options.properties` **[Object][6]** passed to each hexagon or triangle of the grid (optional, default `{}`) - * `options.mask` **[Feature][8]<[Polygon][2]>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * `options.triangles` **[boolean][9]** whether to return as triangles instead of hexagons (optional, default `false`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.properties` **[GeoJsonProperties][7]** Properties to set on returned feature (optional, default `{}`) + * `options.mask` **[Feature][7]<[Polygon][2]>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it + * `options.triangles` **[boolean][8]** whether to return as triangles instead of hexagons (optional, default `false`) ### Examples ```javascript -var bbox = [-96,31,-84,40]; -var cellSide = 50; -var options = {units: 'miles'}; +const bbox = [-96, 31, -84, 40]; +const cellSide = 50; +const options = {units: 'miles'}; -var hexgrid = turf.hexGrid(bbox, cellSide, options); +const hexgrid = turf.hexGrid(bbox, cellSide, options); //addToMap -var addToMap = [hexgrid]; +const addToMap = [hexgrid]; ``` Returns **[FeatureCollection][1]<[Polygon][2]>** a hexagonal grid @@ -47,11 +47,9 @@ Returns **[FeatureCollection][1]<[Polygon][2]>** a hexagonal grid [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[7]: https://tools.ietf.org/html/rfc7946#section-3.2 -[8]: https://tools.ietf.org/html/rfc7946#section-3.2 - -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean diff --git a/packages/turf-hex-grid/index.ts b/packages/turf-hex-grid/index.ts index acf7f8f19b..93149ad3c2 100644 --- a/packages/turf-hex-grid/index.ts +++ b/packages/turf-hex-grid/index.ts @@ -19,20 +19,20 @@ import { polygon, featureCollection, Units } from "@turf/helpers"; * @param {number} cellSide length of the side of the the hexagons or triangles, in units. It will also coincide with the * radius of the circumcircle of the hexagons. * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] used in calculating cell size, can be degrees, radians, miles, or kilometers - * @param {Object} [options.properties={}] passed to each hexagon or triangle of the grid + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @param {Feature} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it * @param {boolean} [options.triangles=false] whether to return as triangles instead of hexagons * @returns {FeatureCollection} a hexagonal grid * @example - * var bbox = [-96,31,-84,40]; - * var cellSide = 50; - * var options = {units: 'miles'}; + * const bbox = [-96, 31, -84, 40]; + * const cellSide = 50; + * const options = {units: 'miles'}; * - * var hexgrid = turf.hexGrid(bbox, cellSide, options); + * const hexgrid = turf.hexGrid(bbox, cellSide, options); * * //addToMap - * var addToMap = [hexgrid]; + * const addToMap = [hexgrid]; */ function hexGrid

( bbox: BBox, diff --git a/packages/turf-interpolate/README.md b/packages/turf-interpolate/README.md index e369e302cd..8a013b8031 100644 --- a/packages/turf-interpolate/README.md +++ b/packages/turf-interpolate/README.md @@ -14,24 +14,24 @@ Takes a set of points and estimates their 'property' values on a grid using the * `options.gridType` **[string][6]** defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') (optional, default `'square'`) * `options.property` **[string][6]** the property name in `points` from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. (optional, default `'elevation'`) - * `options.units` **[string][6]** used in calculating cellSize, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) * `options.weight` **[number][4]** exponent regulating the distance-decay weighting (optional, default `1`) * `options.bbox` **[BBox][7]** Bounding Box Array \[west, south, east, north] associated with the FeatureCollection. (optional, default `bbox(points)`) ### Examples ```javascript -var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]}); +const points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]}); // add a random property to each point turf.featureEach(points, function(point) { point.properties.solRad = Math.random() * 50; }); -var options = {gridType: 'points', property: 'solRad', units: 'miles'}; -var grid = turf.interpolate(points, 100, options); +const options = {gridType: 'points', property: 'solRad', units: 'miles'}; +const grid = turf.interpolate(points, 100, options); //addToMap -var addToMap = [grid]; +const addToMap = [grid]; ``` Returns **[FeatureCollection][2]<([Point][3] | [Polygon][8])>** grid of points or polygons with interpolated 'property' diff --git a/packages/turf-interpolate/index.js b/packages/turf-interpolate/index.js index 426ee7ca96..b76f225fc9 100644 --- a/packages/turf-interpolate/index.js +++ b/packages/turf-interpolate/index.js @@ -19,22 +19,22 @@ import { collectionOf } from "@turf/invariant"; * @param {Object} [options={}] Optional parameters * @param {string} [options.gridType='square'] defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') * @param {string} [options.property='elevation'] the property name in `points` from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. - * @param {string} [options.units='kilometers'] used in calculating cellSize, can be degrees, radians, miles, or kilometers + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @param {number} [options.weight=1] exponent regulating the distance-decay weighting * @param {BBox} [options.bbox=bbox(points)] Bounding Box Array [west, south, east, north] associated with the FeatureCollection. * @returns {FeatureCollection} grid of points or polygons with interpolated 'property' * @example - * var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]}); + * const points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]}); * * // add a random property to each point * turf.featureEach(points, function(point) { * point.properties.solRad = Math.random() * 50; * }); - * var options = {gridType: 'points', property: 'solRad', units: 'miles'}; - * var grid = turf.interpolate(points, 100, options); + * const options = {gridType: 'points', property: 'solRad', units: 'miles'}; + * const grid = turf.interpolate(points, 100, options); * * //addToMap - * var addToMap = [grid]; + * const addToMap = [grid]; */ function interpolate(points, cellSize, options) { // Optional parameters diff --git a/packages/turf-intersect/README.md b/packages/turf-intersect/README.md index cfbd2f83b7..903c06a580 100644 --- a/packages/turf-intersect/README.md +++ b/packages/turf-intersect/README.md @@ -12,12 +12,12 @@ finds their polygonal intersection. If they don't intersect, returns null. * `features` **[FeatureCollection][3]<([Polygon][1] | [MultiPolygon][2])>** the features to intersect * `options` **[Object][4]** Optional Parameters (optional, default `{}`) - * `options.properties` **[Object][4]** Translate GeoJSON Properties to Feature (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var poly1 = turf.polygon([[ +const poly1 = turf.polygon([[ [-122.801742, 45.48565], [-122.801742, 45.60491], [-122.584762, 45.60491], @@ -25,7 +25,7 @@ var poly1 = turf.polygon([[ [-122.801742, 45.48565] ]]); -var poly2 = turf.polygon([[ +const poly2 = turf.polygon([[ [-122.520217, 45.535693], [-122.64038, 45.553967], [-122.720031, 45.526554], @@ -36,10 +36,10 @@ var poly2 = turf.polygon([[ [-122.520217, 45.535693] ]]); -var intersection = turf.intersect(turf.featureCollection([poly1, poly2])); +const intersection = turf.intersect(turf.featureCollection([poly1, poly2])); //addToMap -var addToMap = [poly1, poly2, intersection]; +const addToMap = [poly1, poly2, intersection]; ``` Returns **([Feature][5] | null)** returns a feature representing the area they share (either a [Polygon][1] or diff --git a/packages/turf-intersect/index.ts b/packages/turf-intersect/index.ts index 55a2d74cd7..5931a8b0ba 100644 --- a/packages/turf-intersect/index.ts +++ b/packages/turf-intersect/index.ts @@ -16,11 +16,11 @@ import * as polyclip from "polyclip-ts"; * @function * @param {FeatureCollection} features the features to intersect * @param {Object} [options={}] Optional Parameters - * @param {Object} [options.properties={}] Translate GeoJSON Properties to Feature + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature|null} returns a feature representing the area they share (either a {@link Polygon} or * {@link MultiPolygon}). If they do not share any area, returns `null`. * @example - * var poly1 = turf.polygon([[ + * const poly1 = turf.polygon([[ * [-122.801742, 45.48565], * [-122.801742, 45.60491], * [-122.584762, 45.60491], @@ -28,7 +28,7 @@ import * as polyclip from "polyclip-ts"; * [-122.801742, 45.48565] * ]]); * - * var poly2 = turf.polygon([[ + * const poly2 = turf.polygon([[ * [-122.520217, 45.535693], * [-122.64038, 45.553967], * [-122.720031, 45.526554], @@ -39,10 +39,10 @@ import * as polyclip from "polyclip-ts"; * [-122.520217, 45.535693] * ]]); * - * var intersection = turf.intersect(turf.featureCollection([poly1, poly2])); + * const intersection = turf.intersect(turf.featureCollection([poly1, poly2])); * * //addToMap - * var addToMap = [poly1, poly2, intersection]; + * const addToMap = [poly1, poly2, intersection]; */ function intersect

( features: FeatureCollection, diff --git a/packages/turf-isobands/lib/matrix-to-grid.js b/packages/turf-isobands/lib/matrix-to-grid.js index bd63fb9d1c..b5de3a4bf0 100644 --- a/packages/turf-isobands/lib/matrix-to-grid.js +++ b/packages/turf-isobands/lib/matrix-to-grid.js @@ -11,13 +11,13 @@ import { rhumbDestination } from "@turf/rhumb-destination"; * @param {number} cellSize the distance across each cell * @param {Object} [options={}] optional parameters * @param {string} [options.zProperty='elevation'] the grid points property name associated with the matrix value - * @param {Object} [options.properties={}] GeoJSON properties passed to all the points - * @param {string} [options.units='kilometers'] used in calculating cellSize, can be miles, or kilometers + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {FeatureCollection} grid of points * * @example - * var matrixToGrid = require('matrix-to-grid'); - * var matrix = [ + * const matrixToGrid = require('matrix-to-grid'); + * const matrix = [ * [ 1, 13, 20, 9, 10, 13, 18], * [34, 8, 0, 4, 5, 8, 13], * [10, 5, 2, 1, 2, 5, 24], @@ -27,7 +27,7 @@ import { rhumbDestination } from "@turf/rhumb-destination"; * [ 3, 13, 0, 9, 5, 13, 35], * [18, 13, 10, 9, 78, 13, 18] * ]; - * var origin = [-70.823364, -33.553984] + * const origin = [-70.823364, -33.553984] * matrixToGrid(matrix, origin, 10); * //= pointGrid */ diff --git a/packages/turf-isolines/lib/matrix-to-grid.js b/packages/turf-isolines/lib/matrix-to-grid.js index bd63fb9d1c..b5de3a4bf0 100644 --- a/packages/turf-isolines/lib/matrix-to-grid.js +++ b/packages/turf-isolines/lib/matrix-to-grid.js @@ -11,13 +11,13 @@ import { rhumbDestination } from "@turf/rhumb-destination"; * @param {number} cellSize the distance across each cell * @param {Object} [options={}] optional parameters * @param {string} [options.zProperty='elevation'] the grid points property name associated with the matrix value - * @param {Object} [options.properties={}] GeoJSON properties passed to all the points - * @param {string} [options.units='kilometers'] used in calculating cellSize, can be miles, or kilometers + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {FeatureCollection} grid of points * * @example - * var matrixToGrid = require('matrix-to-grid'); - * var matrix = [ + * const matrixToGrid = require('matrix-to-grid'); + * const matrix = [ * [ 1, 13, 20, 9, 10, 13, 18], * [34, 8, 0, 4, 5, 8, 13], * [10, 5, 2, 1, 2, 5, 24], @@ -27,7 +27,7 @@ import { rhumbDestination } from "@turf/rhumb-destination"; * [ 3, 13, 0, 9, 5, 13, 35], * [18, 13, 10, 9, 78, 13, 18] * ]; - * var origin = [-70.823364, -33.553984] + * const origin = [-70.823364, -33.553984] * matrixToGrid(matrix, origin, 10); * //= pointGrid */ diff --git a/packages/turf-length/README.md b/packages/turf-length/README.md index 6a280be539..43e275749c 100644 --- a/packages/turf-length/README.md +++ b/packages/turf-length/README.md @@ -11,20 +11,20 @@ Takes a [GeoJSON][1] and measures its length in the specified units, [(Multi)Poi * `geojson` **[Feature][3]<([LineString][4] | [MultiLineString][5])>** GeoJSON to measure * `options` **[Object][6]** Optional parameters (optional, default `{}`) - * `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `kilometers`) ### Examples ```javascript -var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]); -var length = turf.length(line, {units: 'miles'}); +const line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]); +const length = turf.length(line, {units: 'miles'}); //addToMap -var addToMap = [line]; +const addToMap = [line]; line.properties.distance = length; ``` -Returns **[number][8]** length of GeoJSON +Returns **[number][7]** length of GeoJSON [1]: https://tools.ietf.org/html/rfc7946#section-3 @@ -38,9 +38,7 @@ Returns **[number][8]** length of GeoJSON [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/packages/turf-length/index.ts b/packages/turf-length/index.ts index fb861fc33b..0651b50895 100644 --- a/packages/turf-length/index.ts +++ b/packages/turf-length/index.ts @@ -9,14 +9,14 @@ import { segmentReduce } from "@turf/meta"; * @function * @param {Feature} geojson GeoJSON to measure * @param {Object} [options={}] Optional parameters - * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers + * @param {Units} [options.units=kilometers] Units in which linear values are expressed * @returns {number} length of GeoJSON * @example - * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]); - * var length = turf.length(line, {units: 'miles'}); + * const line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]); + * const length = turf.length(line, {units: 'miles'}); * * //addToMap - * var addToMap = [line]; + * const addToMap = [line]; * line.properties.distance = length; */ function length( diff --git a/packages/turf-line-arc/README.md b/packages/turf-line-arc/README.md index 0a8327926e..daea8b01ea 100644 --- a/packages/turf-line-arc/README.md +++ b/packages/turf-line-arc/README.md @@ -16,23 +16,23 @@ Creates a circular arc, of a circle of the given radius and center point, betwee * `options` **[Object][3]** Optional parameters (optional, default `{}`) * `options.steps` **[number][2]** number of steps (straight segments) that will constitute the arc (optional, default `64`) - * `options.units` **[string][4]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var center = turf.point([-75, 40]); -var radius = 5; -var bearing1 = 25; -var bearing2 = 47; +const center = turf.point([-75, 40]); +const radius = 5; +const bearing1 = 25; +const bearing2 = 47; -var arc = turf.lineArc(center, radius, bearing1, bearing2); +const arc = turf.lineArc(center, radius, bearing1, bearing2); //addToMap -var addToMap = [center, arc] +const addToMap = [center, arc] ``` -Returns **[Feature][5]<[LineString][6]>** line arc +Returns **[Feature][4]<[LineString][5]>** line arc [1]: https://tools.ietf.org/html/rfc7946#section-3.1.1 @@ -40,11 +40,9 @@ Returns **[Feature][5]<[LineString][6]>** line arc [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[4]: https://tools.ietf.org/html/rfc7946#section-3.2 -[5]: https://tools.ietf.org/html/rfc7946#section-3.2 - -[6]: https://tools.ietf.org/html/rfc7946#section-3.1.4 +[5]: https://tools.ietf.org/html/rfc7946#section-3.1.4 diff --git a/packages/turf-line-arc/index.ts b/packages/turf-line-arc/index.ts index 5c988589aa..29910416c0 100644 --- a/packages/turf-line-arc/index.ts +++ b/packages/turf-line-arc/index.ts @@ -14,18 +14,18 @@ import { Coord, lineString, Units } from "@turf/helpers"; * @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc * @param {Object} [options={}] Optional parameters * @param {number} [options.steps=64] number of steps (straight segments) that will constitute the arc - * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {Feature} line arc * @example - * var center = turf.point([-75, 40]); - * var radius = 5; - * var bearing1 = 25; - * var bearing2 = 47; + * const center = turf.point([-75, 40]); + * const radius = 5; + * const bearing1 = 25; + * const bearing2 = 47; * - * var arc = turf.lineArc(center, radius, bearing1, bearing2); + * const arc = turf.lineArc(center, radius, bearing1, bearing2); * * //addToMap - * var addToMap = [center, arc] + * const addToMap = [center, arc] */ function lineArc( center: Coord, diff --git a/packages/turf-line-chunk/README.md b/packages/turf-line-chunk/README.md index ef0b74797d..571dc99976 100644 --- a/packages/turf-line-chunk/README.md +++ b/packages/turf-line-chunk/README.md @@ -13,18 +13,18 @@ If the line is shorter than the segment length then the original line is returne * `segmentLength` **[number][6]** how long to make each segment * `options` **[Object][7]** Optional parameters (optional, default `{}`) - * `options.units` **[string][8]** units can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) - * `options.reverse` **[boolean][9]** reverses coordinates to start the first chunked segment at the end (optional, default `false`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.reverse` **[boolean][8]** reverses coordinates to start the first chunked segment at the end (optional, default `false`) ### Examples ```javascript -var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]); +const line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]); -var chunk = turf.lineChunk(line, 15, {units: 'miles'}); +const chunk = turf.lineChunk(line, 15, {units: 'miles'}); //addToMap -var addToMap = [chunk]; +const addToMap = [chunk]; ``` Returns **[FeatureCollection][2]<[LineString][1]>** collection of line segments @@ -43,9 +43,7 @@ Returns **[FeatureCollection][2]<[LineString][1]>** collection of line segments [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean diff --git a/packages/turf-line-chunk/index.js b/packages/turf-line-chunk/index.js index 02b6a0a266..e0d1b0ea5f 100644 --- a/packages/turf-line-chunk/index.js +++ b/packages/turf-line-chunk/index.js @@ -11,16 +11,16 @@ import { featureCollection, isObject } from "@turf/helpers"; * @param {FeatureCollection|Geometry|Feature} geojson the lines to split * @param {number} segmentLength how long to make each segment * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] units can be degrees, radians, miles, or kilometers + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @param {boolean} [options.reverse=false] reverses coordinates to start the first chunked segment at the end * @returns {FeatureCollection} collection of line segments * @example - * var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]); + * const line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]); * - * var chunk = turf.lineChunk(line, 15, {units: 'miles'}); + * const chunk = turf.lineChunk(line, 15, {units: 'miles'}); * * //addToMap - * var addToMap = [chunk]; + * const addToMap = [chunk]; */ function lineChunk(geojson, segmentLength, options) { // Optional parameters diff --git a/packages/turf-line-offset/README.md b/packages/turf-line-offset/README.md index 3301253d70..a188a82ac3 100644 --- a/packages/turf-line-offset/README.md +++ b/packages/turf-line-offset/README.md @@ -12,17 +12,17 @@ Takes a [line][1] and returns a [line][1] at offset by the specified distance. * `distance` **[number][5]** distance to offset the line (can be of negative value) * `options` **[Object][6]** Optional parameters (optional, default `{}`) - * `options.units` **[string][7]** can be degrees, radians, miles, kilometers, inches, yards, meters (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" }); +const line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" }); -var offsetLine = turf.lineOffset(line, 2, {units: 'miles'}); +const offsetLine = turf.lineOffset(line, 2, {units: 'miles'}); //addToMap -var addToMap = [offsetLine, line] +const addToMap = [offsetLine, line] offsetLine.properties.stroke = "#00F" ``` @@ -40,8 +40,6 @@ Returns **[Feature][3]<([LineString][1] | [MultiLineString][4])>** Line offset f [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - --- diff --git a/packages/turf-line-offset/index.js b/packages/turf-line-offset/index.js index 583d17816a..a1e87190cc 100644 --- a/packages/turf-line-offset/index.js +++ b/packages/turf-line-offset/index.js @@ -15,15 +15,15 @@ import { intersection } from "./lib/intersection.js"; * @param {Geometry|Feature} geojson input GeoJSON * @param {number} distance distance to offset the line (can be of negative value) * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] can be degrees, radians, miles, kilometers, inches, yards, meters + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {Feature} Line offset from the input line * @example - * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" }); + * const line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" }); * - * var offsetLine = turf.lineOffset(line, 2, {units: 'miles'}); + * const offsetLine = turf.lineOffset(line, 2, {units: 'miles'}); * * //addToMap - * var addToMap = [offsetLine, line] + * const addToMap = [offsetLine, line] * offsetLine.properties.stroke = "#00F" */ function lineOffset(geojson, distance, options) { diff --git a/packages/turf-line-slice-along/README.md b/packages/turf-line-slice-along/README.md index 4fddeb597c..c7871ca7cb 100644 --- a/packages/turf-line-slice-along/README.md +++ b/packages/turf-line-slice-along/README.md @@ -17,18 +17,18 @@ This can be useful for extracting only the part of a route between two distances * `stopDist` **[number][4]** distance along the line to ending point * `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.units` **[string][6]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var line = turf.lineString([[7, 45], [9, 45], [14, 40], [14, 41]]); -var start = 12.5; -var stop = 25; -var sliced = turf.lineSliceAlong(line, start, stop, {units: 'miles'}); +const line = turf.lineString([[7, 45], [9, 45], [14, 40], [14, 41]]); +const start = 12.5; +const stop = 25; +const sliced = turf.lineSliceAlong(line, start, stop, {units: 'miles'}); //addToMap -var addToMap = [line, start, stop, sliced] +const addToMap = [line, start, stop, sliced] ``` Returns **[Feature][3]<[LineString][1]>** sliced line @@ -43,8 +43,6 @@ Returns **[Feature][3]<[LineString][1]>** sliced line [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - --- diff --git a/packages/turf-line-slice-along/index.js b/packages/turf-line-slice-along/index.js index d26d00d7e5..1505660cea 100644 --- a/packages/turf-line-slice-along/index.js +++ b/packages/turf-line-slice-along/index.js @@ -15,16 +15,16 @@ import { lineString, isObject } from "@turf/helpers"; * @param {number} startDist distance along the line to starting point * @param {number} stopDist distance along the line to ending point * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {Feature} sliced line * @example - * var line = turf.lineString([[7, 45], [9, 45], [14, 40], [14, 41]]); - * var start = 12.5; - * var stop = 25; - * var sliced = turf.lineSliceAlong(line, start, stop, {units: 'miles'}); + * const line = turf.lineString([[7, 45], [9, 45], [14, 40], [14, 41]]); + * const start = 12.5; + * const stop = 25; + * const sliced = turf.lineSliceAlong(line, start, stop, {units: 'miles'}); * * //addToMap - * var addToMap = [line, start, stop, sliced] + * const addToMap = [line, start, stop, sliced] */ function lineSliceAlong(line, startDist, stopDist, options) { // Optional parameters diff --git a/packages/turf-line-to-polygon/README.md b/packages/turf-line-to-polygon/README.md index 93e53f3a13..07e17afb58 100644 --- a/packages/turf-line-to-polygon/README.md +++ b/packages/turf-line-to-polygon/README.md @@ -11,7 +11,7 @@ Converts (Multi)LineString(s) to Polygon(s). * `lines` **([FeatureCollection][1] | [Feature][2]<([LineString][3] | [MultiLineString][4])>)** Features to convert * `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][5]** translates GeoJSON properties to Feature (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][2]** Properties to set on returned feature (optional, default `{}`) * `options.autoComplete` **[boolean][6]** auto complete linestrings (matches first & last coordinates) (optional, default `true`) * `options.orderCoords` **[boolean][6]** sorts linestrings to place outer ring at the first position of the coordinates (optional, default `true`) * `options.mutate` **[boolean][6]** mutate the original linestring using autoComplete (matches first & last coordinates) (optional, default `false`) @@ -19,12 +19,12 @@ Converts (Multi)LineString(s) to Polygon(s). ### Examples ```javascript -var line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]); +const line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]); -var polygon = turf.lineToPolygon(line); +const polygon = turf.lineToPolygon(line); //addToMap -var addToMap = [polygon]; +const addToMap = [polygon]; ``` Returns **[Feature][2]<([Polygon][7] | [MultiPolygon][8])>** converted to Polygons diff --git a/packages/turf-line-to-polygon/index.ts b/packages/turf-line-to-polygon/index.ts index cdf859cf16..1772aa0fc3 100644 --- a/packages/turf-line-to-polygon/index.ts +++ b/packages/turf-line-to-polygon/index.ts @@ -18,18 +18,18 @@ import { clone } from "@turf/clone"; * @function * @param {FeatureCollection|Feature} lines Features to convert * @param {Object} [options={}] Optional parameters - * @param {Object} [options.properties={}] translates GeoJSON properties to Feature + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @param {boolean} [options.autoComplete=true] auto complete linestrings (matches first & last coordinates) * @param {boolean} [options.orderCoords=true] sorts linestrings to place outer ring at the first position of the coordinates * @param {boolean} [options.mutate=false] mutate the original linestring using autoComplete (matches first & last coordinates) * @returns {Feature} converted to Polygons * @example - * var line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]); + * const line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]); * - * var polygon = turf.lineToPolygon(line); + * const polygon = turf.lineToPolygon(line); * * //addToMap - * var addToMap = [polygon]; + * const addToMap = [polygon]; */ function lineToPolygon( lines: Feature | FeatureCollection | G, diff --git a/packages/turf-meta/README.md b/packages/turf-meta/README.md index 95dc11e476..d73c1c0e60 100644 --- a/packages/turf-meta/README.md +++ b/packages/turf-meta/README.md @@ -765,14 +765,14 @@ Point & MultiPoint will always return null. * `options.multiFeatureIndex` **[number][3]** Multi-Feature Index (optional, default `0`) * `options.geometryIndex` **[number][3]** Geometry Index (optional, default `0`) * `options.segmentIndex` **[number][3]** Segment Index (optional, default `0`) - * `options.properties` **[Object][24]** Translate Properties to output LineString (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][7]** Properties to set on returned feature (optional, default `{}`) * `options.bbox` **[BBox][15]** Translate BBox to output LineString (optional, default `{}`) * `options.id` **([number][3] | [string][25])** Translate Id to output LineString (optional, default `{}`) ### Examples ```javascript -var multiLine = turf.multiLineString([ +const multiLine = turf.multiLineString([ [[10, 10], [50, 30], [30, 40]], [[-10, -10], [-50, -30], [-30, -40]] ]); @@ -807,7 +807,7 @@ Negative indexes are permitted. * `options.multiFeatureIndex` **[number][3]** Multi-Feature Index (optional, default `0`) * `options.geometryIndex` **[number][3]** Geometry Index (optional, default `0`) * `options.coordIndex` **[number][3]** Coord Index (optional, default `0`) - * `options.properties` **[Object][24]** Translate Properties to output Point (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][7]** Properties to set on returned feature (optional, default `{}`) * `options.bbox` **[BBox][15]** Translate BBox to output Point (optional, default `{}`) * `options.id` **([number][3] | [string][25])** Translate Id to output Point (optional, default `{}`) diff --git a/packages/turf-meta/index.d.ts b/packages/turf-meta/index.d.ts index 4fbab38490..d841951522 100644 --- a/packages/turf-meta/index.d.ts +++ b/packages/turf-meta/index.d.ts @@ -12,7 +12,7 @@ import { GeoJsonProperties, BBox, } from "geojson"; -import { AllGeoJSON, Lines, Id } from "@turf/helpers"; +import { AllGeoJSON, Lines } from "@turf/helpers"; /** * http://turfjs.org/docs/#coordreduce @@ -128,7 +128,7 @@ declare function geomReduce< featureIndex: number, featureProperties: P, featureBBox: BBox, - featureId: Id + featureId: string | number ) => Reducer, initialValue?: Reducer ): Reducer; @@ -151,7 +151,7 @@ declare function geomEach< featureIndex: number, featureProperties: P, featureBBox: BBox, - featureId: Id + featureId: string | number ) => void ): void; @@ -292,7 +292,7 @@ declare function findSegment< segmentIndex?: number; properties?: P; bbox?: BBox; - id?: Id; + id?: string | number; } ): Feature; @@ -311,7 +311,7 @@ declare function findPoint< coordIndex?: number; properties?: P; bbox?: BBox; - id?: Id; + id?: string | number; } ): Feature; diff --git a/packages/turf-meta/index.js b/packages/turf-meta/index.js index d1fe722c83..94c0255f2c 100644 --- a/packages/turf-meta/index.js +++ b/packages/turf-meta/index.js @@ -1184,12 +1184,12 @@ function lineReduce(geojson, callback, initialValue) { * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index * @param {number} [options.geometryIndex=0] Geometry Index * @param {number} [options.segmentIndex=0] Segment Index - * @param {Object} [options.properties={}] Translate Properties to output LineString + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @param {BBox} [options.bbox={}] Translate BBox to output LineString * @param {number|string} [options.id={}] Translate Id to output LineString * @returns {Feature} 2-vertex GeoJSON Feature LineString * @example - * var multiLine = turf.multiLineString([ + * const multiLine = turf.multiLineString([ * [[10, 10], [50, 30], [30, 40]], * [[-10, -10], [-50, -30], [-30, -40]] * ]); @@ -1313,7 +1313,7 @@ function findSegment(geojson, options) { * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index * @param {number} [options.geometryIndex=0] Geometry Index * @param {number} [options.coordIndex=0] Coord Index - * @param {Object} [options.properties={}] Translate Properties to output Point + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @param {BBox} [options.bbox={}] Translate BBox to output Point * @param {number|string} [options.id={}] Translate Id to output Point * @returns {Feature} 2-vertex GeoJSON Feature Point diff --git a/packages/turf-nearest-neighbor-analysis/README.md b/packages/turf-nearest-neighbor-analysis/README.md index 0536682bd9..6ef21578ee 100644 --- a/packages/turf-nearest-neighbor-analysis/README.md +++ b/packages/turf-nearest-neighbor-analysis/README.md @@ -71,17 +71,17 @@ Measure of Spatial Relationships in Populations,” *Ecology* 35, no. 4 * `options` **[Object][1]** Optional parameters (optional, default `{}`) * `options.studyArea` **[Feature][4]<[Polygon][6]>?** polygon representing the study area - * `options.properties` **[GeoJsonProperties][4]** properties (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][4]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var bbox = [-65, 40, -63, 42]; -var dataset = turf.randomPoint(100, { bbox: bbox }); -var nearestNeighborStudyArea = turf.nearestNeighborAnalysis(dataset); +const bbox = [-65, 40, -63, 42]; +const dataset = turf.randomPoint(100, { bbox: bbox }); +const nearestNeighborStudyArea = turf.nearestNeighborAnalysis(dataset); //addToMap -var addToMap = [dataset, nearestNeighborStudyArea]; +const addToMap = [dataset, nearestNeighborStudyArea]; ``` Returns **[NearestNeighborStudyArea][11]** A polygon of the study area or an approximation of one. diff --git a/packages/turf-nearest-neighbor-analysis/index.ts b/packages/turf-nearest-neighbor-analysis/index.ts index fbde954cc7..9580f3459a 100644 --- a/packages/turf-nearest-neighbor-analysis/index.ts +++ b/packages/turf-nearest-neighbor-analysis/index.ts @@ -95,15 +95,15 @@ interface NearestNeighborStudyArea extends Feature { * @param {Object} [options={}] Optional parameters * @param {Feature} [options.studyArea] polygon representing the study area * @param {Units & AreaUnits} [options.units='kilometers'] unit of measurement for distances and, squared, area. - * @param {GeoJsonProperties} [options.properties={}] properties + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {NearestNeighborStudyArea} A polygon of the study area or an approximation of one. * @example - * var bbox = [-65, 40, -63, 42]; - * var dataset = turf.randomPoint(100, { bbox: bbox }); - * var nearestNeighborStudyArea = turf.nearestNeighborAnalysis(dataset); + * const bbox = [-65, 40, -63, 42]; + * const dataset = turf.randomPoint(100, { bbox: bbox }); + * const nearestNeighborStudyArea = turf.nearestNeighborAnalysis(dataset); * * //addToMap - * var addToMap = [dataset, nearestNeighborStudyArea]; + * const addToMap = [dataset, nearestNeighborStudyArea]; */ function nearestNeighborAnalysis( dataset: FeatureCollection, diff --git a/packages/turf-nearest-point-on-line/README.md b/packages/turf-nearest-point-on-line/README.md index 15c0261407..5b818d1870 100644 --- a/packages/turf-nearest-point-on-line/README.md +++ b/packages/turf-nearest-point-on-line/README.md @@ -12,12 +12,12 @@ Returns the nearest point on a line to a given point. * `pt` **([Geometry][1] | [Feature][2]<[Point][5]> | [Array][6]<[number][7]>)** point to snap from * `options` **[Object][8]** Optional parameters (optional, default `{}`) - * `options.units` **[string][9]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var line = turf.lineString([ +const line = turf.lineString([ [-77.031669, 38.878605], [-77.029609, 38.881946], [-77.020339, 38.884084], @@ -25,12 +25,12 @@ var line = turf.lineString([ [-77.021884, 38.889563], [-77.019824, 38.892368] ]); -var pt = turf.point([-77.037076, 38.884017]); +const pt = turf.point([-77.037076, 38.884017]); -var snapped = turf.nearestPointOnLine(line, pt, {units: 'miles'}); +const snapped = turf.nearestPointOnLine(line, pt, {units: 'miles'}); //addToMap -var addToMap = [line, pt, snapped]; +const addToMap = [line, pt, snapped]; snapped.properties['marker-color'] = '#00f'; ``` @@ -52,8 +52,6 @@ Returns **[Feature][2]<[Point][5]>** closest point on the `line` to `point`. The [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - --- diff --git a/packages/turf-nearest-point-on-line/index.ts b/packages/turf-nearest-point-on-line/index.ts index 1b75bd172d..d591988e25 100644 --- a/packages/turf-nearest-point-on-line/index.ts +++ b/packages/turf-nearest-point-on-line/index.ts @@ -17,10 +17,10 @@ import { getCoord, getCoords } from "@turf/invariant"; * @param {Geometry|Feature} lines lines to snap to * @param {Geometry|Feature|number[]} pt point to snap from * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {Feature} closest point on the `line` to `point`. The properties object will contain four values: `index`: closest point was found on nth line part, `multiFeatureIndex`: closest point was found on the nth line of the `MultiLineString`, `dist`: distance between pt and the closest point, `location`: distance along the line between start and the closest point. * @example - * var line = turf.lineString([ + * const line = turf.lineString([ * [-77.031669, 38.878605], * [-77.029609, 38.881946], * [-77.020339, 38.884084], @@ -28,12 +28,12 @@ import { getCoord, getCoords } from "@turf/invariant"; * [-77.021884, 38.889563], * [-77.019824, 38.892368] * ]); - * var pt = turf.point([-77.037076, 38.884017]); + * const pt = turf.point([-77.037076, 38.884017]); * - * var snapped = turf.nearestPointOnLine(line, pt, {units: 'miles'}); + * const snapped = turf.nearestPointOnLine(line, pt, {units: 'miles'}); * * //addToMap - * var addToMap = [line, pt, snapped]; + * const addToMap = [line, pt, snapped]; * snapped.properties['marker-color'] = '#00f'; */ function nearestPointOnLine( diff --git a/packages/turf-nearest-point-to-line/README.md b/packages/turf-nearest-point-to-line/README.md index 2355437467..e7b06e2495 100644 --- a/packages/turf-nearest-point-to-line/README.md +++ b/packages/turf-nearest-point-to-line/README.md @@ -13,22 +13,21 @@ to a [line][3]. The returned point has a `dist` property indicating its distance * `line` **([Feature][5] | [Geometry][6]<[LineString][3]>)** Line Feature * `options` **[Object][7]?** Optional parameters (optional, default `{}`) - * `options.units` **[string][8]** unit of the output distance property - (eg: degrees, radians, miles, or kilometers) (optional, default `'kilometers'`) - * `options.properties` **[Object][7]** Translate Properties to Point (optional, default `{}`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var pt1 = turf.point([0, 0]); -var pt2 = turf.point([0.5, 0.5]); -var points = turf.featureCollection([pt1, pt2]); -var line = turf.lineString([[1,1], [-1,1]]); +const pt1 = turf.point([0, 0]); +const pt2 = turf.point([0.5, 0.5]); +const points = turf.featureCollection([pt1, pt2]); +const line = turf.lineString([[1,1], [-1,1]]); -var nearest = turf.nearestPointToLine(points, line); +const nearest = turf.nearestPointToLine(points, line); //addToMap -var addToMap = [nearest, line]; +const addToMap = [nearest, line]; ``` Returns **[Feature][5]<[Point][1]>** the closest point @@ -47,8 +46,6 @@ Returns **[Feature][5]<[Point][1]>** the closest point [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - --- diff --git a/packages/turf-nearest-point-to-line/index.ts b/packages/turf-nearest-point-to-line/index.ts index 8b647218c0..f8180ee0ba 100644 --- a/packages/turf-nearest-point-to-line/index.ts +++ b/packages/turf-nearest-point-to-line/index.ts @@ -19,20 +19,19 @@ import { pointToLineDistance } from "@turf/point-to-line-distance"; * @param {FeatureCollection|GeometryCollection} points Point Collection * @param {Feature|Geometry} line Line Feature * @param {Object} [options] Optional parameters - * @param {string} [options.units='kilometers'] unit of the output distance property - * (eg: degrees, radians, miles, or kilometers) - * @param {Object} [options.properties={}] Translate Properties to Point + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} the closest point * @example - * var pt1 = turf.point([0, 0]); - * var pt2 = turf.point([0.5, 0.5]); - * var points = turf.featureCollection([pt1, pt2]); - * var line = turf.lineString([[1,1], [-1,1]]); + * const pt1 = turf.point([0, 0]); + * const pt2 = turf.point([0.5, 0.5]); + * const points = turf.featureCollection([pt1, pt2]); + * const line = turf.lineString([[1,1], [-1,1]]); * - * var nearest = turf.nearestPointToLine(points, line); + * const nearest = turf.nearestPointToLine(points, line); * * //addToMap - * var addToMap = [nearest, line]; + * const addToMap = [nearest, line]; */ function nearestPointToLine

( points: diff --git a/packages/turf-nearest-point/README.md b/packages/turf-nearest-point/README.md index 818a71afb4..2973a34234 100644 --- a/packages/turf-nearest-point/README.md +++ b/packages/turf-nearest-point/README.md @@ -15,26 +15,26 @@ is geodesic. * `points` **[FeatureCollection][3]<[Point][1]>** against input point set * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.units` **[string][5]** the units of the numeric result (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) ### Examples ```javascript -var targetPoint = turf.point([28.965797, 41.010086], {"marker-color": "#0F0"}); -var points = turf.featureCollection([ +const targetPoint = turf.point([28.965797, 41.010086], {"marker-color": "#0F0"}); +const points = turf.featureCollection([ turf.point([28.973865, 41.011122]), turf.point([28.948459, 41.024204]), turf.point([28.938674, 41.013324]) ]); -var nearest = turf.nearestPoint(targetPoint, points); +const nearest = turf.nearestPoint(targetPoint, points); //addToMap -var addToMap = [targetPoint, points, nearest]; +const addToMap = [targetPoint, points, nearest]; nearest.properties['marker-color'] = '#F00'; ``` -Returns **[Feature][6]<[Point][1]>** the closest point in the set to the reference point +Returns **[Feature][5]<[Point][1]>** the closest point in the set to the reference point [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -44,9 +44,7 @@ Returns **[Feature][6]<[Point][1]>** the closest point in the set to the referen [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[6]: https://tools.ietf.org/html/rfc7946#section-3.2 +[5]: https://tools.ietf.org/html/rfc7946#section-3.2 diff --git a/packages/turf-nearest-point/index.ts b/packages/turf-nearest-point/index.ts index 7d2fa0e49d..8eb019243e 100644 --- a/packages/turf-nearest-point/index.ts +++ b/packages/turf-nearest-point/index.ts @@ -22,20 +22,20 @@ interface NearestPoint extends Feature { * @param {Coord} targetPoint the reference point * @param {FeatureCollection} points against input point set * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] the units of the numeric result + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @returns {Feature} the closest point in the set to the reference point * @example - * var targetPoint = turf.point([28.965797, 41.010086], {"marker-color": "#0F0"}); - * var points = turf.featureCollection([ + * const targetPoint = turf.point([28.965797, 41.010086], {"marker-color": "#0F0"}); + * const points = turf.featureCollection([ * turf.point([28.973865, 41.011122]), * turf.point([28.948459, 41.024204]), * turf.point([28.938674, 41.013324]) * ]); * - * var nearest = turf.nearestPoint(targetPoint, points); + * const nearest = turf.nearestPoint(targetPoint, points); * * //addToMap - * var addToMap = [targetPoint, points, nearest]; + * const addToMap = [targetPoint, points, nearest]; * nearest.properties['marker-color'] = '#F00'; */ function nearestPoint( diff --git a/packages/turf-point-grid/README.md b/packages/turf-point-grid/README.md index 7ef41b043d..7912695914 100644 --- a/packages/turf-point-grid/README.md +++ b/packages/turf-point-grid/README.md @@ -8,28 +8,28 @@ Creates a grid of points ### Parameters -* `bbox` **[BBox][1]** extent of grid in \[minX, minY, maxX, maxY] order -* `cellSide` **[number][2]** the distance between points +* `bbox` **[BBox][1]** Extent of grid in \[minX, minY, maxX, maxY] order +* `cellSide` **[number][2]** Distance between points * `options` **[Object][3]** Optional parameters (optional, default `{}`) - * `options.units` **Units** the units of the cellSide value. Supports all valid Turf [Units][4] (optional, default `'kilometers'`) - * `options.mask` **[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * `options.properties` **[Object][3]** passed to each point of the grid (optional, default `{}`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.mask` **[Feature][4]<([Polygon][5] | [MultiPolygon][6])>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it + * `options.properties` **[GeoJsonProperties][4]** Properties to set on each point of the returned grid (optional, default `{}`) ### Examples ```javascript -var extent = [-70.823364, -33.553984, -70.473175, -33.302986]; -var cellSide = 3; -var options = {units: 'miles'}; +const extent = [-70.823364, -33.553984, -70.473175, -33.302986]; +const cellSide = 3; +const options = {units: 'miles'}; -var grid = turf.pointGrid(extent, cellSide, options); +const grid = turf.pointGrid(extent, cellSide, options); //addToMap -var addToMap = [grid]; +const addToMap = [grid]; ``` -Returns **[FeatureCollection][8]<[Point][9]>** grid of points +Returns **[FeatureCollection][7]<[Point][8]>** Grid of points [1]: https://tools.ietf.org/html/rfc7946#section-5 @@ -37,17 +37,15 @@ Returns **[FeatureCollection][8]<[Point][9]>** grid of points [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[4]: https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md +[4]: https://tools.ietf.org/html/rfc7946#section-3.2 -[5]: https://tools.ietf.org/html/rfc7946#section-3.2 +[5]: https://tools.ietf.org/html/rfc7946#section-3.1.6 -[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.7 -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.7 +[7]: https://tools.ietf.org/html/rfc7946#section-3.3 -[8]: https://tools.ietf.org/html/rfc7946#section-3.3 - -[9]: https://tools.ietf.org/html/rfc7946#section-3.1.2 +[8]: https://tools.ietf.org/html/rfc7946#section-3.1.2 diff --git a/packages/turf-point-grid/index.ts b/packages/turf-point-grid/index.ts index a577d2dc26..ef0180189e 100644 --- a/packages/turf-point-grid/index.ts +++ b/packages/turf-point-grid/index.ts @@ -15,22 +15,22 @@ import { point, featureCollection, Units } from "@turf/helpers"; * Creates a grid of points * * @function - * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order - * @param {number} cellSide the distance between points + * @param {BBox} bbox Extent of grid in [minX, minY, maxX, maxY] order + * @param {number} cellSide Distance between points * @param {Object} [options={}] Optional parameters - * @param {Units} [options.units='kilometers'] the units of the cellSide value. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units} + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @param {Feature} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * @param {Object} [options.properties={}] passed to each point of the grid - * @returns {FeatureCollection} grid of points + * @param {GeoJsonProperties} [options.properties={}] Properties to set on each point of the returned grid + * @returns {FeatureCollection} Grid of points * @example - * var extent = [-70.823364, -33.553984, -70.473175, -33.302986]; - * var cellSide = 3; - * var options = {units: 'miles'}; + * const extent = [-70.823364, -33.553984, -70.473175, -33.302986]; + * const cellSide = 3; + * const options = {units: 'miles'}; * - * var grid = turf.pointGrid(extent, cellSide, options); + * const grid = turf.pointGrid(extent, cellSide, options); * * //addToMap - * var addToMap = [grid]; + * const addToMap = [grid]; */ function pointGrid

( bbox: BBox, diff --git a/packages/turf-point-to-line-distance/README.md b/packages/turf-point-to-line-distance/README.md index 8e61c23004..9fc5d0602d 100644 --- a/packages/turf-point-to-line-distance/README.md +++ b/packages/turf-point-to-line-distance/README.md @@ -9,40 +9,39 @@ line. Sometimes referred to as the cross track distance. ### Parameters -* `pt` **([Feature][1]<[Point][2]> | [Array][3]<[number][4]>)** Feature or Geometry -* `line` **[Feature][1]<[LineString][5]>** GeoJSON Feature or Geometry -* `options` **[Object][6]** Optional parameters (optional, default `{}`) +* `pt` **([Feature][1]<[Point][2]> | [Point][2] | [Position][3])** Feature or Geometry +* `line` **[Feature][1]<[LineString][4]>** GeoJSON Feature or Geometry +* `options` **[Object][5]** Optional parameters (optional, default `{}`) - * `options.units` **[string][7]** can be anything supported by turf/convertLength - (ex: degrees, radians, miles, or kilometers) (optional, default `"kilometers"`) - * `options.method` **[string][7]** whether to calculate the distance based on geodesic (spheroid) or + * `options.units` **Units** Units in which linear values are expressed (optional, default `"kilometers"`) + * `options.method` **[string][6]** whether to calculate the distance based on geodesic (spheroid) or planar (flat) method. Valid options are 'geodesic' or 'planar'. (optional, default `"geodesic"`) ### Examples ```javascript -var pt = turf.point([0, 0]); -var line = turf.lineString([[1, 1],[-1, 1]]); +const pt = turf.point([0, 0]); +const line = turf.lineString([[1, 1],[-1, 1]]); -var distance = turf.pointToLineDistance(pt, line, {units: 'miles'}); +const distance = turf.pointToLineDistance(pt, line, {units: 'miles'}); //=69.11854715938406 ``` -Returns **[number][4]** distance between point and line +Returns **[number][7]** distance between point and line [1]: https://tools.ietf.org/html/rfc7946#section-3.2 [2]: https://tools.ietf.org/html/rfc7946#section-3.1.2 -[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[3]: https://developer.mozilla.org/docs/Web/API/Position -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[4]: https://tools.ietf.org/html/rfc7946#section-3.1.4 -[5]: https://tools.ietf.org/html/rfc7946#section-3.1.4 +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/packages/turf-point-to-line-distance/index.ts b/packages/turf-point-to-line-distance/index.ts index bb97eaf7b4..8649ec2360 100644 --- a/packages/turf-point-to-line-distance/index.ts +++ b/packages/turf-point-to-line-distance/index.ts @@ -1,8 +1,7 @@ // Taken from http://geomalgorithms.com/a02-_lines.html -import { Feature, LineString } from "geojson"; +import { Feature, LineString, Point, Position } from "geojson"; import { convertLength, - Coord, feature, lineString, point, @@ -18,23 +17,22 @@ import { rhumbDistance } from "@turf/rhumb-distance"; * line. Sometimes referred to as the cross track distance. * * @function - * @param {Feature|Array} pt Feature or Geometry + * @param {Feature|Point|Position} pt Feature or Geometry * @param {Feature} line GeoJSON Feature or Geometry * @param {Object} [options={}] Optional parameters - * @param {string} [options.units="kilometers"] can be anything supported by turf/convertLength - * (ex: degrees, radians, miles, or kilometers) + * @param {Units} [options.units="kilometers"] Units in which linear values are expressed * @param {string} [options.method="geodesic"] whether to calculate the distance based on geodesic (spheroid) or * planar (flat) method. Valid options are 'geodesic' or 'planar'. * @returns {number} distance between point and line * @example - * var pt = turf.point([0, 0]); - * var line = turf.lineString([[1, 1],[-1, 1]]); + * const pt = turf.point([0, 0]); + * const line = turf.lineString([[1, 1],[-1, 1]]); * - * var distance = turf.pointToLineDistance(pt, line, {units: 'miles'}); + * const distance = turf.pointToLineDistance(pt, line, {units: 'miles'}); * //=69.11854715938406 */ function pointToLineDistance( - pt: Coord, + pt: Feature | Point | Position, line: Feature | LineString, options: { units?: Units; diff --git a/packages/turf-point-to-polygon-distance/README.md b/packages/turf-point-to-polygon-distance/README.md index e2d9584cd9..b5a5136c20 100644 --- a/packages/turf-point-to-polygon-distance/README.md +++ b/packages/turf-point-to-polygon-distance/README.md @@ -15,14 +15,14 @@ A hole is treated as the exterior of the polygon. * `polygonOrMultiPolygon` **([Feature][1]<([Polygon][4] | [MultiPolygon][5])> | [Polygon][4] | [MultiPolygon][5])** Input polygon or multipolygon * `options` **[Object][6]** Optional parameters (optional, default `{}`) - * `options.units` **Units** Units of the result e.g. "kilometers", "miles", "meters" - * `options.method` **(`"geodesic"` | `"planar"`)** Method of the result + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.method` **(`"geodesic"` | `"planar"`)** Method of calculation (optional, default `"geodesic"`) * Throws **[Error][7]** If input geometries are invalid -Returns **[number][8]** Distance in meters (negative values for points inside the polygon) +Returns **[number][8]** Distance to nearest edge of input polygon (negative values for points inside the polygon) [1]: https://tools.ietf.org/html/rfc7946#section-3.2 diff --git a/packages/turf-point-to-polygon-distance/index.ts b/packages/turf-point-to-polygon-distance/index.ts index 1a674d5b77..b677591366 100644 --- a/packages/turf-point-to-polygon-distance/index.ts +++ b/packages/turf-point-to-polygon-distance/index.ts @@ -21,10 +21,10 @@ import { polygon, Units } from "@turf/helpers"; * * @param {Feature | Point | Position} point Input point * @param {Feature | Polygon | MultiPolygon} polygonOrMultiPolygon Input polygon or multipolygon - * @param {Object} options Optional parameters - * @param {Units} options.units Units of the result e.g. "kilometers", "miles", "meters" - * @param {"geodesic" | "planar"} options.method Method of the result - * @returns {number} Distance in meters (negative values for points inside the polygon) + * @param {Object} [options={}] Optional parameters + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {"geodesic" | "planar"} [options.method="geodesic"] Method of calculation + * @returns {number} Distance to nearest edge of input polygon (negative values for points inside the polygon) * @throws {Error} If input geometries are invalid */ export function pointToPolygonDistance( diff --git a/packages/turf-polygon-to-line/README.md b/packages/turf-polygon-to-line/README.md index 0205df3f74..eb44d4c4cc 100644 --- a/packages/turf-polygon-to-line/README.md +++ b/packages/turf-polygon-to-line/README.md @@ -9,23 +9,23 @@ Converts a [Polygon][1] to [(Multi)LineString][2] or [MultiPolygon][3] to a ### Parameters -* `poly` **[Feature][5]<([Polygon][1] | [MultiPolygon][3])>** Feature to convert +* `poly` **([Feature][5]<([Polygon][1] | [MultiPolygon][3])> | [Polygon][1] | [MultiPolygon][3])** Feature to convert * `options` **[Object][6]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][6]** translates GeoJSON properties to Feature (optional, default `{}`) + * `options.properties` **[Object][6]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]); +const poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]); -var line = turf.polygonToLine(poly); +const line = turf.polygonToLine(poly); //addToMap -var addToMap = [line]; +const addToMap = [line]; ``` -Returns **([FeatureCollection][4] | [Feature][5]<([LineString][2] | MultiLinestring)>)** converted (Multi)Polygon to (Multi)LineString +Returns **([FeatureCollection][4]<([LineString][2] | MultiLinestring)> | [Feature][5]<([LineString][2] | MultiLinestring)>)** converted (Multi)Polygon to (Multi)LineString [1]: https://tools.ietf.org/html/rfc7946#section-3.1.6 diff --git a/packages/turf-polygon-to-line/index.ts b/packages/turf-polygon-to-line/index.ts index 618e6187ea..3465790a10 100644 --- a/packages/turf-polygon-to-line/index.ts +++ b/packages/turf-polygon-to-line/index.ts @@ -15,17 +15,17 @@ import { getGeom } from "@turf/invariant"; * {@link FeatureCollection} of {@link LineString|(Multi)LineString}. * * @function - * @param {Feature} poly Feature to convert + * @param {Feature|Polygon|MultiPolygon} poly Feature to convert * @param {Object} [options={}] Optional parameters - * @param {Object} [options.properties={}] translates GeoJSON properties to Feature - * @returns {FeatureCollection|Feature} converted (Multi)Polygon to (Multi)LineString + * @param {Object} [options.properties={}] Properties to set on returned feature + * @returns {FeatureCollection|Feature} converted (Multi)Polygon to (Multi)LineString * @example - * var poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]); + * const poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]); * - * var line = turf.polygonToLine(poly); + * const line = turf.polygonToLine(poly); * * //addToMap - * var addToMap = [line]; + * const addToMap = [line]; */ function polygonToLine< G extends Polygon | MultiPolygon, diff --git a/packages/turf-rectangle-grid/README.md b/packages/turf-rectangle-grid/README.md index 95540ea266..a8ac12400b 100644 --- a/packages/turf-rectangle-grid/README.md +++ b/packages/turf-rectangle-grid/README.md @@ -13,29 +13,28 @@ Creates a grid of rectangular polygons with width and height consistent in degre * `cellHeight` **[number][2]** height of each cell, in units * `options` **[Object][3]** Optional parameters (optional, default `{}`) - * `options.units` **Units** the units of the cell width and height value. - Supports all valid Turf [Units][4]. + * `options.units` **Units** Units in which linear values are expressed. If you are looking for rectangles with equal width and height in linear units (e.g. kilometers) this is not the module for you. The cellWidth and cellHeight is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees. (optional, default `'kilometers'`) - * `options.mask` **[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon, + * `options.mask` **[Feature][4]<([Polygon][5] | [MultiPolygon][6])>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * `options.properties` **[Object][3]** passed to each point of the grid (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][4]** Properties to set on each polygon of the grid (optional, default `{}`) ### Examples ```javascript -var bbox = [-95, 30 ,-85, 40]; -var cellWidth = 50; -var cellHeight = 20; -var options = {units: 'miles'}; +const bbox = [-95, 30 ,-85, 40]; +const cellWidth = 50; +const cellHeight = 20; +const options = {units: 'miles'}; -var rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options); +const rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options); //addToMap -var addToMap = [rectangleGrid] +const addToMap = [rectangleGrid] ``` -Returns **[FeatureCollection][8]<[Polygon][6]>** a grid of polygons +Returns **[FeatureCollection][7]<[Polygon][5]>** a grid of polygons [1]: https://tools.ietf.org/html/rfc7946#section-5 @@ -43,15 +42,13 @@ Returns **[FeatureCollection][8]<[Polygon][6]>** a grid of polygons [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[4]: https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md +[4]: https://tools.ietf.org/html/rfc7946#section-3.2 -[5]: https://tools.ietf.org/html/rfc7946#section-3.2 +[5]: https://tools.ietf.org/html/rfc7946#section-3.1.6 -[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.7 -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.7 - -[8]: https://tools.ietf.org/html/rfc7946#section-3.3 +[7]: https://tools.ietf.org/html/rfc7946#section-3.3 diff --git a/packages/turf-rectangle-grid/index.ts b/packages/turf-rectangle-grid/index.ts index 15bbbfabb5..06868cc711 100644 --- a/packages/turf-rectangle-grid/index.ts +++ b/packages/turf-rectangle-grid/index.ts @@ -21,24 +21,23 @@ import { * @param {number} cellWidth width of each cell, in units * @param {number} cellHeight height of each cell, in units * @param {Object} [options={}] Optional parameters - * @param {Units} [options.units='kilometers'] the units of the cell width and height value. - * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}. + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed. * If you are looking for rectangles with equal width and height in linear units (e.g. kilometers) this is not the module for you. * The cellWidth and cellHeight is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees. * @param {Feature} [options.mask] if passed a Polygon or MultiPolygon, * the grid Points will be created only inside it - * @param {Object} [options.properties={}] passed to each point of the grid + * @param {GeoJsonProperties} [options.properties={}] Properties to set on each polygon of the grid * @returns {FeatureCollection} a grid of polygons * @example - * var bbox = [-95, 30 ,-85, 40]; - * var cellWidth = 50; - * var cellHeight = 20; - * var options = {units: 'miles'}; + * const bbox = [-95, 30 ,-85, 40]; + * const cellWidth = 50; + * const cellHeight = 20; + * const options = {units: 'miles'}; * - * var rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options); + * const rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options); * * //addToMap - * var addToMap = [rectangleGrid] + * const addToMap = [rectangleGrid] */ function rectangleGrid

( bbox: BBox, diff --git a/packages/turf-rhumb-destination/README.md b/packages/turf-rhumb-destination/README.md index 001ad5d59b..6158e3996a 100644 --- a/packages/turf-rhumb-destination/README.md +++ b/packages/turf-rhumb-destination/README.md @@ -14,25 +14,25 @@ origin Point with the (varant) given bearing. * `bearing` **[number][3]** varant bearing angle ranging from -180 to 180 degrees from north * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.units` **[string][5]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) - * `options.properties` **[Object][4]** translate properties to destination point (optional, default `{}`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var pt = turf.point([-75.343, 39.984], {"marker-color": "F00"}); -var distance = 50; -var bearing = 90; -var options = {units: 'miles'}; +const pt = turf.point([-75.343, 39.984], {"marker-color": "F00"}); +const distance = 50; +const bearing = 90; +const options = {units: 'miles'}; -var destination = turf.rhumbDestination(pt, distance, bearing, options); +const destination = turf.rhumbDestination(pt, distance, bearing, options); //addToMap -var addToMap = [pt, destination] +const addToMap = [pt, destination] destination.properties['marker-color'] = '#00F'; ``` -Returns **[Feature][6]<[Point][1]>** Destination point. +Returns **[Feature][5]<[Point][1]>** Destination point. [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -42,9 +42,7 @@ Returns **[Feature][6]<[Point][1]>** Destination point. [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[6]: https://tools.ietf.org/html/rfc7946#section-3.2 +[5]: https://tools.ietf.org/html/rfc7946#section-3.2 diff --git a/packages/turf-rhumb-destination/index.ts b/packages/turf-rhumb-destination/index.ts index 17e0472f32..d780bd33df 100644 --- a/packages/turf-rhumb-destination/index.ts +++ b/packages/turf-rhumb-destination/index.ts @@ -19,19 +19,19 @@ import { getCoord } from "@turf/invariant"; * @param {number} distance distance from the starting point * @param {number} bearing varant bearing angle ranging from -180 to 180 degrees from north * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers - * @param {Object} [options.properties={}] translate properties to destination point + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} Destination point. * @example - * var pt = turf.point([-75.343, 39.984], {"marker-color": "F00"}); - * var distance = 50; - * var bearing = 90; - * var options = {units: 'miles'}; + * const pt = turf.point([-75.343, 39.984], {"marker-color": "F00"}); + * const distance = 50; + * const bearing = 90; + * const options = {units: 'miles'}; * - * var destination = turf.rhumbDestination(pt, distance, bearing, options); + * const destination = turf.rhumbDestination(pt, distance, bearing, options); * * //addToMap - * var addToMap = [pt, destination] + * const addToMap = [pt, destination] * destination.properties['marker-color'] = '#00F'; */ function rhumbDestination

( diff --git a/packages/turf-rhumb-distance/README.md b/packages/turf-rhumb-distance/README.md index 3dd3bf2e09..d2a0fe7bde 100644 --- a/packages/turf-rhumb-distance/README.md +++ b/packages/turf-rhumb-distance/README.md @@ -13,24 +13,24 @@ miles, or kilometers. * `to` **[Coord][2]** destination point * `options` **[Object][3]?** Optional parameters (optional, default `{}`) - * `options.units` **[string][4]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `"kilometers"`) ### Examples ```javascript -var from = turf.point([-75.343, 39.984]); -var to = turf.point([-75.534, 39.123]); -var options = {units: 'miles'}; +const from = turf.point([-75.343, 39.984]); +const to = turf.point([-75.534, 39.123]); +const options = {units: 'miles'}; -var distance = turf.rhumbDistance(from, to, options); +const distance = turf.rhumbDistance(from, to, options); //addToMap -var addToMap = [from, to]; +const addToMap = [from, to]; from.properties.distance = distance; to.properties.distance = distance; ``` -Returns **[number][5]** distance between the two points +Returns **[number][4]** distance between the two points [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -38,9 +38,7 @@ Returns **[number][5]** distance between the two points [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/packages/turf-rhumb-distance/index.ts b/packages/turf-rhumb-distance/index.ts index 37f7f04291..94f4b19531 100644 --- a/packages/turf-rhumb-distance/index.ts +++ b/packages/turf-rhumb-distance/index.ts @@ -10,17 +10,17 @@ import { getCoord } from "@turf/invariant"; * @param {Coord} from origin point * @param {Coord} to destination point * @param {Object} [options] Optional parameters - * @param {string} [options.units="kilometers"] can be degrees, radians, miles, or kilometers + * @param {Units} [options.units="kilometers"] Units in which linear values are expressed * @returns {number} distance between the two points * @example - * var from = turf.point([-75.343, 39.984]); - * var to = turf.point([-75.534, 39.123]); - * var options = {units: 'miles'}; + * const from = turf.point([-75.343, 39.984]); + * const to = turf.point([-75.534, 39.123]); + * const options = {units: 'miles'}; * - * var distance = turf.rhumbDistance(from, to, options); + * const distance = turf.rhumbDistance(from, to, options); * * //addToMap - * var addToMap = [from, to]; + * const addToMap = [from, to]; * from.properties.distance = distance; * to.properties.distance = distance; */ diff --git a/packages/turf-sector/README.md b/packages/turf-sector/README.md index 6e86c00828..3ed339b6bb 100644 --- a/packages/turf-sector/README.md +++ b/packages/turf-sector/README.md @@ -15,25 +15,25 @@ between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, p * `bearing2` **[number][3]** angle, in decimal degrees, of the second radius of the sector * `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.units` **[string][5]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) + * `options.units` **Units** Units in which linear values are expressed (optional, default `'kilometers'`) * `options.steps` **[number][3]** number of steps (optional, default `64`) - * `options.properties` **Properties** Translate properties to Feature Polygon (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) ### Examples ```javascript -var center = turf.point([-75, 40]); -var radius = 5; -var bearing1 = 25; -var bearing2 = 45; +const center = turf.point([-75, 40]); +const radius = 5; +const bearing1 = 25; +const bearing2 = 45; -var sector = turf.sector(center, radius, bearing1, bearing2); +const sector = turf.sector(center, radius, bearing1, bearing2); //addToMap -var addToMap = [center, sector]; +const addToMap = [center, sector]; ``` -Returns **[Feature][6]<[Polygon][7]>** sector polygon +Returns **[Feature][5]<[Polygon][6]>** sector polygon [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -43,11 +43,9 @@ Returns **[Feature][6]<[Polygon][7]>** sector polygon [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[5]: https://tools.ietf.org/html/rfc7946#section-3.2 -[6]: https://tools.ietf.org/html/rfc7946#section-3.2 - -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 diff --git a/packages/turf-sector/index.ts b/packages/turf-sector/index.ts index 21755a4b39..6236f5cf3e 100644 --- a/packages/turf-sector/index.ts +++ b/packages/turf-sector/index.ts @@ -15,20 +15,20 @@ import { getCoords } from "@turf/invariant"; * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector * @param {Object} [options={}] Optional parameters - * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * @param {number} [options.steps=64] number of steps - * @param {Properties} [options.properties={}] Translate properties to Feature Polygon + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} sector polygon * @example - * var center = turf.point([-75, 40]); - * var radius = 5; - * var bearing1 = 25; - * var bearing2 = 45; + * const center = turf.point([-75, 40]); + * const radius = 5; + * const bearing1 = 25; + * const bearing2 = 45; * - * var sector = turf.sector(center, radius, bearing1, bearing2); + * const sector = turf.sector(center, radius, bearing1, bearing2); * * //addToMap - * var addToMap = [center, sector]; + * const addToMap = [center, sector]; */ function sector( center: Coord, diff --git a/packages/turf-square-grid/README.md b/packages/turf-square-grid/README.md index 28d11fbd05..39e78ccbf3 100644 --- a/packages/turf-square-grid/README.md +++ b/packages/turf-square-grid/README.md @@ -12,28 +12,27 @@ Creates a grid of square polygons with cell length consistent in degrees * `cellSide` **[number][2]** length of each cell side. * `options` **[Object][3]** Optional parameters (optional, default `{}`) - * `options.units` **Units** the units of the cellSide value. - Supports all valid Turf [Units][4]. + * `options.units` **Units** Units in which linear values are expressed If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you. The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees. (optional, default `'kilometers'`) - * `options.mask` **[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon, + * `options.mask` **[Feature][4]<([Polygon][5] | [MultiPolygon][6])>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * `options.properties` **[Object][3]** passed to each point of the grid (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][4]** Properties to set on each polygon of the grid (optional, default `{}`) ### Examples ```javascript -var bbox = [-95, 30 ,-85, 40]; -var cellSide = 50; -var options = {units: 'miles'}; +const bbox = [-95, 30 ,-85, 40]; +const cellSide = 50; +const options = {units: 'miles'}; -var squareGrid = turf.squareGrid(bbox, cellSide, options); +const squareGrid = turf.squareGrid(bbox, cellSide, options); //addToMap -var addToMap = [squareGrid] +const addToMap = [squareGrid] ``` -Returns **[FeatureCollection][8]<[Polygon][6]>** a grid of polygons with equal width and height in degrees. +Returns **[FeatureCollection][7]<[Polygon][5]>** a grid of polygons with equal width and height in degrees. [1]: https://tools.ietf.org/html/rfc7946#section-5 @@ -41,15 +40,13 @@ Returns **[FeatureCollection][8]<[Polygon][6]>** a grid of polygons with equal w [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[4]: https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md +[4]: https://tools.ietf.org/html/rfc7946#section-3.2 -[5]: https://tools.ietf.org/html/rfc7946#section-3.2 +[5]: https://tools.ietf.org/html/rfc7946#section-3.1.6 -[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6 +[6]: https://tools.ietf.org/html/rfc7946#section-3.1.7 -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.7 - -[8]: https://tools.ietf.org/html/rfc7946#section-3.3 +[7]: https://tools.ietf.org/html/rfc7946#section-3.3 diff --git a/packages/turf-square-grid/index.ts b/packages/turf-square-grid/index.ts index 4cf2d1acc1..a6b4f9bd95 100644 --- a/packages/turf-square-grid/index.ts +++ b/packages/turf-square-grid/index.ts @@ -16,23 +16,22 @@ import { rectangleGrid } from "@turf/rectangle-grid"; * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered. * @param {number} cellSide length of each cell side. * @param {Object} [options={}] Optional parameters - * @param {Units} [options.units='kilometers'] the units of the cellSide value. - * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}. + * @param {Units} [options.units='kilometers'] Units in which linear values are expressed * If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you. * The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees. * @param {Feature} [options.mask] if passed a Polygon or MultiPolygon, * the grid Points will be created only inside it - * @param {Object} [options.properties={}] passed to each point of the grid + * @param {GeoJsonProperties} [options.properties={}] Properties to set on each polygon of the grid * @returns {FeatureCollection} a grid of polygons with equal width and height in degrees. * @example - * var bbox = [-95, 30 ,-85, 40]; - * var cellSide = 50; - * var options = {units: 'miles'}; + * const bbox = [-95, 30 ,-85, 40]; + * const cellSide = 50; + * const options = {units: 'miles'}; * - * var squareGrid = turf.squareGrid(bbox, cellSide, options); + * const squareGrid = turf.squareGrid(bbox, cellSide, options); * * //addToMap - * var addToMap = [squareGrid] + * const addToMap = [squareGrid] */ function squareGrid

( diff --git a/packages/turf-standard-deviational-ellipse/README.md b/packages/turf-standard-deviational-ellipse/README.md index 727d3b1f38..04e4d52b96 100644 --- a/packages/turf-standard-deviational-ellipse/README.md +++ b/packages/turf-standard-deviational-ellipse/README.md @@ -30,7 +30,7 @@ doi:{@link [https://doi.org/10.1086/214336|10.1086/214336}][4]. * `options.weight` **[string][8]?** the property name used to weight the center * `options.steps` **[number][9]** number of steps for the polygon (optional, default `64`) - * `options.properties` **[Object][7]** properties to pass to the resulting ellipse (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][10]** Properties to set on returned feature (optional, default `{}`) ### Examples diff --git a/packages/turf-standard-deviational-ellipse/index.ts b/packages/turf-standard-deviational-ellipse/index.ts index a3c9204b5f..e8328f5773 100644 --- a/packages/turf-standard-deviational-ellipse/index.ts +++ b/packages/turf-standard-deviational-ellipse/index.ts @@ -55,7 +55,7 @@ declare interface StandardDeviationalEllipse extends Feature { * @param {Object} [options={}] Optional parameters * @param {string} [options.weight] the property name used to weight the center * @param {number} [options.steps=64] number of steps for the polygon - * @param {Object} [options.properties={}] properties to pass to the resulting ellipse + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature * @returns {Feature} an elliptical Polygon that includes approximately 1 SD of the dataset within it. * @example * diff --git a/packages/turf-triangle-grid/README.md b/packages/turf-triangle-grid/README.md index 0517776214..8722d35818 100644 --- a/packages/turf-triangle-grid/README.md +++ b/packages/turf-triangle-grid/README.md @@ -14,19 +14,19 @@ Creates a grid of triangular polygons. * `options.units` **Units** used in calculating cellSide. Supports all valid Turf [Units][4] (optional, default `'kilometers'`) * `options.mask` **[Feature][5]<[Polygon][6]>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * `options.properties` **[Object][3]** passed to each point of the grid (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on each polygon of the grid (optional, default `{}`) ### Examples ```javascript -var bbox = [-95, 30 ,-85, 40]; -var cellSide = 50; -var options = {units: 'miles'}; +const bbox = [-95, 30 ,-85, 40]; +const cellSide = 50; +const options = {units: 'miles'}; -var triangleGrid = turf.triangleGrid(bbox, cellSide, options); +const triangleGrid = turf.triangleGrid(bbox, cellSide, options); //addToMap -var addToMap = [triangleGrid]; +const addToMap = [triangleGrid]; ``` Returns **[FeatureCollection][7]<[Polygon][6]>** grid of polygons diff --git a/packages/turf-triangle-grid/index.ts b/packages/turf-triangle-grid/index.ts index cf11f2b498..582a233310 100644 --- a/packages/turf-triangle-grid/index.ts +++ b/packages/turf-triangle-grid/index.ts @@ -18,17 +18,17 @@ import { polygon, featureCollection, Units } from "@turf/helpers"; * @param {Object} [options={}] Optional parameters * @param {Units} [options.units='kilometers'] used in calculating cellSide. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units} * @param {Feature} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it - * @param {Object} [options.properties={}] passed to each point of the grid + * @param {GeoJsonProperties} [options.properties={}] Properties to set on each polygon of the grid * @returns {FeatureCollection} grid of polygons * @example - * var bbox = [-95, 30 ,-85, 40]; - * var cellSide = 50; - * var options = {units: 'miles'}; + * const bbox = [-95, 30 ,-85, 40]; + * const cellSide = 50; + * const options = {units: 'miles'}; * - * var triangleGrid = turf.triangleGrid(bbox, cellSide, options); + * const triangleGrid = turf.triangleGrid(bbox, cellSide, options); * * //addToMap - * var addToMap = [triangleGrid]; + * const addToMap = [triangleGrid]; */ function triangleGrid

( bbox: BBox, diff --git a/packages/turf-union/README.md b/packages/turf-union/README.md index ed82325d73..2c1e6d49d5 100644 --- a/packages/turf-union/README.md +++ b/packages/turf-union/README.md @@ -10,10 +10,10 @@ feature. ### Parameters -* `features` **[FeatureCollection][1]<([Polygon][2] | [MultiPolygon][3])>** input polygon features -* `options` **[Object][4]** Optional Parameters (optional, default `{}`) +* `features` **[FeatureCollection][1]<([Polygon][2] | [MultiPolygon][3])>** Input polygon features +* `options` **[Object][4]** Optional parameters (optional, default `{}`) - * `options.properties` **[GeoJsonProperties][5]** properties to assign to output feature (optional, default `{}`) + * `options.properties` **[GeoJsonProperties][5]** Properties to set on returned feature (optional, default `{}`) ### Examples @@ -55,7 +55,7 @@ union.properties["stroke-width"] = 4; union.properties.fill = "transparent"; ``` -Returns **([Feature][5]<([Polygon][2] | [MultiPolygon][3])> | null)** a combined polygon or multi-polygon feature, or null if there were no input polygons to combine +Returns **([Feature][5]<([Polygon][2] | [MultiPolygon][3])> | null)** Combined polygon or multi-polygon feature, or null if there were no input polygons to combine [1]: https://tools.ietf.org/html/rfc7946#section-3.3 diff --git a/packages/turf-union/index.ts b/packages/turf-union/index.ts index 94428494af..e6e17baa42 100644 --- a/packages/turf-union/index.ts +++ b/packages/turf-union/index.ts @@ -15,10 +15,10 @@ import { * feature. * * @function - * @param {FeatureCollection} features input polygon features - * @param {Object} [options={}] Optional Parameters - * @param {GeoJsonProperties} [options.properties={}] properties to assign to output feature - * @returns {Feature<(Polygon|MultiPolygon)>|null} a combined polygon or multi-polygon feature, or null if there were no input polygons to combine + * @param {FeatureCollection} features Input polygon features + * @param {Object} [options={}] Optional parameters + * @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature + * @returns {Feature<(Polygon|MultiPolygon)>|null} Combined polygon or multi-polygon feature, or null if there were no input polygons to combine * @example * * const poly1 = turf.polygon( From 20e2e47859ffd74622653c4f43a9289fc95ea214 Mon Sep 17 00:00:00 2001 From: James Beard Date: Mon, 30 Dec 2024 16:12:34 +1100 Subject: [PATCH 2/2] Mentions of Position type in documentation weren't being converted to links. --- documentation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.yml b/documentation.yml index 0f5445a780..10e3b60929 100644 --- a/documentation.yml +++ b/documentation.yml @@ -195,3 +195,4 @@ paths: BBox: "https://tools.ietf.org/html/rfc7946#section-5" BoundingBox: "https://tools.ietf.org/html/rfc7946#section-5" Coord: "https://tools.ietf.org/html/rfc7946#section-3.1.1" + Position: "https://tools.ietf.org/html/rfc7946#section-3.1.1"