Skip to content

Commit 53a6c77

Browse files
committed
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.
1 parent a8cbea3 commit 53a6c77

File tree

87 files changed

+619
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+619
-658
lines changed

packages/turf-bbox-polygon/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ Takes a bbox and returns an equivalent [polygon][1].
88

99
### Parameters
1010

11-
* `bbox` **[BBox][2]** extent in \[minX, minY, maxX, maxY] order
11+
* `bbox` **[BBox][2]** Extent in \[minX, minY, maxX, maxY] order
1212
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
1313

14-
* `options.properties` **[GeoJsonProperties][4]** Translate properties to Polygon (optional, default `{}`)
15-
* `options.id` **([string][5] | [number][6])** Translate Id to Polygon (optional, default `{}`)
14+
* `options.properties` **[GeoJsonProperties][4]** Properties to set on returned feature (optional, default `{}`)
15+
* `options.id` **([string][5] | [number][6])** Id to set on returned feature (optional, default `{}`)
1616

1717
### Examples
1818

1919
```javascript
20-
var bbox = [0, 0, 10, 10];
20+
const bbox = [0, 0, 10, 10];
2121

22-
var poly = turf.bboxPolygon(bbox);
22+
const poly = turf.bboxPolygon(bbox);
2323

2424
//addToMap
25-
var addToMap = [poly]
25+
const addToMap = [poly]
2626
```
2727

28-
Returns **[Feature][4]<[Polygon][1]>** a Polygon representation of the bounding box
28+
Returns **[Feature][4]<[Polygon][1]>** Polygon representing the bounding box
2929

3030
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
3131

packages/turf-bbox-polygon/index.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import { BBox, Feature, Polygon, GeoJsonProperties } from "geojson";
2-
import { polygon, Id } from "@turf/helpers";
2+
import { polygon } from "@turf/helpers";
33

