@turf/line-arc
Advanced tools
Comparing version 5.1.5 to 6.0.0
@@ -1,15 +0,29 @@ | ||
import { Coord, Feature, LineString, Units } from '@turf/helpers'; | ||
import { Coord, Feature, LineString, Units } from "@turf/helpers"; | ||
/** | ||
* http://turfjs.org/docs/#linearc | ||
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; | ||
* 0 bearing is North of center point, positive clockwise. | ||
* | ||
* @name lineArc | ||
* @param {Coord} center center point | ||
* @param {number} radius radius of the circle | ||
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc | ||
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {number} [options.steps=64] number of steps | ||
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians | ||
* @returns {Feature<LineString>} line arc | ||
* @example | ||
* var center = turf.point([-75, 40]); | ||
* var radius = 5; | ||
* var bearing1 = 25; | ||
* var bearing2 = 47; | ||
* | ||
* var arc = turf.lineArc(center, radius, bearing1, bearing2); | ||
* | ||
* //addToMap | ||
* var addToMap = [center, arc] | ||
*/ | ||
export default function lineArc( | ||
center: Coord, | ||
radius: number, | ||
bearing1: number, | ||
bearing2: number, | ||
options?: { | ||
steps?: number, | ||
units?: Units | ||
} | ||
): Feature<LineString>; | ||
export default function lineArc(center: Coord, radius: number, bearing1: number, bearing2: number, options?: { | ||
steps?: number; | ||
units?: Units; | ||
}): Feature<LineString>; |
47
index.js
@@ -1,5 +0,9 @@ | ||
import destination from '@turf/destination'; | ||
import circle from '@turf/circle'; | ||
import { lineString, isObject } from '@turf/helpers'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var circle_1 = __importDefault(require("@turf/circle")); | ||
var destination_1 = __importDefault(require("@turf/destination")); | ||
var helpers_1 = require("@turf/helpers"); | ||
/** | ||
@@ -30,35 +34,19 @@ * Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; | ||
function lineArc(center, radius, bearing1, bearing2, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var steps = options.steps; | ||
var units = options.units; | ||
// validation | ||
if (!center) throw new Error('center is required'); | ||
if (!radius) throw new Error('radius is required'); | ||
if (bearing1 === undefined || bearing1 === null) throw new Error('bearing1 is required'); | ||
if (bearing2 === undefined || bearing2 === null) throw new Error('bearing2 is required'); | ||
if (typeof options !== 'object') throw new Error('options must be an object'); | ||
if (options === void 0) { options = {}; } | ||
// default params | ||
steps = steps || 64; | ||
var steps = options.steps || 64; | ||
var angle1 = convertAngleTo360(bearing1); | ||
var angle2 = convertAngleTo360(bearing2); | ||
var properties = center.properties; | ||
var properties = (!Array.isArray(center) && center.type === "Feature") ? center.properties : {}; | ||
// handle angle parameters | ||
if (angle1 === angle2) { | ||
return lineString(circle(center, radius, options).geometry.coordinates[0], properties); | ||
return helpers_1.lineString(circle_1.default(center, radius, options).geometry.coordinates[0], properties); | ||
} | ||
var arcStartDegree = angle1; | ||
var arcEndDegree = (angle1 < angle2) ? angle2 : angle2 + 360; | ||
var alfa = arcStartDegree; | ||
var coordinates = []; | ||
var i = 0; | ||
while (alfa < arcEndDegree) { | ||
coordinates.push(destination(center, radius, alfa, units).geometry.coordinates); | ||
coordinates.push(destination_1.default(center, radius, alfa, options).geometry.coordinates); | ||
i++; | ||
@@ -68,8 +56,7 @@ alfa = arcStartDegree + i * 360 / steps; | ||
if (alfa > arcEndDegree) { | ||
coordinates.push(destination(center, radius, arcEndDegree, units).geometry.coordinates); | ||
coordinates.push(destination_1.default(center, radius, arcEndDegree, options).geometry.coordinates); | ||
} | ||
return lineString(coordinates, properties); | ||
return helpers_1.lineString(coordinates, properties); | ||
} | ||
exports.default = lineArc; | ||
/** | ||
@@ -90,3 +77,1 @@ * Takes any angle in degrees | ||
} | ||
export default lineArc; |
{ | ||
"name": "@turf/line-arc", | ||
"version": "5.1.5", | ||
"version": "6.0.0", | ||
"description": "turf line-arc module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"main.js", | ||
"main.es.js" | ||
"index.d.ts" | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"prepare": "tsc", | ||
"pretest": "tsc", | ||
"test": "node test.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -36,7 +33,6 @@ }, | ||
"devDependencies": { | ||
"@std/esm": "*", | ||
"@turf/truncate": "^5.1.5", | ||
"@turf/truncate": "*", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"typescript": "*", | ||
"tape": "*", | ||
@@ -46,10 +42,6 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/circle": "^5.1.5", | ||
"@turf/destination": "^5.1.5", | ||
"@turf/helpers": "^5.1.5" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
"@turf/circle": "6.x", | ||
"@turf/destination": "6.x", | ||
"@turf/helpers": "6.x" | ||
} | ||
} |
@@ -12,9 +12,9 @@ # @turf/line-arc | ||
- `center` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** center point | ||
- `radius` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** radius of the circle | ||
- `bearing1` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** angle, in decimal degrees, of the first radius of the arc | ||
- `bearing2` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** angle, in decimal degrees, of the second radius of the arc | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`) | ||
- `options.steps` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** number of steps (optional, default `64`) | ||
- `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) | ||
- `center` **[Coord][1]** center point | ||
- `radius` **[number][2]** radius of the circle | ||
- `bearing1` **[number][2]** angle, in decimal degrees, of the first radius of the arc | ||
- `bearing2` **[number][2]** angle, in decimal degrees, of the second radius of the arc | ||
- `options` **[Object][3]** Optional parameters (optional, default `{}`) | ||
- `options.steps` **[number][2]** number of steps (optional, default `64`) | ||
- `options.units` **[string][4]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) | ||
@@ -35,4 +35,16 @@ **Examples** | ||
Returns **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4)>** line arc | ||
Returns **[Feature][5]<[LineString][6]>** line arc | ||
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.1 | ||
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number | ||
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object | ||
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String | ||
[5]: https://tools.ietf.org/html/rfc7946#section-3.2 | ||
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.4 | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -39,0 +51,0 @@ if you find an error, edit the source file (likely index.js), and re-run |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
72
8161
5
103
1
+ Added@turf/circle@6.5.0(transitive)
+ Added@turf/destination@6.5.0(transitive)
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/invariant@6.5.0(transitive)
- Removed@turf/circle@5.1.5(transitive)
- Removed@turf/destination@5.1.5(transitive)
- Removed@turf/helpers@5.1.5(transitive)
- Removed@turf/invariant@5.2.0(transitive)
Updated@turf/circle@6.x
Updated@turf/destination@6.x
Updated@turf/helpers@6.x