Esempio n. 1
0
    def _parse_route_point(self, node):
        if not node.attributes.has_key("lat"):
            raise Exception("Waypoint without latitude")
        if not node.attributes.has_key("lon"):
            raise Exception("Waypoint without longitude")

        lat = mod_utils.to_number(node.attributes["lat"].nodeValue)
        lon = mod_utils.to_number(node.attributes["lon"].nodeValue)

        elevation_node = mod_utils.find_first_node(node, "ele")
        elevation = mod_utils.to_number(self.get_node_data(elevation_node), 0)

        time_node = mod_utils.find_first_node(node, "time")
        time_str = self.get_node_data(time_node)
        time = parse_time(time_str)

        name_node = mod_utils.find_first_node(node, "name")
        name = self.get_node_data(name_node)

        desc_node = mod_utils.find_first_node(node, "desc")
        desc = self.get_node_data(desc_node)

        sym_node = mod_utils.find_first_node(node, "sym")
        sym = self.get_node_data(sym_node)

        type_node = mod_utils.find_first_node(node, "type")
        type = self.get_node_data(type_node)

        comment_node = mod_utils.find_first_node(node, "cmt")
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, "hdop")
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))

        vdop_node = mod_utils.find_first_node(node, "vdop")
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))

        pdop_node = mod_utils.find_first_node(node, "pdop")
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        return mod_gpx.GPXRoutePoint(
            lat,
            lon,
            elevation,
            time,
            name,
            desc,
            sym,
            type,
            comment,
            horizontal_dilution=hdop,
            vertical_dilution=vdop,
            position_dilution=pdop,
        )
    def _parse_route_point(self, node):
        if not node.attributes.has_key('lat'):
            raise mod_gpx.GPXException('Waypoint without latitude')
        if not node.attributes.has_key('lon'):
            raise mod_gpx.GPXException('Waypoint without longitude')

        lat = mod_utils.to_number(node.attributes['lat'].nodeValue)
        lon = mod_utils.to_number(node.attributes['lon'].nodeValue)

        elevation_node = mod_utils.find_first_node(node, 'ele')
        elevation = mod_utils.to_number(self.get_node_data(elevation_node), 0)

        time_node = mod_utils.find_first_node(node, 'time')
        time_str = self.get_node_data(time_node)
        time = parse_time(time_str)

        name_node = mod_utils.find_first_node(node, 'name')
        name = self.get_node_data(name_node)

        desc_node = mod_utils.find_first_node(node, 'desc')
        desc = self.get_node_data(desc_node)

        sym_node = mod_utils.find_first_node(node, 'sym')
        sym = self.get_node_data(sym_node)

        type_node = mod_utils.find_first_node(node, 'type')
        type = self.get_node_data(type_node)

        comment_node = mod_utils.find_first_node(node, 'cmt')
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, 'hdop')
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))

        vdop_node = mod_utils.find_first_node(node, 'vdop')
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))

        pdop_node = mod_utils.find_first_node(node, 'pdop')
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        return mod_gpx.GPXRoutePoint(lat,
                                     lon,
                                     elevation,
                                     time,
                                     name,
                                     desc,
                                     sym,
                                     type,
                                     comment,
                                     horizontal_dilution=hdop,
                                     vertical_dilution=vdop,
                                     position_dilution=pdop)
