Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-tag

Package Overview
Dependencies
Maintainers
9
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-tag - npm Package Compare versions

Comparing version 1.0.1 to 3.0.0-canary.2f5f7167

6

bench.js

@@ -5,4 +5,4 @@ var tag = require('./');

var points = JSON.parse(fs.readFileSync('./geojson/tagPoints.geojson'));
var polygons = JSON.parse(fs.readFileSync('./geojson/tagPolygons.geojson'));
var points = JSON.parse(fs.readFileSync('./test/tagPoints.geojson'));
var polygons = JSON.parse(fs.readFileSync('./test/tagPolygons.geojson'));

@@ -20,2 +20,2 @@ var suite = new Benchmark.Suite('turf-tag');

})
.run();
.run();
var inside = require('turf-inside');
/**
* Takes a {@link FeatureCollection} of {@link Point} features and a FeatureCollection of {@link Polygon} features and performs a spatial join.
* Takes a set of {@link Point|points} and a set of {@link Polygon|polygons} and performs a spatial join.
*
* @module turf/tag
* @name tag
* @category joins
* @param {FeatureCollection} points a FeatureCollection of {@link Point} features
* @param {FeatureCollection} polygons a FeatureCollection of {@link Polygon} features
* @param {FeatureCollection<Point>} points input points
* @param {FeatureCollection<Polygon>} polygons input polygons
* @param {String} polyId property in `polygons` to add to joined Point features
* @param {String} containingPolyId property in `points` in which to store joined property from `polygons
* @return {FeatureCollection} a FeatureCollection of point features
* @return {FeatureCollection<Point>} points with `containingPolyId` property containing values from `polyId`
* @example
* var bbox = [0, 0, 50, 50];
* var bbox = [0, 0, 10, 10];
* // create a triangular grid of polygons
* var triangleGrid = turf.tin(turf.grid(bbox, 10));
* var triangleGrid = turf.triangleGrid(bbox, 50, 'miles');
* triangleGrid.features.forEach(function(f) {

@@ -38,20 +38,20 @@ * f.properties.fill = '#' +

*/
module.exports = function(points, polygons, field, outField){
// prevent mutations
points = JSON.parse(JSON.stringify(points));
polygons = JSON.parse(JSON.stringify(polygons));
points.features.forEach(function(pt) {
if (!pt.properties) {
pt.properties = {};
}
polygons.features.forEach(function(poly) {
if (pt.properties[outField] === undefined) {
var isInside = inside(pt, poly);
if (isInside) {
pt.properties[outField] = poly.properties[field];
module.exports = function (points, polygons, field, outField) {
// prevent mutations
points = JSON.parse(JSON.stringify(points));
polygons = JSON.parse(JSON.stringify(polygons));
points.features.forEach(function (pt) {
if (!pt.properties) {
pt.properties = {};
}
}
polygons.features.forEach(function (poly) {
if (pt.properties[outField] === undefined) {
var isInside = inside(pt, poly);
if (isInside) {
pt.properties[outField] = poly.properties[field];
}
}
});
});
});
return points;
return points;
};
{
"name": "turf-tag",
"version": "1.0.1",
"version": "3.0.0-canary.2f5f7167",
"description": "turf tag module",
"main": "index.js",
"scripts": {
"test": "node test.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
"test": "node test.js"
},

@@ -31,10 +30,8 @@ "repository": {

"dependencies": {
"turf-inside": "^1.1.3"
"turf-inside": "^3.0.0-canary.2f5f7167"
},
"devDependencies": {
"benchmark": "^1.0.0",
"tape": "^3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.3"
"tape": "^3.5.0"
}
}

@@ -10,3 +10,3 @@ # turf-tag

Takes a FeatureCollection of Point features and a FeatureCollection of Polygon features and performs a spatial join.
Takes a set of Point|points and a set of Polygon|polygons and performs a spatial join.

@@ -16,8 +16,8 @@

| parameter | type | description |
| ------------------ | ----------------- | --------------------------------------------------------------------- |
| `points` | FeatureCollection | a FeatureCollection of Point features |
| `polygons` | FeatureCollection | a FeatureCollection of Polygon features |
| `polyId` | String | property in `polygons` to add to joined Point features |
| `containingPolyId` | String | property in `points` in which to store joined property from `polygons |
| parameter | type | description |
| ------------------ | ------------------------------ | --------------------------------------------------------------------- |
| `points` | FeatureCollection\.\<Point\> | input points |
| `polygons` | FeatureCollection\.\<Polygon\> | input polygons |
| `polyId` | String | property in `polygons` to add to joined Point features |
| `containingPolyId` | String | property in `points` in which to store joined property from `polygons |

@@ -28,5 +28,5 @@

```js
var bbox = [0, 0, 50, 50];
var bbox = [0, 0, 10, 10];
// create a triangular grid of polygons
var triangleGrid = turf.tin(turf.grid(bbox, 10));
var triangleGrid = turf.triangleGrid(bbox, 50, 'miles');
triangleGrid.features.forEach(function(f) {

@@ -54,2 +54,5 @@ f.properties.fill = '#' +

**Returns** `FeatureCollection.<Point>`, points with `containingPolyId` property containing values from `polyId`
## Installation

@@ -69,1 +72,2 @@

@@ -6,4 +6,4 @@ var test = require('tape');

test('tag', function(t){
var points = JSON.parse(fs.readFileSync(__dirname + '/geojson/tagPoints.geojson'));
var polygons = JSON.parse(fs.readFileSync(__dirname + '/geojson/tagPolygons.geojson'));
var points = JSON.parse(fs.readFileSync(__dirname + '/test/tagPoints.geojson'));
var polygons = JSON.parse(fs.readFileSync(__dirname + '/test/tagPolygons.geojson'));

@@ -10,0 +10,0 @@ var taggedPoints = tag(points, polygons, 'polyID', 'containingPolyID');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc