Protobuf-net 反序列化开放街道地图
对于我的一生,我无法反序列化 开放街道地图 中的 protobuf 文件。
我正在尝试反序列化以下摘录: http://download. geofabrik.de/osm/north-america/us-northeast.osm.pbf 来获取节点,我正在使用 http://code.google.com/p/protobuf-net/ 作为库。我尝试反序列化一堆不同的对象,但它们都为空。
原型文件可以在这里找到: http://trac.openstreetmap.org /browser/applications/utils/export/osm2pgsql/protobuf
有什么建议吗?
For the life of me I cannot deserialize the protobuf file from Open Street Maps.
I am trying to deserialize the following extract: http://download.geofabrik.de/osm/north-america/us-northeast.osm.pbf to get Nodes and I am using http://code.google.com/p/protobuf-net/ as the library. I have tried to deserialize a bunch of different objects but they all come up null.
The proto files can be found here: http://trac.openstreetmap.org/browser/applications/utils/export/osm2pgsql/protobuf
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正确的;问题是,这不仅仅是 protobuf - 它是一种混合文件格式(在这里定义包括内部各种格式的protobuf。它还包含压缩(尽管这看起来是可选的),
并且我已经从规范中分离出来了。这里有一个 C# 阅读器,它使用 protobuf-net 来处理块 - 它很高兴地读取该文件到最后 - 我可以告诉你有 4515 个块(当它到达
BlockHeader
时)。 code>Blob 我对规范如何区分OSMHeader
和OSMData
有点困惑 - 我愿意接受我也使用过的建议! ZLIB.NET 来处理正在使用的 zlib 压缩。由于没有解决这个问题,我决定处理 ZLIB 数据并根据声明的大小验证它,以检查它至少是否正常。如果您能弄清楚(或询问作者)他们如何分离
OSMHeader
和OSMData
我会很高兴地添加其他内容。我希望您不介意我已经停在这里了 - 但已经几个小时了;pRight; the problem is that this isn't just protobuf - it is a hybrid file format (defined here that includes protobuf among various formats internally. It also incorporates compression (although that looks to be optional).
I've pulled apart what I can from the spec, and I've got a C# reader here that uses protobuf-net to handle the chunks - it happily reads through that file to the end - I can tell you there are 4515 blocks (
BlockHeader
). When it gets to theBlob
I'm a bit confused as to how the spec demarksOSMHeader
andOSMData
- I'm open to suggestions here! I've also used ZLIB.NET to handle the zlib compression that is being used. In the absence of getting my head around this, I've settled for processing the ZLIB data and validating it against the claimed size, to check it is at least sane.If you can figure out (or ask the author) how they are separating
OSMHeader
andOSMData
I'll happily crank something else in. I hope you don't mind that I've stopped here - but it has been a few hours ;p在马克设置大纲后,我通过查看 http://git.openstreetmap.nl/index.cgi/pbf2osm.git/tree/src/main.c?h=35116112eb0066c7729a963b292faa608ddc8ad7
这是最终代码。
After the outline setup by Mark I figured out the last part by looking at http://git.openstreetmap.nl/index.cgi/pbf2osm.git/tree/src/main.c?h=35116112eb0066c7729a963b292faa608ddc8ad7
Here is the final code.
是的,它来自 Fileformat.cs 中的 protogen(基于 OSM Fileformat.proto 文件..下面的代码。)
这是生成文件中的 BlockHeader 声明:
->使用 pb = global::Google.ProtocolBuffers;
(ProtocolBuffers.dll) 附带此包:
http://code.google.com/p/protobuf-csharp-port/downloads/detail?name=protobuf-csharp-port-2.4。 1.473-full-binaries.zip&can=2&q=
Yes, it came from protogen in Fileformat.cs (based on OSM Fileformat.proto file.. code below.)
Here is the declaration of BlockHeader in generated file :
-> using pb = global::Google.ProtocolBuffers;
(ProtocolBuffers.dll) came with this package :
http://code.google.com/p/protobuf-csharp-port/downloads/detail?name=protobuf-csharp-port-2.4.1.473-full-binaries.zip&can=2&q=
您是否尝试过获得更小的区域?例如 us-pacific.osm.pbf
最终发布错误消息会很有用。
Have you tried to get some smaller area? such as us-pacific.osm.pbf
Eventually it would be useful to post the error-messages.