@turf/circle 7.0.0-alpha.2 → 7.0.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 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](http://turfjs.org/), an open source
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 Turf module that includes it as a function:
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 destination from "@turf/destination";
2
- import { polygon } from "@turf/helpers";
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
- // default params
25
- const steps = options.steps || 64;
26
- const properties = options.properties
27
- ? options.properties
28
- : !Array.isArray(center) && center.type === "Feature" && center.properties
29
- ? center.properties
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 };
@@ -1,5 +1,6 @@
1
- import { GeoJsonProperties, Feature, Point, Polygon } from "geojson";
2
- import { Units } from "@turf/helpers";
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
- export default circle;
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.js.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.2",
3
+ "version": "7.0.0",
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
- "main": "dist/js/index.js",
28
- "module": "dist/es/index.js",
27
+ "type": "module",
28
+ "main": "dist/cjs/index.cjs",
29
+ "module": "dist/esm/index.js",
30
+ "types": "dist/esm/index.d.ts",
29
31
  "exports": {
30
32
  "./package.json": "./package.json",
31
33
  ".": {
32
- "types": "./dist/js/index.d.ts",
33
- "import": "./dist/es/index.js",
34
- "require": "./dist/js/index.js"
34
+ "import": {
35
+ "types": "./dist/esm/index.d.ts",
36
+ "default": "./dist/esm/index.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/cjs/index.d.cts",
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.js",
44
- "build": "npm-run-all build:*",
45
- "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
46
- "build:js": "tsc",
47
- "docs": "tsx ../../scripts/generate-readmes",
48
- "test": "npm-run-all test:*",
49
- "test:tape": "tsx test.js",
50
- "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
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",
54
+ "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
51
55
  },
52
56
  "devDependencies": {
53
- "@mapbox/geojsonhint": "*",
54
- "@turf/truncate": "^7.0.0-alpha.2",
55
- "@types/tape": "*",
56
- "benchmark": "*",
57
- "load-json-file": "*",
58
- "npm-run-all": "*",
59
- "tape": "*",
60
- "tslint": "*",
61
- "tsx": "*",
62
- "typescript": "*",
63
- "write-json-file": "*"
57
+ "@placemarkio/check-geojson": "^0.1.12",
58
+ "@turf/truncate": "^7.0.0",
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.2",
67
- "@turf/helpers": "^7.0.0-alpha.2",
68
- "tslib": "^2.3.0"
71
+ "@turf/destination": "^7.0.0",
72
+ "@turf/helpers": "^7.0.0",
73
+ "tslib": "^2.6.2"
69
74
  },
70
- "gitHead": "dd35b52725945b4fa29a98d9a550733e06cc222e"
75
+ "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
71
76
  }
@@ -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;