turf-point
Advanced tools
| # 2.0.0 | ||
| * Only accept `[x, y]` arrays, not as arguments |
+2
-2
@@ -25,3 +25,3 @@ #!/usr/bin/env node | ||
| console.log(JSON.stringify(point(x, y))); | ||
| console.log(JSON.stringify(point([x, y]))); | ||
| } | ||
@@ -37,2 +37,2 @@ | ||
| console.log('\ndefault: \nturf-point [num1] [num2]\n\n') | ||
| } | ||
| } |
+14
-12
| /** | ||
| * Generates a new GeoJSON Point feature, given coordinates | ||
| * Generates a new {@link Point} feature, given coordinates | ||
| * and, optionally, properties. | ||
@@ -8,13 +8,15 @@ * | ||
| * @param {number} latitude - position south to north in decimal degrees | ||
| * @param {Object} properties | ||
| * @return {GeoJSONPoint} output | ||
| * @param {Object} properties - an optional object that is used as the Feature's | ||
| * properties | ||
| * @return {Point} output | ||
| * @example | ||
| * var pt1 = turf.point(-75.343, 39.984) | ||
| * var pt1 = turf.point([-75.343, 39.984]); | ||
| * //=pt1 | ||
| */ | ||
| module.exports = function(x, y, properties){ | ||
| if(x instanceof Array) { | ||
| properties = y; | ||
| y = x[1]; | ||
| x = x[0]; | ||
| } else if(isNaN(x) || isNaN(y)) throw new Error('Invalid coordinates') | ||
| var isArray = Array.isArray || function(arg) { | ||
| return Object.prototype.toString.call(arg) === '[object Array]'; | ||
| }; | ||
| module.exports = function(coordinates, properties) { | ||
| if (!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'); | ||
| return { | ||
@@ -24,6 +26,6 @@ type: "Feature", | ||
| type: "Point", | ||
| coordinates: [x, y] | ||
| coordinates: coordinates | ||
| }, | ||
| properties: properties || {} | ||
| }; | ||
| } | ||
| }; |
+9
-6
| { | ||
| "name": "turf-point", | ||
| "version": "1.2.1", | ||
| "version": "2.0.0", | ||
| "description": "turf point module", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "tape test.js" | ||
| "test": "tape test.js", | ||
| "doc": "dox -r < index.js | doxme --readme > README.md" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/morganherlocker/turf-point.git" | ||
| "url": "https://github.com/Turfjs/turf-point.git" | ||
| }, | ||
@@ -22,8 +23,10 @@ "keywords": [ | ||
| "bugs": { | ||
| "url": "https://github.com/morganherlocker/turf-point/issues" | ||
| "url": "https://github.com/Turfjs/turf-point/issues" | ||
| }, | ||
| "homepage": "https://github.com/morganherlocker/turf-point", | ||
| "homepage": "https://github.com/Turfjs/turf-point", | ||
| "devDependencies": { | ||
| "benchmark": "^1.0.0", | ||
| "tape": "^3.0.3" | ||
| "tape": "^3.0.3", | ||
| "dox": "^0.6.1", | ||
| "doxme": "^1.3.0" | ||
| }, | ||
@@ -30,0 +33,0 @@ "dependencies": { |
+20
-29
@@ -1,45 +0,36 @@ | ||
| turf-point | ||
| ========== | ||
| [](https://travis-ci.org/Turfjs/turf-point) | ||
| # turf-point | ||
| Creates a geojson Point Feature based on an x and y coordinate. Properties can be added optionally. | ||
| [](http://travis-ci.org/Turfjs/turf-point) | ||
| ###Install | ||
| turf point module | ||
| ```sh | ||
| npm install turf-point | ||
| ``` | ||
| ###Parameters | ||
| ### `turf.point(longitude, latitude, properties)` | ||
| |name|description| | ||
| |---|---| | ||
| |x|x coordinate| | ||
| |y|y coordinate| | ||
| Generates a new Point feature, given coordinates | ||
| and, optionally, properties. | ||
| ###Usage | ||
| * `longitude` (`number`): - position west to east in decimal degrees | ||
| * `latitude` (`number`): - position south to north in decimal degrees | ||
| * `properties` (`Object`): - an optional object that is used as the Feature's properties | ||
| ```js | ||
| point(x, y) | ||
| var pt1 = turf.point(-75.343, 39.984); | ||
| //=pt1 | ||
| ``` | ||
| ###Example | ||
| ## Installation | ||
| ```javascript | ||
| var point = require('turf-point') | ||
| Requires [nodejs](http://nodejs.org/). | ||
| var pt1 = point(-75.343, 39.984) | ||
| var pt2 = point(-75.343, 39.984, {name: 'point 1', population: 5000}) | ||
| console.log(pt1) | ||
| console.log(pt2) | ||
| ```sh | ||
| $ npm install turf-point | ||
| ``` | ||
| ###CLI | ||
| ## Tests | ||
| ```sh | ||
| $ npm test | ||
| ``` | ||
| npm install turf-point -g | ||
| turf-point 2 1 | ||
| turf-point --lat 1 --lon 2 | ||
| turf-point --latitude 1 --longitude 2 | ||
| turf-point -x 2 -y 1 | ||
| ``` | ||
+1
-8
@@ -5,9 +5,2 @@ var test = require('tape'); | ||
| test('point', function(t){ | ||
| var pt = point(5, 10, {name: 'test point'}); | ||
| t.ok(pt); | ||
| t.equal(pt.geometry.coordinates[0], 5); | ||
| t.equal(pt.geometry.coordinates[1], 10); | ||
| t.equal(pt.properties.name, 'test point'); | ||
| var ptArray = point([5, 10], {name: 'test point'}); | ||
@@ -24,3 +17,3 @@ | ||
| var noProps = point(0, 0); | ||
| var noProps = point([0, 0]); | ||
| t.deepEqual(noProps.properties, {}, 'no props becomes {}'); | ||
@@ -27,0 +20,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6213
1.97%10
11.11%0
-100%4
100%92
-2.13%37
-17.78%