Skip to content

Commit

Permalink
Merge #86
Browse files Browse the repository at this point in the history
86: impl Display for Wkt r=lnicola a=categulario

- [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.
---

to address #83 and make it easier to go from Wkt to string representation. Includes test

Co-authored-by: Abraham Toriz <[email protected]>
  • Loading branch information
bors[bot] and categulario authored Apr 2, 2022
2 parents 3833e7f + 37537a4 commit 83294e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## next release
### Changed
* impl `std::fmt::Display` for `Wkt`.

## 0.10.0 - 2022-02-24
### Changed
* Now accepts `MULTIPOINT`s with fewer parentheses, as output by `ST_AsText` in postgis:
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ where
}
}

impl<T> fmt::Display for Wkt<T>
where
T: WktFloat + fmt::Debug + fmt::Display,
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.item.fmt(formatter)
}
}

trait FromTokens<T>: Sized + Default
where
T: WktFloat + FromStr + Default,
Expand Down Expand Up @@ -336,4 +345,11 @@ mod tests {
"Point(Point(Some(Coord { x: 1.0, y: 2.0, z: None, m: None })))"
);
}

#[test]
fn test_display_on_wkt() {
let wktls: Wkt<f64> = Wkt::from_str("LINESTRING(10 20, 20 30)").unwrap();

assert_eq!(wktls.to_string(), "LINESTRING(10 20,20 30)");
}
}

0 comments on commit 83294e0

Please sign in to comment.