-
Notifications
You must be signed in to change notification settings - Fork 31
Add basic read tests of a small pbf file #56
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
base: master
Are you sure you want to change the base?
Conversation
32eae2e to
e0312e0
Compare
TeXitoi
left a comment
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.
Good idea! I’m ok with this small file in the repository.
| let mut num_nodes = 0; | ||
| let mut num_ways = 0; | ||
| let mut num_relations = 0; | ||
| let mut sum_ids = 0; |
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.
Why not doing this sum_id check on the other tests ? If that’s an overflow problem, you can use .wrapping_add(_).
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.
Mostly because I thought of this check at the end, but we could a similar check on the other tests too. I will add it to all tests.
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.
You didn’t do that.
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.
sum_node/way/relation_id are now checked on all functions, thanks to the common Stats struct.
I added the check on sum_ids only here, because get_objs_and_deps() is the only function providing both an OsmId and an OsmObj.
tests/reader.rs
Outdated
|
|
||
| let mut num_nodes = 0; | ||
| let mut num_ways = 0; | ||
| let mut num_relations = 0; |
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 think you can do a struct Stats with these fields (and maybe also sum_ids) and implement FromIterator<OsmObj> for Stats
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.
Good idea, as it would allow to share the expected values between tests.
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.
You didn’t do that.
e0312e0 to
94c063a
Compare
|
I’ve moved all stats to structs, and verified all values with |
TeXitoi
left a comment
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.
The code can be improved, but I don’t want to annoy you with not really criticals remarks. In the other hand, you might be interested in them. So, we can do it in different ways:
- I merge this as is, and improve the code in another commit, that you can read.
- I make a PR on your PR, allowing you to make a "review" of my modification, to understand them and/or challenge them
- I give you insight to do the" idiomatic" thing, and we exchange till the code is beautiful.
What do you prefer?
| decimicro_lon: (-109.2143679 * 1e7) as i32, | ||
| }, | ||
| Node { | ||
| id: NodeId(1724610082), |
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.
All these data are new from the last time. To have easily mergeable PR, it is better to not add features during the review, as they might be remarks on them, that will delay the merge of the already merged parts.
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.
It is on a different commit, so I thought it would be fine. I can remove the second commit if you prefer, and open a second PR afterwards.
|
I'm interested in writing better Rust code, so proposition 3 or 2 would be better for me. But I don't want to take too much of your time. |
|
Is there anything you want me to rewrite in the code? Thanks! |
|
Hi. Sorry, I didn’t had the time to dive into this. I’ll try to advance on this. |
Hi,
I have added a simple pbf test to make it possible to test adding full metadata (will be pushed on a separate branch).
The new pbf file taken is a 43KB file taken from Geofabrik, and which is the smallest file I could find. If you would prefer to not have pbf files in this git repository, I could try to move it to an external git submodule, and even add bigger files there for more testing - but it would make testing a bit harder.
Thanks!