mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-22 03:29:31 -07:00
Fixup mapclick.mjs
This commit is contained in:
@@ -339,15 +339,14 @@ export const convertMapClickForecastToApiFormat = (mapClickData) => {
|
|||||||
return {
|
return {
|
||||||
type: 'Feature',
|
type: 'Feature',
|
||||||
geometry: {
|
geometry: {
|
||||||
type: 'Polygon',
|
type: 'Point',
|
||||||
coordinates: [[[mapClickData.location?.longitude, mapClickData.location?.latitude]]], // Approximate
|
coordinates: [mapClickData.location?.longitude, mapClickData.location?.latitude],
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
updated: mapClickData.creationDate || new Date().toISOString(),
|
|
||||||
units: 'us',
|
units: 'us',
|
||||||
forecastGenerator: 'MapClick',
|
forecastGenerator: 'MapClick',
|
||||||
generatedAt: new Date().toISOString(),
|
generatedAt: new Date().toISOString(),
|
||||||
updateTime: mapClickData.creationDate || new Date().toISOString(),
|
updateTime: parseMapClickDate(mapClickData.creationDateLocal)?.toISOString() || new Date().toISOString(),
|
||||||
validTimes: `${time.startValidTime[0]}/${time.startValidTime[time.startValidTime.length - 1]}`,
|
validTimes: `${time.startValidTime[0]}/${time.startValidTime[time.startValidTime.length - 1]}`,
|
||||||
elevation: {
|
elevation: {
|
||||||
unitCode: 'wmoUnit:m',
|
unitCode: 'wmoUnit:m',
|
||||||
@@ -619,6 +618,7 @@ export const enhanceObservationWithMapClick = async (observationData, options =
|
|||||||
// Build improvements list for logging
|
// Build improvements list for logging
|
||||||
const improvements = [];
|
const improvements = [];
|
||||||
if (isFresher) {
|
if (isFresher) {
|
||||||
|
// NOTE: for the forecast version, we'd want to use the `updateTime` property instead of `timestamp`
|
||||||
const mapClickAgeInMinutes = Math.round((Date.now() - mapClickTimestamp) / (1000 * 60));
|
const mapClickAgeInMinutes = Math.round((Date.now() - mapClickTimestamp) / (1000 * 60));
|
||||||
improvements.push(`${mapClickAgeInMinutes} minutes old vs. ${ageInMinutes.toFixed(0)} minutes old`);
|
improvements.push(`${mapClickAgeInMinutes} minutes old vs. ${ageInMinutes.toFixed(0)} minutes old`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user