github.com/omniscale/go-osm@v0.3.1/parser/pbf/internal/osmpbf/osmformat.proto (about)

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