Esempio n. 3
0
    def __parse_track_point(self, node):
        latitude = None
        if node.attributes.has_key('lat'):
            latitude = mod_utils.to_number(node.attributes['lat'].nodeValue)

        longitude = None
        if node.attributes.has_key('lon'):
            longitude = mod_utils.to_number(node.attributes['lon'].nodeValue)

        time_node = mod_utils.find_first_node(node, 'time')
        time = parse_time(self.get_node_data(time_node))

        elevation_node = mod_utils.find_first_node(node, 'ele')
        elevation = mod_utils.to_number(self.get_node_data(elevation_node))

        symbol_node = mod_utils.find_first_node(node, 'sym')
        symbol = self.get_node_data(symbol_node)

        comment_node = mod_utils.find_first_node(node, 'cmt')
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, 'hdop')
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))
		
        vdop_node = mod_utils.find_first_node(node, 'vdop')
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))
		
        pdop_node = mod_utils.find_first_node(node, 'pdop')
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        return mod_gpx.GPXTrackPoint(latitude=latitude, longitude=longitude, elevation=elevation, time=time,
                symbol=symbol, comment=comment, horizontal_dilution=hdop, vertical_dilution=vdop, 
                position_dilution=pdop)
Esempio n. 4
0
    def _parse_waypoint(self, node):
        if not node.attrib.get('lat'):
            raise mod_gpx.GPXException('Waypoint without latitude')
        if not node.attrib.get('lon'):
            raise mod_gpx.GPXException('Waypoint without longitude')

        lat = mod_utils.to_number(node.attrib.get('lat'))
        lon = mod_utils.to_number(node.attrib.get('lon'))

        elevation_node = mod_utils.find_first_node(node, mod_utils.tag('ele',self.ns))
        elevation = mod_utils.to_number(self.get_node_data(elevation_node), 0)

        time_node = mod_utils.find_first_node(node, mod_utils.tag('time',self.ns))
        time_str = self.get_node_data(time_node)
        time = parse_time(time_str)

        name_node = mod_utils.find_first_node(node, mod_utils.tag('name',self.ns))
        name = self.get_node_data(name_node)

        desc_node = mod_utils.find_first_node(node, mod_utils.tag('desc',self.ns))
        desc = self.get_node_data(desc_node)

        sym_node = mod_utils.find_first_node(node, mod_utils.tag('sym',self.ns))
        sym = self.get_node_data(sym_node)

        type_node = mod_utils.find_first_node(node, mod_utils.tag('type',self.ns))
        type = self.get_node_data(type_node)

        comment_node = mod_utils.find_first_node(node, mod_utils.tag('cmt',self.ns))
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, mod_utils.tag('hdop',self.ns))
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))

        vdop_node = mod_utils.find_first_node(node, mod_utils.tag('vdop',self.ns))
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))

        pdop_node = mod_utils.find_first_node(node, mod_utils.tag('pdop',self.ns))
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        return mod_gpx.GPXWaypoint(latitude=lat, longitude=lon, elevation=elevation,
            time=time, name=name, description=desc, symbol=sym,
            type=type, comment=comment, horizontal_dilution=hdop,
            vertical_dilution=vdop, position_dilution=pdop)
Esempio n. 5
0
    def __parse_track(self, node):
        name_node = mod_utils.find_first_node(node, mod_utils.tag('name',self.ns))
        name = self.get_node_data(name_node)

        description_node = mod_utils.find_first_node(node, mod_utils.tag('desc',self.ns))
        description = self.get_node_data(description_node)

        number_node = mod_utils.find_first_node(node, mod_utils.tag('number',self.ns))
        number = mod_utils.to_number(self.get_node_data(number_node))

        track = mod_gpx.GPXTrack(name, description, number)

        child_nodes = node.getchildren()
        for child_node in child_nodes:
            if child_node.tag == mod_utils.tag('trkseg',self.ns):
                track_segment = self.__parse_track_segment(child_node)
                track.segments.append(track_segment)

        return track
Esempio n. 6
0
    def _parse_route(self, node):
        name_node = mod_utils.find_first_node(node, mod_utils.tag('name',self.ns))
        name = self.get_node_data(name_node)

        description_node = mod_utils.find_first_node(node, mod_utils.tag('desc',self.ns))
        description = self.get_node_data(description_node)

        number_node = mod_utils.find_first_node(node, mod_utils.tag('number',self.ns))
        number = mod_utils.to_number(self.get_node_data(number_node))

        route = mod_gpx.GPXRoute(name, description, number)

        child_nodes = node.getchildren()
        for child_node in child_nodes:
            if child_node.tag == mod_utils.tag('rtept',self.ns):
                route_point = self._parse_route_point(child_node)
                route.points.append(route_point)

        return route
Esempio n. 7
0
File: parser.py Progetto: kipe/gpxpy
    def _parse_route_point(self, node):
        if not node.attributes.has_key('lat'):
            raise mod_gpx.GPXException('Waypoint without latitude')
        if not node.attributes.has_key('lon'):
            raise mod_gpx.GPXException('Waypoint without longitude')

        lat = mod_utils.to_number(node.attributes['lat'].nodeValue)
        lon = mod_utils.to_number(node.attributes['lon'].nodeValue)

        elevation_node = mod_utils.find_first_node(node, 'ele')
        elevation = mod_utils.to_number(self.get_node_data(elevation_node), 0)

        time_node = mod_utils.find_first_node(node, 'time')
        time_str = self.get_node_data(time_node)
        time = parse_time(time_str)

        name_node = mod_utils.find_first_node(node, 'name')
        name = self.get_node_data(name_node)

        desc_node = mod_utils.find_first_node(node, 'desc')
        desc = self.get_node_data(desc_node)

        sym_node = mod_utils.find_first_node(node, 'sym')
        sym = self.get_node_data(sym_node)

        type_node = mod_utils.find_first_node(node, 'type')
        type = self.get_node_data(type_node)

        comment_node = mod_utils.find_first_node(node, 'cmt')
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, 'hdop')
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))
		
        vdop_node = mod_utils.find_first_node(node, 'vdop')
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))
		
        pdop_node = mod_utils.find_first_node(node, 'pdop')
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        return mod_gpx.GPXRoutePoint(lat, lon, elevation, time, name, desc, sym, type, comment,
                horizontal_dilution = hdop, vertical_dilution = vdop, position_dilution = pdop)
    def __parse_track(self, node):
        name_node = mod_utils.find_first_node(node, 'name')
        name = self.get_node_data(name_node)

        description_node = mod_utils.find_first_node(node, 'desc')
        description = self.get_node_data(description_node)

        number_node = mod_utils.find_first_node(node, 'number')
        number = mod_utils.to_number(self.get_node_data(number_node))

        track = mod_gpx.GPXTrack(name, description, number)

        child_nodes = node.childNodes
        for child_node in child_nodes:
            if child_node.nodeName == 'trkseg':
                track_segment = self.__parse_track_segment(child_node)

                track.segments.append(track_segment)

        return track
    def _parse_route(self, node):
        name_node = mod_utils.find_first_node(node, 'name')
        name = self.get_node_data(name_node)

        description_node = mod_utils.find_first_node(node, 'desc')
        description = self.get_node_data(description_node)

        number_node = mod_utils.find_first_node(node, 'number')
        number = mod_utils.to_number(self.get_node_data(number_node))

        route = mod_gpx.GPXRoute(name, description, number)

        child_nodes = node.childNodes
        for child_node in child_nodes:
            node_name = child_node.nodeName
            if node_name == 'rtept':
                route_point = self._parse_route_point(child_node)
                route.points.append(route_point)

        return route
Esempio n. 10
0
    def __parse_track(self, node):
        name_node = mod_utils.find_first_node(node, "name")
        name = self.get_node_data(name_node)

        description_node = mod_utils.find_first_node(node, "desc")
        description = self.get_node_data(description_node)

        number_node = mod_utils.find_first_node(node, "number")
        number = mod_utils.to_number(self.get_node_data(number_node))

        track = mod_gpx.GPXTrack(name, description, number)

        child_nodes = node.childNodes
        for child_node in child_nodes:
            if child_node.nodeName == "trkseg":
                track_segment = self.__parse_track_segment(child_node)

                track.segments.append(track_segment)

        return track
