Skip to content

Commit

Permalink
Merge pull request #92 from r00tat/enhancement/unwetter-display
Browse files Browse the repository at this point in the history
Enhancement/unwetter display
  • Loading branch information
r00tat authored Jun 10, 2024
2 parents 430d3e2 + f8a0a67 commit e34b85e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/app/api/icons/marker/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export async function GET(req: NextRequest) {
`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="${fill}">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zM7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 2.88-2.88 7.19-5 9.88C9.92 16.21 7 11.85 7 9z" />
<circle cx="12" cy="9" r="5" fill="#ddd"/>
<circle cx="12" cy="9" r="2.5" />
</svg>
`,
Expand Down
36 changes: 29 additions & 7 deletions src/components/Map/layers/UnwetterAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ function parseLatLng(text: string) {
];
}

function parseTime(time: string | number) {
if (typeof time === 'string') {
return time;
}
const minutes = time * 24 * 60;
return `${Math.floor(minutes / 60)
.toString()
.padStart(2, '0')}:${Math.floor(minutes % 60)
.toString()
.padStart(2, '0')}`;
}

const fetchUWD = async (sheetId: string, range: string) => {
console.info(`fetching unwetter data of ${sheetId} ${range}`);
const values = await getSpreadsheetData(
Expand Down Expand Up @@ -69,11 +81,14 @@ const fetchUWD = async (sheetId: string, range: string) => {
lng = Number.parseFloat(place.lon);
}
}
const desc = `${searchString}\n${status}${
fzg && ' von '
}${fzg}\n${description}\n${start || alarmTime}${
done && '-'
}${done}\n${info}`.trim();
const desc =
`${searchString}\nStatus: ${status} ${fzg}\n${description}\n${
alarmTime && '\nalarmiert: ' + parseTime(alarmTime)
}\n${start && 'begonnen: ' + parseTime(start)}${
done && '\nabgeschlossen: ' + parseTime(done)
}\n${info}`
.replace(/\n{2,}/g, '\n')
.trim();
return {
id: `${name} ${lat} ${lng}`.trim(),
street,
Expand Down Expand Up @@ -110,6 +125,13 @@ export async function fetchUnwetterData(
return [];
}

console.info(`requested unwetter data for ${sheetId} ${range}`);
return fetchUnwetterCachedData(sheetId, range);
console.info(
`requested unwetter data for ${
sheetId || process.env.EINSATZMAPPE_SHEET_ID
} ${range}`
);
return fetchUnwetterCachedData(
sheetId || process.env.EINSATZMAPPE_SHEET_ID || '',
range
);
}

0 comments on commit e34b85e

Please sign in to comment.