@turf/circle 7.0.0-alpha.1 → 7.0.0-alpha.110
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 +4 -9
- package/dist/cjs/index.cjs +25 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{js → cjs}/index.d.ts +6 -4
- package/dist/{es/index.js → esm/index.d.mts} +10 -20
- package/dist/esm/index.mjs +25 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +34 -29
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -43
package/README.md
CHANGED
|
@@ -46,26 +46,21 @@ Returns **[Feature][2]<[Polygon][8]>** circle polygon
|
|
|
46
46
|
|
|
47
47
|
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
48
48
|
|
|
49
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
50
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
51
|
-
./scripts/generate-readmes in the turf project. -->
|
|
49
|
+
<!-- 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. -->
|
|
52
50
|
|
|
53
51
|
---
|
|
54
52
|
|
|
55
|
-
This module is part of the [Turfjs project](
|
|
56
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
57
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
58
|
-
PRs and issues.
|
|
53
|
+
This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
|
|
59
54
|
|
|
60
55
|
### Installation
|
|
61
56
|
|
|
62
|
-
Install this module individually:
|
|
57
|
+
Install this single module individually:
|
|
63
58
|
|
|
64
59
|
```sh
|
|
65
60
|
$ npm install @turf/circle
|
|
66
61
|
```
|
|
67
62
|
|
|
68
|
-
Or install the
|
|
63
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
69
64
|
|
|
70
65
|
```sh
|
|
71
66
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
var _destination = require('@turf/destination');
|
|
6
|
+
var _helpers = require('@turf/helpers');
|
|
7
|
+
function circle(center, radius, options = {}) {
|
|
8
|
+
const steps = options.steps || 64;
|
|
9
|
+
const properties = options.properties ? options.properties : !Array.isArray(center) && center.type === "Feature" && center.properties ? center.properties : {};
|
|
10
|
+
const coordinates = [];
|
|
11
|
+
for (let i = 0; i < steps; i++) {
|
|
12
|
+
coordinates.push(
|
|
13
|
+
_destination.destination.call(void 0, center, radius, i * -360 / steps, options).geometry.coordinates
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
coordinates.push(coordinates[0]);
|
|
17
|
+
return _helpers.polygon.call(void 0, [coordinates], properties);
|
|
18
|
+
}
|
|
19
|
+
__name(circle, "circle");
|
|
20
|
+
var turf_circle_default = circle;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.circle = circle; exports.default = turf_circle_default;
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,eAAsB;AAsB/B,SAAS,OACP,QACA,QACA,UAII,CAAC,GACgB;AAErB,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,aAAkB,QAAQ,aAC5B,QAAQ,aACR,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,aAAa,OAAO,aAC5D,OAAO,aACP,CAAC;AAGP,QAAM,cAAc,CAAC;AACrB,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAC9B,gBAAY;AAAA,MACV,YAAY,QAAQ,QAAS,IAAI,OAAQ,OAAO,OAAO,EAAE,SACtD;AAAA,IACL;AAAA,EACF;AACA,cAAY,KAAK,YAAY,CAAC,CAAC;AAE/B,SAAO,QAAQ,CAAC,WAAW,GAAG,UAAU;AAC1C;AA5BS;AA+BT,IAAO,sBAAQ","sourcesContent":["import { GeoJsonProperties, Feature, Point, Polygon } from \"geojson\";\nimport { destination } from \"@turf/destination\";\nimport { polygon, Units } from \"@turf/helpers\";\n\n/**\n * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.\n *\n * @name circle\n * @param {Feature<Point>|number[]} center center point\n * @param {number} radius radius of the circle\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.steps=64] number of steps\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @param {Object} [options.properties={}] properties\n * @returns {Feature<Polygon>} circle polygon\n * @example\n * var center = [-75.343, 39.984];\n * var radius = 5;\n * var options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}};\n * var circle = turf.circle(center, radius, options);\n *\n * //addToMap\n * var addToMap = [turf.point(center), circle]\n */\nfunction circle<P extends GeoJsonProperties = GeoJsonProperties>(\n center: number[] | Point | Feature<Point, P>,\n radius: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Polygon, P> {\n // default params\n const steps = options.steps || 64;\n const properties: any = options.properties\n ? options.properties\n : !Array.isArray(center) && center.type === \"Feature\" && center.properties\n ? center.properties\n : {};\n\n // main\n const coordinates = [];\n for (let i = 0; i < steps; i++) {\n coordinates.push(\n destination(center, radius, (i * -360) / steps, options).geometry\n .coordinates\n );\n }\n coordinates.push(coordinates[0]);\n\n return polygon([coordinates], properties);\n}\n\nexport { circle };\nexport default circle;\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GeoJsonProperties,
|
|
2
|
-
import { Units } from
|
|
1
|
+
import { GeoJsonProperties, Point, Feature, Polygon } from 'geojson';
|
|
2
|
+
import { Units } from '@turf/helpers';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
5
6
|
*
|
|
@@ -20,9 +21,10 @@ import { Units } from "@turf/helpers";
|
|
|
20
21
|
* //addToMap
|
|
21
22
|
* var addToMap = [turf.point(center), circle]
|
|
22
23
|
*/
|
|
23
|
-
declare function circle<P = GeoJsonProperties>(center: number[] | Point | Feature<Point, P>, radius: number, options?: {
|
|
24
|
+
declare function circle<P extends GeoJsonProperties = GeoJsonProperties>(center: number[] | Point | Feature<Point, P>, radius: number, options?: {
|
|
24
25
|
steps?: number;
|
|
25
26
|
units?: Units;
|
|
26
27
|
properties?: P;
|
|
27
28
|
}): Feature<Polygon, P>;
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
export { circle, circle as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { GeoJsonProperties, Point, Feature, Polygon } from 'geojson';
|
|
2
|
+
import { Units } from '@turf/helpers';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
5
6
|
*
|
|
@@ -20,21 +21,10 @@ import { polygon } from "@turf/helpers";
|
|
|
20
21
|
* //addToMap
|
|
21
22
|
* var addToMap = [turf.point(center), circle]
|
|
22
23
|
*/
|
|
23
|
-
function circle(center, radius, options
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: {};
|
|
31
|
-
// main
|
|
32
|
-
const coordinates = [];
|
|
33
|
-
for (let i = 0; i < steps; i++) {
|
|
34
|
-
coordinates.push(destination(center, radius, (i * -360) / steps, options).geometry
|
|
35
|
-
.coordinates);
|
|
36
|
-
}
|
|
37
|
-
coordinates.push(coordinates[0]);
|
|
38
|
-
return polygon([coordinates], properties);
|
|
39
|
-
}
|
|
40
|
-
export default circle;
|
|
24
|
+
declare function circle<P extends GeoJsonProperties = GeoJsonProperties>(center: number[] | Point | Feature<Point, P>, radius: number, options?: {
|
|
25
|
+
steps?: number;
|
|
26
|
+
units?: Units;
|
|
27
|
+
properties?: P;
|
|
28
|
+
}): Feature<Polygon, P>;
|
|
29
|
+
|
|
30
|
+
export { circle, circle as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { destination } from "@turf/destination";
|
|
6
|
+
import { polygon } from "@turf/helpers";
|
|
7
|
+
function circle(center, radius, options = {}) {
|
|
8
|
+
const steps = options.steps || 64;
|
|
9
|
+
const properties = options.properties ? options.properties : !Array.isArray(center) && center.type === "Feature" && center.properties ? center.properties : {};
|
|
10
|
+
const coordinates = [];
|
|
11
|
+
for (let i = 0; i < steps; i++) {
|
|
12
|
+
coordinates.push(
|
|
13
|
+
destination(center, radius, i * -360 / steps, options).geometry.coordinates
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
coordinates.push(coordinates[0]);
|
|
17
|
+
return polygon([coordinates], properties);
|
|
18
|
+
}
|
|
19
|
+
__name(circle, "circle");
|
|
20
|
+
var turf_circle_default = circle;
|
|
21
|
+
export {
|
|
22
|
+
circle,
|
|
23
|
+
turf_circle_default as default
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { GeoJsonProperties, Feature, Point, Polygon } from \"geojson\";\nimport { destination } from \"@turf/destination\";\nimport { polygon, Units } from \"@turf/helpers\";\n\n/**\n * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.\n *\n * @name circle\n * @param {Feature<Point>|number[]} center center point\n * @param {number} radius radius of the circle\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.steps=64] number of steps\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @param {Object} [options.properties={}] properties\n * @returns {Feature<Polygon>} circle polygon\n * @example\n * var center = [-75.343, 39.984];\n * var radius = 5;\n * var options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}};\n * var circle = turf.circle(center, radius, options);\n *\n * //addToMap\n * var addToMap = [turf.point(center), circle]\n */\nfunction circle<P extends GeoJsonProperties = GeoJsonProperties>(\n center: number[] | Point | Feature<Point, P>,\n radius: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Polygon, P> {\n // default params\n const steps = options.steps || 64;\n const properties: any = options.properties\n ? options.properties\n : !Array.isArray(center) && center.type === \"Feature\" && center.properties\n ? center.properties\n : {};\n\n // main\n const coordinates = [];\n for (let i = 0; i < steps; i++) {\n coordinates.push(\n destination(center, radius, (i * -360) / steps, options).geometry\n .coordinates\n );\n }\n coordinates.push(coordinates[0]);\n\n return polygon([coordinates], properties);\n}\n\nexport { circle };\nexport default circle;\n"],"mappings":";;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,eAAsB;AAsB/B,SAAS,OACP,QACA,QACA,UAII,CAAC,GACgB;AAErB,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,aAAkB,QAAQ,aAC5B,QAAQ,aACR,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,aAAa,OAAO,aAC5D,OAAO,aACP,CAAC;AAGP,QAAM,cAAc,CAAC;AACrB,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAC9B,gBAAY;AAAA,MACV,YAAY,QAAQ,QAAS,IAAI,OAAQ,OAAO,OAAO,EAAE,SACtD;AAAA,IACL;AAAA,EACF;AACA,cAAY,KAAK,YAAY,CAAC,CAAC;AAE/B,SAAO,QAAQ,CAAC,WAAW,GAAG,UAAU;AAC1C;AA5BS;AA+BT,IAAO,sBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/circle",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.110+1411d63a7",
|
|
4
4
|
"description": "turf circle module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,48 +24,53 @@
|
|
|
24
24
|
"miles",
|
|
25
25
|
"km"
|
|
26
26
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"type": "commonjs",
|
|
28
|
+
"main": "dist/cjs/index.cjs",
|
|
29
|
+
"module": "dist/esm/index.mjs",
|
|
30
|
+
"types": "dist/cjs/index.d.ts",
|
|
29
31
|
"exports": {
|
|
30
32
|
"./package.json": "./package.json",
|
|
31
33
|
".": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/esm/index.d.mts",
|
|
36
|
+
"default": "./dist/esm/index.mjs"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/cjs/index.d.ts",
|
|
40
|
+
"default": "./dist/cjs/index.cjs"
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
|
-
"types": "dist/js/index.d.ts",
|
|
38
44
|
"sideEffects": false,
|
|
39
45
|
"files": [
|
|
40
46
|
"dist"
|
|
41
47
|
],
|
|
42
48
|
"scripts": {
|
|
43
|
-
"bench": "tsx bench.
|
|
44
|
-
"build": "
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"test": "npm-run-all test:*",
|
|
49
|
-
"test:tape": "tsx test.js",
|
|
49
|
+
"bench": "tsx bench.ts",
|
|
50
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
51
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
52
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
53
|
+
"test:tape": "tsx test.ts",
|
|
50
54
|
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
|
-
"@mapbox/geojsonhint": "
|
|
54
|
-
"@turf/truncate": "^7.0.0-alpha.
|
|
55
|
-
"@types/
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
57
|
+
"@mapbox/geojsonhint": "^3.2.0",
|
|
58
|
+
"@turf/truncate": "^7.0.0-alpha.110+1411d63a7",
|
|
59
|
+
"@types/benchmark": "^2.1.5",
|
|
60
|
+
"@types/tape": "^4.2.32",
|
|
61
|
+
"benchmark": "^2.1.4",
|
|
62
|
+
"load-json-file": "^7.0.1",
|
|
63
|
+
"npm-run-all": "^4.1.5",
|
|
64
|
+
"tape": "^5.7.2",
|
|
65
|
+
"tsup": "^8.0.1",
|
|
66
|
+
"tsx": "^4.6.2",
|
|
67
|
+
"typescript": "^5.2.2",
|
|
68
|
+
"write-json-file": "^5.0.0"
|
|
64
69
|
},
|
|
65
70
|
"dependencies": {
|
|
66
|
-
"@turf/destination": "^7.0.0-alpha.
|
|
67
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
68
|
-
"tslib": "^2.
|
|
71
|
+
"@turf/destination": "^7.0.0-alpha.110+1411d63a7",
|
|
72
|
+
"@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
|
|
73
|
+
"tslib": "^2.6.2"
|
|
69
74
|
},
|
|
70
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
|
|
71
76
|
}
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const destination_1 = tslib_1.__importDefault(require("@turf/destination"));
|
|
5
|
-
const helpers_1 = require("@turf/helpers");
|
|
6
|
-
/**
|
|
7
|
-
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
|
8
|
-
*
|
|
9
|
-
* @name circle
|
|
10
|
-
* @param {Feature<Point>|number[]} center center point
|
|
11
|
-
* @param {number} radius radius of the circle
|
|
12
|
-
* @param {Object} [options={}] Optional parameters
|
|
13
|
-
* @param {number} [options.steps=64] number of steps
|
|
14
|
-
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
15
|
-
* @param {Object} [options.properties={}] properties
|
|
16
|
-
* @returns {Feature<Polygon>} circle polygon
|
|
17
|
-
* @example
|
|
18
|
-
* var center = [-75.343, 39.984];
|
|
19
|
-
* var radius = 5;
|
|
20
|
-
* var options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}};
|
|
21
|
-
* var circle = turf.circle(center, radius, options);
|
|
22
|
-
*
|
|
23
|
-
* //addToMap
|
|
24
|
-
* var addToMap = [turf.point(center), circle]
|
|
25
|
-
*/
|
|
26
|
-
function circle(center, radius, options = {}) {
|
|
27
|
-
// default params
|
|
28
|
-
const steps = options.steps || 64;
|
|
29
|
-
const properties = options.properties
|
|
30
|
-
? options.properties
|
|
31
|
-
: !Array.isArray(center) && center.type === "Feature" && center.properties
|
|
32
|
-
? center.properties
|
|
33
|
-
: {};
|
|
34
|
-
// main
|
|
35
|
-
const coordinates = [];
|
|
36
|
-
for (let i = 0; i < steps; i++) {
|
|
37
|
-
coordinates.push(destination_1.default(center, radius, (i * -360) / steps, options).geometry
|
|
38
|
-
.coordinates);
|
|
39
|
-
}
|
|
40
|
-
coordinates.push(coordinates[0]);
|
|
41
|
-
return helpers_1.polygon([coordinates], properties);
|
|
42
|
-
}
|
|
43
|
-
exports.default = circle;
|