mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
better gpx route error handling
This commit is contained in:
parent
e995b46641
commit
3ffba24994
2 changed files with 19 additions and 13 deletions
|
@ -384,7 +384,9 @@ function* uploadGpx({ file }: ReturnType<typeof editorUploadGpx>) {
|
|||
editorSetGpx({
|
||||
list: [
|
||||
...list,
|
||||
...gpx.map(item => ({
|
||||
...gpx
|
||||
.filter(item => item.latlngs && item.latlngs.length)
|
||||
.map(item => ({
|
||||
enabled: true,
|
||||
latlngs: item.latlngs,
|
||||
color: getRandomColor(),
|
||||
|
|
|
@ -93,12 +93,16 @@ export const importGpxTrack = async (file: File) => {
|
|||
if (!gpx || !gpx.trk) return null;
|
||||
|
||||
const latlngs: LatLng[] = gpx.trk.reduce((trk_res, trk) => {
|
||||
return trk.trkseg.reduce((trkseg_res, trkseg) => {
|
||||
return [
|
||||
return trk.trkseg
|
||||
? trk.trkseg.reduce((trkseg_res, trkseg) => {
|
||||
return trkseg.trkpt
|
||||
? [
|
||||
...trkseg_res,
|
||||
...trkseg.trkpt.map(pnt => ({ lat: pnt['$'].lat, lng: pnt['$'].lon })),
|
||||
];
|
||||
}, trk_res);
|
||||
]
|
||||
: trkseg_res;
|
||||
}, trk_res)
|
||||
: trk_res;
|
||||
}, []);
|
||||
|
||||
return [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue