mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
added points to gpx track
This commit is contained in:
parent
9c46f11a94
commit
1222b8f513
2 changed files with 34 additions and 26 deletions
|
@ -560,12 +560,14 @@ function* setTitleSaga({ title }: ReturnType<typeof ActionCreators.setTitle>):Sa
|
||||||
}
|
}
|
||||||
|
|
||||||
function* getGPXTrackSaga(): SagaIterator {
|
function* getGPXTrackSaga(): SagaIterator {
|
||||||
const { route } = editor.dumpData();
|
const { route, stickers } = editor.dumpData();
|
||||||
const { title, address } = yield select(getState);
|
const { title, address } = yield select(getState);
|
||||||
|
|
||||||
if (!route || route.length <= 0) return;
|
if (!route || route.length <= 0) return;
|
||||||
|
|
||||||
const track = getGPXString({ points: route, title: (title || address) });
|
const track = getGPXString({ route, stickers, title: (title || address) });
|
||||||
|
|
||||||
|
console.log({ route, stickers });
|
||||||
|
|
||||||
return downloadGPXTrack({ track, title });
|
return downloadGPXTrack({ track, title });
|
||||||
}
|
}
|
||||||
|
@ -601,8 +603,6 @@ export function* userSaga() {
|
||||||
yield takeLatest(ACTIONS.GOT_VK_USER, gotVkUserSaga);
|
yield takeLatest(ACTIONS.GOT_VK_USER, gotVkUserSaga);
|
||||||
yield takeLatest(ACTIONS.KEY_PRESSED, keyPressedSaga);
|
yield takeLatest(ACTIONS.KEY_PRESSED, keyPressedSaga);
|
||||||
|
|
||||||
// yield takeLatest(ACTIONS.IFRAME_LOGIN_VK, iframeLoginVkSaga);
|
|
||||||
|
|
||||||
yield takeLatest(ACTIONS.SET_TITLE, setTitleSaga);
|
yield takeLatest(ACTIONS.SET_TITLE, setTitleSaga);
|
||||||
|
|
||||||
yield takeLatest([
|
yield takeLatest([
|
||||||
|
|
|
@ -5,36 +5,44 @@ export interface IRoutePoint {
|
||||||
lng: number,
|
lng: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface IGPXSticker {
|
||||||
|
latlng: IRoutePoint,
|
||||||
|
text?: string,
|
||||||
|
}
|
||||||
|
|
||||||
interface IGetGPXString {
|
interface IGetGPXString {
|
||||||
points: Array<IRoutePoint>,
|
route: Array<IRoutePoint>,
|
||||||
|
stickers?: Array<IGPXSticker>
|
||||||
title?: string,
|
title?: string,
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// export const getGPXString = ({ points, title }: IGetGPXString): string => (`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
// <gpx>
|
|
||||||
// <rte>
|
|
||||||
// <name>${title || 'GPX Track'}</name>
|
|
||||||
// ${
|
|
||||||
// points.reduce((cat, { lat, lng }, index) => (
|
|
||||||
// ` ${cat}
|
|
||||||
// <wpt lat="${lat.toFixed(6)}" lon="${lng.toFixed(6)}"></wpt>`
|
|
||||||
// ), '')
|
|
||||||
// }
|
|
||||||
// </rte>
|
|
||||||
// </gpx>
|
|
||||||
// `);
|
|
||||||
|
|
||||||
export const getGPXString = ({ points, title }: IGetGPXString): string => (`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<gpx>
|
export const getGPXString = ({ route, title, stickers }: IGetGPXString): string => (`<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<rte>
|
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
|
||||||
|
<metadata>
|
||||||
|
<name>${title || 'GPX Track'}</name>
|
||||||
|
</metadata>
|
||||||
|
${
|
||||||
|
stickers.reduce((cat, { latlng: { lat, lng }, text }, index) => (
|
||||||
|
`${cat}
|
||||||
|
<wpt lat="${lat}" lon="${lng}">
|
||||||
|
<name>${text}</name>
|
||||||
|
<sym>generic</sym>
|
||||||
|
<type>Generic</type>
|
||||||
|
</wpt>`), '')
|
||||||
|
}
|
||||||
|
<trk>
|
||||||
<name>${title || 'GPX Track'}</name>
|
<name>${title || 'GPX Track'}</name>
|
||||||
|
<trkseg>
|
||||||
${
|
${
|
||||||
points.reduce((cat, { lat, lng }, index) => (
|
route.reduce((cat, { lat, lng }, index) => (
|
||||||
`${cat}
|
` ${cat}
|
||||||
<rtept lat="${lat}" lon="${lng}"></rtept>`
|
<trkpt lat="${lat}" lon="${lng}"></trkpt>`
|
||||||
), '')
|
), '')
|
||||||
}
|
}
|
||||||
</rte>
|
</trkseg>
|
||||||
|
</trk>
|
||||||
</gpx>
|
</gpx>
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue