Skip to content

Commit

Permalink
fix: gps output
Browse files Browse the repository at this point in the history
Fixes #60, broken with previous refactoring.
  • Loading branch information
tkurki committed Apr 3, 2024
1 parent c69d7b4 commit a5fa839
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/HistoryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,15 @@ function outputPositionsGpx(data: DataResult, context: string, res: SimpleRespon
<metadata><author>${context}</author></metadata>
<trk>`
let inSegment = false
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data.data.forEach((p: any) => {
if (p.lat != null && p.lon != null) {
data.data.forEach((p: [Timestamp, [number, number]]) => {
const [time, position] = p
const [lon, lat] = position
if (lat !== null && lon !== null) {
if (!inSegment) {
responseBody += '\n<trseg>'
inSegment = true
}
responseBody += `<trkpt lat="${p.lat}" lon="${p.lon}"><time>${p.time.toISOString()}</time></trkpt>`
responseBody += `<trkpt lat="${lat}" lon="${lon}"><time>${time}</time></trkpt>`
} else {
if (inSegment) {
responseBody += '</trseg>'
Expand Down

0 comments on commit a5fa839

Please sign in to comment.