@turf/circle 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 +10 -9
- package/dist/es/index.js +6 -7
- package/dist/js/index.d.ts +3 -2
- package/dist/js/index.js +8 -11
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -6,16 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
Takes a [Point][1] and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `options.steps` **[number][5]** number of steps (optional, default `64`)
|
|
15
|
-
- `options.units` **[string][7]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
16
|
-
- `options.properties` **[Object][6]** properties (optional, default `{}`)
|
|
11
|
+
* `center` **([Feature][2]<[Point][3]> | [Array][4]<[number][5]>)** center point
|
|
12
|
+
* `radius` **[number][5]** radius of the circle
|
|
13
|
+
* `options` **[Object][6]** Optional parameters (optional, default `{}`)
|
|
17
14
|
|
|
18
|
-
**
|
|
15
|
+
* `options.steps` **[number][5]** number of steps (optional, default `64`)
|
|
16
|
+
* `options.units` **[string][7]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
17
|
+
* `options.properties` **[Object][6]** properties (optional, default `{}`)
|
|
18
|
+
|
|
19
|
+
### Examples
|
|
19
20
|
|
|
20
21
|
```javascript
|
|
21
22
|
var center = [-75.343, 39.984];
|
|
@@ -27,7 +28,7 @@ var circle = turf.circle(center, radius, options);
|
|
|
27
28
|
var addToMap = [turf.point(center), circle]
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
Returns **[Feature][2]
|
|
31
|
+
Returns **[Feature][2]<[Polygon][8]>** circle polygon
|
|
31
32
|
|
|
32
33
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
33
34
|
|
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import destination from "@turf/destination";
|
|
2
|
-
import { polygon
|
|
2
|
+
import { polygon } from "@turf/helpers";
|
|
3
3
|
/**
|
|
4
4
|
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
5
5
|
*
|
|
@@ -20,18 +20,17 @@ import { polygon, } from "@turf/helpers";
|
|
|
20
20
|
* //addToMap
|
|
21
21
|
* var addToMap = [turf.point(center), circle]
|
|
22
22
|
*/
|
|
23
|
-
function circle(center, radius, options) {
|
|
24
|
-
if (options === void 0) { options = {}; }
|
|
23
|
+
function circle(center, radius, options = {}) {
|
|
25
24
|
// default params
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const steps = options.steps || 64;
|
|
26
|
+
const properties = options.properties
|
|
28
27
|
? options.properties
|
|
29
28
|
: !Array.isArray(center) && center.type === "Feature" && center.properties
|
|
30
29
|
? center.properties
|
|
31
30
|
: {};
|
|
32
31
|
// main
|
|
33
|
-
|
|
34
|
-
for (
|
|
32
|
+
const coordinates = [];
|
|
33
|
+
for (let i = 0; i < steps; i++) {
|
|
35
34
|
coordinates.push(destination(center, radius, (i * -360) / steps, options).geometry
|
|
36
35
|
.coordinates);
|
|
37
36
|
}
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GeoJsonProperties, Feature, Point, Polygon } from "geojson";
|
|
2
|
+
import { Units } from "@turf/helpers";
|
|
2
3
|
/**
|
|
3
4
|
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
4
5
|
*
|
|
@@ -19,7 +20,7 @@ import { Units, Point, Properties, Feature, Polygon } from "@turf/helpers";
|
|
|
19
20
|
* //addToMap
|
|
20
21
|
* var addToMap = [turf.point(center), circle]
|
|
21
22
|
*/
|
|
22
|
-
declare function circle<P =
|
|
23
|
+
declare function circle<P = GeoJsonProperties>(center: number[] | Point | Feature<Point, P>, radius: number, options?: {
|
|
23
24
|
steps?: number;
|
|
24
25
|
units?: Units;
|
|
25
26
|
properties?: P;
|
package/dist/js/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const destination_1 = tslib_1.__importDefault(require("@turf/destination"));
|
|
5
|
+
const helpers_1 = require("@turf/helpers");
|
|
8
6
|
/**
|
|
9
7
|
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
10
8
|
*
|
|
@@ -25,18 +23,17 @@ var helpers_1 = require("@turf/helpers");
|
|
|
25
23
|
* //addToMap
|
|
26
24
|
* var addToMap = [turf.point(center), circle]
|
|
27
25
|
*/
|
|
28
|
-
function circle(center, radius, options) {
|
|
29
|
-
if (options === void 0) { options = {}; }
|
|
26
|
+
function circle(center, radius, options = {}) {
|
|
30
27
|
// default params
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const steps = options.steps || 64;
|
|
29
|
+
const properties = options.properties
|
|
33
30
|
? options.properties
|
|
34
31
|
: !Array.isArray(center) && center.type === "Feature" && center.properties
|
|
35
32
|
? center.properties
|
|
36
33
|
: {};
|
|
37
34
|
// main
|
|
38
|
-
|
|
39
|
-
for (
|
|
35
|
+
const coordinates = [];
|
|
36
|
+
for (let i = 0; i < steps; i++) {
|
|
40
37
|
coordinates.push(destination_1.default(center, radius, (i * -360) / steps, options).geometry
|
|
41
38
|
.coordinates);
|
|
42
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/circle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf circle 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
|
},
|
|
@@ -45,11 +46,11 @@
|
|
|
45
46
|
"docs": "node ../../scripts/generate-readmes",
|
|
46
47
|
"test": "npm-run-all test:*",
|
|
47
48
|
"test:tape": "ts-node -r esm test.js",
|
|
48
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
49
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@mapbox/geojsonhint": "*",
|
|
52
|
-
"@turf/truncate": "^
|
|
53
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
53
54
|
"@types/tape": "*",
|
|
54
55
|
"benchmark": "*",
|
|
55
56
|
"load-json-file": "*",
|
|
@@ -61,8 +62,9 @@
|
|
|
61
62
|
"write-json-file": "*"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@turf/destination": "^
|
|
65
|
-
"@turf/helpers": "^
|
|
65
|
+
"@turf/destination": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
67
|
+
"tslib": "^2.3.0"
|
|
66
68
|
},
|
|
67
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
68
70
|
}
|