@turf/sector 6.4.0 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -11
- package/dist/es/index.js +1 -1
- package/dist/js/index.js +10 -6
- package/index.d.ts +3 -2
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -7,18 +7,19 @@
|
|
|
7
7
|
Creates a circular sector of a circle of given radius and center [Point][1],
|
|
8
8
|
between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- `options.units` **[string][5]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
18
|
-
- `options.steps` **[number][3]** number of steps (optional, default `64`)
|
|
19
|
-
- `options.properties` **Properties** Translate properties to Feature Polygon (optional, default `{}`)
|
|
12
|
+
* `center` **[Coord][2]** center point
|
|
13
|
+
* `radius` **[number][3]** radius of the circle
|
|
14
|
+
* `bearing1` **[number][3]** angle, in decimal degrees, of the first radius of the sector
|
|
15
|
+
* `bearing2` **[number][3]** angle, in decimal degrees, of the second radius of the sector
|
|
16
|
+
* `options` **[Object][4]** Optional parameters (optional, default `{}`)
|
|
20
17
|
|
|
21
|
-
**
|
|
18
|
+
* `options.units` **[string][5]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
19
|
+
* `options.steps` **[number][3]** number of steps (optional, default `64`)
|
|
20
|
+
* `options.properties` **Properties** Translate properties to Feature Polygon (optional, default `{}`)
|
|
21
|
+
|
|
22
|
+
### Examples
|
|
22
23
|
|
|
23
24
|
```javascript
|
|
24
25
|
var center = turf.point([-75, 40]);
|
|
@@ -32,7 +33,7 @@ var sector = turf.sector(center, radius, bearing1, bearing2);
|
|
|
32
33
|
var addToMap = [center, sector];
|
|
33
34
|
```
|
|
34
35
|
|
|
35
|
-
Returns **[Feature][6]
|
|
36
|
+
Returns **[Feature][6]<[Polygon][7]>** sector polygon
|
|
36
37
|
|
|
37
38
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
38
39
|
|
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import circle from '@turf/circle';
|
|
2
2
|
import lineArc from '@turf/line-arc';
|
|
3
3
|
import { coordEach } from '@turf/meta';
|
|
4
|
-
import {
|
|
4
|
+
import { isObject, polygon } from '@turf/helpers';
|
|
5
5
|
import { getCoords } from '@turf/invariant';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/js/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var circle = _interopDefault(require('@turf/circle'));
|
|
6
|
-
var lineArc = _interopDefault(require('@turf/line-arc'));
|
|
3
|
+
var circle = require('@turf/circle');
|
|
4
|
+
var lineArc = require('@turf/line-arc');
|
|
7
5
|
var meta = require('@turf/meta');
|
|
8
6
|
var helpers = require('@turf/helpers');
|
|
9
7
|
var invariant = require('@turf/invariant');
|
|
10
8
|
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var circle__default = /*#__PURE__*/_interopDefaultLegacy(circle);
|
|
12
|
+
var lineArc__default = /*#__PURE__*/_interopDefaultLegacy(lineArc);
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
* Creates a circular sector of a circle of given radius and center {@link Point},
|
|
13
16
|
* between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
|
|
@@ -49,10 +52,10 @@ function sector(center, radius, bearing1, bearing2, options) {
|
|
|
49
52
|
if (typeof options !== "object") throw new Error("options must be an object");
|
|
50
53
|
|
|
51
54
|
if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
|
|
52
|
-
return
|
|
55
|
+
return circle__default['default'](center, radius, options);
|
|
53
56
|
}
|
|
54
57
|
var coords = invariant.getCoords(center);
|
|
55
|
-
var arc =
|
|
58
|
+
var arc = lineArc__default['default'](center, radius, bearing1, bearing2, options);
|
|
56
59
|
var sliceCoords = [[coords]];
|
|
57
60
|
meta.coordEach(arc, function (currentCoords) {
|
|
58
61
|
sliceCoords[0].push(currentCoords);
|
|
@@ -77,3 +80,4 @@ function convertAngleTo360(alfa) {
|
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
module.exports = sector;
|
|
83
|
+
module.exports.default = sector;
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Feature, Polygon,
|
|
1
|
+
import { Feature, Polygon, GeoJsonProperties } from "geojson";
|
|
2
|
+
import { Units, Coord } from "@turf/helpers";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* http://turfjs.org/docs/#sector
|
|
@@ -11,6 +12,6 @@ export default function sector(
|
|
|
11
12
|
options?: {
|
|
12
13
|
steps?: number;
|
|
13
14
|
units?: Units;
|
|
14
|
-
properties?:
|
|
15
|
+
properties?: GeoJsonProperties;
|
|
15
16
|
}
|
|
16
17
|
): Feature<Polygon>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/sector",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf sector module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git://github.com/Turfjs/turf.git"
|
|
14
14
|
},
|
|
15
|
+
"funding": "https://opencollective.com/turf",
|
|
15
16
|
"publishConfig": {
|
|
16
17
|
"access": "public"
|
|
17
18
|
},
|
|
@@ -40,10 +41,10 @@
|
|
|
40
41
|
"docs": "node ../../scripts/generate-readmes",
|
|
41
42
|
"test": "npm-run-all test:*",
|
|
42
43
|
"test:tape": "node -r esm test.js",
|
|
43
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
44
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@turf/truncate": "^
|
|
47
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
47
48
|
"benchmark": "*",
|
|
48
49
|
"load-json-file": "*",
|
|
49
50
|
"npm-run-all": "*",
|
|
@@ -52,11 +53,11 @@
|
|
|
52
53
|
"write-json-file": "*"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
|
-
"@turf/circle": "^
|
|
56
|
-
"@turf/helpers": "^
|
|
57
|
-
"@turf/invariant": "^
|
|
58
|
-
"@turf/line-arc": "^
|
|
59
|
-
"@turf/meta": "^
|
|
56
|
+
"@turf/circle": "^7.0.0-alpha.0",
|
|
57
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
58
|
+
"@turf/invariant": "^7.0.0-alpha.0",
|
|
59
|
+
"@turf/line-arc": "^7.0.0-alpha.0",
|
|
60
|
+
"@turf/meta": "^7.0.0-alpha.0"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
62
63
|
}
|