@turf/helpers
Advanced tools
Comparing version 4.0.1 to 4.1.0
77
index.js
@@ -30,3 +30,2 @@ /** | ||
} | ||
module.exports.feature = feature; | ||
@@ -46,3 +45,3 @@ /** | ||
*/ | ||
module.exports.point = function (coordinates, properties) { | ||
function point(coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -57,3 +56,3 @@ if (coordinates.length === undefined) throw new Error('Coordinates must be an array'); | ||
}, properties); | ||
}; | ||
} | ||
@@ -81,3 +80,3 @@ /** | ||
*/ | ||
module.exports.polygon = function (coordinates, properties) { | ||
function polygon(coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -101,3 +100,3 @@ | ||
}, properties); | ||
}; | ||
} | ||
@@ -131,3 +130,3 @@ /** | ||
*/ | ||
module.exports.lineString = function (coordinates, properties) { | ||
function lineString(coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -139,3 +138,3 @@ | ||
}, properties); | ||
}; | ||
} | ||
@@ -159,3 +158,3 @@ /** | ||
*/ | ||
module.exports.featureCollection = function (features) { | ||
function featureCollection(features) { | ||
if (!features) throw new Error('No features passed'); | ||
@@ -167,3 +166,3 @@ | ||
}; | ||
}; | ||
} | ||
@@ -185,3 +184,3 @@ /** | ||
*/ | ||
module.exports.multiLineString = function (coordinates, properties) { | ||
function multiLineString(coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -193,3 +192,3 @@ | ||
}, properties); | ||
}; | ||
} | ||
@@ -211,3 +210,3 @@ /** | ||
*/ | ||
module.exports.multiPoint = function (coordinates, properties) { | ||
function multiPoint(coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -219,3 +218,3 @@ | ||
}, properties); | ||
}; | ||
} | ||
@@ -238,3 +237,3 @@ | ||
*/ | ||
module.exports.multiPolygon = function (coordinates, properties) { | ||
function multiPolygon(coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -246,3 +245,3 @@ | ||
}, properties); | ||
}; | ||
} | ||
@@ -270,3 +269,3 @@ /** | ||
*/ | ||
module.exports.geometryCollection = function (geometries, properties) { | ||
function geometryCollection(geometries, properties) { | ||
if (!geometries) throw new Error('No geometries passed'); | ||
@@ -278,3 +277,3 @@ | ||
}, properties); | ||
}; | ||
} | ||
@@ -295,12 +294,11 @@ var factors = { | ||
/* | ||
/** | ||
* Convert a distance measurement from radians to a more friendly unit. | ||
* | ||
* @name radiansToDistance | ||
* @param {number} distance in radians across the sphere | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers | ||
* inches, yards, metres, meters, kilometres, kilometers. | ||
* @param {number} radians in radians across the sphere | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. | ||
* @returns {number} distance | ||
*/ | ||
module.exports.radiansToDistance = function (radians, units) { | ||
function radiansToDistance(radians, units) { | ||
var factor = factors[units || 'kilometers']; | ||
@@ -310,5 +308,5 @@ if (factor === undefined) throw new Error('Invalid unit'); | ||
return radians * factor; | ||
}; | ||
} | ||
/* | ||
/** | ||
* Convert a distance measurement from a real-world unit into radians | ||
@@ -318,7 +316,6 @@ * | ||
* @param {number} distance in real units | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers | ||
* inches, yards, metres, meters, kilometres, kilometers. | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. | ||
* @returns {number} radians | ||
*/ | ||
module.exports.distanceToRadians = function (distance, units) { | ||
function distanceToRadians(distance, units) { | ||
var factor = factors[units || 'kilometers']; | ||
@@ -328,14 +325,13 @@ if (factor === undefined) throw new Error('Invalid unit'); | ||
return distance / factor; | ||
}; | ||
} | ||
/* | ||
/** | ||
* Convert a distance measurement from a real-world unit into degrees | ||
* | ||
* @name distanceToRadians | ||
* @name distanceToDegrees | ||
* @param {number} distance in real units | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers | ||
* inches, yards, metres, meters, kilometres, kilometers. | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. | ||
* @returns {number} degrees | ||
*/ | ||
module.exports.distanceToDegrees = function (distance, units) { | ||
function distanceToDegrees(distance, units) { | ||
var factor = factors[units || 'kilometers']; | ||
@@ -345,2 +341,17 @@ if (factor === undefined) throw new Error('Invalid unit'); | ||
return (distance / factor) * 57.2958; | ||
} | ||
module.exports = { | ||
feature: feature, | ||
featureCollection: featureCollection, | ||
geometryCollection: geometryCollection, | ||
point: point, | ||
multiPoint: multiPoint, | ||
lineString: lineString, | ||
multiLineString: multiLineString, | ||
polygon: polygon, | ||
multiPolygon: multiPolygon, | ||
radiansToDistance: radiansToDistance, | ||
distanceToRadians: distanceToRadians, | ||
distanceToDegrees: distanceToDegrees | ||
}; |
{ | ||
"name": "@turf/helpers", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "turf helpers module", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -232,2 +232,35 @@ # @turf/helpers | ||
# radiansToDistance | ||
Convert a distance measurement from radians to a more friendly unit. | ||
**Parameters** | ||
- `radians` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** in radians across the sphere | ||
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`) | ||
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** distance | ||
# distanceToRadians | ||
Convert a distance measurement from a real-world unit into radians | ||
**Parameters** | ||
- `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** in real units | ||
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`) | ||
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** radians | ||
# distanceToDegrees | ||
Convert a distance measurement from a real-world unit into degrees | ||
**Parameters** | ||
- `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** in real units | ||
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`) | ||
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** degrees | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -234,0 +267,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
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
27526
384
289