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,13 +384,15 @@ function* uploadGpx({ file }: ReturnType<typeof editorUploadGpx>) {
|
||||||
editorSetGpx({
|
editorSetGpx({
|
||||||
list: [
|
list: [
|
||||||
...list,
|
...list,
|
||||||
...gpx.map(item => ({
|
...gpx
|
||||||
enabled: true,
|
.filter(item => item.latlngs && item.latlngs.length)
|
||||||
latlngs: item.latlngs,
|
.map(item => ({
|
||||||
color: getRandomColor(),
|
enabled: true,
|
||||||
name: item.name || `Track #${list.length + 1}`,
|
latlngs: item.latlngs,
|
||||||
id: uuid() as string,
|
color: getRandomColor(),
|
||||||
})),
|
name: item.name || `Track #${list.length + 1}`,
|
||||||
|
id: uuid() as string,
|
||||||
|
})),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -93,12 +93,16 @@ export const importGpxTrack = async (file: File) => {
|
||||||
if (!gpx || !gpx.trk) return null;
|
if (!gpx || !gpx.trk) return null;
|
||||||
|
|
||||||
const latlngs: LatLng[] = gpx.trk.reduce((trk_res, trk) => {
|
const latlngs: LatLng[] = gpx.trk.reduce((trk_res, trk) => {
|
||||||
return trk.trkseg.reduce((trkseg_res, trkseg) => {
|
return trk.trkseg
|
||||||
return [
|
? trk.trkseg.reduce((trkseg_res, trkseg) => {
|
||||||
...trkseg_res,
|
return trkseg.trkpt
|
||||||
...trkseg.trkpt.map(pnt => ({ lat: pnt['$'].lat, lng: pnt['$'].lon })),
|
? [
|
||||||
];
|
...trkseg_res,
|
||||||
}, trk_res);
|
...trkseg.trkpt.map(pnt => ({ lat: pnt['$'].lat, lng: pnt['$'].lon })),
|
||||||
|
]
|
||||||
|
: trkseg_res;
|
||||||
|
}, trk_res)
|
||||||
|
: trk_res;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue