orthographic/wedgen.py

61 lines
1.9 KiB
Python

# -------------------------------------------------------------------
# ORTHOGRAPHIC
# Your personal aerial satellite. Always on. At any altitude.*
# Developed by MarStrMind
# License: Open Software License 3.0
# Up to date version always on marstr.online
# -------------------------------------------------------------------
# wedgen.py
# Generates the XML for X-Plane's WED, which you need to use the
# orthos in the flight simulator.
# -------------------------------------------------------------------
import xml.dom.minidom
from defines import *
from log import *
from tiledb import *
class mstr_wedgen:
def __init__(self, lat, lng):
self._lat = lat
self._lng = lng
self._curID = 2
self._tiledb = mstr_tiledb(lat, lng)
# Creates the XML file for WED in one go
def create_WED_XML(self):
# Generates a very basic skeleton for the World Editor
root = xml.dom.minidom.Document()
xmlobj = root.createElement("doc")
root.appendChild(xmlobj)
objs = root.createElement("objects")
xmlobj.appendChild(objs)
rtobj = root.createElement("object")
rtobj.setAttribute("class", "WED_Root")
rtobj.setAttribute("id", "1")
rtobj.setAttribute("parent_id", "0")
chdobj = root.createElement("children")
rtobj.appendChild(chdobj)
hiera = root.createElement("hierarchy")
hiera.setAttribute("name", "root")
rtobj.appendChild(hiera)
# We now open the DB and check for everything that needs to be added,
# predominantely forests
# I believe this needs to be in
prefs = root.createElement("prefs")
xmlobj.appendChild(prefs)
file_handle = open(mstr_datafolder + "Tiles/" + str(self._lat) + "_" + str(self._lng) + "/earth.wed.xml","w")
root.writexml(file_handle)
file_handle.close()