@turf/helpers
Advanced tools
Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -22,3 +22,3 @@ /** | ||
feet: earthRadius * 3.28084, | ||
inches: earthRadius * 39.370, | ||
inches: earthRadius * 39.37, | ||
kilometers: earthRadius / 1000, | ||
@@ -46,3 +46,3 @@ kilometres: earthRadius / 1000, | ||
feet: 3.28084, | ||
inches: 39.370, | ||
inches: 39.37, | ||
kilometers: 1 / 1000, | ||
@@ -70,2 +70,3 @@ kilometres: 1 / 1000, | ||
feet: 10.763910417, | ||
hectares: 0.0001, | ||
inches: 1550.003100006, | ||
@@ -129,12 +130,19 @@ kilometers: 0.000001, | ||
*/ | ||
export function geometry(type, coordinates, options) { | ||
if (options === void 0) { options = {}; } | ||
export function geometry(type, coordinates, _options) { | ||
if (_options === void 0) { _options = {}; } | ||
switch (type) { | ||
case "Point": return point(coordinates).geometry; | ||
case "LineString": return lineString(coordinates).geometry; | ||
case "Polygon": return polygon(coordinates).geometry; | ||
case "MultiPoint": return multiPoint(coordinates).geometry; | ||
case "MultiLineString": return multiLineString(coordinates).geometry; | ||
case "MultiPolygon": return multiPolygon(coordinates).geometry; | ||
default: throw new Error(type + " is invalid"); | ||
case "Point": | ||
return point(coordinates).geometry; | ||
case "LineString": | ||
return lineString(coordinates).geometry; | ||
case "Polygon": | ||
return polygon(coordinates).geometry; | ||
case "MultiPoint": | ||
return multiPoint(coordinates).geometry; | ||
case "MultiLineString": | ||
return multiLineString(coordinates).geometry; | ||
case "MultiPolygon": | ||
return multiPolygon(coordinates).geometry; | ||
default: | ||
throw new Error(type + " is invalid"); | ||
} | ||
@@ -159,2 +167,14 @@ } | ||
if (options === void 0) { options = {}; } | ||
if (!coordinates) { | ||
throw new Error("coordinates is required"); | ||
} | ||
if (!Array.isArray(coordinates)) { | ||
throw new Error("coordinates must be an Array"); | ||
} | ||
if (coordinates.length < 2) { | ||
throw new Error("coordinates must be at least 2 numbers long"); | ||
} | ||
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) { | ||
throw new Error("coordinates must contain numbers"); | ||
} | ||
var geom = { | ||
@@ -534,3 +554,3 @@ type: "Point", | ||
var degrees = radians % (2 * Math.PI); | ||
return degrees * 180 / Math.PI; | ||
return (degrees * 180) / Math.PI; | ||
} | ||
@@ -546,3 +566,3 @@ /** | ||
var radians = degrees % 360; | ||
return radians * Math.PI / 180; | ||
return (radians * Math.PI) / 180; | ||
} | ||
@@ -568,3 +588,3 @@ /** | ||
* Converts a area to the requested unit. | ||
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches | ||
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares | ||
* @param {number} area to be converted | ||
@@ -617,3 +637,3 @@ * @param {Units} [originalUnit="meters"] of the distance | ||
export function isObject(input) { | ||
return (!!input) && (input.constructor === Object); | ||
return !!input && input.constructor === Object; | ||
} | ||
@@ -620,0 +640,0 @@ /** |
import { BBox, CollectionTypes, Feature, FeatureCollection, GeoJSONObject, Geometries, Geometry, GeometryCollection, GeometryObject, GeometryTypes, Id, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Position, Properties, Types } from "./lib/geojson"; | ||
export { Id, Properties, BBox, Position, Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryObject, GeoJSONObject, GeometryCollection, Geometry, GeometryTypes, Types, CollectionTypes, Geometries, Feature, FeatureCollection, }; | ||
export declare type Coord = Feature<Point> | Point | Position; | ||
export declare type Units = "meters" | "millimeters" | "centimeters" | "kilometers" | "acres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees"; | ||
export declare type Units = "meters" | "millimeters" | "centimeters" | "kilometers" | "acres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees" | "hectares"; | ||
export declare type Grid = "point" | "square" | "hex" | "triangle"; | ||
@@ -83,3 +83,3 @@ export declare type Corners = "sw" | "se" | "nw" | "ne" | "center" | "centroid"; | ||
*/ | ||
export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], options?: {}): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon; | ||
export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], _options?: {}): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon; | ||
/** | ||
@@ -409,3 +409,3 @@ * Creates a {@link Point} {@link Feature} from a Position. | ||
* Converts a area to the requested unit. | ||
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches | ||
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares | ||
* @param {number} area to be converted | ||
@@ -412,0 +412,0 @@ * @param {Units} [originalUnit="meters"] of the distance |
@@ -24,3 +24,3 @@ "use strict"; | ||
feet: exports.earthRadius * 3.28084, | ||
inches: exports.earthRadius * 39.370, | ||
inches: exports.earthRadius * 39.37, | ||
kilometers: exports.earthRadius / 1000, | ||
@@ -48,3 +48,3 @@ kilometres: exports.earthRadius / 1000, | ||
feet: 3.28084, | ||
inches: 39.370, | ||
inches: 39.37, | ||
kilometers: 1 / 1000, | ||
@@ -72,2 +72,3 @@ kilometres: 1 / 1000, | ||
feet: 10.763910417, | ||
hectares: 0.0001, | ||
inches: 1550.003100006, | ||
@@ -132,12 +133,19 @@ kilometers: 0.000001, | ||
*/ | ||
function geometry(type, coordinates, options) { | ||
if (options === void 0) { options = {}; } | ||
function geometry(type, coordinates, _options) { | ||
if (_options === void 0) { _options = {}; } | ||
switch (type) { | ||
case "Point": return point(coordinates).geometry; | ||
case "LineString": return lineString(coordinates).geometry; | ||
case "Polygon": return polygon(coordinates).geometry; | ||
case "MultiPoint": return multiPoint(coordinates).geometry; | ||
case "MultiLineString": return multiLineString(coordinates).geometry; | ||
case "MultiPolygon": return multiPolygon(coordinates).geometry; | ||
default: throw new Error(type + " is invalid"); | ||
case "Point": | ||
return point(coordinates).geometry; | ||
case "LineString": | ||
return lineString(coordinates).geometry; | ||
case "Polygon": | ||
return polygon(coordinates).geometry; | ||
case "MultiPoint": | ||
return multiPoint(coordinates).geometry; | ||
case "MultiLineString": | ||
return multiLineString(coordinates).geometry; | ||
case "MultiPolygon": | ||
return multiPolygon(coordinates).geometry; | ||
default: | ||
throw new Error(type + " is invalid"); | ||
} | ||
@@ -163,2 +171,14 @@ } | ||
if (options === void 0) { options = {}; } | ||
if (!coordinates) { | ||
throw new Error("coordinates is required"); | ||
} | ||
if (!Array.isArray(coordinates)) { | ||
throw new Error("coordinates must be an Array"); | ||
} | ||
if (coordinates.length < 2) { | ||
throw new Error("coordinates must be at least 2 numbers long"); | ||
} | ||
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) { | ||
throw new Error("coordinates must contain numbers"); | ||
} | ||
var geom = { | ||
@@ -554,3 +574,3 @@ type: "Point", | ||
var degrees = radians % (2 * Math.PI); | ||
return degrees * 180 / Math.PI; | ||
return (degrees * 180) / Math.PI; | ||
} | ||
@@ -567,3 +587,3 @@ exports.radiansToDegrees = radiansToDegrees; | ||
var radians = degrees % 360; | ||
return radians * Math.PI / 180; | ||
return (radians * Math.PI) / 180; | ||
} | ||
@@ -591,3 +611,3 @@ exports.degreesToRadians = degreesToRadians; | ||
* Converts a area to the requested unit. | ||
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches | ||
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares | ||
* @param {number} area to be converted | ||
@@ -642,3 +662,3 @@ * @param {Units} [originalUnit="meters"] of the distance | ||
function isObject(input) { | ||
return (!!input) && (input.constructor === Object); | ||
return !!input && input.constructor === Object; | ||
} | ||
@@ -645,0 +665,0 @@ exports.isObject = isObject; |
{ | ||
"name": "@turf/helpers", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf helpers module", | ||
@@ -32,2 +32,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "dist/js/index.d.ts", | ||
@@ -39,11 +43,10 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "ts-node bench.js", | ||
"build": "npm-run-all build:*", | ||
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"build:js": "tsc", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"prepare": "npm-run-all prepare:*", | ||
"prepare:es": "tsc --outDir dist/es --module esnext --declaration false", | ||
"prepare:js": "tsc", | ||
"test": "npm-run-all prepare test:*", | ||
"test:tape": "node -r esm test.js", | ||
"test:types": "tsc --noEmit types.ts" | ||
"test": "npm-run-all test:*", | ||
"test:tape": "ts-node -r esm test.js", | ||
"test:types": "tsc --esModuleInterop --noEmit types.ts" | ||
}, | ||
@@ -55,6 +58,7 @@ "devDependencies": { | ||
"tape": "*", | ||
"ts-node": "*", | ||
"tslint": "*", | ||
"typescript": "*" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
@@ -456,3 +456,3 @@ # @turf/helpers | ||
Converts a area to the requested unit. | ||
Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches | ||
Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares | ||
@@ -459,0 +459,0 @@ **Parameters** |
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
121016
12
2851
7