Exemple #1
0
    def load_gpx_from_file(self, uri):
        """Parse GPX data, drawing each GPS track segment on the map."""
        start_time = clock()

        open_file = KMLFile if uri[-3:].lower() == 'kml' else GPXFile
        gpx = open_file(uri, self.progressbar)

        # Emitting this signal ensures the new tracks get the correct color.
        get_obj('colorselection').emit('color-changed')

        self.status_message(
            _('%d points loaded in %.2fs.') %
            (len(gpx.tracks), clock() - start_time), True)

        if len(gpx.tracks) < 2:
            return

        points.update(gpx.tracks)
        metadata.alpha = min(metadata.alpha, gpx.alpha)
        metadata.omega = max(metadata.omega, gpx.omega)

        map_view.emit('realize')
        map_view.set_zoom_level(map_view.get_max_zoom_level())
        bounds = Champlain.BoundingBox.new()
        for poly in polygons:
            bounds.compose(poly.get_bounding_box())
        gpx.latitude, gpx.longitude = bounds.get_center()
        map_view.ensure_visible(bounds, False)

        self.prefs.gpx_timezone = gpx.lookup_geoname()
        self.prefs.set_timezone()
        gpx_sensitivity()
Exemple #2
0
 def load_gpx_from_file(self, uri):
     """Parse GPX data, drawing each GPS track segment on the map."""
     start_time = clock()
     
     gpx = get_trackfile(uri)
     
     self.status_message(_('%d points loaded in %.2fs.') %
         (len(gpx.tracks), clock() - start_time), True)
     
     if len(gpx.tracks) < 2:
         return
     
     metadata.alpha = min(metadata.alpha, gpx.alpha)
     metadata.omega = max(metadata.omega, gpx.omega)
     
     map_view.emit('realize')
     map_view.set_zoom_level(map_view.get_max_zoom_level())
     bounds = Champlain.BoundingBox.new()
     for trackfile in known_trackfiles.values():
         for polygon in trackfile.polygons:
             bounds.compose(polygon.get_bounding_box())
     map_view.ensure_visible(bounds, False)
     
     for camera in known_cameras.values():
         camera.set_found_timezone(gpx.timezone)
Exemple #3
0
 def load_gpx_from_file(self, uri):
     """Parse GPX data, drawing each GPS track segment on the map."""
     start_time = clock()
     
     open_file = KMLFile if uri[-3:].lower() == 'kml' else GPXFile
     gpx = open_file(uri, self.progressbar)
     
     # Emitting this signal ensures the new tracks get the correct color.
     get_obj('colorselection').emit('color-changed')
     
     self.status_message(_('%d points loaded in %.2fs.') %
         (len(gpx.tracks), clock() - start_time), True)
     
     if len(gpx.tracks) < 2:
         return
     
     points.update(gpx.tracks)
     metadata.alpha = min(metadata.alpha, gpx.alpha)
     metadata.omega = max(metadata.omega, gpx.omega)
     
     map_view.emit('realize')
     map_view.set_zoom_level(map_view.get_max_zoom_level())
     bounds = Champlain.BoundingBox.new()
     for poly in polygons:
         bounds.compose(poly.get_bounding_box())
     gpx.latitude, gpx.longitude = bounds.get_center()
     map_view.ensure_visible(bounds, False)
     
     self.prefs.gpx_timezone = gpx.lookup_geoname()
     self.prefs.set_timezone()
     gpx_sensitivity()
