turf-point-on-surface
Advanced tools
Comparing version 1.1.0 to 1.1.1
40
index.js
@@ -7,2 +7,30 @@ var featureCollection = require('turf-featurecollection'); | ||
/** | ||
* Finds a {@link Point} guaranteed to be on the surface of | ||
* {@link GeoJSON} object. | ||
* | ||
* * Given a {@link Polygon}, the point will be in the area of the polygon | ||
* * Given a {@link LineString}, the point will be along the string | ||
* * Given a {@link Point}, the point will the same as the input | ||
* | ||
* @module turf/point-on-surface | ||
* @category measurement | ||
* @param {GeoJSON} input any GeoJSON object | ||
* @returns {Feature} a point on the surface of `input` | ||
* @example | ||
* // create a random polygon | ||
* var polygon = turf.random('polygon'); | ||
* | ||
* //=polygon | ||
* | ||
* var pointOnPolygon = turf.pointOnSurface(polygon); | ||
* | ||
* var resultFeatures = polygon.features.concat(pointOnPolygon); | ||
* var result = { | ||
* "type": "FeatureCollection", | ||
* "features": resultFeatures | ||
* }; | ||
* | ||
* //=result | ||
*/ | ||
module.exports = function(fc) { | ||
@@ -14,3 +42,4 @@ // normalize | ||
type: 'Feature', | ||
geometry: fc | ||
geometry: fc, | ||
properties: {} | ||
}; | ||
@@ -86,3 +115,4 @@ } | ||
type: 'Feature', | ||
geometry: geom | ||
geometry: geom, | ||
properties: {} | ||
}; | ||
@@ -92,3 +122,3 @@ if(inside(cent, f)) { | ||
} | ||
} | ||
} | ||
i++; | ||
@@ -114,3 +144,3 @@ } | ||
} | ||
} | ||
}; | ||
@@ -124,2 +154,2 @@ function pointOnSegment (x, y, x1, y1, x2, y2) { | ||
} | ||
} | ||
} |
{ | ||
"name": "turf-point-on-surface", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "turf point-on-surface module", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node test.js", | ||
"doc": "dox -r < index.js | doxme --readme > README.md" | ||
}, | ||
@@ -28,7 +29,9 @@ "repository": { | ||
"devDependencies": { | ||
"tape": "^3.0.3", | ||
"benchmark": "^1.0.0" | ||
"tape": "^3.5.0", | ||
"benchmark": "^1.0.0", | ||
"dox": "^0.6.1", | ||
"doxme": "^1.4.3" | ||
}, | ||
"dependencies": { | ||
"turf-center": "^1.0.0", | ||
"turf-center": "^1.0.1", | ||
"turf-distance": "^1.0.0", | ||
@@ -35,0 +38,0 @@ "turf-explode": "^1.0.0", |
@@ -1,34 +0,55 @@ | ||
turf-point-on-surface | ||
=== | ||
[![Build Status](https://travis-ci.org/Turfjs/turf-point-on-surface.svg)](https://travis-ci.org/Turfjs/turf-point-on-surface) | ||
# turf-point-on-surface | ||
Finds a centroid guaranteed to be on the surface of a geometry, feature, or featurecollection. | ||
[![build status](https://secure.travis-ci.org/Turfjs/turf-point-on-surface.png)](http://travis-ci.org/Turfjs/turf-point-on-surface) | ||
turf point-on-surface module | ||
###Install | ||
```sh | ||
npm install turf-point-on-surface | ||
``` | ||
### `turf.pointOnSurface(input)` | ||
###Parameters | ||
Finds a Point guaranteed to be on the surface of | ||
GeoJSON object. | ||
|name|description| | ||
|---|---| | ||
|fc|A FeatureCollection, Feature, or Geometry of any type| | ||
* Given a Polygon, the point will be in the area of the polygon | ||
* Given a LineString, the point will be along the string | ||
* Given a Point, the point will the same as the input | ||
###Usage | ||
### Parameters | ||
| parameter | type | description | | ||
| --------- | ------- | ------------------ | | ||
| `input` | GeoJSON | any GeoJSON object | | ||
### Example | ||
```js | ||
centroid(fc) | ||
// create a random polygon | ||
var polygon = turf.random('polygon'); | ||
// place a point on it | ||
var pointOnPolygon = turf.pointOnSurface(polygon); | ||
// show both of them | ||
var fc = turf.featurecollection([polygon, pointOnPolygon]); | ||
//=fc | ||
``` | ||
###Example | ||
```js | ||
var centroid = require('turf-point-on-surface'); | ||
var fs = require('fs'); | ||
**Returns** `Feature`, a point on the surface | ||
var fc = JSON.parse(fs.readFileSync('path/to/myFile.geojson')); | ||
var cent = centroid(fc); | ||
``` | ||
## Installation | ||
Requires [nodejs](http://nodejs.org/). | ||
```sh | ||
$ npm install turf-point-on-surface | ||
``` | ||
## Tests | ||
```sh | ||
$ npm test | ||
``` | ||
23296
253
56
4
Updatedturf-center@^1.0.1