Skip to content

Failed to parse GPX1.0 file #105

@CaviarChen

Description

@CaviarChen

Getting: invalid child element course in waypoint thread gpx.
According to the spec[1], course is valid but we do not handle it in the lib [2].

The straight forward fix could be just supporting this tag, but what about just killing InvalidChildElement? Or minting a strict mode and only consider this as an error there?

[1] https://www.topografix.com/gpx_manual.asp
[2]

gpx/src/parser/waypoint.rs

Lines 67 to 123 in ef3ab70

XmlEvent::StartElement { ref name, .. } => {
match name.local_name.as_ref() {
"ele" => {
// Cast the elevation to an f64, from a string.
waypoint.elevation = match string::consume(context, "ele", false) {
Ok(v) => Some(v.parse()?),
Err(GpxError::NoStringContent) => None,
Err(other_err) => return Err(other_err),
}
}
"speed" if context.version == GpxVersion::Gpx10 => {
// Speed is from GPX 1.0
waypoint.speed = Some(string::consume(context, "speed", false)?.parse()?);
}
"time" => waypoint.time = Some(time::consume(context)?),
"name" => waypoint.name = Some(string::consume(context, "name", true)?),
"cmt" => waypoint.comment = Some(string::consume(context, "cmt", true)?),
"desc" => waypoint.description = Some(string::consume(context, "desc", true)?),
"src" => waypoint.source = Some(string::consume(context, "src", true)?),
"link" => waypoint.links.push(link::consume(context)?),
"sym" => waypoint.symbol = Some(string::consume(context, "sym", false)?),
"type" => waypoint.type_ = Some(string::consume(context, "type", false)?),
// Optional accuracy information
"fix" => waypoint.fix = Some(fix::consume(context)?),
"geoidheight" => {
waypoint.geoidheight =
Some(string::consume(context, "geoidheight", false)?.parse()?)
}
"sat" => waypoint.sat = Some(string::consume(context, "sat", false)?.parse()?),
"hdop" => {
waypoint.hdop = Some(string::consume(context, "hdop", false)?.parse()?)
}
"vdop" => {
waypoint.vdop = Some(string::consume(context, "vdop", false)?.parse()?)
}
"pdop" => {
waypoint.pdop = Some(string::consume(context, "pdop", false)?.parse()?)
}
"ageofdgpsdata" => {
waypoint.dgps_age =
Some(string::consume(context, "ageofdgpsdata", false)?.parse()?)
}
"dgpsid" => {
waypoint.dgpsid = Some(string::consume(context, "dgpsid", false)?.parse()?)
}
// Finally the GPX 1.1 extensions
"extensions" => extensions::consume(context)?,
child => {
return Err(GpxError::InvalidChildElement(
String::from(child),
"waypoint",
));
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions