Esempio n. 1
0
    def get_template_data(self):
        """
        Get the point data from the TCX file and save it in template_data.
        """
        if self.options.in_file:
            self.in_file = open(self.options.in_file, "r")
            self.template_data['title'] = \
                os.path.basename(self.options.in_file)
        else:
            self.in_file = sys.stdin
            self.template_data['title'] = "stdin"

        tree = parse_no_def_namespaces(self.in_file)
        count = self.options.start_index
        laps = tree.findall('Activities/Activity/Lap')
        points = []
        for lap in laps:
            pts = lap.findall('Track/Trackpoint')
            for pt in pts:
                if pt.find('Position') and \
                        pt.findtext('AltitudeMeters'):
                    points.append( {'index': count, 
                                    'lat': pt.findtext(
                                'Position/LatitudeDegrees'),
                                    'lon': pt.findtext(
                                'Position/LongitudeDegrees'),
                                    'ele': pt.findtext(
                                'AltitudeMeters')} )
                    count += 1
        self.template_data['points'] = points
Esempio n. 2
0
    def get_template_data(self):
        """
        Get the point data from the GPX file and save it in template_data.
        """
        if self.options.in_file:
            self.in_file = open(self.options.in_file, "r")
            self.template_data['title'] = \
                os.path.basename(self.options.in_file)
        else:
            self.in_file = sys.stdin
            self.template_data['title'] = "stdin"

        tree = parse_no_def_namespaces(self.in_file)
        count = self.options.start_index
        segs = tree.findall('trk/trkseg')
        points = []
        for seg in segs:
            pts = seg.findall('trkpt')
            for pt in pts:
                points.append( {'index': count, 
                                'lat': pt.attrib['lat'], 
                                'lon': pt.attrib['lon'],
                                'ele': pt.findtext('ele')} )
                count += 1
        self.template_data['points'] = points
Esempio n. 3
0
File: map.py Progetto: jfarrimo/sabx
 def get_template_data(self):
     """
     Add all the extra-special goodness to the SABX data for our templates.
     """
     xml_tree = oxm.parse_no_def_namespaces(self.in_file)
     self.template_data.update(oxm.parse_top_level(xml_tree))
     self.template_data['filebase'] = self.filebase
     self.template_data['photos'] = oxm.parse_photos(xml_tree)
     self.template_data['rides'] = \
         _process_all_rides(xml_tree, self.filebase)
     self.template_data['zoom_factor'] = glineenc.zoom_factor
     self.template_data['zoom_levels'] = glineenc.num_levels
     self.template_data['BORDER'] = BORDER
Esempio n. 4
0
    def get_template_data(self):
        """
        Parse the specified SABX 1.0 file and save its object representation.
        Over-ride this in sub-classes to modify the SABX data before passing it
        to the template.
        """
        if self.options.in_file:
            self.in_file = open(self.options.in_file, "r")
        else:
            self.in_file = sys.stdin

        tree = parse_no_def_namespaces(self.in_file)
        self.template_data.update(parse_tree(tree))

        self.in_file.close()
Esempio n. 5
0
def get_usgs(lat, lon):
    """
    Call the USGS web service to get the elevation for a point represented by
    the (lat,lon) pair.
    """
    first = False
    url = "http://gisdata.usgs.gov/" \
        "xmlwebservices2/elevation_service.asmx/getElevation" \
        "?X_Value=%s" \
        "&Y_Value=%s" \
        "&Elevation_Units=METERS" \
        "&Source_Layer=-1" \
        "&Elevation_Only=1" % (lon, lat)
    tree = parse_no_def_namespaces(urllib.urlopen(url))
    return tree.findtext("Elevation_Query/Elevation")
Esempio n. 6
0
File: osm.py Progetto: jfarrimo/sabx
    def get_template_data(self):
        """
        Add all the extra data that Mapnik needs.
        """
        xml_tree = parse_no_def_namespaces(self.in_file)
        self.template_data.update(parse_top_level(xml_tree))

        self.template_data['seg_list'], \
            self.template_data['seg_dict'] = parse_segments(xml_tree)
        node_id = NodeId(self.template_data['seg_list'])
        self.template_data['rides'], self.template_data['bounds'] = \
            _process_all_rides(xml_tree, self.template_data['title'], node_id)
        self.template_data['PIX_SCALE_FACTOR'] = PIX_SCALE_FACTOR
        self.template_data['PPI'] = PPI
        self.template_data['WIDTH'] = WIDTH
        self.template_data['HEIGHT'] = HEIGHT
        self.template_data['BORDER'] = BORDER