Commit 8907b7e5 authored by Akshat Tandon's avatar Akshat Tandon
Browse files

Fix order of node, way and relation blocks generated by shp2osm script

This fix keeps the ID's as negative so as to prevent collision with OSM IDs while keeping the order within each block as non decreasing.

Reviewers: nienhueser, rahn

Differential Revision: https://phabricator.kde.org/D2273
parent 4213c996
......@@ -426,23 +426,25 @@ def start_new_file():
def write_osm_files():
global nodes, ways, relations, element_indices, open_file, file_counter, file_name
node_idx = 0
way_idx = 0
rel_idx = 0
current = [0, 0, 0]
previous = [0, 0, 0]
for indices in element_indices:
start_new_file()
while node_idx < indices[0]:
write_node(nodes[node_idx])
node_idx += 1
while way_idx < indices[1]:
write_way(ways[way_idx])
way_idx += 1
while rel_idx < indices[2]:
write_relation_multipolygon(relations[rel_idx])
rel_idx += 1
current[0] = indices[0] - 1
current[1] = indices[1] - 1
current[2] = indices[2] - 1
while current[0] >= previous[0]:
write_node(nodes[current[0]])
current[0] -= 1
while current[1] >= previous[1]:
write_way(ways[current[1]])
current[1] -= 1
while current[2] >= previous[2]:
write_relation_multipolygon(relations[current[2]])
current[2] -= 1
previous = indices[:]
close_file()
element_indices = []
def clean_attr(val):
"""Internal. Hacky way to make attribute XML safe."""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment