Geography : first try for gobject introspection. partial map, no zoom, no menu, ...
svn: r20280
This commit is contained in:
parent
fe38fb66fc
commit
6227383508
@ -30,7 +30,7 @@
|
||||
import gen.lib
|
||||
import os
|
||||
from gen.const import HOME_DIR
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -93,18 +93,18 @@ map_title = {
|
||||
}
|
||||
|
||||
map_type = {
|
||||
OPENSTREETMAP : osmgpsmap.SOURCE_OPENSTREETMAP,
|
||||
OPENSTREETMAP_RENDERER : osmgpsmap.SOURCE_OPENSTREETMAP_RENDERER,
|
||||
OPENAERIALMAP : osmgpsmap.SOURCE_OPENAERIALMAP,
|
||||
MAPS_FOR_FREE : osmgpsmap.SOURCE_MAPS_FOR_FREE,
|
||||
GOOGLE_STREET : osmgpsmap.SOURCE_GOOGLE_STREET,
|
||||
GOOGLE_SATELLITE : osmgpsmap.SOURCE_GOOGLE_SATELLITE,
|
||||
GOOGLE_HYBRID : osmgpsmap.SOURCE_GOOGLE_HYBRID,
|
||||
VIRTUAL_EARTH_STREET : osmgpsmap.SOURCE_VIRTUAL_EARTH_STREET,
|
||||
VIRTUAL_EARTH_SATELLITE : osmgpsmap.SOURCE_VIRTUAL_EARTH_SATELLITE,
|
||||
VIRTUAL_EARTH_HYBRID : osmgpsmap.SOURCE_VIRTUAL_EARTH_HYBRID,
|
||||
YAHOO_STREET : osmgpsmap.SOURCE_YAHOO_STREET,
|
||||
YAHOO_SATELLITE : osmgpsmap.SOURCE_YAHOO_SATELLITE,
|
||||
YAHOO_HYBRID : osmgpsmap.SOURCE_YAHOO_HYBRID,
|
||||
OPENSTREETMAP : osmgpsmap.MapSource_t.OPENSTREETMAP,
|
||||
OPENSTREETMAP_RENDERER : osmgpsmap.MapSource_t.OPENSTREETMAP_RENDERER,
|
||||
OPENAERIALMAP : osmgpsmap.MapSource_t.OPENAERIALMAP,
|
||||
MAPS_FOR_FREE : osmgpsmap.MapSource_t.MAPS_FOR_FREE,
|
||||
GOOGLE_STREET : osmgpsmap.MapSource_t.GOOGLE_STREET,
|
||||
GOOGLE_SATELLITE : osmgpsmap.MapSource_t.GOOGLE_SATELLITE,
|
||||
GOOGLE_HYBRID : osmgpsmap.MapSource_t.GOOGLE_HYBRID,
|
||||
VIRTUAL_EARTH_STREET : osmgpsmap.MapSource_t.VIRTUAL_EARTH_STREET,
|
||||
VIRTUAL_EARTH_SATELLITE : osmgpsmap.MapSource_t.VIRTUAL_EARTH_SATELLITE,
|
||||
VIRTUAL_EARTH_HYBRID : osmgpsmap.MapSource_t.VIRTUAL_EARTH_HYBRID,
|
||||
YAHOO_STREET : osmgpsmap.MapSource_t.YAHOO_STREET,
|
||||
YAHOO_SATELLITE : osmgpsmap.MapSource_t.YAHOO_SATELLITE,
|
||||
YAHOO_HYBRID : osmgpsmap.MapSource_t.YAHOO_HYBRID,
|
||||
}
|
||||
|
||||
|
@ -61,11 +61,11 @@ import cairo
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class DateLayer(GObject.GObject, osmgpsmap.GpsMapLayer):
|
||||
class DateLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
This is the layer used to display the two extreme dates on the top left of the view
|
||||
"""
|
||||
|
@ -51,11 +51,11 @@ _LOG = logging.getLogger("maps.dummylayer")
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class DummyLayer(GObject.GObject, osmgpsmap.GpsMapLayer):
|
||||
class DummyLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize the dummy layer
|
||||
|
@ -51,11 +51,11 @@ _LOG = logging.getLogger("maps.dummynogps")
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class DummyMapNoGpsPoint(osmgpsmap.GpsMap):
|
||||
class DummyMapNoGpsPoint(osmgpsmap.Map):
|
||||
def do_draw_gps_point(self, drawable):
|
||||
pass
|
||||
|
||||
|
@ -57,7 +57,7 @@ from gen.config import config
|
||||
from gui.editors import EditPlace, EditEvent, EditFamily, EditPerson
|
||||
from gui.selectors.selectplace import SelectPlace
|
||||
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
import constants
|
||||
from osmGps import OsmGps
|
||||
from selectionlayer import SelectionLayer
|
||||
@ -529,6 +529,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
"""
|
||||
Is this marker in the visible area ?
|
||||
"""
|
||||
return True
|
||||
# BUG here : how to replace that ?
|
||||
bbox = self.osm.get_bbox()
|
||||
s_lon = lon + 10.0
|
||||
s_lat = lat + 10.0
|
||||
@ -579,8 +581,15 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
We must use function called by timeout to force map updates.
|
||||
"""
|
||||
level_start = self.osm.props.zoom
|
||||
p1lat, p1lon = self.begin_selection.get_degrees()
|
||||
p2lat, p2lon = self.end_selection.get_degrees()
|
||||
# BUG here : how to replace that ?
|
||||
#p1lat = p1lon = 0.0
|
||||
#p1lat, p1lon = self.begin_selection.get_degrees(p1lat, p1lon)
|
||||
#print p1lat, p1lon
|
||||
#p2lat, p2lon = self.end_selection.get_degrees(0.0, 0.0)
|
||||
p1lat = self.begin_selection.rlat
|
||||
p1lon = self.begin_selection.rlon
|
||||
p2lat = self.end_selection.rlat
|
||||
p2lon = self.end_selection.rlon
|
||||
lat = p1lat + ( p2lat - p1lat ) / 2
|
||||
lon = p1lon + ( p2lon - p1lon ) / 2
|
||||
# We center the map on the center of the region
|
||||
@ -609,9 +618,9 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
signminlat = _get_sign(self.minlat)
|
||||
signmaxlon = _get_sign(self.maxlon)
|
||||
signmaxlat = _get_sign(self.maxlat)
|
||||
current = osmgpsmap.point_new_degrees(self.minlat, self.minlon)
|
||||
current = osmgpsmap.MapPoint.new_degrees(self.minlat, self.minlon)
|
||||
self.end_selection = current
|
||||
current = osmgpsmap.point_new_degrees(self.maxlat, self.maxlon)
|
||||
current = osmgpsmap.MapPoint.new_degrees(self.maxlat, self.maxlon)
|
||||
self.begin_selection = current
|
||||
if signminlon == signmaxlon:
|
||||
maxlong = abs(abs(self.minlon) - abs(self.maxlon))
|
||||
|
@ -60,11 +60,11 @@ import cairo
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class LifeWayLayer(GObject.GObject, osmgpsmap.GpsMapLayer):
|
||||
class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
This is the layer used to display tracks or the life way for one or several
|
||||
individuals.
|
||||
|
@ -68,11 +68,11 @@ _LOG = logging.getLogger("GeoGraphy.markerlayer")
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class MarkerLayer(GObject.GObject, osmgpsmap.GpsMapLayer):
|
||||
class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
This is the layer used to display the markers.
|
||||
"""
|
||||
|
@ -28,7 +28,7 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import gobject
|
||||
from gi.repository import GObject
|
||||
import operator
|
||||
from math import *
|
||||
|
||||
@ -46,7 +46,8 @@ _LOG = logging.getLogger("maps.messagelayer")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Cairo
|
||||
#from gi.repository import Cairo
|
||||
import cairo
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -61,11 +62,11 @@ from gi.repository import Cairo
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class MessageLayer(gobject.GObject, osmgpsmap.GpsMapLayer):
|
||||
class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
This is the layer used to display messages over the map
|
||||
"""
|
||||
@ -73,7 +74,7 @@ class MessageLayer(gobject.GObject, osmgpsmap.GpsMapLayer):
|
||||
"""
|
||||
Initialize the layer
|
||||
"""
|
||||
gobject.GObject.__init__(self)
|
||||
GObject.GObject.__init__(self)
|
||||
self.message = []
|
||||
self.color = "black"
|
||||
self.font = "Arial"
|
||||
@ -163,5 +164,5 @@ class MessageLayer(gobject.GObject, osmgpsmap.GpsMapLayer):
|
||||
"""
|
||||
return False
|
||||
|
||||
gobject.type_register(MessageLayer)
|
||||
GObject.type_register(MessageLayer)
|
||||
|
||||
|
@ -45,6 +45,7 @@ _LOG = logging.getLogger("maps.osmgps")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -70,7 +71,7 @@ from gui.dialog import ErrorDialog
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
@ -134,9 +135,9 @@ class OsmGps():
|
||||
if 0:
|
||||
self.osm = DummyMapNoGpsPoint()
|
||||
else:
|
||||
self.osm = osmgpsmap.GpsMap(tile_cache=tiles_path,
|
||||
self.osm = osmgpsmap.Map(tile_cache=tiles_path,
|
||||
map_source=constants.map_type[map_type])
|
||||
current_map = osmgpsmap.GpsMapOsd( show_dpad=False, show_zoom=True)
|
||||
current_map = osmgpsmap.MapOsd( show_dpad=False, show_zoom=True)
|
||||
self.end_selection = None
|
||||
self.osm.layer_add(current_map)
|
||||
self.osm.layer_add(DummyLayer())
|
||||
@ -145,7 +146,7 @@ class OsmGps():
|
||||
self.marker_layer = self.add_marker_layer()
|
||||
self.date_layer = self.add_date_layer()
|
||||
self.message_layer = self.add_message_layer()
|
||||
self.cross_map = osmgpsmap.GpsMapOsd( show_crosshair=False)
|
||||
self.cross_map = osmgpsmap.MapOsd( show_crosshair=False)
|
||||
self.set_crosshair(config.get("geography.show_cross"))
|
||||
self.osm.set_center_and_zoom(config.get("geography.center-lat"),
|
||||
config.get("geography.center-lon"),
|
||||
@ -246,9 +247,14 @@ class OsmGps():
|
||||
"""
|
||||
Moving during selection
|
||||
"""
|
||||
current = osmgpsmap.point_new_degrees(0.0, 0.0)
|
||||
osmmap.convert_screen_to_geographic(int(event.x), int(event.y), current)
|
||||
lat, lon = current.get_degrees()
|
||||
# BUG here : how to replace that ?
|
||||
#current = osmgpsmap.MapPoint.new_degrees(0.0, 0.0)
|
||||
current = osmgpsmap.MapPoint.new_degrees(int(event.x), int(event.y))
|
||||
# BUG here : how to replace that ?
|
||||
#osmmap.convert_screen_to_geographic(int(event.x), int(event.y), current)
|
||||
#lat, lon = current.get_degrees()
|
||||
lat = current.rlat
|
||||
lon = current.rlon
|
||||
if self.zone_selection:
|
||||
# We draw a rectangle to show the selected region.
|
||||
layer = self.get_selection_layer()
|
||||
@ -302,10 +308,18 @@ class OsmGps():
|
||||
mouse button 2 : begin zone selection
|
||||
mouse button 3 : call the menu
|
||||
"""
|
||||
lat, lon = self.osm.get_event_location(event).get_degrees()
|
||||
current = osmgpsmap.point_new_degrees(0.0, 0.0)
|
||||
osm.convert_screen_to_geographic(int(event.x), int(event.y), current)
|
||||
lat, lon = current.get_degrees()
|
||||
# BUG here : how to replace that ?
|
||||
#lat, lon = self.osm.get_event_location(event).get_degrees()
|
||||
lat = self.osm.get_event_location(event).rlat
|
||||
lon = self.osm.get_event_location(event).rlon
|
||||
current = osmgpsmap.MapPoint.new_degrees(0.0, 0.0)
|
||||
# BUG here : how to replace that ?
|
||||
#osm.convert_screen_to_geographic(int(event.x), int(event.y), current)
|
||||
current = osm.convert_screen_to_geographic(int(event.x), int(event.y))
|
||||
# BUG here : how to replace that ?
|
||||
#lat, lon = current.get_degrees()
|
||||
lat = current.rlat
|
||||
lon = current.rlon
|
||||
if event.button == 1:
|
||||
if self.end_selection is not None:
|
||||
self.activate_selection_zoom(osm, event)
|
||||
|
@ -51,11 +51,11 @@ _LOG = logging.getLogger("maps.selectionlayer")
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import osmgpsmap
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
except:
|
||||
raise
|
||||
|
||||
class SelectionLayer(GObject.GObject, osmgpsmap.GpsMapLayer):
|
||||
class SelectionLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize thz selection layer
|
||||
|
@ -35,16 +35,17 @@ try :
|
||||
if Gtk.get_major_version() >= 3:
|
||||
OSMGPSMAP = False
|
||||
NEWGTK = True
|
||||
if not NEWGTK:
|
||||
# current osmgpsmap does not support GTK3
|
||||
import osmgpsmap
|
||||
if NEWGTK:
|
||||
# current osmgpsmap support GTK3
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
print "OsmGpsMap version : ", osmgpsmap._version
|
||||
OSMGPSMAP = True
|
||||
if osmgpsmap.__version__ < '0.7.0':
|
||||
if osmgpsmap._version < '1.0':
|
||||
OSMGPSMAP = False
|
||||
import logging
|
||||
logging.warning( _("WARNING: osmgpsmap module not loaded. "
|
||||
"osmgpsmap must be >= 0.7.0. yours is %s") %
|
||||
osmgpsmap.__version__)
|
||||
"osmgpsmap must be >= 1.0. yours is %s") %
|
||||
osmgpsmap._version)
|
||||
except:
|
||||
OSMGPSMAP = False
|
||||
import logging
|
||||
|
@ -33,6 +33,7 @@ Geography for one person and all his descendant
|
||||
from gen.ggettext import gettext as _
|
||||
import operator
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GObject
|
||||
import time
|
||||
import threading
|
||||
@ -520,11 +521,12 @@ class GeoMoves(GeoGraphyView):
|
||||
death = high_date
|
||||
new_list.append([level, plxp, birth, death])
|
||||
pidx = 0;
|
||||
try:
|
||||
color = Gdk.color_parse(color)
|
||||
except:
|
||||
# We have already a Gdk.color
|
||||
pass
|
||||
color = Gdk.color_parse(color)
|
||||
#try:
|
||||
# color = Gdk.color_parse(color)
|
||||
#except:
|
||||
# # We have already a Gdk.color
|
||||
# pass
|
||||
for (level, plxp, birth, death) in sorted(new_list, key=operator.itemgetter(0,2)):
|
||||
if index == int(self._config.get("geography.maximum_generations")):
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user