Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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