1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Add getMapPoints() and MapPoints for GPX waypoints

Store waypoints from GPX files' <wpt> tags into MapPoints, while track points remain in MapPath.
This commit is contained in:
zigmhount 2022-03-06 22:04:59 +01:00 committed by GitHub
parent c32d625308
commit ac4a854917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,6 +84,23 @@ export class MapService {
}
return points;
}
// Waypoints <wpt> from GPX files:
public async getMapPoints(file: FileDTO): Promise<MapPoints[]> {
const filePath = Utils.concatUrls(file.directory.path, file.directory.name, file.name);
const gpx = await this.networkService.getXML('/gallery/content/' + filePath);
const elements = gpx.getElementsByTagName('wpt');
const wpoints: MapPoints[] = [];
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < elements.length; i++) {
wpoints.push({
lat: parseFloat(elements[i].getAttribute('lat')),
lng: parseFloat(elements[i].getAttribute('lon'))
});
}
console.log('From file ' + filePath + ', wpoints=' + JSON.stringify(wpoints));
return wpoints;
}
}
@ -92,3 +109,8 @@ export interface MapPath {
lat: number;
lng: number;
}
export interface MapPoints {
lat: number;
lng: number;
}