Skip to content

Commit

Permalink
Merge georust#67
Browse files Browse the repository at this point in the history
67: Minimal support for JTS extensions r=michaelkirk a=rmanoka

Refer discussion in georust#50 

+ support LINEARRING by parsing it as a LINESTRING
+ test LINEARRING parsing

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md).
- [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---




Co-authored-by: Rajsekar Manokaran <rajsekar@gmail.com>
  • Loading branch information
bors[bot] and rmanoka committed Apr 29, 2021
2 parents 5d938ce + 4aad200 commit 2b9afd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Support `POINT EMPTY` in conversion to `geo_types`.
Converts to `MultiPoint([])`.
* <https://github.com/georust/wkt/pull/64>
* Minimal support for JTS extension: `LINEARRING` by parsing it as a `LINESTRING`.

## 0.9.1

Expand Down
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ where
let x = <Point<T> as FromTokens<T>>::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 = <LineString<T> as FromTokens<T>>::from_tokens_with_parens(tokens);
x.map(|y| y.as_item())
}
Expand Down Expand Up @@ -261,6 +261,17 @@ mod tests {
}
}

#[test]
fn support_jts_linearring() {
let mut wkt: Wkt<f64> = 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 {
Expand Down

0 comments on commit 2b9afd8

Please sign in to comment.