@turf/tag
Version:
turf tag module
26 lines (23 loc) • 949 B
JavaScript
;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 turf_tag_default = tag;
exports.default = turf_tag_default; exports.tag = tag;
//# sourceMappingURL=index.cjs.map