Ejemplo n.º 1
0

if __name__ == '__main__':
    print(
        'Calculate distances and azimuth from one node to the rest of nodes in the same zone'
    )
    print('Usage: {} [nid] [filename.cnml]'.format(sys.argv[0]))
    print()

    filename = os.path.expanduser('~/.cache/guifinetstudio/detail/26494.cnml')
    nid = 33968  # MLGInvisible
    if len(sys.argv) == 3:
        nid, filename = sys.argv[1:2]

    # Parse CNML file
    cnmlp = CNMLParser(filename)
    from_node = cnmlp.getNode(nid)
    from_coord = (from_node.latitude, from_node.longitude)
    nodes = cnmlp.getNodes()
    distances = []
    nodes.remove(from_node)

    # Calculate distance to every node in the same zone
    for to_node in nodes:
        to_coord = (to_node.latitude, to_node.longitude)
        dist = distance.VincentyDistance(from_coord, to_coord)
        bearing = calcBearing(from_node.latitude, from_node.longitude,
                              to_node.latitude, to_node.longitude)
        distances.append((dist.km, from_node.title, to_node.title, bearing))

    # Sort by distance
Ejemplo n.º 2
0
 def parse(self):
     """ parse data """
     url = self.config.get('url')
     self.cnml = CNMLParser(url)
     self.parsed_data = self.cnml.getNodes()
Ejemplo n.º 3
0
#!/usr/bin/env python

import os
import sys

os.chdir(os.path.dirname(os.path.abspath(__file__)))
os.chdir('..')
sys.path.append('.')
sys.path.append('lib')

from utils import CNML2KML
from libcnml import CNMLParser

if len(sys.argv) != 3:
    print "CNML2KML"
    print "Usage: %s <IN_cnml_file> <OUT_kml_file>" % sys.argv[0]
    sys.exit(-1)

cnmlp = CNMLParser(sys.argv[1])
CNML2KML(cnmlp, sys.argv[2])
Ejemplo n.º 4
0
def parse(raw_cnml):
    c = CNMLParser(raw_cnml)
    return c