From 92b3bcb1853a4181f94c9bfc79118026790840b5 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 2 Jan 2021 20:44:08 +0100 Subject: [PATCH] Clean up and reformat proto files --- src/fileformat.proto | 22 +++-- src/osmformat.proto | 197 ++++++++++++++++++++++--------------------- 2 files changed, 116 insertions(+), 103 deletions(-) diff --git a/src/fileformat.proto b/src/fileformat.proto index 696b483..632215a 100644 --- a/src/fileformat.proto +++ b/src/fileformat.proto @@ -1,10 +1,22 @@ /** Copyright (c) 2010 Scott A. Crosby. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. */ @@ -30,13 +42,13 @@ message Blob { // PROPOSED feature for LZMA compressed data. SUPPORT IS NOT REQUIRED. optional bytes lzma_data = 4; - // Formerly used for bzip2 compressed data. Depreciated in 2010. + // Formerly used for bzip2 compressed data. Deprecated in 2010. optional bytes OBSOLETE_bzip2_data = 5 [deprecated=true]; // Don't reuse this tag number. } /* A file contains an sequence of fileblock headers, each prefixed by their length in network byte order, followed by a data block -containing the actual data. types staring with a "_" are reserved. +containing the actual data. Types starting with a "_" are reserved. */ message BlobHeader { diff --git a/src/osmformat.proto b/src/osmformat.proto index a5d3b27..b456152 100644 --- a/src/osmformat.proto +++ b/src/osmformat.proto @@ -1,10 +1,22 @@ /** Copyright (c) 2010 Scott A. Crosby. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. */ @@ -13,7 +25,7 @@ syntax = "proto2"; option java_package = "crosby.binary"; package OSMPBF; -/* OSM Binary file format +/* OSM Binary file format This is the master schema file of the OSM binary file format. This file is designed to support limited random-access and future @@ -37,7 +49,7 @@ are measured in units nanodegrees. The default of granularity of 100 nanodegrees corresponds to about 1cm on the ground, and a full lat or lon fits into 32 bits. -Converting an integer to a lattitude or longitude uses the formula: +Converting an integer to a latitude or longitude uses the formula: $OUT = IN * granularity / 10**9$. Many encoding schemes use delta coding when representing nodes and relations. @@ -50,24 +62,25 @@ coding when representing nodes and relations. message HeaderBlock { optional HeaderBBox bbox = 1; + /* Additional tags to aid in parsing this dataset */ repeated string required_features = 4; repeated string optional_features = 5; - optional string writingprogram = 16; + optional string writingprogram = 16; optional string source = 17; // From the bbox field. /* Tags that allow continuing an Osmosis replication */ - // replication timestamp, expressed in seconds since the epoch, + // Replication timestamp, expressed in seconds since the epoch, // otherwise the same value as in the "timestamp=..." field - // in the state.txt file used by Osmosis + // in the state.txt file used by Osmosis. optional int64 osmosis_replication_timestamp = 32; - // replication sequence number (sequenceNumber in state.txt) + // Replication sequence number (sequenceNumber in state.txt). optional int64 osmosis_replication_sequence_number = 33; - // replication base URL (from Osmosis' configuration.txt file) + // Replication base URL (from Osmosis' configuration.txt file). optional string osmosis_replication_base_url = 34; } @@ -77,10 +90,10 @@ header. Units are always in nanodegrees -- they do not obey granularity rules. */ message HeaderBBox { - required sint64 left = 1; - required sint64 right = 2; - required sint64 top = 3; - required sint64 bottom = 4; + required sint64 left = 1; + required sint64 right = 2; + required sint64 top = 3; + required sint64 bottom = 4; } @@ -92,25 +105,22 @@ message PrimitiveBlock { required StringTable stringtable = 1; repeated PrimitiveGroup primitivegroup = 2; - // Granularity, units of nanodegrees, used to store coordinates in this block - optional int32 granularity = 17 [default=100]; - // Offset value between the output coordinates coordinates and the granularity grid in unites of nanodegrees. + // Granularity, units of nanodegrees, used to store coordinates in this block. + optional int32 granularity = 17 [default=100]; + + // Offset value between the output coordinates and the granularity grid in units of nanodegrees. optional int64 lat_offset = 19 [default=0]; - optional int64 lon_offset = 20 [default=0]; + optional int64 lon_offset = 20 [default=0]; -// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch. - optional int32 date_granularity = 18 [default=1000]; - - - // Proposed extension: - //optional BBox bbox = XX; + // Granularity of dates, normally represented in units of milliseconds since the 1970 epoch. + optional int32 date_granularity = 18 [default=1000]; } // Group of OSMPrimitives. All primitives in a group must be the same type. message PrimitiveGroup { - repeated Node nodes = 1; + repeated Node nodes = 1; optional DenseNodes dense = 2; - repeated Way ways = 3; + repeated Way ways = 3; repeated Relation relations = 4; repeated ChangeSet changesets = 5; } @@ -123,82 +133,72 @@ message PrimitiveGroup { */ message StringTable { - repeated bytes s = 1; + repeated bytes s = 1; } /* Optional metadata that may be included into each primitive. */ message Info { - optional int32 version = 1 [default = -1]; - optional int64 timestamp = 2; - optional int64 changeset = 3; - optional int32 uid = 4; - optional uint32 user_sid = 5; // String IDs + optional int32 version = 1 [default = -1]; + optional int64 timestamp = 2; + optional int64 changeset = 3; + optional int32 uid = 4; + optional uint32 user_sid = 5; // String IDs - // The visible flag is used to store history information. It indicates that - // the current object version has been created by a delete operation on the - // OSM API. - // When a writer sets this flag, it MUST add a required_features tag with - // value "HistoricalInformation" to the HeaderBlock. - // If this flag is not available for some object it MUST be assumed to be - // true if the file has the required_features tag "HistoricalInformation" - // set. - optional bool visible = 6; + // The visible flag is used to store history information. It indicates that + // the current object version has been created by a delete operation on the + // OSM API. + // When a writer sets this flag, it MUST add a required_features tag with + // value "HistoricalInformation" to the HeaderBlock. + // If this flag is not available for some object it MUST be assumed to be + // true if the file has the required_features tag "HistoricalInformation" + // set. + optional bool visible = 6; } /** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */ message DenseInfo { - repeated int32 version = 1 [packed = true]; - repeated sint64 timestamp = 2 [packed = true]; // DELTA coded - repeated sint64 changeset = 3 [packed = true]; // DELTA coded - repeated sint32 uid = 4 [packed = true]; // DELTA coded - repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded + repeated int32 version = 1 [packed = true]; + repeated sint64 timestamp = 2 [packed = true]; // DELTA coded + repeated sint64 changeset = 3 [packed = true]; // DELTA coded + repeated sint32 uid = 4 [packed = true]; // DELTA coded + repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded - // The visible flag is used to store history information. It indicates that - // the current object version has been created by a delete operation on the - // OSM API. - // When a writer sets this flag, it MUST add a required_features tag with - // value "HistoricalInformation" to the HeaderBlock. - // If this flag is not available for some object it MUST be assumed to be - // true if the file has the required_features tag "HistoricalInformation" - // set. - repeated bool visible = 6 [packed = true]; + // The visible flag is used to store history information. It indicates that + // the current object version has been created by a delete operation on the + // OSM API. + // When a writer sets this flag, it MUST add a required_features tag with + // value "HistoricalInformation" to the HeaderBlock. + // If this flag is not available for some object it MUST be assumed to be + // true if the file has the required_features tag "HistoricalInformation" + // set. + repeated bool visible = 6 [packed = true]; } // THIS IS STUB DESIGN FOR CHANGESETS. NOT USED RIGHT NOW. // TODO: REMOVE THIS? message ChangeSet { - required int64 id = 1; -// -// // Parallel arrays. -// repeated uint32 keys = 2 [packed = true]; // String IDs. -// repeated uint32 vals = 3 [packed = true]; // String IDs. -// -// optional Info info = 4; - -// optional int64 created_at = 8; -// optional int64 closetime_delta = 9; -// optional bool open = 10; -// optional HeaderBBox bbox = 11; + required int64 id = 1; } message Node { - required sint64 id = 1; - // Parallel arrays. - repeated uint32 keys = 2 [packed = true]; // String IDs. - repeated uint32 vals = 3 [packed = true]; // String IDs. + required sint64 id = 1; - optional Info info = 4; // May be omitted in omitmeta + // Parallel arrays. + repeated uint32 keys = 2 [packed = true]; // String IDs. + repeated uint32 vals = 3 [packed = true]; // String IDs. - required sint64 lat = 8; - required sint64 lon = 9; + optional Info info = 4; // May be omitted in omitmeta + + required sint64 lat = 8; + required sint64 lon = 9; } /* Used to densly represent a sequence of nodes that do not have any tags. We represent these nodes columnwise as five columns: ID's, lats, and -lons, all delta coded. When metadata is not omitted, +lons, all delta coded. When metadata is not omitted, We encode keys & vals for all nodes as a single array of integers containing key-stringid and val-stringid, using a stringid of 0 as a @@ -208,28 +208,28 @@ delimiter between nodes. */ message DenseNodes { - repeated sint64 id = 1 [packed = true]; // DELTA coded + repeated sint64 id = 1 [packed = true]; // DELTA coded - //repeated Info info = 4; - optional DenseInfo denseinfo = 5; + optional DenseInfo denseinfo = 5; - repeated sint64 lat = 8 [packed = true]; // DELTA coded - repeated sint64 lon = 9 [packed = true]; // DELTA coded + repeated sint64 lat = 8 [packed = true]; // DELTA coded + repeated sint64 lon = 9 [packed = true]; // DELTA coded - // Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless. - repeated int32 keys_vals = 10 [packed = true]; + // Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless. + repeated int32 keys_vals = 10 [packed = true]; } message Way { - required int64 id = 1; - // Parallel arrays. - repeated uint32 keys = 2 [packed = true]; - repeated uint32 vals = 3 [packed = true]; + required int64 id = 1; - optional Info info = 4; + // Parallel arrays. + repeated uint32 keys = 2 [packed = true]; + repeated uint32 vals = 3 [packed = true]; - repeated sint64 refs = 8 [packed = true]; // DELTA coded + optional Info info = 4; + + repeated sint64 refs = 8 [packed = true]; // DELTA coded } message Relation { @@ -237,18 +237,19 @@ message Relation { NODE = 0; WAY = 1; RELATION = 2; - } - required int64 id = 1; + } - // Parallel arrays. - repeated uint32 keys = 2 [packed = true]; - repeated uint32 vals = 3 [packed = true]; + required int64 id = 1; - optional Info info = 4; + // Parallel arrays. + repeated uint32 keys = 2 [packed = true]; + repeated uint32 vals = 3 [packed = true]; - // Parallel arrays - repeated int32 roles_sid = 8 [packed = true]; // This should have been defined as uint32 for consistency, but it is now too late to change it - repeated sint64 memids = 9 [packed = true]; // DELTA encoded - repeated MemberType types = 10 [packed = true]; + optional Info info = 4; + + // Parallel arrays + repeated int32 roles_sid = 8 [packed = true]; // This should have been defined as uint32 for consistency, but it is now too late to change it + repeated sint64 memids = 9 [packed = true]; // DELTA encoded + repeated MemberType types = 10 [packed = true]; }