turf-kinks
Advanced tools
Comparing version 1.3.0 to 1.3.1
36
index.js
@@ -0,1 +1,35 @@ | ||
/** | ||
* Takes a {@link Polygon} feature and returns a {@link FeatureCollection} of {@link Point} features at all self-intersections. | ||
* | ||
* @module turf/kinks | ||
* @category misc | ||
* @param {Polygon} polygon a Polygon feature | ||
* @returns {FeatureCollection} a FeatureCollection of {@link Point} features representing self-intersections | ||
* @example | ||
* var poly = { | ||
* "type": "Feature", | ||
* "properties": {}, | ||
* "geometry": { | ||
* "type": "Polygon", | ||
* "coordinates": [[ | ||
* [-12.034835, 8.901183], | ||
* [-12.060413, 8.899826], | ||
* [-12.03638, 8.873199], | ||
* [-12.059383, 8.871418], | ||
* [-12.034835, 8.901183] | ||
* ]] | ||
* } | ||
* }; | ||
* | ||
* var kinks = turf.kinks(poly); | ||
* | ||
* var resultFeatures = kinks.intersections.features.concat(poly); | ||
* var result = { | ||
* "type": "FeatureCollection", | ||
* "features": resultFeatures | ||
* }; | ||
* | ||
* //=result | ||
*/ | ||
var polygon = require('turf-polygon'); | ||
@@ -21,3 +55,3 @@ var point = require('turf-point'); | ||
if(intersection) { | ||
results.intersections.features.push(point(intersection[0], intersection[1])); | ||
results.intersections.features.push(point([intersection[0], intersection[1]])); | ||
} | ||
@@ -24,0 +58,0 @@ } |
{ | ||
"name": "turf-kinks", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "turf kinks module", | ||
@@ -8,11 +8,14 @@ "main": "index.js", | ||
"turf-featurecollection": "^1.0.0", | ||
"turf-point": "^1.2.0", | ||
"turf-polygon": "^1.0.0" | ||
"turf-point": "^2.0.0", | ||
"turf-polygon": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"benchmark": "^1.0.0", | ||
"tape": "^3.0.3" | ||
"tape": "^3.5.0", | ||
"dox": "^0.6.1", | ||
"doxme": "^1.4.3" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node test.js", | ||
"doc": "dox -r < index.js | doxme --readme > README.md" | ||
}, | ||
@@ -19,0 +22,0 @@ "repository": { |
@@ -1,70 +0,55 @@ | ||
turf-kinks | ||
===== | ||
[![Build Status](https://travis-ci.org/Turfjs/turf-kinks.svg)](https://travis-ci.org/Turfjs/turf-kinks) | ||
# turf-kinks | ||
[![build status](https://secure.travis-ci.org/Turfjs/turf-kinks.png)](http://travis-ci.org/Turfjs/turf-kinks) | ||
turf kinks module | ||
### `turf.kinks(polygon)` | ||
Takes a polygon and detects all self-intersections. | ||
*Note: This module uses straight line intersections, so giant edges may not be computed correctly, since the curvature of the earth is not accounted for* | ||
*Experimental:* attempts to correct the kinks with reasonable assumptions | ||
### Parameters | ||
##Install | ||
| parameter | type | description | | ||
| --------- | ------- | ----------------- | | ||
| `polygon` | Polygon | a Polygon feature | | ||
```sh | ||
npm install turf-kinks | ||
``` | ||
##Parameters | ||
name|description | ||
---|--- | ||
polygon|polygon feature or geometry | ||
### Example | ||
##Usage | ||
```js | ||
var poly = turf.polygon([[ | ||
[-12.034835, 8.901183], | ||
[-12.060413, 8.899826], | ||
[-12.03638, 8.873199], | ||
[-12.059383, 8.871418], | ||
[-12.034835, 8.901183] | ||
]]); | ||
```js | ||
kinks(poly) | ||
var kinks = turf.kinks(poly); | ||
var result = turf.featurecollection( | ||
kinks.intersections.features.concat(poly)); | ||
//=result | ||
``` | ||
###Example | ||
```js | ||
var kinks = require('turf-kinks') | ||
**Returns** `FeatureCollection`, a FeatureCollection of Point features representing self-intersections | ||
var poly = { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
-12.034835815429688, | ||
8.901183448260598 | ||
], | ||
[ | ||
-12.060413360595701, | ||
8.899826693726117 | ||
], | ||
[ | ||
-12.036380767822266, | ||
8.873199368734273 | ||
], | ||
[ | ||
-12.059383392333983, | ||
8.871418491385919 | ||
], | ||
[ | ||
-12.034835815429688, | ||
8.901183448260598 | ||
] | ||
] | ||
] | ||
} | ||
## Installation | ||
var result = kinks(poly) | ||
Requires [nodejs](http://nodejs.org/). | ||
console.log(result) | ||
```sh | ||
$ npm install turf-kinks | ||
``` | ||
/* | ||
{ | ||
intersections: {"type":"Feature","geometry":{"type":"Point","coordinates":[-12.047632938440815,8.885666404927512]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-12.047632938440815,8.885666404927512]},"properties":{}}] | ||
} | ||
*/ | ||
## Tests | ||
```sh | ||
$ npm test | ||
``` | ||
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
11317
297
4
56
+ Addedturf-point@2.0.1(transitive)
- Removedturf-point@1.2.1(transitive)
Updatedturf-point@^2.0.0
Updatedturf-polygon@^1.0.2