44
/**
55
* Takes a bbox and returns an equivalent {@link Polygon|polygon}.
66
*
77
* @function
8-
* @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
8+
* @param {BBox} bbox Extent in [minX, minY, maxX, maxY] order
99
* @param {Object} [options={}] Optional parameters
10-
* @param {GeoJsonProperties} [options.properties={}] Translate properties to Polygon
11-
* @param {string|number} [options.id={}] Translate Id to Polygon
12-
* @returns {Feature<Polygon>} a Polygon representation of the bounding box
10+
* @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature
11+
* @param {string|number} [options.id={}] Id to set on returned feature
12+
* @returns {Feature<Polygon>} Polygon representing the bounding box
1313
* @example
14-
* var bbox = [0, 0, 10, 10];
14+
* const bbox = [0, 0, 10, 10];
1515
*
16-
* var poly = turf.bboxPolygon(bbox);
16+
* const poly = turf.bboxPolygon(bbox);
1717
*
1818
* //addToMap
19-
* var addToMap = [poly]
19+
* const addToMap = [poly]
2020
*/
2121
function bboxPolygon<P extends GeoJsonProperties = GeoJsonProperties>(
2222
bbox: BBox,
2323
options: {
2424
properties?: P;
25-
id?: Id;
25+
id?: string | number;
2626
} = {}
2727
): Feature<Polygon, P> {
2828
// Convert BBox positions to Numbers

packages/turf-bezier-spline/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ The bezier spline implementation is by [Leszek Rybicki][3].
1212

1313
### Parameters
1414

15-
* `line` **[Feature][4]<[LineString][1]>** input LineString
15+
* `line` **[Feature][4]<[LineString][1]>** Input LineString
1616
* `options` **[Object][5]** Optional parameters (optional, default `{}`)
1717

18-
* `options.properties` **[Object][5]** Translate properties to output (optional, default `{}`)
19-
* `options.resolution` **[number][6]** time in milliseconds between points (optional, default `10000`)
20-
* `options.sharpness` **[number][6]** a measure of how curvy the path should be between splines (optional, default `0.85`)
18+
* `options.properties` **[GeoJsonProperties][4]** Properties to set on returned feature (optional, default `{}`)
19+
* `options.resolution` **[number][6]** Time in milliseconds between points (optional, default `10000`)
20+
* `options.sharpness` **[number][6]** Measure of how curvy the path should be between splines (optional, default `0.85`)
2121

2222
### Examples
2323

2424
```javascript
25-
var line = turf.lineString([
25+
const line = turf.lineString([
2626
[-76.091308, 18.427501],
2727
[-76.695556, 18.729501],
2828
[-76.552734, 19.40443],
@@ -31,14 +31,14 @@ var line = turf.lineString([
3131
[-73.157958, 20.210656]
3232
]);
3333

34-
var curved = turf.bezierSpline(line);
34+
const curved = turf.bezierSpline(line);
3535

3636
//addToMap
37-
var addToMap = [line, curved]
37+
const addToMap = [line, curved]
3838
curved.properties = { stroke: '#0F0' };
3939
```
4040

41-
Returns **[Feature][4]<[LineString][1]>** curved line
41+
Returns **[Feature][4]<[LineString][1]>** Curved line
4242

4343
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
4444

packages/turf-bezier-spline/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { Spline } from "./lib/spline.js";
1111
* The bezier spline implementation is by [Leszek Rybicki](http://leszek.rybicki.cc/).
1212
*
1313
* @function
14-
* @param {Feature<LineString>} line input LineString
14+
* @param {Feature<LineString>} line Input LineString
1515
* @param {Object} [options={}] Optional parameters
16-
* @param {Object} [options.properties={}] Translate properties to output
17-
* @param {number} [options.resolution=10000] time in milliseconds between points
18-
* @param {number} [options.sharpness=0.85] a measure of how curvy the path should be between splines
19-
* @returns {Feature<LineString>} curved line
16+
* @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature
17+
* @param {number} [options.resolution=10000] Time in milliseconds between points
18+
* @param {number} [options.sharpness=0.85] Measure of how curvy the path should be between splines
19+
* @returns {Feature<LineString>} Curved line
2020
* @example
21-
* var line = turf.lineString([
21+
* const line = turf.lineString([
2222
* [-76.091308, 18.427501],
2323
* [-76.695556, 18.729501],
2424
* [-76.552734, 19.40443],
@@ -27,10 +27,10 @@ import { Spline } from "./lib/spline.js";
2727
* [-73.157958, 20.210656]
2828
* ]);
2929
*
30-
* var curved = turf.bezierSpline(line);
30+
* const curved = turf.bezierSpline(line);
3131
*
3232
* //addToMap
33-
* var addToMap = [line, curved]
33+
* const addToMap = [line, curved]
3434
* curved.properties = { stroke: '#0F0' };
3535
*/
3636
function bezierSpline<P extends GeoJsonProperties = GeoJsonProperties>(

packages/turf-boolean-intersects/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Boolean-intersects returns (TRUE) if the intersection of the two geometries is N
1212
* `feature2` **([Geometry][1] | [Feature][2]\<any>)** GeoJSON Feature or Geometry
1313
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
1414

15-
* `options.ignoreSelfIntersections` **[boolean][4]** ignores self-intersections on input features (optional, default `false`)
15+
* `options.ignoreSelfIntersections` **[boolean][4]** ignore self-intersections on input features (optional, default `true`)
1616

1717
### Examples
1818

packages/turf-buffer/README.md

+11-13
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ the input, or even be empty.
1414

1515
### Parameters
1616

17-
* `geojson` **([FeatureCollection][1] | [Geometry][2] | [Feature][3]\<any>)** input to be buffered
18-
* `radius` **[number][4]** distance to draw the buffer (negative values are allowed)
17+
* `geojson` **([FeatureCollection][1] | [Geometry][2] | [Feature][3]\<any>)** Input to be buffered
18+
* `radius` **[number][4]** Distance to draw the buffer (negative values are allowed)
1919
* `options` **[Object][5]** Optional parameters (optional, default `{}`)
2020

21-
* `options.units` **[string][6]** any of the options supported by turf units (optional, default `"kilometers"`)
22-
* `options.steps` **[number][4]** number of steps (optional, default `8`)
21+
* `options.units` **Units** Units in which linear values are expressed (optional, default `"kilometers"`)
22+
* `options.steps` **[number][4]** Number of steps (optional, default `8`)
2323

2424
### Examples
2525

2626
```javascript
27-
var point = turf.point([-90.548630, 14.616599]);
28-
var buffered = turf.buffer(point, 500, {units: 'miles'});
27+
const point = turf.point([-90.548630, 14.616599]);
28+
const buffered = turf.buffer(point, 500, {units: 'miles'});
2929

3030
//addToMap
31-
var addToMap = [point, buffered]
31+
const addToMap = [point, buffered]
3232
```
3333

34-
Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][7] | [MultiPolygon][8])> | [undefined][9])** buffered features
34+
Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][6] | [MultiPolygon][7])> | [undefined][8])** Buffered features
3535

3636
[1]: https://tools.ietf.org/html/rfc7946#section-3.3
3737

@@ -43,13 +43,11 @@ Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][7] | [MultiPolygon][
4343

4444
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
4545

46-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
46+
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6
4747

48-
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6
48+
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.7
4949

50-
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.7
51-
52-
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
50+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
5351

5452
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
5553

packages/turf-buffer/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ const { BufferOp, GeoJSONReader, GeoJSONWriter } = jsts;
2222
* the input, or even be empty.
2323
*
2424
* @function
25-
* @param {FeatureCollection|Geometry|Feature<any>} geojson input to be buffered
26-
* @param {number} radius distance to draw the buffer (negative values are allowed)
25+
* @param {FeatureCollection|Geometry|Feature<any>} geojson Input to be buffered
26+
* @param {number} radius Distance to draw the buffer (negative values are allowed)
2727
* @param {Object} [options={}] Optional parameters
28-
* @param {string} [options.units="kilometers"] any of the options supported by turf units
29-
* @param {number} [options.steps=8] number of steps
30-
* @returns {FeatureCollection|Feature<Polygon|MultiPolygon>|undefined} buffered features
28+
* @param {Units} [options.units="kilometers"] Units in which linear values are expressed
29+
* @param {number} [options.steps=8] Number of steps
30+
* @returns {FeatureCollection|Feature<Polygon|MultiPolygon>|undefined} Buffered features
3131
* @example
32-
* var point = turf.point([-90.548630, 14.616599]);
33-
* var buffered = turf.buffer(point, 500, {units: 'miles'});
32+
* const point = turf.point([-90.548630, 14.616599]);
33+
* const buffered = turf.buffer(point, 500, {units: 'miles'});
3434
*
3535
* //addToMap
36-
* var addToMap = [point, buffered]
36+
* const addToMap = [point, buffered]
3737
*/
3838
function buffer(geojson, radius, options) {
3939
// Optional params

packages/turf-center-mean/README.md

+15-11
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ Takes a [Feature][1] or [FeatureCollection][2] and returns the mean center. Can
1111
* `geojson` **[GeoJSON][3]** GeoJSON to be centered
1212
* `options` **[Object][4]** Optional parameters (optional, default `{}`)
1313

14-
* `options.properties` **[Object][4]** Translate GeoJSON Properties to Point (optional, default `{}`)
15-
* `options.bbox` **[Object][4]** Translate GeoJSON BBox to Point (optional, default `{}`)
16-
* `options.id` **[Object][4]** Translate GeoJSON Id to Point (optional, default `{}`)
17-
* `options.weight` **[string][5]?** the property name used to weight the center
14+
* `options.properties` **[GeoJsonProperties][1]** Properties to set on returned feature (optional, default `{}`)
15+
* `options.bbox` **[BBox][5]** TranslBBox to set on returned feature (optional, default `{}`)
16+
* `options.id` **([string][6] | [number][7])** Id to set on returned feature (optional, default `{}`)
17+
* `options.weight` **[string][6]?** Property name used to weight the center
1818

1919
### Examples
2020

2121
```javascript
22-
var features = turf.featureCollection([
22+
const features = turf.featureCollection([
2323
turf.point([-97.522259, 35.4691], {value: 10}),
2424
turf.point([-97.502754, 35.463455], {value: 3}),
2525
turf.point([-97.508269, 35.463245], {value: 5})
2626
]);
2727

28-
var options = {weight: "value"}
29-
var mean = turf.centerMean(features, options);
28+
const options = {weight: "value"}
29+
const mean = turf.centerMean(features, options);
3030

3131
//addToMap
32-
var addToMap = [features, mean]
32+
const addToMap = [features, mean]
3333
mean.properties['marker-size'] = 'large';
3434
mean.properties['marker-color'] = '#000';
3535
```
3636

37-
Returns **[Feature][1]<[Point][6]>** a Point feature at the mean center point of all input features
37+
Returns **[Feature][1]<[Point][8]>** Point feature at the mean center point of all input features
3838

3939
[1]: https://tools.ietf.org/html/rfc7946#section-3.2
4040

@@ -44,9 +44,13 @@ Returns **[Feature][1]<[Point][6]>** a Point feature at the mean center point of
4444

4545
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
4646

47-
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
47+
[5]: https://tools.ietf.org/html/rfc7946#section-5
4848

49-
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.2
49+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
50+
51+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
52+
53+
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.2
5054

5155
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
5256

packages/turf-center-mean/index.ts

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
import { BBox, Feature, Point, GeoJsonProperties } from "geojson";
22
import { geomEach, coordEach } from "@turf/meta";
3-
import { isNumber, point, Id } from "@turf/helpers";
3+
import { isNumber, point } from "@turf/helpers";
44

55
/**
66
* Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
77
*
88
* @function
99
* @param {GeoJSON} geojson GeoJSON to be centered
1010
* @param {Object} [options={}] Optional parameters
11-
* @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
12-
* @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point
13-
* @param {Object} [options.id={}] Translate GeoJSON Id to Point
14-
* @param {string} [options.weight] the property name used to weight the center
15-
* @returns {Feature<Point>} a Point feature at the mean center point of all input features
11+
* @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature
12+
* @param {BBox} [options.bbox={}] TranslBBox to set on returned feature
13+
* @param {string | number} [options.id={}] Id to set on returned feature
14+
* @param {string} [options.weight] Property name used to weight the center
15+
* @returns {Feature<Point>} Point feature at the mean center point of all input features
1616
* @example
17-
* var features = turf.featureCollection([
17+
* const features = turf.featureCollection([
1818
* turf.point([-97.522259, 35.4691], {value: 10}),
1919
* turf.point([-97.502754, 35.463455], {value: 3}),
2020
* turf.point([-97.508269, 35.463245], {value: 5})
2121
* ]);
2222
*
23-
* var options = {weight: "value"}
24-
* var mean = turf.centerMean(features, options);
23+
* const options = {weight: "value"}
24+
* const mean = turf.centerMean(features, options);
2525
*
2626
* //addToMap
27-
* var addToMap = [features, mean]
27+
* const addToMap = [features, mean]
2828
* mean.properties['marker-size'] = 'large';
2929
* mean.properties['marker-color'] = '#000';
3030
*/
3131
function centerMean<P extends GeoJsonProperties = GeoJsonProperties>(
3232
geojson: any, // To-Do include Typescript AllGeoJSON
33-
options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}
33+
options: {
34+
properties?: P;
35+
bbox?: BBox;
36+
id?: string | number;
37+
weight?: string;
38+
} = {}
3439
): Feature<Point, P> {
3540
let sumXs = 0;
3641
let sumYs = 0;

packages/turf-center-of-mass/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ Takes any [Feature][1] or a [FeatureCollection][2] and returns its [center of ma
1111
* `geojson` **[GeoJSON][5]** GeoJSON to be centered
1212
* `options` **[Object][6]** Optional Parameters (optional, default `{}`)
1313

14-
* `options.properties` **[Object][6]** Translate Properties to Feature (optional, default `{}`)
14+
* `options.properties` **[GeoJsonProperties][1]** Properties to set on returned feature (optional, default `{}`)
1515

1616
### Examples
1717

1818
```javascript
19-
var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
19+
const polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
2020

21-
var center = turf.centerOfMass(polygon);
21+
const center = turf.centerOfMass(polygon);
2222

2323
//addToMap
24-
var addToMap = [polygon, center]
24+
const addToMap = [polygon, center]
2525
```
2626

2727
Returns **[Feature][1]<[Point][7]>** the center of mass

packages/turf-center-of-mass/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import { coordEach } from "@turf/meta";
1111
* @function
1212
* @param {GeoJSON} geojson GeoJSON to be centered
1313
* @param {Object} [options={}] Optional Parameters
14-
* @param {Object} [options.properties={}] Translate Properties to Feature
14+
* @param {GeoJsonProperties} [options.properties={}] Properties to set on returned feature
1515
* @returns {Feature<Point>} the center of mass
1616
* @example
17-
* var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
17+
* const polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
1818
*
19-
* var center = turf.centerOfMass(polygon);
19+
* const center = turf.centerOfMass(polygon);
2020
*
2121
* //addToMap
22-
* var addToMap = [polygon, center]
22+
* const addToMap = [polygon, center]
2323
*/
2424
function centerOfMass<P extends GeoJsonProperties = GeoJsonProperties>(
2525
geojson: any,

0 commit comments

Comments
 (0)