UNPKG

@turf/tag

Version:

Takes a set of points and a set of polygons and/or multipolygons and performs a spatial join.

26 lines (23 loc) 943 B
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts var _booleanpointinpolygon = require('@turf/boolean-point-in-polygon'); var _clone = require('@turf/clone'); var _meta = require('@turf/meta'); function tag(points, polygons, field, outField) { points = _clone.clone.call(void 0, points); polygons = _clone.clone.call(void 0, polygons); _meta.featureEach.call(void 0, points, function(pt) { if (!pt.properties) pt.properties = {}; _meta.featureEach.call(void 0, polygons, function(poly) { if (pt.properties && poly.properties) { if (pt.properties[outField] === void 0) { if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0, pt, poly)) pt.properties[outField] = poly.properties[field]; } } }); }); return points; } var index_default = tag; exports.default = index_default; exports.tag = tag; //# sourceMappingURL=index.cjs.map