mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-11-18 07:27:43 +00:00
keep waypoint time on import (#409)
* keep waypoint time on import * Remove extra newline in parse.rs test file --------- Co-authored-by: vcoppe <vianney.coppe@gmail.com>
This commit is contained in:
1 parent
58b2861160
commit
8aede444fc
1 file changed
+14
-4
@@ -213,10 +213,13 @@ fn apply_text(
|
||||
}
|
||||
Some(GPXElement::Time) => {
|
||||
stack.pop();
|
||||
if let Some(GPXElement::Trackpoint(trkpt)) = stack.last_mut() {
|
||||
trkpt.time = DateTime::parse_from_rfc3339(e)
|
||||
.ok()
|
||||
.map(|time| time.timestamp_millis());
|
||||
let time = DateTime::parse_from_rfc3339(e)
|
||||
.ok()
|
||||
.map(|time| time.timestamp_millis());
|
||||
match stack.last_mut() {
|
||||
Some(GPXElement::Trackpoint(trkpt)) => trkpt.time = time,
|
||||
Some(GPXElement::Waypoint(wpt)) => wpt.time = time,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
Some(GPXElement::Temperature) => {
|
||||
@@ -1143,6 +1146,13 @@ mod tests {
|
||||
assert!(wpt.type_.as_ref().is_some_and(|t| t == "Bike Trail"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_waypoint_time() {
|
||||
let data = r#"<gpx><wpt lat="1" lon="2"><time>2024-05-01T06:10:00Z</time></wpt></gpx>"#;
|
||||
let gpx = parse(data.as_bytes(), &mut Default::default()).unwrap();
|
||||
assert_eq!(gpx.wpt[0].time, Some(1714543800000));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_trackpoint_time() {
|
||||
let gpx = parse_data("with_time");
|
||||
|
||||
Reference in new issue
Block a user