Esempio n. 11
0
    def _parse_route(self, node):
        name_node = mod_utils.find_first_node(node, "name")
        name = self.get_node_data(name_node)

        description_node = mod_utils.find_first_node(node, "desc")
        description = self.get_node_data(description_node)

        number_node = mod_utils.find_first_node(node, "number")
        number = mod_utils.to_number(self.get_node_data(number_node))

        route = mod_gpx.GPXRoute(name, description, number)

        child_nodes = node.childNodes
        for child_node in child_nodes:
            node_name = child_node.nodeName
            if node_name == "rtept":
                route_point = self._parse_route_point(child_node)
                route.points.append(route_point)

        return route
Esempio n. 12
0
    def __parse_track_point(self, node):
        latitude = None
        if node.attrib.get('lat'):
            latitude = mod_utils.to_number(node.attrib.get('lat'))

        longitude = None
        if node.attrib.get('lon'):
            longitude = mod_utils.to_number(node.attrib.get('lon'))

        time_node = mod_utils.find_first_node(node, mod_utils.tag('time',self.ns))
        time_str = self.get_node_data(time_node)
        time = parse_time(time_str)

        elevation_node = mod_utils.find_first_node(node, mod_utils.tag('ele',self.ns))
        elevation = mod_utils.to_number(self.get_node_data(elevation_node), 0)

        sym_node = mod_utils.find_first_node(node, mod_utils.tag('sym',self.ns))
        symbol = self.get_node_data(sym_node)

        comment_node = mod_utils.find_first_node(node, mod_utils.tag('cmt',self.ns))
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, mod_utils.tag('hdop',self.ns))
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))

        vdop_node = mod_utils.find_first_node(node, mod_utils.tag('vdop',self.ns))
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))

        pdop_node = mod_utils.find_first_node(node, mod_utils.tag('pdop',self.ns))
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        speed_node = mod_utils.find_first_node(node, mod_utils.tag('speed',self.ns))
        speed = mod_utils.to_number(self.get_node_data(speed_node))

        return mod_gpx.GPXTrackPoint(latitude=latitude, longitude=longitude, elevation=elevation, time=time,
            symbol=symbol, comment=comment, horizontal_dilution=hdop, vertical_dilution=vdop,
            position_dilution=pdop, speed=speed)
Esempio n. 13
0
    def __parse_track_point(self, node):
        latitude = None
        if node.attributes.has_key("lat"):
            latitude = mod_utils.to_number(node.attributes["lat"].nodeValue)

        longitude = None
        if node.attributes.has_key("lon"):
            longitude = mod_utils.to_number(node.attributes["lon"].nodeValue)

        time_node = mod_utils.find_first_node(node, "time")
        time = parse_time(self.get_node_data(time_node))

        elevation_node = mod_utils.find_first_node(node, "ele")
        elevation = mod_utils.to_number(self.get_node_data(elevation_node))

        symbol_node = mod_utils.find_first_node(node, "sym")
        symbol = self.get_node_data(symbol_node)

        comment_node = mod_utils.find_first_node(node, "cmt")
        comment = self.get_node_data(comment_node)

        hdop_node = mod_utils.find_first_node(node, "hdop")
        hdop = mod_utils.to_number(self.get_node_data(hdop_node))

        vdop_node = mod_utils.find_first_node(node, "vdop")
        vdop = mod_utils.to_number(self.get_node_data(vdop_node))

        pdop_node = mod_utils.find_first_node(node, "pdop")
        pdop = mod_utils.to_number(self.get_node_data(pdop_node))

        return mod_gpx.GPXTrackPoint(
            latitude=latitude,
            longitude=longitude,
            elevation=elevation,
            time=time,
            symbol=symbol,
            comment=comment,
            horizontal_dilution=hdop,
            vertical_dilution=vdop,
            position_dilution=pdop,
        )