@turf/line-arc
Advanced tools
Comparing version 4.7.3 to 5.0.4
@@ -1,10 +0,15 @@ | ||
/// <reference types="geojson" /> | ||
import { Coord, Feature, LineString, Units } from '@turf/helpers'; | ||
import {Point, LineString, Units} from '@turf/helpers'; | ||
/** | ||
* http://turfjs.org/docs/#linearc | ||
*/ | ||
declare function lineArc(center: Point, radius: number, bearing1: number, bearing2: number, steps?: number, units?: string): LineString; | ||
declare namespace lineArc { } | ||
export = lineArc; | ||
export default function lineArc( | ||
center: Coord, | ||
radius: number, | ||
bearing1: number, | ||
bearing2: number, | ||
options?: { | ||
steps?: number, | ||
units?: Units | ||
} | ||
): Feature<LineString>; |
28
index.js
@@ -1,4 +0,4 @@ | ||
var destination = require('@turf/destination'); | ||
var circle = require('@turf/circle'); | ||
var lineString = require('@turf/helpers').lineString; | ||
import destination from '@turf/destination'; | ||
import circle from '@turf/circle'; | ||
import { lineString, isObject } from '@turf/helpers'; | ||
@@ -14,4 +14,5 @@ /** | ||
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc | ||
* @param {number} [steps=64] number of steps | ||
* @param {string} [units=kilometers] miles, kilometers, degrees, or radians | ||
* @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 | ||
@@ -29,8 +30,15 @@ * @example | ||
*/ | ||
module.exports = function (center, radius, bearing1, bearing2, steps, units) { | ||
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 (!radius) throw new Error('radius is required'); | ||
if (typeof options !== 'object') throw new Error('options must be an object'); | ||
@@ -46,3 +54,3 @@ // default params | ||
if (angle1 === angle2) { | ||
return lineString(circle(center, radius, steps, units).geometry.coordinates[0], properties); | ||
return lineString(circle(center, radius, options).geometry.coordinates[0], properties); | ||
} | ||
@@ -65,3 +73,3 @@ var arcStartDegree = angle1; | ||
return lineString(coordinates, properties); | ||
}; | ||
} | ||
@@ -84,1 +92,3 @@ | ||
} | ||
export default lineArc; |
{ | ||
"name": "@turf/line-arc", | ||
"version": "4.7.3", | ||
"version": "5.0.4", | ||
"description": "turf line-arc module", | ||
"main": "index.js", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"main.js" | ||
], | ||
"scripts": { | ||
"test": "node test.js", | ||
"bench": "node bench.js" | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"bench": "node -r @std/esm bench.js" | ||
}, | ||
@@ -30,13 +34,19 @@ "repository": { | ||
"devDependencies": { | ||
"@turf/truncate": "^4.7.3", | ||
"benchmark": "^2.1.4", | ||
"load-json-file": "^2.0.0", | ||
"tape": "^4.6.3", | ||
"write-json-file": "^2.0.0" | ||
"@std/esm": "*", | ||
"@turf/truncate": "^5.0.4", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"tape": "*", | ||
"write-json-file": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/circle": "^4.7.3", | ||
"@turf/destination": "^4.7.3", | ||
"@turf/helpers": "^4.7.3" | ||
"@turf/circle": "^5.0.4", | ||
"@turf/destination": "^5.0.4", | ||
"@turf/helpers": "^5.0.4" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
# @turf/line-arc | ||
# lineArc | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
## lineArc | ||
Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; | ||
@@ -14,4 +16,5 @@ 0 bearing is North of center point, positive clockwise. | ||
- `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 | ||
- `steps` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** number of steps (optional, default `64`) | ||
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** miles, kilometers, degrees, or radians (optional, default `kilometers`) | ||
- `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'`) | ||
@@ -18,0 +21,0 @@ **Examples** |
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
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
11105
6
175
60
7
+ Added@turf/circle@5.1.5(transitive)
+ Added@turf/destination@5.1.5(transitive)
+ Added@turf/helpers@5.1.5(transitive)
+ Added@turf/invariant@5.2.0(transitive)
- Removed@turf/circle@4.7.3(transitive)
- Removed@turf/destination@4.7.3(transitive)
- Removed@turf/helpers@4.7.3(transitive)
- Removed@turf/invariant@4.7.3(transitive)
Updated@turf/circle@^5.0.4
Updated@turf/destination@^5.0.4
Updated@turf/helpers@^5.0.4