Ejemplo n.º 1
0
 def parseorigin(self):
     """
     Parse any origin tag from the Mobility Plan and set the CoreLocation
     reference point appropriately.
     """
     origin = xmlutils.get_one_element(self.mp, "origin")
     if not origin:
         return
     location = self.session.location
     geo = []
     attrs = ("lat", "lon", "alt")
     for i in xrange(3):
         a = origin.getAttribute(attrs[i])
         if a is not None:
             a = float(a)
         geo.append(a)
     location.setrefgeo(geo[0], geo[1], geo[2])
     scale = origin.getAttribute("scale100")
     if scale is not None and scale:
         location.refscale = float(scale)
     point = xmlutils.get_one_element(origin, "point")
     if point is not None and point.firstChild is not None:
         xyz = point.firstChild.nodeValue.split(',')
         if len(xyz) == 2:
             xyz.append('0.0')
         if len(xyz) == 3:
             xyz = map(lambda (x): float(x), xyz)
             location.refxyz = (xyz[0], xyz[1], xyz[2])
Ejemplo n.º 2
0
    def __init__(self, session, filename, options):
        self.session = session
        self.filename = filename
        if 'dom' in options:
            # this prevents parsing twice when detecting file versions
            self.dom = options['dom']
        else:
            self.dom = parse(filename)
        self.start = options['start']
        self.nodecls = options['nodecls']

        self.np = xmlutils.get_one_element(self.dom, "NetworkPlan")
        if self.np is None:
            raise ValueError, "missing NetworkPlan!"
        self.mp = xmlutils.get_one_element(self.dom, "MotionPlan")
        self.sp = xmlutils.get_one_element(self.dom, "ServicePlan")
        self.meta = xmlutils.get_one_element(self.dom, "CoreMetaData")

        self.coords = self.getmotiondict(self.mp)
        # link parameters parsed in parsenets(), applied in parsenodes()
        self.linkparams = {}

        self.parsedefaultservices()
        self.parseorigin()
        self.parsenets()
        self.parsenodes()
        self.parseservices()
        self.parsemeta()
Ejemplo n.º 3
0
 def parseorigin(self):
     """
     Parse any origin tag from the Mobility Plan and set the CoreLocation
     reference point appropriately.
     """
     origin = xmlutils.get_one_element(self.mp, "origin")
     if not origin:
         return
     location = self.session.location
     geo = []
     attrs = ("lat", "lon", "alt")
     for i in xrange(3):
         a = origin.getAttribute(attrs[i])
         if a is not None:
             a = float(a)
         geo.append(a)
     location.setrefgeo(geo[0], geo[1], geo[2])
     scale = origin.getAttribute("scale100")
     if scale is not None and scale:
         location.refscale = float(scale)
     point = xmlutils.get_one_element(origin, "point")
     if point is not None and point.firstChild is not None:
         xyz = point.firstChild.nodeValue.split(',')
         if len(xyz) == 2:
             xyz.append('0.0')
         if len(xyz) == 3:
             xyz = map(lambda (x): float(x), xyz)
             location.refxyz = (xyz[0], xyz[1], xyz[2])
Ejemplo n.º 4
0
    def __init__(self, session, filename, options):
        self.session = session
        self.filename = filename
        if 'dom' in options:
            # this prevents parsing twice when detecting file versions
            self.dom = options['dom']
        else:
            self.dom = parse(filename)
        self.start = options['start']
        self.nodecls = options['nodecls']

        self.np = xmlutils.get_one_element(self.dom, "NetworkPlan")
        if self.np is None:
            raise ValueError, "missing NetworkPlan!"
        self.mp = xmlutils.get_one_element(self.dom, "MotionPlan")
        self.sp = xmlutils.get_one_element(self.dom, "ServicePlan")
        self.meta = xmlutils.get_one_element(self.dom, "CoreMetaData")

        self.coords = self.getmotiondict(self.mp)
        # link parameters parsed in parsenets(), applied in parsenodes()
        self.linkparams = {}

        self.parsedefaultservices()
        self.parseorigin()
        self.parsenets()
        self.parsenodes()
        self.parseservices()
        self.parsemeta()
Ejemplo n.º 5
0
 def parsemeta(self):
     opt = xmlutils.get_one_element(self.meta, "SessionOptions")
     if opt:
         for param in opt.getElementsByTagName("param"):
             k = str(param.getAttribute("name"))
             v = str(param.getAttribute("value"))
             if v == '':
                 v = xmlutils.get_text_child(param)  # allow attribute/text for newlines
             self.session.options.set_config(k, v)
     hooks = xmlutils.get_one_element(self.meta, "Hooks")
     if hooks:
         self.parsehooks(hooks)
     meta = xmlutils.get_one_element(self.meta, "MetaData")
     if meta:
         for param in meta.getElementsByTagName("param"):
             k = str(param.getAttribute("name"))
             v = str(param.getAttribute("value"))
             if v == '':
                 v = xmlutils.get_text_child(param)
             self.session.metadata.set_config(k, v)
Ejemplo n.º 6
0
 def parsemeta(self):
     opt = xmlutils.get_one_element(self.meta, "SessionOptions")
     if opt:
         for param in opt.getElementsByTagName("param"):
             k = str(param.getAttribute("name"))
             v = str(param.getAttribute("value"))
             if v == '':
                 v = xmlutils.get_text_child(
                     param)  # allow attribute/text for newlines
             setattr(self.session.options, k, v)
     hooks = xmlutils.get_one_element(self.meta, "Hooks")
     if hooks:
         self.parsehooks(hooks)
     meta = xmlutils.get_one_element(self.meta, "MetaData")
     if meta:
         for param in meta.getElementsByTagName("param"):
             k = str(param.getAttribute("name"))
             v = str(param.getAttribute("value"))
             if v == '':
                 v = xmlutils.get_text_child(param)
             self.session.metadata.add_item(k, v)