Skip to content

Commit

Permalink
Fixed bug that sometimes scrambled the string table when writing out …
Browse files Browse the repository at this point in the history
…PBF files
  • Loading branch information
joto committed Apr 23, 2012
1 parent 1b8cd44 commit e84e8f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/osmium/output/pbf.hpp
Expand Up @@ -527,6 +527,11 @@ namespace Osmium {
std::cerr << "storing primitive block with " << primitive_block_contents << " items" << std::endl;
}

// add empty StringTable entry at index 0
// StringTable index 0 is reserved as delimiter in the densenodes key/value list
// this line also ensures that there's always a valid StringTable
pbf_primitive_block.mutable_stringtable()->add_s("");

// store the interim StringTable into the protobuf object
string_table.store_stringtable(pbf_primitive_block.mutable_stringtable());

Expand All @@ -539,11 +544,6 @@ namespace Osmium {
// clear the PrimitiveBlock struct
pbf_primitive_block.Clear();

// add empty StringTable entry at index 0
// StringTable index 0 is rserved as delimiter in the densenodes key/value list
// this line also ensures that there's always a valid StringTable
pbf_primitive_block.mutable_stringtable()->add_s("");

// set the granularity
pbf_primitive_block.set_granularity(location_granularity());
pbf_primitive_block.set_date_granularity(date_granularity());
Expand Down
1 change: 1 addition & 0 deletions include/osmium/utils/stringtable.hpp
Expand Up @@ -157,6 +157,7 @@ namespace Osmium {
*/
void clear() {
m_strings.clear();
m_id2id_map.clear();
m_size = 0;
}

Expand Down

0 comments on commit e84e8f2

Please sign in to comment.