~ubuntu-branches/ubuntu/precise/imposm-parser/precise

« back to all changes in this revision

Viewing changes to osm.proto

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2011-04-24 21:24:57 UTC
  • Revision ID: james.westby@ubuntu.com-20110424212457-92qcgtvkrmycgmbr
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
 
2
 
 
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.
 
7
 
 
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.
 
12
 
 
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/>.
 
15
 
 
16
*/
 
17
 
 
18
option java_package = "crosby.binary";
 
19
package OSMPBF;
 
20
 
 
21
//protoc --java_out=../.. fileformat.proto
 
22
 
 
23
 
 
24
//
 
25
//  STORAGE LAYER: Storing primitives.
 
26
//
 
27
 
 
28
message Blob {
 
29
  optional bytes raw = 1; // No compression
 
30
  optional int32 raw_size = 2; // When compressed, the uncompressed size
 
31
 
 
32
  // Possible compressed versions of the data.
 
33
  optional bytes zlib_data = 3;
 
34
 
 
35
  // PROPOSED feature for LZMA compressed data. SUPPORT IS NOT REQUIRED.
 
36
  optional bytes lzma_data = 4;
 
37
 
 
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.
 
40
}
 
41
 
 
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.
 
45
*/
 
46
 
 
47
message BlobHeader {
 
48
  required string type = 1;
 
49
  optional bytes indexdata = 2;
 
50
  required int32 datasize = 3;
 
51
}
 
52
 
 
53
 
 
54
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
 
55
 
 
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.
 
60
 
 
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.
 
65
 
 
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/>.
 
68
 
 
69
*/
 
70
 
 
71
/* OSM Binary file format 
 
72
 
 
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
 
75
extendability.
 
76
 
 
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.
 
81
 
 
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
 
86
block.
 
87
 
 
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.
 
94
 
 
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.
 
98
 
 
99
*/
 
100
 
 
101
//////////////////////////////////////////////////////////////////////////
 
102
//////////////////////////////////////////////////////////////////////////
 
103
 
 
104
/* Contains the file header. */
 
105
 
 
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;
 
111
 
 
112
  optional string writingprogram = 16; 
 
113
  optional string source = 17; // From the bbox field.
 
114
}
 
115
 
 
116
 
 
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. */
 
120
 
 
121
message HeaderBBox {
 
122
   required sint64 left = 1;
 
123
   required sint64 right = 2;
 
124
   required sint64 top = 3;
 
125
   required sint64 bottom = 4;
 
126
}
 
127
 
 
128
 
 
129
///////////////////////////////////////////////////////////////////////
 
130
///////////////////////////////////////////////////////////////////////
 
131
 
 
132
 
 
133
message PrimitiveBlock {
 
134
  required StringTable stringtable = 1;
 
135
  repeated PrimitiveGroup primitivegroup = 2;
 
136
 
 
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]; 
 
142
 
 
143
// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
 
144
  optional int32 date_granularity = 18 [default=1000]; 
 
145
 
 
146
 
 
147
  // Proposed extension:
 
148
  //optional BBox bbox = XX;
 
149
}
 
150
 
 
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;
 
158
}
 
159
 
 
160
 
 
161
/** String table, contains the common strings in each block.
 
162
 
 
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.
 
165
 
 
166
 */
 
167
message StringTable {
 
168
   repeated bytes s = 1;
 
169
}
 
170
 
 
171
/* Optional metadata that may be included into each primitive. */
 
172
message Info {
 
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
 
178
}
 
179
 
 
180
/** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */
 
181
message DenseInfo {
 
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
 
187
}
 
188
 
 
189
 
 
190
// THIS IS STUB DESIGN FOR CHANGESETS. NOT USED RIGHT NOW.
 
191
// TODO:    REMOVE THIS?
 
192
message ChangeSet {
 
193
   required int64 id = 1;
 
194
//   
 
195
//   // Parallel arrays.
 
196
//   repeated uint32 keys = 2 [packed = true]; // String IDs.
 
197
//   repeated uint32 vals = 3 [packed = true]; // String IDs.
 
198
//
 
199
//   optional Info info = 4;
 
200
 
 
201
//   optional int64 created_at = 8;
 
202
//   optional int64 closetime_delta = 9;
 
203
//   optional bool open = 10;
 
204
//   optional HeaderBBox bbox = 11;
 
205
}
 
206
 
 
207
 
 
208
message Node {
 
209
   required sint64 id = 1;
 
210
   // Parallel arrays.
 
211
   repeated uint32 keys = 2 [packed = true]; // String IDs.
 
212
   repeated uint32 vals = 3 [packed = true]; // String IDs.
 
213
 
 
214
   optional Info info = 4; // May be omitted in omitmeta
 
215
 
 
216
   required sint64 lat = 8;
 
217
   required sint64 lon = 9;
 
218
}
 
219
 
 
220
/* Used to densly represent a sequence of nodes that do not have any tags.
 
221
 
 
222
We represent these nodes columnwise as five columns: ID's, lats, and
 
223
lons, all delta coded. When metadata is not omitted, 
 
224
 
 
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.
 
228
 
 
229
   ( (<keyid> <valid>)* '0' )*
 
230
 */
 
231
 
 
232
message DenseNodes {
 
233
   repeated sint64 id = 1 [packed = true]; // DELTA coded
 
234
 
 
235
   //repeated Info info = 4;
 
236
   optional DenseInfo denseinfo = 5;
 
237
 
 
238
   repeated sint64 lat = 8 [packed = true]; // DELTA coded
 
239
   repeated sint64 lon = 9 [packed = true]; // DELTA coded
 
240
 
 
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]; 
 
243
}
 
244
 
 
245
 
 
246
message Way {
 
247
   required int64 id = 1;
 
248
   // Parallel arrays.
 
249
   repeated uint32 keys = 2 [packed = true];
 
250
   repeated uint32 vals = 3 [packed = true];
 
251
 
 
252
   optional Info info = 4;
 
253
 
 
254
   repeated sint64 refs = 8 [packed = true];  // DELTA coded
 
255
}
 
256
 
 
257
message Relation {
 
258
  enum MemberType {
 
259
    NODE = 0;
 
260
    WAY = 1;
 
261
    RELATION = 2;
 
262
  } 
 
263
   required int64 id = 1;
 
264
 
 
265
   // Parallel arrays.
 
266
   repeated uint32 keys = 2 [packed = true];
 
267
   repeated uint32 vals = 3 [packed = true];
 
268
 
 
269
   optional Info info = 4;
 
270
 
 
271
   // Parallel arrays
 
272
   repeated int32 roles_sid = 8 [packed = true];
 
273
   repeated sint64 memids = 9 [packed = true]; // DELTA encoded
 
274
   repeated MemberType types = 10 [packed = true];
 
275
}
 
276