Skip to content

Quickly convert your custom struct to/from a single Feature #253

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

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

michaelkirk
Copy link
Member

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

analogous to serde_json::{to_value,from_value}

We have a slew of methods for dealing with entire feature collections, but not for dealing with individual features.

Like those other "bring your own struct" methods, your custom struct must have a geometry field. All other fields will be mapped to feature.properties.

analogous to serde_json::{to_value,from_value}

Your custom struct must have a `geometry` field, all other fields will
be mapped to feature.properties.
/// All other fields will be deserialized from `feature.properties`.
///
/// # Examples
#[cfg_attr(feature = "geo-types", doc = "```")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we done this before? I love it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been known to sprinkle it around. It's pretty arcane, but it does the trick. I was kind of shocked the first time I tried it and it worked.

Copy link
Member

@urschrei urschrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@michaelkirk michaelkirk added this pull request to the merge queue Feb 21, 2025
Merged via the queue into main with commit 6c29f3f Feb 21, 2025
3 checks passed
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.

2 participants