-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodeling_map.py
More file actions
28 lines (22 loc) · 1.01 KB
/
modeling_map.py
File metadata and controls
28 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import xml.etree.ElementTree as ET
# Delete an layer of the map
def delete_map_layer(root, layer_name):
for child in root:
# If id of the child is viewbox, then print its children
if child.tag == '{http://www.w3.org/2000/svg}g' and child.attrib.get('id') == 'viewbox':
for grandchild in child:
if grandchild.tag == '{http://www.w3.org/2000/svg}g' and grandchild.attrib.get('id') == layer_name:
child.remove(grandchild)
return root
# Print the layers of the map
def print_map_layers(root):
for child in root:
# If id of the child is viewbox, then print its children
if child.tag == '{http://www.w3.org/2000/svg}g' and child.attrib.get('id') == 'viewbox':
for grandchild in child:
# Layers of the SVG Map
print(grandchild.tag, grandchild.attrib)
def remove_multiple_layers(root, layer_list):
for layer in layer_list:
root = delete_map_layer(root, layer)
return root