You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarify behavior of some existing turf modules (#2683)
* update turf-rectangle-grid and turf-square-grid docs
* improve area docs
* cleanup
* update earthRadius, first crack at units link, other nits
* improve docs
* nit
* add readme units file
* update area readme manually
* one more readme
* update all readmes
<!-- 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. -->
Copy file name to clipboardExpand all lines: packages/turf-helpers/index.ts
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -57,15 +57,14 @@ export type AllGeoJSON =
57
57
*/
58
58
59
59
/**
60
-
* Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
61
-
*
60
+
* The Earth radius in kilometers. Used by Turf modules that model the Earth as a sphere. The {@link https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius mean radius} was selected because it is {@link https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended recommended } by the Haversine formula (used by turf/distance) to reduce error.
62
61
* @memberof helpers
63
62
* @type {number}
64
63
*/
65
64
exportconstearthRadius=6371008.8;
66
65
67
66
/**
68
-
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
67
+
* Unit of measurement factors based on earthRadius.
69
68
*
70
69
* Keys are the name of the unit, values are the number of that unit in a single radian
*`options.units`**[string][7]**used in calculating cellSide, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
16
-
*`options.mask`**[Feature][3]<([Polygon][8] | [MultiPolygon][9])>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
17
-
*`options.properties`**[Object][6]** passed to each point of the grid (optional, default `{}`)
15
+
*`options.units`**Units**the units of the cellSide value. Supports all valid Turf [Units][4] (optional, default `'kilometers'`)
16
+
*`options.mask`**[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
17
+
*`options.properties`**[Object][3]** passed to each point of the grid (optional, default `{}`)
18
18
19
19
### Examples
20
20
@@ -29,25 +29,25 @@ var grid = turf.pointGrid(extent, cellSide, options);
29
29
var addToMap = [grid];
30
30
```
31
31
32
-
Returns **[FeatureCollection][2]<[Point][1]>** grid of points
32
+
Returns **[FeatureCollection][8]<[Point][9]>** grid of points
<!-- 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. -->
* @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees, radians, miles, or kilometers
21
+
* @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}
22
22
* @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
23
23
* @param {Object} [options.properties={}] passed to each point of the grid
24
24
* @returns {FeatureCollection<Point>} grid of points
*`options.units`**[string][6]** units ("degrees", "radians", "miles", "kilometers") that the given cellWidth
17
-
and cellHeight are expressed in. Converted at the southern border. (optional, default `'kilometers'`)
18
-
*`options.mask`**[Feature][1]<([Polygon][7] | [MultiPolygon][8])>?** if passed a Polygon or MultiPolygon,
16
+
*`options.units`**Units** the units of the cell width and height value.
17
+
Supports all valid Turf [Units][4].
18
+
If you are looking for rectangles with equal width and height in linear units (e.g. kilometers) this is not the module for you.
19
+
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'`)
20
+
*`options.mask`**[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon,
19
21
the grid Points will be created only inside it
20
-
*`options.properties`**[Object][5]** passed to each point of the grid (optional, default `{}`)
22
+
*`options.properties`**[Object][3]** passed to each point of the grid (optional, default `{}`)
<!-- 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. -->
* @param {string} [options.units='kilometers'] units ("degrees", "radians", "miles", "kilometers") that the given cellWidth
25
-
* and cellHeight are expressed in. Converted at the southern border.
24
+
* @param {Units} [options.units='kilometers'] the units of the cell width and height value.
25
+
* Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}.
26
+
* If you are looking for rectangles with equal width and height in linear units (e.g. kilometers) this is not the module for you.
27
+
* 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.
26
28
* @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
27
29
* the grid Points will be created only inside it
28
30
* @param {Object} [options.properties={}] passed to each point of the grid
*`options.units`**[string][4]** used in calculating cellSide, can be degrees,
16
-
radians, miles, or kilometers (optional, default `'kilometers'`)
15
+
*`options.units`**Units** the units of the cellSide value.
16
+
Supports all valid Turf [Units][4].
17
+
If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.
18
+
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'`)
17
19
*`options.mask`**[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon,
18
20
the grid Points will be created only inside it
19
21
*`options.properties`**[Object][3]** passed to each point of the grid (optional, default `{}`)
@@ -31,15 +33,15 @@ var squareGrid = turf.squareGrid(bbox, cellSide, options);
31
33
var addToMap = [squareGrid]
32
34
```
33
35
34
-
Returns **[FeatureCollection][8]<[Polygon][6]>**grid a grid of polygons
36
+
Returns **[FeatureCollection][8]<[Polygon][6]>** a grid of polygons with equal width and height in degrees.
0 commit comments