Skip to content

Conversation

@jocelynj
Copy link

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!

Copy link
Owner

@TeXitoi TeXitoi left a 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;
Copy link
Owner

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(_).

Copy link
Author

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.

Copy link
Owner

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.

Copy link
Author

@jocelynj jocelynj May 2, 2025

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;
Copy link
Owner

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

Copy link
Author

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.

Copy link
Owner

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.

@jocelynj
Copy link
Author

I’ve moved all stats to structs, and verified all values with osmium fileinfo -e and osmium show <pbf> | grep "node.*visible" | cut -d" " -f2 | awk '{s+=$1} END {print s}'.

Copy link
Owner

@TeXitoi TeXitoi left a 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),
Copy link
Owner

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.

Copy link
Author

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.

@jocelynj
Copy link
Author

jocelynj commented May 2, 2025

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.

@jocelynj jocelynj force-pushed the add-simple-test branch from 1d6092c to 139c69c Compare May 2, 2025 18:20
@jocelynj
Copy link
Author

Is there anything you want me to rewrite in the code?

Thanks!

@TeXitoi
Copy link
Owner

TeXitoi commented May 27, 2025

Hi. Sorry, I didn’t had the time to dive into this. I’ll try to advance on this.

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