Skip to content

Conversation

angelcervera
Copy link
Member

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.3%) to 90.435% when pulling 6d79635 on feature/#37_spark_splitting into 3d80468 on master.

@angelcervera angelcervera merged commit 45965da into master Oct 18, 2020
@angelcervera angelcervera deleted the feature/#37_spark_splitting branch October 18, 2020 14:05
import scala.annotation.tailrec

object OSMDataFinder {
val pattern = Array[Byte](0x0A, 0x07, 0x4F, 0x53, 0x4D, 0x44, 0x61, 0x74, 0x61)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we pick these bytes here? Seems like magic number and not that safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the static value for block headers that are used in osm.pbf
This is the protobuf definition:

 message BlobHeader {
   required string type = 1;
   optional bytes indexdata = 2;
   required int32 datasize = 3;
 }

And type, for osm data blocks, is always OSMData as protobuf string representation. It is part of the format spec.

https://wiki.openstreetmap.org/wiki/PBF_Format#File_format
https://wiki.openstreetmap.org/wiki/PBF_Format#Encoding_OSM_entities_into_fileblocks
https://wiki.openstreetmap.org/wiki/PBF_Format#Format_example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The reference is here, right?

00000090  __ 0a - S 1 'type'
00000090  __ __ 07 - length 7 bytes
00000090  __ __ __ 4f 53 4d 44 61  74 61 "OSMData"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. What I did, to double check, was to open a file with a hexadecimal editor. Only to confirm.

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.

3 participants