summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshat Tandon <akshat.tandon@research.iiit.ac.in>2016-07-24 14:30:41 (GMT)
committerAkshat Tandon <akshat.tandon@research.iiit.ac.in>2016-07-24 14:34:01 (GMT)
commit8907b7e525ccb926c3fbaac1cccd3498cdd224d0 (patch)
tree7c3b058f12eb6f3b46ac9bdaa14b0cce96d3f1f6
parent4213c996dba39106b6b0b05208c362efb2846f2e (diff)
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
-rw-r--r--tools/shp2osm/polyshp2osm.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/tools/shp2osm/polyshp2osm.py b/tools/shp2osm/polyshp2osm.py
index e81e6d4..0234d2d 100644
--- a/tools/shp2osm/polyshp2osm.py
+++ b/tools/shp2osm/polyshp2osm.py
@@ -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."""