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):
|
2020-06-08 20:49:58 +02:00
|
|
|
print("No input filename given")
|
2020-03-02 06:17:12 +01:00
|
|
|
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:
|
2020-03-02 07:40:11 +01:00
|
|
|
currentPoints = (p.attrib['points']).replace(","," ").split()
|
|
|
|
|
|
|
|
if(len(currentPoints) > 12): #remove little circles in the McCurley maps
|
|
|
|
outlist.extend(currentPoints)
|
|
|
|
outlist.extend(["0","0"])
|
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)
|
2020-06-08 20:49:58 +02:00
|
|
|
bin_file.close()
|