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;
