Comparing version 0.0.1 to 0.0.2
@@ -11,3 +11,3 @@ var inside = require('turf-inside') | ||
if (inside(pt, poly)) { | ||
values.push(1) | ||
values.push(1) | ||
} | ||
@@ -14,0 +14,0 @@ }) |
{ | ||
"name": "turf-count", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "turf count module", | ||
@@ -30,3 +30,4 @@ "main": "index.js", | ||
"turf-point": "^0.1.0", | ||
"turf-polygon": "^0.1.0" | ||
"turf-polygon": "^0.1.0", | ||
"deep-freeze": "0.0.1" | ||
}, | ||
@@ -33,0 +34,0 @@ "dependencies": { |
turf-count | ||
========== | ||
[![Build Status](https://travis-ci.org/Turfjs/turf-count.svg)](https://travis-ci.org/Turfjs/turf-count) | ||
Calculates the number of points that fall within a set of polygons. | ||
## Install | ||
npm install turf-count | ||
## API | ||
### `count(polygonCollection, pointCollection, countProperty)` | ||
* `polygonCollection` should be a FeatureCollection of Polygons | ||
* `pointCollection` should be a FeatureCollection of Points | ||
* `countProperty` is the property in the returned FeatureCollection that records the count of points in each polygon. | ||
## Example | ||
```js | ||
var point = require('turf-point') | ||
var polygon = require('turf-polygon') | ||
var featurecollection = require('turf-featurecollection') | ||
var poly1 = polygon([[[0,0],[10,0],[10,10], [0,10]]]) | ||
var poly2 = polygon([[[10,0],[20,10],[20,20], [20,0]]]) | ||
var polyFC = featurecollection([poly1, poly2]) | ||
var pt1 = point(5,5, {population: 200}) | ||
var pt2 = point(1,3, {population: 600}) | ||
var ptFC = featurecollection([pt1, pt2]) | ||
var counted = count(polyFC, ptFC, 'pt_count') | ||
console.log(counted) | ||
``` |
@@ -6,4 +6,6 @@ var count = require('./') | ||
var featurecollection = require('turf-featurecollection') | ||
var deepFreeze = require('deep-freeze') | ||
test('count', function(t){ | ||
'use strict'; | ||
var poly1 = polygon([[[0,0],[10,0],[10,10], [0,10]]]) | ||
@@ -18,2 +20,4 @@ var poly2 = polygon([[[10,0],[20,10],[20,20], [20,0]]]) | ||
var ptFC = featurecollection([pt1, pt2, pt3, pt4, pt5]) | ||
deepFreeze(ptFC) | ||
deepFreeze(polyFC) | ||
@@ -28,2 +32,2 @@ var counted = count(polyFC, ptFC, 'pt_count') | ||
t.end() | ||
}) | ||
}) |
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
4982
7
42
37
5