From 19ff862e8a3163fbf0cf1c689d7349d3e59f3037 Mon Sep 17 00:00:00 2001 From: Rajsekar Manokaran Date: Thu, 29 Apr 2021 22:16:49 +0530 Subject: [PATCH 1/2] Minimal support for JTS extensions + support LINEARRING by parsing it as a LINESTRING + test LINEARRING parsing --- src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 7b6a3efba..3205e802a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ where let x = as FromTokens>::from_tokens_with_parens(tokens); x.map(|y| y.as_item()) } - w if w.eq_ignore_ascii_case("LINESTRING") => { + w if w.eq_ignore_ascii_case("LINESTRING") || w.eq_ignore_ascii_case("LINEARRING") => { let x = as FromTokens>::from_tokens_with_parens(tokens); x.map(|y| y.as_item()) } @@ -261,6 +261,18 @@ mod tests { } } + #[test] + fn support_jts_linearring() { + let mut wkt: Wkt = Wkt::from_str("linearring (10 20, 30 40)").ok().unwrap(); + assert_eq!(1, wkt.items.len()); + + match wkt.items.pop().unwrap() { + Geometry::LineString(_ls) => (), + _ => panic!("expected to be parsed as a LINESTRING"), + }; + + } + #[test] fn test_debug() { let g = Geometry::Point(Point(Some(Coord { From 4aad200018055904aa963f4de986a3fa397cff9b Mon Sep 17 00:00:00 2001 From: Rajsekar Manokaran Date: Thu, 29 Apr 2021 22:21:22 +0530 Subject: [PATCH 2/2] Add a line in changes.md --- CHANGES.md | 1 + src/lib.rs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0e3d1873d..e49d1b582 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ * Support `POINT EMPTY` in conversion to `geo_types`. Converts to `MultiPoint([])`. * +* Minimal support for JTS extension: `LINEARRING` by parsing it as a `LINESTRING`. ## 0.9.1 diff --git a/src/lib.rs b/src/lib.rs index 3205e802a..0dd204120 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ where let x = as FromTokens>::from_tokens_with_parens(tokens); x.map(|y| y.as_item()) } - w if w.eq_ignore_ascii_case("LINESTRING") || w.eq_ignore_ascii_case("LINEARRING") => { + w if w.eq_ignore_ascii_case("LINESTRING") || w.eq_ignore_ascii_case("LINEARRING") => { let x = as FromTokens>::from_tokens_with_parens(tokens); x.map(|y| y.as_item()) } @@ -270,7 +270,6 @@ mod tests { Geometry::LineString(_ls) => (), _ => panic!("expected to be parsed as a LINESTRING"), }; - } #[test]