Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -41,16 +41,17 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; | ||
function tag(points, polygons, field, outField) { | ||
// prevent mutations | ||
points = clone(points); | ||
polygons = clone(polygons); | ||
featureEach(points, function (pt) { | ||
if (!pt.properties) pt.properties = {}; | ||
featureEach(polygons, function (poly) { | ||
if (pt.properties[outField] === undefined) { | ||
if (booleanPointInPolygon(pt, poly)) pt.properties[outField] = poly.properties[field]; | ||
} | ||
}); | ||
// prevent mutations | ||
points = clone(points); | ||
polygons = clone(polygons); | ||
featureEach(points, function (pt) { | ||
if (!pt.properties) pt.properties = {}; | ||
featureEach(polygons, function (poly) { | ||
if (pt.properties[outField] === undefined) { | ||
if (booleanPointInPolygon(pt, poly)) | ||
pt.properties[outField] = poly.properties[field]; | ||
} | ||
}); | ||
return points; | ||
}); | ||
return points; | ||
} | ||
export default tag; |
@@ -45,17 +45,17 @@ 'use strict'; | ||
function tag(points, polygons, field, outField) { | ||
// prevent mutations | ||
points = clone(points); | ||
polygons = clone(polygons); | ||
meta.featureEach(points, function (pt) { | ||
if (!pt.properties) pt.properties = {}; | ||
meta.featureEach(polygons, function (poly) { | ||
if (pt.properties[outField] === undefined) { | ||
if (booleanPointInPolygon(pt, poly)) pt.properties[outField] = poly.properties[field]; | ||
} | ||
}); | ||
// prevent mutations | ||
points = clone(points); | ||
polygons = clone(polygons); | ||
meta.featureEach(points, function (pt) { | ||
if (!pt.properties) pt.properties = {}; | ||
meta.featureEach(polygons, function (poly) { | ||
if (pt.properties[outField] === undefined) { | ||
if (booleanPointInPolygon(pt, poly)) | ||
pt.properties[outField] = poly.properties[field]; | ||
} | ||
}); | ||
return points; | ||
}); | ||
return points; | ||
} | ||
module.exports = tag; | ||
module.exports.default = tag; |
@@ -1,2 +0,2 @@ | ||
import { BBox, Point, FeatureCollection, Polygon } from '@turf/helpers' | ||
import { Point, FeatureCollection, Polygon } from "@turf/helpers"; | ||
@@ -7,6 +7,6 @@ /** | ||
export default function tag( | ||
points: FeatureCollection<Point>, | ||
polygons: FeatureCollection<Polygon>, | ||
field: string, | ||
outField: string | ||
points: FeatureCollection<Point>, | ||
polygons: FeatureCollection<Polygon>, | ||
field: string, | ||
outField: string | ||
): FeatureCollection<Point>; |
{ | ||
"name": "@turf/tag", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf tag module", | ||
@@ -30,2 +30,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "index.d.ts", | ||
@@ -38,8 +42,7 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "node -r esm bench.js", | ||
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"posttest": "node -r esm ../../scripts/validate-es5-dependencies.js", | ||
"prepare": "rollup -c ../../rollup.config.js", | ||
"test": "npm-run-all prepare test:*", | ||
"test": "npm-run-all test:*", | ||
"test:tape": "node -r esm test.js" | ||
@@ -55,8 +58,8 @@ }, | ||
"dependencies": { | ||
"@turf/boolean-point-in-polygon": "^6.2.0-alpha.2", | ||
"@turf/clone": "^6.2.0-alpha.2", | ||
"@turf/helpers": "^6.2.0-alpha.2", | ||
"@turf/meta": "^6.2.0-alpha.2" | ||
"@turf/boolean-point-in-polygon": "^6.2.0-alpha.3", | ||
"@turf/clone": "^6.2.0-alpha.3", | ||
"@turf/helpers": "^6.2.0-alpha.3", | ||
"@turf/meta": "^6.2.0-alpha.3" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
10542
8
173