mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-03 18:38:30 +00:00
Add geonearestpoint operator
This commit is contained in:
@@ -28,4 +28,20 @@ exports.geodistance = function(source,operator,options) {
|
||||
return [JSON.stringify(turf.distance(from,to,{units: units}))];
|
||||
};
|
||||
|
||||
exports.geonearestpoint = function(source,operator,options) {
|
||||
var target = geotools.parsePoint(operator.operands[0]),
|
||||
points = [];
|
||||
source(function(tiddler,title) {
|
||||
var point = geotools.parsePoint(title);
|
||||
if(point) {
|
||||
points.push(point)
|
||||
}
|
||||
});
|
||||
if(points.length > 0) {
|
||||
return [JSON.stringify(turf.nearestPoint(target,turf.featureCollection(points)))];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user