* 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)
| 158 | * @throws {Error} If coordinates are missing or invalid |
| 159 | */ |
| 160 | function 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 | |
| 170 | module.exports = { |
| 171 | convertWeatherType, |
no test coverage detected