From d573c87ebe5d80f373f0b736c99c133d9a019467 Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Wed, 23 Jul 2025 11:25:39 +0200 Subject: [PATCH 1/3] dont fail parsing on empty coordinates --- src/reader.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 2f37179..8809e43 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1134,18 +1134,13 @@ where _ => {} } } - if coords.is_empty() { - Err(Error::InvalidGeometry( - "Geometry must contain coordinates element".to_string(), - )) - } else { - Ok(GeomProps { - coords, - altitude_mode, - extrude, - tessellate, - }) - } + + Ok(GeomProps { + coords, + altitude_mode, + extrude, + tessellate, + }) } fn read_float(&mut self) -> Result { From 3aa765ce10d325aa19cd3210a923d312e2e38e7f Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Thu, 24 Jul 2025 16:43:43 +0200 Subject: [PATCH 2/3] test parse document with empty coordinates --- src/reader.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/reader.rs b/src/reader.rs index 8809e43..a7ff948 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1758,4 +1758,27 @@ mod tests { Kml::KmlDocument(_) )); } + + #[test] + fn test_parse_empty_coordinates() { + let kml_str = r#" + + + + + test + + absolute + + + + + + "#; + + assert!(matches!( + Kml::::from_str(kml_str).unwrap(), + Kml::KmlDocument(_) + )); + } } From a7f9c8ec3990b23531e89bf712210dfed3a0518f Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Fri, 25 Jul 2025 15:13:49 +0200 Subject: [PATCH 3/3] updated test --- src/reader.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index a7ff948..02d2b88 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1762,23 +1762,19 @@ mod tests { #[test] fn test_parse_empty_coordinates() { let kml_str = r#" - - - - - test - - absolute - - - - - + + absolute + + "#; - assert!(matches!( + assert_eq!( Kml::::from_str(kml_str).unwrap(), - Kml::KmlDocument(_) - )); + Kml::LineString(LineString { + coords: vec![], + altitude_mode: types::AltitudeMode::Absolute, + ..Default::default() + }) + ); } }