1
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
3
This program is free software: you can redistribute it and/or modify
4
it under the terms of the GNU Lesser General Public License as
5
published by the Free Software Foundation, either version 3 of the
6
License, or (at your option) any later version.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
option java_package = "crosby.binary";
21
//protoc --java_out=../.. fileformat.proto
25
// STORAGE LAYER: Storing primitives.
29
optional bytes raw = 1; // No compression
30
optional int32 raw_size = 2; // When compressed, the uncompressed size
32
// Possible compressed versions of the data.
33
optional bytes zlib_data = 3;
35
// PROPOSED feature for LZMA compressed data. SUPPORT IS NOT REQUIRED.
36
optional bytes lzma_data = 4;
38
// Formerly used for bzip2 compressed data. Depreciated in 2010.
39
optional bytes OBSOLETE_bzip2_data = 5 [deprecated=true]; // Don't reuse this tag number.
42
/* A file contains an sequence of fileblock headers, each prefixed by
43
their length in network byte order, followed by a data block
44
containing the actual data. types staring with a "_" are reserved.
48
required string type = 1;
49
optional bytes indexdata = 2;
50
required int32 datasize = 3;
54
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
56
This program is free software: you can redistribute it and/or modify
57
it under the terms of the GNU Lesser General Public License as
58
published by the Free Software Foundation, either version 3 of the
59
License, or (at your option) any later version.
61
This program is distributed in the hope that it will be useful,
62
but WITHOUT ANY WARRANTY; without even the implied warranty of
63
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64
GNU General Public License for more details.
66
You should have received a copy of the GNU General Public License
67
along with this program. If not, see <http://www.gnu.org/licenses/>.
71
/* OSM Binary file format
73
This is the master schema file of the OSM binary file format. This
74
file is designed to support limited random-access and future
77
A binary OSM file consists of a sequence of FileBlocks (please see
78
fileformat.proto). The first fileblock contains a serialized instance
79
of HeaderBlock, followed by a sequence of PrimitiveBlock blocks that
80
contain the primitives.
82
Each primitiveblock is designed to be independently parsable. It
83
contains a string table storing all strings in that block (keys and
84
values in tags, roles in relations, usernames, etc.) as well as
85
metadata containing the precision of coordinates or timestamps in that
88
A primitiveblock contains a sequence of primitive groups, each
89
containing primitives of the same type (nodes, densenodes, ways,
90
relations). Coordinates are stored in signed 64-bit integers. Lat&lon
91
are measured in units <granularity> nanodegrees. The default of
92
granularity of 100 nanodegrees corresponds to about 1cm on the ground,
93
and a full lat or lon fits into 32 bits.
95
Converting an integer to a lattitude or longitude uses the formula:
96
$OUT = IN * granularity / 10**9$. Many encoding schemes use delta
97
coding when representing nodes and relations.
101
//////////////////////////////////////////////////////////////////////////
102
//////////////////////////////////////////////////////////////////////////
104
/* Contains the file header. */
106
message HeaderBlock {
107
optional HeaderBBox bbox = 1;
108
/* Additional tags to aid in parsing this dataset */
109
repeated string required_features = 4;
110
repeated string optional_features = 5;
112
optional string writingprogram = 16;
113
optional string source = 17; // From the bbox field.
117
/** The bounding box field in the OSM header. BBOX, as used in the OSM
118
header. Units are always in nanodegrees -- they do not obey
119
granularity rules. */
122
required sint64 left = 1;
123
required sint64 right = 2;
124
required sint64 top = 3;
125
required sint64 bottom = 4;
129
///////////////////////////////////////////////////////////////////////
130
///////////////////////////////////////////////////////////////////////
133
message PrimitiveBlock {
134
required StringTable stringtable = 1;
135
repeated PrimitiveGroup primitivegroup = 2;
137
// Granularity, units of nanodegrees, used to store coordinates in this block
138
optional int32 granularity = 17 [default=100];
139
// Offset value between the output coordinates coordinates and the granularity grid in unites of nanodegrees.
140
optional int64 lat_offset = 19 [default=0];
141
optional int64 lon_offset = 20 [default=0];
143
// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
144
optional int32 date_granularity = 18 [default=1000];
147
// Proposed extension:
148
//optional BBox bbox = XX;
151
// Group of OSMPrimitives. All primitives in a group must be the same type.
152
message PrimitiveGroup {
153
repeated Node nodes = 1;
154
optional DenseNodes dense = 2;
155
repeated Way ways = 3;
156
repeated Relation relations = 4;
157
repeated ChangeSet changesets = 5;
161
/** String table, contains the common strings in each block.
163
Note that we reserve index '0' as a delimiter, so the entry at that
164
index in the table is ALWAYS blank and unused.
167
message StringTable {
168
repeated bytes s = 1;
171
/* Optional metadata that may be included into each primitive. */
173
optional int32 version = 1 [default = -1];
174
optional int64 timestamp = 2;
175
optional int64 changeset = 3;
176
optional int32 uid = 4;
177
optional uint32 user_sid = 5; // String IDs
180
/** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */
182
repeated int32 version = 1 [packed = true];
183
repeated sint64 timestamp = 2 [packed = true]; // DELTA coded
184
repeated sint64 changeset = 3 [packed = true]; // DELTA coded
185
repeated sint32 uid = 4 [packed = true]; // DELTA coded
186
repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded
190
// THIS IS STUB DESIGN FOR CHANGESETS. NOT USED RIGHT NOW.
191
// TODO: REMOVE THIS?
193
required int64 id = 1;
195
// // Parallel arrays.
196
// repeated uint32 keys = 2 [packed = true]; // String IDs.
197
// repeated uint32 vals = 3 [packed = true]; // String IDs.
199
// optional Info info = 4;
201
// optional int64 created_at = 8;
202
// optional int64 closetime_delta = 9;
203
// optional bool open = 10;
204
// optional HeaderBBox bbox = 11;
209
required sint64 id = 1;
211
repeated uint32 keys = 2 [packed = true]; // String IDs.
212
repeated uint32 vals = 3 [packed = true]; // String IDs.
214
optional Info info = 4; // May be omitted in omitmeta
216
required sint64 lat = 8;
217
required sint64 lon = 9;
220
/* Used to densly represent a sequence of nodes that do not have any tags.
222
We represent these nodes columnwise as five columns: ID's, lats, and
223
lons, all delta coded. When metadata is not omitted,
225
We encode keys & vals for all nodes as a single array of integers
226
containing key-stringid and val-stringid, using a stringid of 0 as a
227
delimiter between nodes.
229
( (<keyid> <valid>)* '0' )*
233
repeated sint64 id = 1 [packed = true]; // DELTA coded
235
//repeated Info info = 4;
236
optional DenseInfo denseinfo = 5;
238
repeated sint64 lat = 8 [packed = true]; // DELTA coded
239
repeated sint64 lon = 9 [packed = true]; // DELTA coded
241
// Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless.
242
repeated int32 keys_vals = 10 [packed = true];
247
required int64 id = 1;
249
repeated uint32 keys = 2 [packed = true];
250
repeated uint32 vals = 3 [packed = true];
252
optional Info info = 4;
254
repeated sint64 refs = 8 [packed = true]; // DELTA coded
263
required int64 id = 1;
266
repeated uint32 keys = 2 [packed = true];
267
repeated uint32 vals = 3 [packed = true];
269
optional Info info = 4;
272
repeated int32 roles_sid = 8 [packed = true];
273
repeated sint64 memids = 9 [packed = true]; // DELTA encoded
274
repeated MemberType types = 10 [packed = true];