Skip to content

Commit 1709c61

Browse files
committed
Use zigzag encoding for way node lists
The delta encoded ids are, of course, sometimes positive, sometimes negative. The zigzag encoding makes sure this is efficiently encoded.
1 parent db6d89d commit 1709c61

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/middle-ram.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ static void add_delta_encoded_way_node_list(std::string *data,
142142
// Add delta encoded node ids
143143
osmium::DeltaEncode<osmid_t> delta;
144144
for (auto const &nr : wnl) {
145-
protozero::add_varint_to_buffer(data, delta.update(nr.ref()));
145+
protozero::add_varint_to_buffer(
146+
data, protozero::encode_zigzag64(delta.update(nr.ref())));
146147
}
147148
}
148149

@@ -228,7 +229,8 @@ get_delta_encoded_way_nodes_list(std::string const &data, std::size_t offset,
228229
osmium::DeltaDecode<osmid_t> delta;
229230
osmium::builder::WayNodeListBuilder wnl_builder{*builder};
230231
while (count > 0) {
231-
auto const val = protozero::decode_varint(&begin, end);
232+
auto const val =
233+
protozero::decode_zigzag64(protozero::decode_varint(&begin, end));
232234
wnl_builder.add_node_ref(delta.update(val));
233235
--count;
234236
}

0 commit comments

Comments
 (0)