Skip to content

Commit

Permalink
to_wkt_string
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Apr 1, 2022
1 parent 37537a4 commit a4291fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changes

## next release
### Changed

### Added
* impl `std::fmt::Display` for `Wkt`.
* <https://github.com/georust/wkt/pull/88>
* added `to_wkt_string` method to `ToWkt`
* <https://github.com/georust/wkt/pull/89>

## 0.10.0 - 2022-02-24
### Changed
Expand Down
15 changes: 13 additions & 2 deletions src/towkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ use geo_types::CoordFloat;
/// A trait for converting values to WKT
pub trait ToWkt<T>
where
T: CoordFloat,
T: CoordFloat + std::fmt::Display,
{
/// Converts the value of `self` to an instance of WKT
fn to_wkt(&self) -> Wkt<T>;

/// Serialize as a WKT string
///
/// ```
/// use wkt::ToWkt;
/// let point: geo_types::Geometry<f64> = geo_types::point!(x: 1.0, y: 2.0).into();
/// assert_eq!("POINT(1 2)", &point.to_wkt_string());
/// ```
fn to_wkt_string(&self) -> String {
self.to_wkt().to_string()
}
}

fn g_point_to_w_coord<T>(g_point: &geo_types::Coordinate<T>) -> Coord<T>
Expand Down Expand Up @@ -215,7 +226,7 @@ where

impl<T> ToWkt<T> for geo_types::Geometry<T>
where
T: CoordFloat,
T: CoordFloat + std::fmt::Display
{
fn to_wkt(&self) -> Wkt<T> {
let w_geom = g_geom_to_w_geom(self);
Expand Down

0 comments on commit a4291fc

Please sign in to comment.