-
Notifications
You must be signed in to change notification settings - Fork 53
Add OSM PBF encoder #52
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
Add osm pbf encoder
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.
Hello, thank you for providing this fork. I've used it successfully in one of my internal projects, though not without some (easily fixed) issues. I've pointed them out in this review, didn't have time to submit a proper pull request, though I'm considering making my own fork eventually to alleviate a few other pet peeves I have with this library in general.
|
||
blockData, err := proto.Marshal(block) | ||
if err != nil { | ||
return nil |
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.
Looks like a typo, should return err
instead of nil
. This came up in my attempt to use this fork, concealing the issue above that quietly omitted all Node
s from the output file.
} | ||
} | ||
groupDense.Denseinfo.Uid = append(groupDense.Denseinfo.Uid, int32(current.UserID-previous.UserID)) | ||
groupDense.Denseinfo.Version = append(groupDense.Denseinfo.Version, int32(current.Version-previous.Version)) |
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.
Versions aren't delta-encoded in the spec, this causes issues with the current decoder. Should just append current.Version
.
for k := range e.reverseStringTable { | ||
delete(e.reverseStringTable, k) | ||
} | ||
|
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 ran into a few issues with Node
s that had empty stringtables, adding this snippet right here before proto.Marshal
seemingly solved it for me. I'm assuming it has something to do with missing idx-0
delimiters, but I didn't have time to properly study the spec and figure out if that's the case.
if block.Stringtable == nil {
block.Stringtable = &osmpbf.ForkStringTable{}
}
if block.Stringtable.S == nil {
block.Stringtable.S = []string{""}
}
Description
This PR adds a PBF Encoder. It is inspired by
OsmSharp
's encoder. Most likely this code can be simplified and made morego
idiomatic.The
Encoder
has a methodEncode(obj osm.Object) error
which can be used to encode structs of typeosm.Object
.Resolves #48