Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Impl/from geo types #88

Closed
wants to merge 6 commits into from

Conversation

categulario
Copy link
Contributor

@categulario categulario commented Apr 1, 2022

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.
  • I ran cargo fmt

addresses #73 and #48.

This adds impls of From for every type and the Geometry enum in geo_types. It makes it unnecessary to bring to scope the ToWkt trait which gets deleted because it was not being used actually. Of course this is a breaking change.

Additionally I added some docs on the most relevant cases for this crate: parsing a wkt and getting a geometry and having a geometry and getting its WKT string. This is what actually motivates most of the PRs I've been doing, I just wanted to do that .-.

Some opinions

What if Wkt was instead a trait itself, implemented for every type in geo_types that provided a single method: wkt(&self) -> String?

being georust an environment for building geo applications it makes sense that things are integrated to work well within the environment, and maybe providing some LineString etc. traits which, if implemented on foreign types would give automatically a Wkt impl that allows to get its WKT string. And perhaps a WktGeometry enum with inner types refering to those in the geo_types crate just for the purposes of having something to parse a string into. Although it probably makes more sense to just have FromStr impls for the geo_types themselves...

Just an idea, I think it would simplify a lot how work with this crate happens.

This actually requires #86 for the docs to pass the tests

@categulario
Copy link
Contributor Author

it also addresses #55

@categulario categulario changed the title Impl/from geo types WIP: Impl/from geo types Apr 1, 2022
@michaelkirk
Copy link
Member

I'm curious what you though of my proposal in #89 @categulario

@categulario
Copy link
Contributor Author

With Display implemented for Wkt<T> I don't tink it is necessary because people using ToWkt are already getting a Wkt out of it, which can be to_string()ed

@urschrei urschrei mentioned this pull request Apr 1, 2022
@categulario
Copy link
Contributor Author

Just pushed some commits and rebased main.

ToWkt is restored but deprecated. The doc tests are fixed.

@categulario
Copy link
Contributor Author

Closing this since it no longer reflects my ideas, mostly laid out in #73

bors bot added a commit that referenced this pull request Apr 14, 2022
89: Easier serialization of wkt with ToWkt::wkt_string/write_wkt r=urschrei a=michaelkirk

- [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.
- [x] I ran cargo fmt
---
Fixes #55 - adds an easier API to serialize a geo-type.

~~Depends on #86, so merge that first.~~ Merged!

~~partially conflicts with #88, because I'm relying on the `ToWkt` trait.~~ superseded!


Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants