2020-01-22 08:24:29 +01:00
|
|
|
from lxml import etree as ElementTree
|
2020-03-02 06:17:12 +01:00
|
|
|
import numpy as np
|
|
|
|
import sys
|
|
|
|
|
|
|
|
filename = sys.argv[1]
|
|
|
|
|
|
|
|
if(len(filename) == 0):
|
|
|
|
print "No input filename given"
|
|
|
|
exit()
|
2020-01-22 08:24:29 +01:00
|
|
|
|
|
|
|
parser = ElementTree.XMLParser(recover=True)
|
2020-03-02 06:17:12 +01:00
|
|
|
tree = ElementTree.parse(filename, parser)
|
2020-01-22 08:24:29 +01:00
|
|
|
polys = tree.xpath('//polygon')
|
|
|
|
|
2020-03-02 06:17:12 +01:00
|
|
|
bin_file = open("mapdata.bin", "wt")
|
|
|
|
|
|
|
|
outlist = []
|
2020-01-22 08:24:29 +01:00
|
|
|
|
|
|
|
for p in polys:
|
|
|
|
currentPoints = p.attrib['points']
|
2020-03-02 06:17:12 +01:00
|
|
|
outlist.extend((currentPoints.replace(","," ") + " 0 0").split())
|
2020-01-22 08:24:29 +01:00
|
|
|
|
2020-03-02 06:17:12 +01:00
|
|
|
np.asarray(outlist).astype(np.single).tofile(bin_file)
|
|
|
|
bin_file.close()
|