First commit

This is the beginnings of a new core plugin to add geospatial capabilities, building on the JSON operators that we now have in the core. It uses the libraries leaflet.js for mapping and turf.js for geospatial calculations.
This commit is contained in:
jeremy@jermolene.com
2022-12-02 10:13:03 +00:00
parent 66cf779abb
commit d3aca065ab
33 changed files with 15684 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
/*\
title: $:/plugins/tiddlywiki/geospatial/operators/helper.js
type: application/javascript
module-type: filteroperator
Filter operators for geospatial helpers
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var turf = require("$:/plugins/tiddlywiki/geospatial/turf.js");
exports.geopoint = function(source,operator,options) {
var lat = $tw.utils.parseNumber(operator.operands[0] || 0),
long = $tw.utils.parseNumber(operator.operands[1] || 0),
alt = $tw.utils.parseNumber(operator.operands[2] || 0);
return [JSON.stringify(turf.point([lat,long,alt]))];
};
})();

View File

@@ -0,0 +1,31 @@
/*\
title: $:/plugins/tiddlywiki/geospatial/operators/measurement.js
type: application/javascript
module-type: filteroperator
Filter operators for geospatial measurement
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var turf = require("$:/plugins/tiddlywiki/geospatial/turf.js"),
geotools = require("$:/plugins/tiddlywiki/geospatial/geotools.js");
var VALID_UNITS = ["miles","kilometers","radians","degrees"],
DEFAULT_UNITS = "miles";
exports.geodistance = function(source,operator,options) {
var from = geotools.parsePoint(operator.operands[0]),
to = geotools.parsePoint(operator.operands[1]),
units = operator.operands[2] || DEFAULT_UNITS;
if(VALID_UNITS.indexOf(units) === -1) {
units = DEFAULT_UNITS;
}
return [JSON.stringify(turf.distance(from,to,{units: units}))];
};
})();