Exemple #4
0
 def test_navigation_controller(self):
     """Ensure that it's possible to navigate the map."""
     coords = [[
         map_view.get_property('latitude'),
         map_view.get_property('longitude')
     ]]
     map_view.emit('realize')
     map_view.emit('animation-completed')
     self.assertGreater(len(get_obj('main').get_title()[18:]), 5)
     
     lat = round(random_coord(90),  6)
     lon = round(random_coord(180), 6)
     map_view.center_on(lat, lon)
     coords.append([lat, lon])
     
     self.assertAlmostEqual(coords[0][0], gst_get('history')[-1][0], 5)
     self.assertAlmostEqual(coords[0][1], gst_get('history')[-1][1], 5)
     
     lat = round(random_coord(80),  6)
     lon = round(random_coord(170), 6)
     map_view.center_on(lat, lon)
     
     zoom_in  = get_obj('zoom_in_button')
     zoom_out = get_obj('zoom_out_button')
     map_view.set_zoom_level(0)
     self.assertFalse(zoom_out.get_sensitive())
     self.assertTrue(zoom_in.get_sensitive())
     zoom_in.emit('clicked')
     self.assertTrue(zoom_out.get_sensitive())
     self.assertTrue(zoom_in.get_sensitive())
     self.assertEqual(1, map_view.get_zoom_level())
     zoom_in.emit('clicked')
     self.assertEqual(2, map_view.get_zoom_level())
     zoom_in.emit('clicked')
     self.assertEqual(3, map_view.get_zoom_level())
     zoom_out.emit('clicked')
     self.assertEqual(2, map_view.get_zoom_level())
     map_view.set_zoom_level(map_view.get_max_zoom_level()-1)
     self.assertTrue(zoom_out.get_sensitive())
     self.assertTrue(zoom_in.get_sensitive())
     zoom = map_view.get_zoom_level()
     zoom_in.emit('clicked')
     self.assertTrue(zoom_out.get_sensitive())
     self.assertFalse(zoom_in.get_sensitive())
     self.assertEqual(map_view.get_max_zoom_level(),
         map_view.get_zoom_level())
     
     get_obj("back_button").emit('clicked')
     
     map_view.set_zoom_level(5)
     
     lat = map_view.get_property('latitude')
     lon = map_view.get_property('longitude')
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Left"), None)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     self.assertGreater(    lon, map_view.get_property('longitude'))
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Right"), None)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 0)
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Right"), None)
     self.assertLess(       lon, map_view.get_property('longitude'))
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Left"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 0)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     
     lon = map_view.get_property('longitude')
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Up"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertLess(       lat, map_view.get_property('latitude'))
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Down"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 0)
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Down"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertGreater(    lat, map_view.get_property('latitude'))
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Up"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 0)
 def test_navigation_controller(self):
     """Ensure that it's possible to navigate the map."""
     coords = [[
         map_view.get_property('latitude'),
         map_view.get_property('longitude')
     ]]
     map_view.emit('realize')
     map_view.emit('animation-completed')
     self.assertGreater(len(get_obj('main').get_title()[18:]), 5)
     
     lat = round(random_coord(90),  6)
     lon = round(random_coord(180), 6)
     map_view.center_on(lat, lon)
     coords.append([lat, lon])
     
     self.assertAlmostEqual(coords[0][0], gst_get('history')[-1][0], 5)
     self.assertAlmostEqual(coords[0][1], gst_get('history')[-1][1], 5)
     
     lat = round(random_coord(80),  6)
     lon = round(random_coord(170), 6)
     map_view.center_on(lat, lon)
     
     zoom_in  = get_obj('zoom_in_button')
     zoom_out = get_obj('zoom_out_button')
     map_view.set_zoom_level(0)
     self.assertFalse(zoom_out.get_sensitive())
     self.assertTrue(zoom_in.get_sensitive())
     zoom_in.emit('clicked')
     self.assertTrue(zoom_out.get_sensitive())
     self.assertTrue(zoom_in.get_sensitive())
     self.assertEqual(1, map_view.get_zoom_level())
     zoom_in.emit('clicked')
     self.assertEqual(2, map_view.get_zoom_level())
     zoom_in.emit('clicked')
     self.assertEqual(3, map_view.get_zoom_level())
     zoom_out.emit('clicked')
     self.assertEqual(2, map_view.get_zoom_level())
     map_view.set_zoom_level(map_view.get_max_zoom_level()-1)
     self.assertTrue(zoom_out.get_sensitive())
     self.assertTrue(zoom_in.get_sensitive())
     zoom = map_view.get_zoom_level()
     zoom_in.emit('clicked')
     self.assertTrue(zoom_out.get_sensitive())
     self.assertFalse(zoom_in.get_sensitive())
     self.assertEqual(map_view.get_max_zoom_level(),
         map_view.get_zoom_level())
     
     get_obj("back_button").emit('clicked')
     
     map_view.set_zoom_level(5)
     
     lat = map_view.get_property('latitude')
     lon = map_view.get_property('longitude')
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Left"), None)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     self.assertGreater(    lon, map_view.get_property('longitude'))
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Right"), None)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 0)
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Right"), None)
     self.assertLess(       lon, map_view.get_property('longitude'))
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Left"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 0)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 4)
     
     lon = map_view.get_property('longitude')
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Up"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertLess(       lat, map_view.get_property('latitude'))
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Down"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 0)
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Down"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertGreater(    lat, map_view.get_property('latitude'))
     
     move_by_arrow_keys(None, None, Gdk.keyval_from_name("Up"), None)
     self.assertAlmostEqual(lon, map_view.get_property('longitude'), 4)
     self.assertAlmostEqual(lat, map_view.get_property('latitude'), 0)