-
Notifications
You must be signed in to change notification settings - Fork 25
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
Easier serialization of wkt with ToWkt::wkt_string/write_wkt #89
Conversation
a4291fc
to
b4074e0
Compare
Also renamed "to_wkt_string" to just "wkt_string", it's shorter and I don't think anything is lost.
cc5f47a
to
17825e7
Compare
At this point I do think that this impl goes in the right direction, but it is not (for me) the best possible scenario |
Ok, l'm going to call this ready for review. Please take a look anyone who's interested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where this has ended up.
bors r=urschrei |
Already running a review |
Build succeeded: |
92: impl ToWkt for inner geo_type variants, allow non-geotypes to impl ToWkt r=uschrei 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 --- ~~Draft because it's based on #89, so please review that first.~~ **update:** merged! The user benefit here is the implementation of `ToWkt` directly on the inner geometry enums so... instead of: ``` let point: geo_types::point!(x: 1.0, y: 2.0); let geo_geometry = geo_types::Geometry::from(point); let string = geo_geometry.wkt_string(); assert_eq!("POINT(1 2)", string); ``` you can do: ``` let point: geo_types::point!(x: 1.0, y: 2.0); let string = point.wkt_string(); assert_eq!("POINT(1 2)", string); ``` I also wanted to detangle ToWkt from geo-types, so that (hypothetical) non-geo-types users could implement it. The majority of the lines changed are in [ToWkt for non-geotypes](75ab496), but it's a misleading large diff (sorry). Largely it's a cut and paste job: I cut the `geo-types` specific code from `towkt.rs` and pasted it into the new `geo_types_to_wkt.rs`. For symmetry, and to better reflect it's functionality, I renamed the `conversions` module to `geo_types_from_wkt`. Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
…ediate representation. Note that this isn't a performance change. It's about (hopefully) making the library easier to use. This is a corollary to #89, but for reading WKT, rather than writing. As we discussed there, probably there is no reason for the user to care about the Wkt struct. Note that the intermediate representation is still used (for now!), but the user is no longer required to interact with it. The road is open though for having a direct translation from Wkt text to the geo-types (or whatever) represenation (see geozero for inspiration).
…ediate representation. Note that this isn't a performance change. It's about (hopefully) making the library easier to use. This is a corollary to #89, but for reading WKT, rather than writing. As we discussed there, probably there is no reason for the user to care about the Wkt struct. Note that the intermediate representation is still used (for now!), but the user is no longer required to interact with it. The road is open though for having a direct translation from Wkt text to the geo-types (or whatever) represenation (see geozero for inspiration).
…ediate representation. Note that this isn't a performance change. It's about (hopefully) making the library easier to use. This is a corollary to #89, but for reading WKT, rather than writing. As we discussed there, probably there is no reason for the user to care about the Wkt struct. Note that the intermediate representation is still used (for now!), but the user is no longer required to interact with it. The road is open though for having a direct translation from Wkt text to the geo-types (or whatever) represenation (see geozero for inspiration).
…ediate representation. Note that this isn't a performance change. It's about (hopefully) making the library easier to use. This is a corollary to #89, but for reading WKT, rather than writing. As we discussed there, probably there is no reason for the user to care about the Wkt struct. Note that the intermediate representation is still used (for now!), but the user is no longer required to interact with it. The road is open though for having a direct translation from Wkt text to the geo-types (or whatever) represenation (see geozero for inspiration).
…ediate representation. Note that this isn't a performance change. It's about (hopefully) making the library easier to use. This is a corollary to #89, but for reading WKT, rather than writing. As we discussed there, probably there is no reason for the user to care about the Wkt struct. Note that the intermediate representation is still used (for now!), but the user is no longer required to interact with it. The road is open though for having a direct translation from Wkt text to the geo-types (or whatever) represenation (see geozero for inspiration).
95: FromWkt trait for reading WKT without exposing the user to the intermediate representation. 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 --- Draft because it's based on #94. Please review that first. --- Note that this isn't a performance change. It's about (hopefully) making the library easier to use. This is a corollary to #89, but for reading WKT, rather than writing. As we discussed there, probably there is no reason for the user to care about the Wkt struct. Note that the intermediate representation is still used (for now!), but the user is no longer required to interact with it. The road is open though for having a direct translation from Wkt text to the geo-types (or whatever) represenation (see geozero for inspiration). --- I also added the missing GeometryCollection::from(wkt) implementation to make this work for all geo-types. Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
CHANGES.md
if knowledge of this change could be valuable to users.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 thesuperseded!ToWkt
trait.