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

Parse only for specific element types #34

Open
KonradBreitsprecher opened this issue Nov 19, 2019 · 2 comments
Open

Parse only for specific element types #34

KonradBreitsprecher opened this issue Nov 19, 2019 · 2 comments

Comments

@KonradBreitsprecher
Copy link

Thanks for this nice package!
I'm using it for a routing application that is only interested in the nodes that appear in ways. To filter this and not run into memory problems, my approaching was to scan a file twice; first for the ways, then again only for the relevant nodes. Is there an easy workaround to skip the way/node/relation blocks entirely?

@jongillham
Copy link
Member

Hi @KonradBreitsprecher unfortunately you need to parse the PBF file from beginning to end and just ignore the blocks you don't want. I wonder if it's possible just to do one parse of the file and store the information you need as you go in order to be referenced later in the PBF file?

@KonradBreitsprecher
Copy link
Author

Ok I ended up skipping the blocks in parsePrimitiveGroup(). If I keep track of all the IDs that appear in ways and skip those nodes in the second run (with a lookup map[int64]struct{}), I'm already a little bit faster than collecting all the nodes. At least for the germany pbf.
I was also wondering if I could reuse the decoder and jump back to the beginning of the file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants