@turf/sector 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 +51 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +35 -0
- package/dist/esm/index.d.mts +35 -0
- package/dist/esm/index.mjs +51 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +37 -28
- package/dist/es/index.js +0 -75
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -83
- package/index.d.ts +0 -17
package/README.md
CHANGED
|
@@ -49,26 +49,21 @@ Returns **[Feature][6]<[Polygon][7]>** sector polygon
|
|
|
49
49
|
|
|
50
50
|
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
51
51
|
|
|
52
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
53
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
54
|
-
./scripts/generate-readmes in the turf project. -->
|
|
52
|
+
<!-- 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. -->
|
|
55
53
|
|
|
56
54
|
---
|
|
57
55
|
|
|
58
|
-
This module is part of the [Turfjs project](
|
|
59
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
60
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
61
|
-
PRs and issues.
|
|
56
|
+
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.
|
|
62
57
|
|
|
63
58
|
### Installation
|
|
64
59
|
|
|
65
|
-
Install this module individually:
|
|
60
|
+
Install this single module individually:
|
|
66
61
|
|
|
67
62
|
```sh
|
|
68
63
|
$ npm install @turf/sector
|
|
69
64
|
```
|
|
70
65
|
|
|
71
|
-
Or install the
|
|
66
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
72
67
|
|
|
73
68
|
```sh
|
|
74
69
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,51 @@
|
|
|
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 _circle = require('@turf/circle');
|
|
6
|
+
var _linearc = require('@turf/line-arc');
|
|
7
|
+
var _meta = require('@turf/meta');
|
|
8
|
+
var _helpers = require('@turf/helpers');
|
|
9
|
+
var _invariant = require('@turf/invariant');
|
|
10
|
+
function sector(center, radius, bearing1, bearing2, options = {}) {
|
|
11
|
+
options = options || {};
|
|
12
|
+
if (!_helpers.isObject.call(void 0, options))
|
|
13
|
+
throw new Error("options is invalid");
|
|
14
|
+
const properties = options.properties;
|
|
15
|
+
if (!center)
|
|
16
|
+
throw new Error("center is required");
|
|
17
|
+
if (bearing1 === void 0 || bearing1 === null)
|
|
18
|
+
throw new Error("bearing1 is required");
|
|
19
|
+
if (bearing2 === void 0 || bearing2 === null)
|
|
20
|
+
throw new Error("bearing2 is required");
|
|
21
|
+
if (!radius)
|
|
22
|
+
throw new Error("radius is required");
|
|
23
|
+
if (typeof options !== "object")
|
|
24
|
+
throw new Error("options must be an object");
|
|
25
|
+
if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
|
|
26
|
+
return _circle.circle.call(void 0, center, radius, options);
|
|
27
|
+
}
|
|
28
|
+
const coords = _invariant.getCoords.call(void 0, center);
|
|
29
|
+
const arc = _linearc.lineArc.call(void 0, center, radius, bearing1, bearing2, options);
|
|
30
|
+
const sliceCoords = [[coords]];
|
|
31
|
+
_meta.coordEach.call(void 0, arc, function(currentCoords) {
|
|
32
|
+
sliceCoords[0].push(currentCoords);
|
|
33
|
+
});
|
|
34
|
+
sliceCoords[0].push(coords);
|
|
35
|
+
return _helpers.polygon.call(void 0, sliceCoords, properties);
|
|
36
|
+
}
|
|
37
|
+
__name(sector, "sector");
|
|
38
|
+
function convertAngleTo360(alpha) {
|
|
39
|
+
let beta = alpha % 360;
|
|
40
|
+
if (beta < 0) {
|
|
41
|
+
beta += 360;
|
|
42
|
+
}
|
|
43
|
+
return beta;
|
|
44
|
+
}
|
|
45
|
+
__name(convertAngleTo360, "convertAngleTo360");
|
|
46
|
+
var turf_sector_default = sector;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.default = turf_sector_default; exports.sector = sector;
|
|
51
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AACA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAuB,UAAU,eAAe;AAChD,SAAS,iBAAiB;AA2B1B,SAAS,OACP,QACA,QACA,UACA,UACA,UAII,CAAC,GACa;AAElB,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAE5D,QAAM,aAAa,QAAQ;AAG3B,MAAI,CAAC;AAAQ,UAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,CAAC;AAAQ,UAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,OAAO,YAAY;AAAU,UAAM,IAAI,MAAM,2BAA2B;AAE5E,MAAI,kBAAkB,QAAQ,MAAM,kBAAkB,QAAQ,GAAG;AAC/D,WAAO,OAAO,QAAQ,QAAQ,OAAO;AAAA,EACvC;AACA,QAAM,SAAS,UAAU,MAAM;AAC/B,QAAM,MAAM,QAAQ,QAAQ,QAAQ,UAAU,UAAU,OAAO;AAC/D,QAAM,cAAc,CAAC,CAAC,MAAM,CAAC;AAC7B,YAAU,KAAK,SAAU,eAAe;AACtC,gBAAY,CAAC,EAAE,KAAK,aAAa;AAAA,EACnC,CAAC;AACD,cAAY,CAAC,EAAE,KAAK,MAAM;AAE1B,SAAO,QAAQ,aAAa,UAAU;AACxC;AAtCS;AAgDT,SAAS,kBAAkB,OAAe;AACxC,MAAI,OAAO,QAAQ;AACnB,MAAI,OAAO,GAAG;AACZ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AANS;AAST,IAAO,sBAAQ","sourcesContent":["import { Feature, Polygon, GeoJsonProperties } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { lineArc } from \"@turf/line-arc\";\nimport { coordEach } from \"@turf/meta\";\nimport { Units, Coord, isObject, polygon } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\n\n/**\n * Creates a circular sector of a circle of given radius and center {@link Point},\n * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.\n *\n * @name sector\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @param {number} [options.steps=64] number of steps\n * @param {Properties} [options.properties={}] Translate properties to Feature Polygon\n * @returns {Feature<Polygon>} sector polygon\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 45;\n *\n * var sector = turf.sector(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, sector];\n */\nfunction sector(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: GeoJsonProperties;\n } = {}\n): Feature<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n // Most options only for passing through to circle()\n const properties = options.properties;\n\n // validation\n if (!center) throw new Error(\"center is required\");\n if (bearing1 === undefined || bearing1 === null)\n throw new Error(\"bearing1 is required\");\n if (bearing2 === undefined || bearing2 === null)\n throw new Error(\"bearing2 is required\");\n if (!radius) throw new Error(\"radius is required\");\n if (typeof options !== \"object\") throw new Error(\"options must be an object\");\n\n if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {\n return circle(center, radius, options);\n }\n const coords = getCoords(center);\n const arc = lineArc(center, radius, bearing1, bearing2, options);\n const sliceCoords = [[coords]];\n coordEach(arc, function (currentCoords) {\n sliceCoords[0].push(currentCoords);\n });\n sliceCoords[0].push(coords);\n\n return polygon(sliceCoords, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { sector };\nexport default sector;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GeoJsonProperties, Feature, Polygon } from 'geojson';
|
|
2
|
+
import { Coord, Units } from '@turf/helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a circular sector of a circle of given radius and center {@link Point},
|
|
6
|
+
* between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
|
|
7
|
+
*
|
|
8
|
+
* @name sector
|
|
9
|
+
* @param {Coord} center center point
|
|
10
|
+
* @param {number} radius radius of the circle
|
|
11
|
+
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
|
|
12
|
+
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
|
|
13
|
+
* @param {Object} [options={}] Optional parameters
|
|
14
|
+
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
15
|
+
* @param {number} [options.steps=64] number of steps
|
|
16
|
+
* @param {Properties} [options.properties={}] Translate properties to Feature Polygon
|
|
17
|
+
* @returns {Feature<Polygon>} sector polygon
|
|
18
|
+
* @example
|
|
19
|
+
* var center = turf.point([-75, 40]);
|
|
20
|
+
* var radius = 5;
|
|
21
|
+
* var bearing1 = 25;
|
|
22
|
+
* var bearing2 = 45;
|
|
23
|
+
*
|
|
24
|
+
* var sector = turf.sector(center, radius, bearing1, bearing2);
|
|
25
|
+
*
|
|
26
|
+
* //addToMap
|
|
27
|
+
* var addToMap = [center, sector];
|
|
28
|
+
*/
|
|
29
|
+
declare function sector(center: Coord, radius: number, bearing1: number, bearing2: number, options?: {
|
|
30
|
+
steps?: number;
|
|
31
|
+
units?: Units;
|
|
32
|
+
properties?: GeoJsonProperties;
|
|
33
|
+
}): Feature<Polygon>;
|
|
34
|
+
|
|
35
|
+
export { sector as default, sector };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GeoJsonProperties, Feature, Polygon } from 'geojson';
|
|
2
|
+
import { Coord, Units } from '@turf/helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a circular sector of a circle of given radius and center {@link Point},
|
|
6
|
+
* between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
|
|
7
|
+
*
|
|
8
|
+
* @name sector
|
|
9
|
+
* @param {Coord} center center point
|
|
10
|
+
* @param {number} radius radius of the circle
|
|
11
|
+
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
|
|
12
|
+
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
|
|
13
|
+
* @param {Object} [options={}] Optional parameters
|
|
14
|
+
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
15
|
+
* @param {number} [options.steps=64] number of steps
|
|
16
|
+
* @param {Properties} [options.properties={}] Translate properties to Feature Polygon
|
|
17
|
+
* @returns {Feature<Polygon>} sector polygon
|
|
18
|
+
* @example
|
|
19
|
+
* var center = turf.point([-75, 40]);
|
|
20
|
+
* var radius = 5;
|
|
21
|
+
* var bearing1 = 25;
|
|
22
|
+
* var bearing2 = 45;
|
|
23
|
+
*
|
|
24
|
+
* var sector = turf.sector(center, radius, bearing1, bearing2);
|
|
25
|
+
*
|
|
26
|
+
* //addToMap
|
|
27
|
+
* var addToMap = [center, sector];
|
|
28
|
+
*/
|
|
29
|
+
declare function sector(center: Coord, radius: number, bearing1: number, bearing2: number, options?: {
|
|
30
|
+
steps?: number;
|
|
31
|
+
units?: Units;
|
|
32
|
+
properties?: GeoJsonProperties;
|
|
33
|
+
}): Feature<Polygon>;
|
|
34
|
+
|
|
35
|
+
export { sector as default, sector };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { circle } from "@turf/circle";
|
|
6
|
+
import { lineArc } from "@turf/line-arc";
|
|
7
|
+
import { coordEach } from "@turf/meta";
|
|
8
|
+
import { isObject, polygon } from "@turf/helpers";
|
|
9
|
+
import { getCoords } from "@turf/invariant";
|
|
10
|
+
function sector(center, radius, bearing1, bearing2, options = {}) {
|
|
11
|
+
options = options || {};
|
|
12
|
+
if (!isObject(options))
|
|
13
|
+
throw new Error("options is invalid");
|
|
14
|
+
const properties = options.properties;
|
|
15
|
+
if (!center)
|
|
16
|
+
throw new Error("center is required");
|
|
17
|
+
if (bearing1 === void 0 || bearing1 === null)
|
|
18
|
+
throw new Error("bearing1 is required");
|
|
19
|
+
if (bearing2 === void 0 || bearing2 === null)
|
|
20
|
+
throw new Error("bearing2 is required");
|
|
21
|
+
if (!radius)
|
|
22
|
+
throw new Error("radius is required");
|
|
23
|
+
if (typeof options !== "object")
|
|
24
|
+
throw new Error("options must be an object");
|
|
25
|
+
if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
|
|
26
|
+
return circle(center, radius, options);
|
|
27
|
+
}
|
|
28
|
+
const coords = getCoords(center);
|
|
29
|
+
const arc = lineArc(center, radius, bearing1, bearing2, options);
|
|
30
|
+
const sliceCoords = [[coords]];
|
|
31
|
+
coordEach(arc, function(currentCoords) {
|
|
32
|
+
sliceCoords[0].push(currentCoords);
|
|
33
|
+
});
|
|
34
|
+
sliceCoords[0].push(coords);
|
|
35
|
+
return polygon(sliceCoords, properties);
|
|
36
|
+
}
|
|
37
|
+
__name(sector, "sector");
|
|
38
|
+
function convertAngleTo360(alpha) {
|
|
39
|
+
let beta = alpha % 360;
|
|
40
|
+
if (beta < 0) {
|
|
41
|
+
beta += 360;
|
|
42
|
+
}
|
|
43
|
+
return beta;
|
|
44
|
+
}
|
|
45
|
+
__name(convertAngleTo360, "convertAngleTo360");
|
|
46
|
+
var turf_sector_default = sector;
|
|
47
|
+
export {
|
|
48
|
+
turf_sector_default as default,
|
|
49
|
+
sector
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Polygon, GeoJsonProperties } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { lineArc } from \"@turf/line-arc\";\nimport { coordEach } from \"@turf/meta\";\nimport { Units, Coord, isObject, polygon } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\n\n/**\n * Creates a circular sector of a circle of given radius and center {@link Point},\n * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.\n *\n * @name sector\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @param {number} [options.steps=64] number of steps\n * @param {Properties} [options.properties={}] Translate properties to Feature Polygon\n * @returns {Feature<Polygon>} sector polygon\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 45;\n *\n * var sector = turf.sector(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, sector];\n */\nfunction sector(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: GeoJsonProperties;\n } = {}\n): Feature<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n // Most options only for passing through to circle()\n const properties = options.properties;\n\n // validation\n if (!center) throw new Error(\"center is required\");\n if (bearing1 === undefined || bearing1 === null)\n throw new Error(\"bearing1 is required\");\n if (bearing2 === undefined || bearing2 === null)\n throw new Error(\"bearing2 is required\");\n if (!radius) throw new Error(\"radius is required\");\n if (typeof options !== \"object\") throw new Error(\"options must be an object\");\n\n if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {\n return circle(center, radius, options);\n }\n const coords = getCoords(center);\n const arc = lineArc(center, radius, bearing1, bearing2, options);\n const sliceCoords = [[coords]];\n coordEach(arc, function (currentCoords) {\n sliceCoords[0].push(currentCoords);\n });\n sliceCoords[0].push(coords);\n\n return polygon(sliceCoords, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { sector };\nexport default sector;\n"],"mappings":";;;;AACA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAuB,UAAU,eAAe;AAChD,SAAS,iBAAiB;AA2B1B,SAAS,OACP,QACA,QACA,UACA,UACA,UAII,CAAC,GACa;AAElB,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAE5D,QAAM,aAAa,QAAQ;AAG3B,MAAI,CAAC;AAAQ,UAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,CAAC;AAAQ,UAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,OAAO,YAAY;AAAU,UAAM,IAAI,MAAM,2BAA2B;AAE5E,MAAI,kBAAkB,QAAQ,MAAM,kBAAkB,QAAQ,GAAG;AAC/D,WAAO,OAAO,QAAQ,QAAQ,OAAO;AAAA,EACvC;AACA,QAAM,SAAS,UAAU,MAAM;AAC/B,QAAM,MAAM,QAAQ,QAAQ,QAAQ,UAAU,UAAU,OAAO;AAC/D,QAAM,cAAc,CAAC,CAAC,MAAM,CAAC;AAC7B,YAAU,KAAK,SAAU,eAAe;AACtC,gBAAY,CAAC,EAAE,KAAK,aAAa;AAAA,EACnC,CAAC;AACD,cAAY,CAAC,EAAE,KAAK,MAAM;AAE1B,SAAO,QAAQ,aAAa,UAAU;AACxC;AAtCS;AAgDT,SAAS,kBAAkB,OAAe;AACxC,MAAI,OAAO,QAAQ;AACnB,MAAI,OAAO,GAAG;AACZ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AANS;AAST,IAAO,sBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/sector",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.110+1411d63a7",
|
|
4
4
|
"description": "turf sector module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,46 +20,55 @@
|
|
|
20
20
|
"turf",
|
|
21
21
|
"gif"
|
|
22
22
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"type": "commonjs",
|
|
24
|
+
"main": "dist/cjs/index.cjs",
|
|
25
|
+
"module": "dist/esm/index.mjs",
|
|
26
|
+
"types": "dist/cjs/index.d.ts",
|
|
25
27
|
"exports": {
|
|
26
28
|
"./package.json": "./package.json",
|
|
27
29
|
".": {
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/esm/index.d.mts",
|
|
32
|
+
"default": "./dist/esm/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/cjs/index.d.ts",
|
|
36
|
+
"default": "./dist/cjs/index.cjs"
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
},
|
|
33
|
-
"types": "index.d.ts",
|
|
34
40
|
"sideEffects": false,
|
|
35
41
|
"files": [
|
|
36
|
-
"dist"
|
|
37
|
-
"index.d.ts"
|
|
42
|
+
"dist"
|
|
38
43
|
],
|
|
39
44
|
"scripts": {
|
|
40
|
-
"bench": "tsx bench.
|
|
41
|
-
"build": "
|
|
42
|
-
"docs": "tsx ../../scripts/generate-readmes",
|
|
43
|
-
"test": "npm-run-all test:*",
|
|
44
|
-
"test:tape": "tsx test.
|
|
45
|
+
"bench": "tsx bench.ts",
|
|
46
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
47
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
48
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
49
|
+
"test:tape": "tsx test.ts",
|
|
45
50
|
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
46
51
|
},
|
|
47
52
|
"devDependencies": {
|
|
48
|
-
"@turf/truncate": "^7.0.0-alpha.
|
|
49
|
-
"benchmark": "
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
53
|
+
"@turf/truncate": "^7.0.0-alpha.110+1411d63a7",
|
|
54
|
+
"@types/benchmark": "^2.1.5",
|
|
55
|
+
"@types/tape": "^4.2.32",
|
|
56
|
+
"benchmark": "^2.1.4",
|
|
57
|
+
"load-json-file": "^7.0.1",
|
|
58
|
+
"npm-run-all": "^4.1.5",
|
|
59
|
+
"tape": "^5.7.2",
|
|
60
|
+
"tsup": "^8.0.1",
|
|
61
|
+
"tsx": "^4.6.2",
|
|
62
|
+
"typescript": "^5.2.2",
|
|
63
|
+
"write-json-file": "^5.0.0"
|
|
56
64
|
},
|
|
57
65
|
"dependencies": {
|
|
58
|
-
"@turf/circle": "^7.0.0-alpha.
|
|
59
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
60
|
-
"@turf/invariant": "^7.0.0-alpha.
|
|
61
|
-
"@turf/line-arc": "^7.0.0-alpha.
|
|
62
|
-
"@turf/meta": "^7.0.0-alpha.
|
|
66
|
+
"@turf/circle": "^7.0.0-alpha.110+1411d63a7",
|
|
67
|
+
"@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
|
|
68
|
+
"@turf/invariant": "^7.0.0-alpha.110+1411d63a7",
|
|
69
|
+
"@turf/line-arc": "^7.0.0-alpha.110+1411d63a7",
|
|
70
|
+
"@turf/meta": "^7.0.0-alpha.110+1411d63a7",
|
|
71
|
+
"tslib": "^2.6.2"
|
|
63
72
|
},
|
|
64
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
|
|
65
74
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import circle from '@turf/circle';
|
|
2
|
-
import lineArc from '@turf/line-arc';
|
|
3
|
-
import { coordEach } from '@turf/meta';
|
|
4
|
-
import { isObject, polygon } from '@turf/helpers';
|
|
5
|
-
import { getCoords } from '@turf/invariant';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a circular sector of a circle of given radius and center {@link Point},
|
|
9
|
-
* between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
|
|
10
|
-
*
|
|
11
|
-
* @name sector
|
|
12
|
-
* @param {Coord} center center point
|
|
13
|
-
* @param {number} radius radius of the circle
|
|
14
|
-
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
|
|
15
|
-
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
|
|
16
|
-
* @param {Object} [options={}] Optional parameters
|
|
17
|
-
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
18
|
-
* @param {number} [options.steps=64] number of steps
|
|
19
|
-
* @param {Properties} [options.properties={}] Translate properties to Feature Polygon
|
|
20
|
-
* @returns {Feature<Polygon>} sector polygon
|
|
21
|
-
* @example
|
|
22
|
-
* var center = turf.point([-75, 40]);
|
|
23
|
-
* var radius = 5;
|
|
24
|
-
* var bearing1 = 25;
|
|
25
|
-
* var bearing2 = 45;
|
|
26
|
-
*
|
|
27
|
-
* var sector = turf.sector(center, radius, bearing1, bearing2);
|
|
28
|
-
*
|
|
29
|
-
* //addToMap
|
|
30
|
-
* var addToMap = [center, sector];
|
|
31
|
-
*/
|
|
32
|
-
function sector(center, radius, bearing1, bearing2, options) {
|
|
33
|
-
// Optional parameters
|
|
34
|
-
options = options || {};
|
|
35
|
-
if (!isObject(options)) throw new Error("options is invalid");
|
|
36
|
-
var properties = options.properties;
|
|
37
|
-
|
|
38
|
-
// validation
|
|
39
|
-
if (!center) throw new Error("center is required");
|
|
40
|
-
if (bearing1 === undefined || bearing1 === null)
|
|
41
|
-
throw new Error("bearing1 is required");
|
|
42
|
-
if (bearing2 === undefined || bearing2 === null)
|
|
43
|
-
throw new Error("bearing2 is required");
|
|
44
|
-
if (!radius) throw new Error("radius is required");
|
|
45
|
-
if (typeof options !== "object") throw new Error("options must be an object");
|
|
46
|
-
|
|
47
|
-
if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
|
|
48
|
-
return circle(center, radius, options);
|
|
49
|
-
}
|
|
50
|
-
var coords = getCoords(center);
|
|
51
|
-
var arc = lineArc(center, radius, bearing1, bearing2, options);
|
|
52
|
-
var sliceCoords = [[coords]];
|
|
53
|
-
coordEach(arc, function (currentCoords) {
|
|
54
|
-
sliceCoords[0].push(currentCoords);
|
|
55
|
-
});
|
|
56
|
-
sliceCoords[0].push(coords);
|
|
57
|
-
|
|
58
|
-
return polygon(sliceCoords, properties);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Takes any angle in degrees
|
|
63
|
-
* and returns a valid angle between 0-360 degrees
|
|
64
|
-
*
|
|
65
|
-
* @private
|
|
66
|
-
* @param {number} alfa angle between -180-180 degrees
|
|
67
|
-
* @returns {number} angle between 0-360 degrees
|
|
68
|
-
*/
|
|
69
|
-
function convertAngleTo360(alfa) {
|
|
70
|
-
var beta = alfa % 360;
|
|
71
|
-
if (beta < 0) beta += 360;
|
|
72
|
-
return beta;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default sector;
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var circle = require('@turf/circle');
|
|
4
|
-
var lineArc = require('@turf/line-arc');
|
|
5
|
-
var meta = require('@turf/meta');
|
|
6
|
-
var helpers = require('@turf/helpers');
|
|
7
|
-
var invariant = require('@turf/invariant');
|
|
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
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Creates a circular sector of a circle of given radius and center {@link Point},
|
|
16
|
-
* between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
|
|
17
|
-
*
|
|
18
|
-
* @name sector
|
|
19
|
-
* @param {Coord} center center point
|
|
20
|
-
* @param {number} radius radius of the circle
|
|
21
|
-
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
|
|
22
|
-
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
|
|
23
|
-
* @param {Object} [options={}] Optional parameters
|
|
24
|
-
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
25
|
-
* @param {number} [options.steps=64] number of steps
|
|
26
|
-
* @param {Properties} [options.properties={}] Translate properties to Feature Polygon
|
|
27
|
-
* @returns {Feature<Polygon>} sector polygon
|
|
28
|
-
* @example
|
|
29
|
-
* var center = turf.point([-75, 40]);
|
|
30
|
-
* var radius = 5;
|
|
31
|
-
* var bearing1 = 25;
|
|
32
|
-
* var bearing2 = 45;
|
|
33
|
-
*
|
|
34
|
-
* var sector = turf.sector(center, radius, bearing1, bearing2);
|
|
35
|
-
*
|
|
36
|
-
* //addToMap
|
|
37
|
-
* var addToMap = [center, sector];
|
|
38
|
-
*/
|
|
39
|
-
function sector(center, radius, bearing1, bearing2, options) {
|
|
40
|
-
// Optional parameters
|
|
41
|
-
options = options || {};
|
|
42
|
-
if (!helpers.isObject(options)) throw new Error("options is invalid");
|
|
43
|
-
var properties = options.properties;
|
|
44
|
-
|
|
45
|
-
// validation
|
|
46
|
-
if (!center) throw new Error("center is required");
|
|
47
|
-
if (bearing1 === undefined || bearing1 === null)
|
|
48
|
-
throw new Error("bearing1 is required");
|
|
49
|
-
if (bearing2 === undefined || bearing2 === null)
|
|
50
|
-
throw new Error("bearing2 is required");
|
|
51
|
-
if (!radius) throw new Error("radius is required");
|
|
52
|
-
if (typeof options !== "object") throw new Error("options must be an object");
|
|
53
|
-
|
|
54
|
-
if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
|
|
55
|
-
return circle__default['default'](center, radius, options);
|
|
56
|
-
}
|
|
57
|
-
var coords = invariant.getCoords(center);
|
|
58
|
-
var arc = lineArc__default['default'](center, radius, bearing1, bearing2, options);
|
|
59
|
-
var sliceCoords = [[coords]];
|
|
60
|
-
meta.coordEach(arc, function (currentCoords) {
|
|
61
|
-
sliceCoords[0].push(currentCoords);
|
|
62
|
-
});
|
|
63
|
-
sliceCoords[0].push(coords);
|
|
64
|
-
|
|
65
|
-
return helpers.polygon(sliceCoords, properties);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Takes any angle in degrees
|
|
70
|
-
* and returns a valid angle between 0-360 degrees
|
|
71
|
-
*
|
|
72
|
-
* @private
|
|
73
|
-
* @param {number} alfa angle between -180-180 degrees
|
|
74
|
-
* @returns {number} angle between 0-360 degrees
|
|
75
|
-
*/
|
|
76
|
-
function convertAngleTo360(alfa) {
|
|
77
|
-
var beta = alfa % 360;
|
|
78
|
-
if (beta < 0) beta += 360;
|
|
79
|
-
return beta;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
module.exports = sector;
|
|
83
|
-
module.exports.default = sector;
|
package/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Feature, Polygon, GeoJsonProperties } from "geojson";
|
|
2
|
-
import { Units, Coord } from "@turf/helpers";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* http://turfjs.org/docs/#sector
|
|
6
|
-
*/
|
|
7
|
-
export default function sector(
|
|
8
|
-
center: Coord,
|
|
9
|
-
radius: number,
|
|
10
|
-
bearing1: number,
|
|
11
|
-
bearing2: number,
|
|
12
|
-
options?: {
|
|
13
|
-
steps?: number;
|
|
14
|
-
units?: Units;
|
|
15
|
-
properties?: GeoJsonProperties;
|
|
16
|
-
}
|
|
17
|
-
): Feature<Polygon>;
|