1 |
option java_package = "crosby.binary";
|
2 |
package OSMPBF;
|
3 |
|
4 |
/* OSM Binary file format
|
5 |
|
6 |
This is the master schema file of the OSM binary file format. This
|
7 |
file is designed to support limited random-access and future
|
8 |
extendability.
|
9 |
|
10 |
A binary OSM file consists of a sequence of FileBlocks (please see
|
11 |
fileformat.proto). The first fileblock contains a serialized instance
|
12 |
of HeaderBlock, followed by a sequence of PrimitiveBlock blocks that
|
13 |
contain the primitives.
|
14 |
|
15 |
Each primitiveblock is designed to be independently parsable. It
|
16 |
contains a string table storing all strings in that block (keys and
|
17 |
values in tags, roles in relations, usernames, etc.) as well as
|
18 |
metadata containing the precision of coordinates or timestamps in that
|
19 |
block.
|
20 |
|
21 |
A primitiveblock contains a sequence of primitive groups, each
|
22 |
containing primitives of the same type (nodes, densenodes, ways,
|
23 |
relations). Coordinates are stored in signed 64-bit integers. Lat&lon
|
24 |
are measured in units <granularity> nanodegrees. The default of
|
25 |
granularity of 100 nanodegrees corresponds to about 1cm on the ground,
|
26 |
and a full lat or lon fits into 32 bits.
|
27 |
|
28 |
Converting an integer to a lattitude or longitude uses the formula:
|
29 |
$OUT = IN * granularity / 10**9$. Many encoding schemes use delta
|
30 |
coding when representing nodes and relations.
|
31 |
|
32 |
*/
|
33 |
|
34 |
//////////////////////////////////////////////////////////////////////////
|
35 |
//////////////////////////////////////////////////////////////////////////
|
36 |
|
37 |
/* Contains the file header. */
|
38 |
|
39 |
message HeaderBlock {
|
40 |
optional HeaderBBox bbox = 1;
|
41 |
/* Additional tags to aid in parsing this dataset */
|
42 |
repeated string required_features = 4;
|
43 |
repeated string optional_features = 5;
|
44 |
|
45 |
optional string writingprogram = 16;
|
46 |
optional string source = 17; // From the bbox field.
|
47 |
}
|
48 |
|
49 |
|
50 |
/** The bounding box field in the OSM header. BBOX, as used in the OSM
|
51 |
header. Units are always in nanodegrees -- they do not obey
|
52 |
granularity rules. */
|
53 |
|
54 |
message HeaderBBox {
|
55 |
required sint64 left = 1;
|
56 |
required sint64 right = 2;
|
57 |
required sint64 top = 3;
|
58 |
required sint64 bottom = 4;
|
59 |
}
|
60 |
|
61 |
|
62 |
///////////////////////////////////////////////////////////////////////
|
63 |
///////////////////////////////////////////////////////////////////////
|
64 |
|
65 |
|
66 |
message PrimitiveBlock {
|
67 |
required StringTable stringtable = 1;
|
68 |
repeated PrimitiveGroup primitivegroup = 2;
|
69 |
|
70 |
// Granularity, units of nanodegrees, used to store coordinates in this block
|
71 |
optional int32 granularity = 17 [default=100];
|
72 |
// Offset value between the output coordinates coordinates and the granularity grid in unites of nanodegrees.
|
73 |
optional int64 lat_offset = 19 [default=0];
|
74 |
optional int64 lon_offset = 20 [default=0];
|
75 |
|
76 |
// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
|
77 |
optional int32 date_granularity = 18 [default=1000];
|
78 |
|
79 |
|
80 |
// Proposed extension:
|
81 |
//optional BBox bbox = XX;
|
82 |
}
|
83 |
|
84 |
// Group of OSMPrimitives. All primitives in a group must be the same type.
|
85 |
message PrimitiveGroup {
|
86 |
repeated Node nodes = 1;
|
87 |
optional DenseNodes dense = 2;
|
88 |
repeated Way ways = 3;
|
89 |
repeated Relation relations = 4;
|
90 |
repeated ChangeSet changesets = 5;
|
91 |
}
|
92 |
|
93 |
|
94 |
/** String table, contains the common strings in each block.
|
95 |
|
96 |
Note that we reserve index '0' as a delimiter, so the entry at that
|
97 |
index in the table is ALWAYS blank and unused.
|
98 |
|
99 |
*/
|
100 |
message StringTable {
|
101 |
repeated bytes s = 1;
|
102 |
}
|
103 |
|
104 |
/* Optional metadata that may be included into each primitive. */
|
105 |
message Info {
|
106 |
optional int32 version = 1 [default = -1];
|
107 |
optional int64 timestamp = 2;
|
108 |
optional int64 changeset = 3;
|
109 |
optional int32 uid = 4;
|
110 |
optional uint32 user_sid = 5; // String IDs
|
111 |
}
|
112 |
|
113 |
/** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */
|
114 |
message DenseInfo {
|
115 |
repeated int32 version = 1 [packed = true];
|
116 |
repeated sint64 timestamp = 2 [packed = true]; // DELTA coded
|
117 |
repeated sint64 changeset = 3 [packed = true]; // DELTA coded
|
118 |
repeated sint32 uid = 4 [packed = true]; // DELTA coded
|
119 |
repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded
|
120 |
}
|
121 |
|
122 |
|
123 |
// THIS IS STUB DESIGN FOR CHANGESETS. NOT USED RIGHT NOW.
|
124 |
// TODO: REMOVE THIS?
|
125 |
message ChangeSet {
|
126 |
required int64 id = 1;
|
127 |
//
|
128 |
// // Parallel arrays.
|
129 |
// repeated uint32 keys = 2 [packed = true]; // String IDs.
|
130 |
// repeated uint32 vals = 3 [packed = true]; // String IDs.
|
131 |
//
|
132 |
// optional Info info = 4;
|
133 |
|
134 |
// optional int64 created_at = 8;
|
135 |
// optional int64 closetime_delta = 9;
|
136 |
// optional bool open = 10;
|
137 |
// optional HeaderBBox bbox = 11;
|
138 |
}
|
139 |
|
140 |
|
141 |
message Node {
|
142 |
required sint64 id = 1;
|
143 |
// Parallel arrays.
|
144 |
repeated uint32 keys = 2 [packed = true]; // String IDs.
|
145 |
repeated uint32 vals = 3 [packed = true]; // String IDs.
|
146 |
|
147 |
optional Info info = 4; // May be omitted in omitmeta
|
148 |
|
149 |
required sint64 lat = 8;
|
150 |
required sint64 lon = 9;
|
151 |
}
|
152 |
|
153 |
/* Used to densly represent a sequence of nodes that do not have any tags.
|
154 |
|
155 |
We represent these nodes columnwise as five columns: ID's, lats, and
|
156 |
lons, all delta coded. When metadata is not omitted,
|
157 |
|
158 |
We encode keys & vals for all nodes as a single array of integers
|
159 |
containing key-stringid and val-stringid, using a stringid of 0 as a
|
160 |
delimiter between nodes.
|
161 |
|
162 |
( (<keyid> <valid>)* '0' )*
|
163 |
*/
|
164 |
|
165 |
message DenseNodes {
|
166 |
repeated sint64 id = 1 [packed = true]; // DELTA coded
|
167 |
|
168 |
//repeated Info info = 4;
|
169 |
optional DenseInfo denseinfo = 5;
|
170 |
|
171 |
repeated sint64 lat = 8 [packed = true]; // DELTA coded
|
172 |
repeated sint64 lon = 9 [packed = true]; // DELTA coded
|
173 |
|
174 |
// Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless.
|
175 |
repeated int32 keys_vals = 10 [packed = true];
|
176 |
}
|
177 |
|
178 |
|
179 |
message Way {
|
180 |
required int64 id = 1;
|
181 |
// Parallel arrays.
|
182 |
repeated uint32 keys = 2 [packed = true];
|
183 |
repeated uint32 vals = 3 [packed = true];
|
184 |
|
185 |
optional Info info = 4;
|
186 |
|
187 |
repeated sint64 refs = 8 [packed = true]; // DELTA coded
|
188 |
}
|
189 |
|
190 |
message Relation {
|
191 |
enum MemberType {
|
192 |
NODE = 0;
|
193 |
WAY = 1;
|
194 |
RELATION = 2;
|
195 |
}
|
196 |
required int64 id = 1;
|
197 |
|
198 |
// Parallel arrays.
|
199 |
repeated uint32 keys = 2 [packed = true];
|
200 |
repeated uint32 vals = 3 [packed = true];
|
201 |
|
202 |
optional Info info = 4;
|
203 |
|
204 |
// Parallel arrays
|
205 |
repeated int32 roles_sid = 8 [packed = true];
|
206 |
repeated sint64 memids = 9 [packed = true]; // DELTA encoded
|
207 |
repeated MemberType types = 10 [packed = true];
|
208 |
}
|
209 |
|