New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@turf/tag

Package Overview
Dependencies
Maintainers
4
Versions
54
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 4.7.3 to 5.0.4

main.js

15

index.d.ts

@@ -1,12 +0,11 @@

/// <reference types="geojson" />
import { BBox, Point, FeatureCollection, Polygon } from '@turf/helpers'
type BBox = Array<number>;
type Points = GeoJSON.FeatureCollection<GeoJSON.Point>;
type Polygons = GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* http://turfjs.org/docs/#tag
*/
declare function tag(points: Points, polygons: Polygons, field: string, outField: string): Points;
declare namespace tag { }
export = tag;
export default function tag(
points: FeatureCollection<Point>,
polygons: FeatureCollection<Polygon>,
field: string,
outField: string
): FeatureCollection<Point>;

@@ -1,2 +0,4 @@

var inside = require('@turf/inside');
import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
import clone from '@turf/clone';
import { featureEach } from '@turf/meta';

@@ -38,16 +40,11 @@ /**

*/
module.exports = function (points, polygons, field, outField) {
function tag(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) {
points = clone(points);
polygons = clone(polygons);
featureEach(points, function (pt) {
if (!pt.properties) pt.properties = {};
featureEach(polygons, function (poly) {
if (pt.properties[outField] === undefined) {
var isInside = inside(pt, poly);
if (isInside) {
pt.properties[outField] = poly.properties[field];
}
if (booleanPointInPolygon(pt, poly)) pt.properties[outField] = poly.properties[field];
}

@@ -57,2 +54,4 @@ });

return points;
};
}
export default tag;
{
"name": "@turf/tag",
"version": "4.7.3",
"version": "5.0.4",
"description": "turf tag module",
"main": "index.js",
"main": "main",
"module": "index",
"jsnext:main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"main.js"
],
"scripts": {
"test": "node test.js",
"bench": "node bench.js"
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"bench": "node -r @std/esm bench.js"
},

@@ -36,8 +40,18 @@ "repository": {

"devDependencies": {
"benchmark": "^2.1.4",
"tape": "^4.6.3"
"@std/esm": "*",
"benchmark": "*",
"load-json-file": "*",
"rollup": "*",
"tape": "*"
},
"dependencies": {
"@turf/inside": "^4.7.3"
"@turf/boolean-point-in-polygon": "^5.0.4",
"@turf/clone": "^5.0.4",
"@turf/helpers": "^5.0.4",
"@turf/meta": "^5.0.4"
},
"@std/esm": {
"esm": "js",
"cjs": true
}
}
# @turf/tag
# tag
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## tag
Takes a set of [points](http://geojson.org/geojson-spec.html#point) and a set of [polygons](http://geojson.org/geojson-spec.html#polygon) and performs a spatial join.

@@ -6,0 +8,0 @@

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