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

TryFromWkt for integer geometries #103

Merged
merged 1 commit into from Jun 16, 2022
Merged

TryFromWkt for integer geometries #103

merged 1 commit into from Jun 16, 2022

Conversation

michaelkirk
Copy link
Member

@michaelkirk michaelkirk commented May 18, 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

Fixes #102

This is based on #101, which @rmanoka already approved (thanks!), but I'm going to wait just a bit longer to merge it in case someone else wanted to take a look at it.
update: #101 has been merged, and this is ready for review!

@michaelkirk
Copy link
Member Author

#101 has been merged, and this is ready for review

@@ -38,15 +38,15 @@ pub enum Error {
},
#[error("Wrong number of Geometries: {0}")]
WrongNumberOfGeometries(usize),
#[error("Invalid WKT")]
#[error("Invalid WKT: {0}")]
Copy link
Member Author

Choose a reason for hiding this comment

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

Note the InvalidWKT error message now includes the underlying error reason.

Cargo.toml Outdated

[dev-dependencies]
criterion = { version = "0.2" }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
env_logger = "0.9.0"
Copy link
Member

Choose a reason for hiding this comment

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

Is this used?

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 only used it locally. I'll remove it.

Copy link
Member

Choose a reason for hiding this comment

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

Are you still planning on removing this?

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 think this is a stale diff - it was removed in 5cdefc6

type_name::<T>()
);
return Some(Err(
"Unable to parse input number as the desired output type",
Copy link
Member

Choose a reason for hiding this comment

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

This is probably not a number, right?

Actually, we might as well include it in the error instead of pulling log along.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is numberlike as per line 83. In particular to this PR is the case when trying to parse "1.23" as an integer, which will fail with this message.

The reason I logged here rather than building a String with the error details to the error is that errors throughout the WKT library are &'static str. I could do something different here, but it'd affect multiple places since this error is propagated.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like a good approach to me fwiw

@michaelkirk
Copy link
Member Author

Rebased since merging #99

@michaelkirk michaelkirk mentioned this pull request Jun 14, 2022
Note that we error when trying to parse any numbers with decimal points
with message:
"Unable to parse input number as the desired output type"

And log a more descriptive message like:
[2022-05-18T19:26:16Z WARN  wkt::tokenizer] Failed to parse input: '1.1' as i32
[2022-05-18T19:26:16Z WARN  wkt::tokenizer] Failed to parse input: '1.9' as i32
@michaelkirk
Copy link
Member Author

bors r=urschrei

@bors
Copy link
Contributor

bors bot commented Jun 16, 2022

Build succeeded:

@bors bors bot merged commit 63a21d8 into main Jun 16, 2022
@bors bors bot deleted the mkirk/try-from-int-fail branch June 16, 2022 02:42
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.

Support deserializing integer geometries
3 participants