mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:07:08 +00:00
Add replaceMarkers utility function
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
geometryAsString: require('./geometryAsString'),
|
geometryAsString: require('./geometryAsString'),
|
||||||
dms: require('./dms')
|
dms: require('./dms'),
|
||||||
|
replaceMarkers: require('./replaceMarkers')
|
||||||
};
|
};
|
||||||
|
|||||||
17
lib/www/server/lib/utils/replaceMarkers.js
Normal file
17
lib/www/server/lib/utils/replaceMarkers.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const geometryAsString = require('./geometryAsString');
|
||||||
|
|
||||||
|
function replaceMarkers (item, opts={}) {
|
||||||
|
const textkey = opts.text || "remarks";
|
||||||
|
|
||||||
|
const text = item[textkey];
|
||||||
|
|
||||||
|
if (text && typeof text === "string") {
|
||||||
|
item[textkey] = text
|
||||||
|
.replace(/@POS(ITION)?@/g, geometryAsString(item, opts) || "(position unknown)")
|
||||||
|
.replace(/@DMS@/g, geometryAsString(item, {...opts, dms:true}) || "(position unknown)")
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = replaceMarkers;
|
||||||
Reference in New Issue
Block a user