MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / validateCoordinates

Function validateCoordinates

defaultmodules/weather/provider-utils.js:160–168  ·  view source on GitHub ↗

* Validate and limit coordinate precision * @param {object} config - Configuration object with lat/lon properties * @param {number} maxDecimals - Maximum decimal places to preserve * @throws {Error} If coordinates are missing or invalid

(config, maxDecimals = 4)

Source from the content-addressed store, hash-verified

158 * @throws {Error} If coordinates are missing or invalid
159 */
160function validateCoordinates (config, maxDecimals = 4) {
161 if (config.lat == null || config.lon == null
162 || !Number.isFinite(config.lat) || !Number.isFinite(config.lon)) {
163 throw new Error("Latitude and longitude are required");
164 }
165
166 config.lat = limitDecimals(config.lat, maxDecimals);
167 config.lon = limitDecimals(config.lon, maxDecimals);
168}
169
170module.exports = {
171 convertWeatherType,

Callers 2

initializeMethod · 0.85
initializeMethod · 0.85

Calls 1

limitDecimalsFunction · 0.85

Tested by

no test coverage detected