Geography: better management when closing database
This commit is contained in:
parent
053ed269b3
commit
84d523a109
gramps
@ -178,7 +178,6 @@ register('export.proxy-order',
|
||||
register('geography.center-lon', 0.0)
|
||||
register('geography.lock', False)
|
||||
register('geography.center-lat', 0.0)
|
||||
register('geography.map', "person")
|
||||
register('geography.map_service', 1)
|
||||
register('geography.zoom', 0)
|
||||
register('geography.zoom_when_center', 12)
|
||||
|
@ -34,10 +34,6 @@ from gi.repository import Gtk
|
||||
# the print settings to remember between print sessions
|
||||
PRINT_SETTINGS = None
|
||||
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=maybe-no-member
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# CairoPrintSave class
|
||||
@ -132,6 +128,9 @@ class CairoPrintSave:
|
||||
def on_draw_page(self, operation, context, page_nr):
|
||||
"""Draw a page on a Cairo context.
|
||||
"""
|
||||
dummy_op = operation
|
||||
dummy_ct = context
|
||||
dummy_pg = page_nr
|
||||
ctx = context.get_cairo_context()
|
||||
self.drawfunc(self.parent, ctx)
|
||||
|
||||
@ -141,6 +140,9 @@ class CairoPrintSave:
|
||||
default application is set with gir 3.3.2 (typically evince not
|
||||
installed)!
|
||||
"""
|
||||
dummy_op = operation
|
||||
dummy_ct = context
|
||||
dummy_pr = preview
|
||||
dummy_pa = parent
|
||||
operation.run(Gtk.PrintOperationAction.PREVIEW, None)
|
||||
return False
|
||||
|
||||
|
@ -25,12 +25,13 @@
|
||||
# standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.lib import EventType
|
||||
import os
|
||||
from gramps.gen.const import HOME_DIR
|
||||
import gi
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
from gramps.gen.lib import EventType
|
||||
from gramps.gen.const import HOME_DIR
|
||||
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -39,8 +40,6 @@ from gi.repository import OsmGpsMap as osmgpsmap
|
||||
#-------------------------------------------------------------------------
|
||||
GEOGRAPHY_PATH = os.path.join(HOME_DIR, "maps")
|
||||
|
||||
# pylint: disable=bad-whitespace
|
||||
|
||||
ICONS = {
|
||||
EventType.BIRTH : 'gramps-geo-birth',
|
||||
EventType.DEATH : 'gramps-geo-death',
|
||||
@ -119,4 +118,3 @@ MAP_TYPE = {
|
||||
VIRTUAL_EARTH_HYBRID : osmgpsmap.MapSource_t.VIRTUAL_EARTH_HYBRID,
|
||||
PERSONAL : None,
|
||||
}
|
||||
|
||||
|
@ -25,15 +25,8 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.datelayer")
|
||||
import cairo
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -41,7 +34,7 @@ _LOG = logging.getLogger("maps.datelayer")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
import cairo
|
||||
from gi.repository import GObject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -58,12 +51,17 @@ from gramps.gen.config import config
|
||||
|
||||
try:
|
||||
import gi
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.datelayer")
|
||||
|
||||
class DateLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
@ -117,6 +115,7 @@ class DateLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
Draw the two extreme dates
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
ctx.select_font_face(self.font,
|
||||
cairo.FONT_SLANT_NORMAL,
|
||||
cairo.FONT_WEIGHT_NORMAL)
|
||||
@ -150,7 +149,8 @@ class DateLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
When we press a button.
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(DateLayer)
|
||||
|
||||
|
@ -25,15 +25,7 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.dummylayer")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -46,7 +38,7 @@ _LOG = logging.getLogger("maps.dummylayer")
|
||||
# osmGpsMap
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
from gi.repository import GObject
|
||||
try:
|
||||
import gi
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
@ -54,7 +46,12 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.dummylayer")
|
||||
|
||||
class DummyLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
@ -88,7 +85,8 @@ class DummyLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
Someone press a button
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(DummyLayer)
|
||||
|
||||
|
@ -25,15 +25,7 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.dummynogps")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -46,7 +38,7 @@ _LOG = logging.getLogger("maps.dummynogps")
|
||||
# osmGpsMap
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
from gi.repository import GObject
|
||||
try:
|
||||
import gi
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
@ -54,6 +46,13 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.dummynogps")
|
||||
|
||||
class DummyMapNoGpsPoint(osmgpsmap.Map):
|
||||
""" . """
|
||||
def do_draw_gps_point(self, drawable):
|
||||
@ -61,4 +60,3 @@ class DummyMapNoGpsPoint(osmgpsmap.Map):
|
||||
pass
|
||||
|
||||
GObject.type_register(DummyMapNoGpsPoint)
|
||||
|
||||
|
@ -23,31 +23,31 @@
|
||||
"""
|
||||
This module is the base class for all geography view module
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import logging
|
||||
import gi
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.lib import EventType, Place, PlaceRef, PlaceName
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gen.display.place import displayer as _pd
|
||||
@ -68,30 +68,31 @@ from .placeselection import PlaceSelection
|
||||
from .cairoprint import CairoPrintSave
|
||||
from .libkml import Kml
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.geography")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
_ = glocale.translation.sgettext
|
||||
GEOGRAPHY_PATH = os.path.join(HOME_DIR, "maps")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Functions and variables
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
PLACE_REGEXP = re.compile('<span background="green">(.*)</span>')
|
||||
PLACE_STRING = '<span background="green">%s</span>'
|
||||
|
||||
|
||||
def _get_sign(value):
|
||||
"""
|
||||
return 1 if we have a negative number, 0 in other case
|
||||
@ -101,17 +102,18 @@ def _get_sign(value):
|
||||
else:
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoGraphyView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoGraphyView(OsmGps, NavigationView):
|
||||
"""
|
||||
View for pedigree tree.
|
||||
Displays the ancestors of a selected individual.
|
||||
"""
|
||||
#settings in the config file
|
||||
# settings in the config file
|
||||
CONFIGSETTINGS = (
|
||||
('geography.path', GEOGRAPHY_PATH),
|
||||
|
||||
@ -152,8 +154,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
else:
|
||||
self.tile_path_ok = False
|
||||
try:
|
||||
os.makedirs(tile_path, 0o755) # create dir like mkdir -p
|
||||
except:
|
||||
os.makedirs(tile_path, 0o755) # create dir like mkdir -p
|
||||
except Exception:
|
||||
from gramps.gui.dialog import WarningDialog
|
||||
WarningDialog(_("Tile path"),
|
||||
_("The tile directory doesn't exist anymore:"
|
||||
@ -176,6 +178,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
self.without = 0
|
||||
self.place_list = []
|
||||
self.places_found = []
|
||||
self.place_list_active = []
|
||||
self.place_list_ref = []
|
||||
self.select_fct = None
|
||||
self.geo_mainmap = None
|
||||
self.reloadtiles = None
|
||||
@ -208,18 +212,18 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
self.nbplaces = 0
|
||||
self.nbmarkers = 0
|
||||
self.place_without_coordinates = []
|
||||
self.stop = False
|
||||
|
||||
def font_changed(self):
|
||||
"""
|
||||
The font or the death symbol changed.
|
||||
"""
|
||||
self.build_tree()
|
||||
self.goto_handle(None)
|
||||
|
||||
def add_bookmark(self, menu):
|
||||
def add_bookmark(self, *obj):
|
||||
"""
|
||||
Add the place to the bookmark
|
||||
"""
|
||||
dummy_menu = menu
|
||||
mlist = self.selected_handles()
|
||||
if mlist:
|
||||
self.bookmarks.add(mlist[0])
|
||||
@ -291,14 +295,28 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
|
||||
def clear_view(self):
|
||||
"""
|
||||
We have no database.
|
||||
Clear the map: places, markers, tracks, messages...
|
||||
"""
|
||||
if self.osm is not None:
|
||||
self.place_list = []
|
||||
self.remove_all_markers()
|
||||
self.remove_all_gps()
|
||||
self.remove_all_tracks()
|
||||
self.message_layer.clear_messages()
|
||||
self.lifeway_layer.clear_ways()
|
||||
self.date_layer.clear_dates()
|
||||
self.message_layer.set_font_attributes(None, None, None)
|
||||
self.kml_layer.clear()
|
||||
|
||||
self.place_list = []
|
||||
self.place_list_active = []
|
||||
self.place_list_ref = []
|
||||
self.sort = []
|
||||
self.places_found = []
|
||||
self.place_without_coordinates = []
|
||||
|
||||
# In case we have some methods running while no database.
|
||||
self.stop = True
|
||||
|
||||
def change_db(self, dbse):
|
||||
"""
|
||||
@ -308,7 +326,9 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
is no need to store the database, since we will get the value
|
||||
from self.state.db
|
||||
"""
|
||||
dummy_dbse = dbse
|
||||
if dbse.__class__.__name__ == "DummyDb":
|
||||
return
|
||||
self.stop = False
|
||||
if self.active:
|
||||
self.bookmarks.redraw()
|
||||
if self.osm is not None:
|
||||
@ -362,11 +382,11 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
dummy_data = data
|
||||
config.set("geography.zoom_when_center", int(entry))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Map Menu
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def build_nav_menu(self, osm, event, lat, lon):
|
||||
"""
|
||||
Builds the menu for actions on the map.
|
||||
@ -421,7 +441,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
menu.append(add_item)
|
||||
|
||||
map_name = constants.MAP_TITLE[config.get("geography.map_service")]
|
||||
title = _("Replace '%(map)s' by =>") % {'map' : map_name}
|
||||
title = _("Replace '%(map)s' by =>") % {'map': map_name}
|
||||
add_item = Gtk.MenuItem(label=title)
|
||||
add_item.show()
|
||||
menu.append(add_item)
|
||||
@ -438,7 +458,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
changemap.append(changemapitem)
|
||||
|
||||
reload_text = _("Reload all visible tiles for '%(map)s'.") % {
|
||||
'map' : map_name}
|
||||
'map': map_name}
|
||||
self.reloadtiles = Gtk.MenuItem(label=reload_text)
|
||||
reloadtiles = self.reloadtiles
|
||||
reloadtiles.connect("activate", self.reload_visible_tiles)
|
||||
@ -447,7 +467,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
menu.append(reloadtiles)
|
||||
|
||||
clear_text = _("Clear the '%(map)s' tiles cache.") % {
|
||||
'map' : map_name}
|
||||
'map': map_name}
|
||||
self.clearmap = Gtk.MenuItem(label=clear_text)
|
||||
clearmap = self.clearmap
|
||||
clearmap.connect("activate", self.clear_map,
|
||||
@ -495,11 +515,11 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
config.get("geography.zoom_when_center"))
|
||||
self.save_center(lat, lon)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Markers management
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
def is_there_a_marker_here(self, event, lat, lon):
|
||||
"""
|
||||
Is there a marker at this position ?
|
||||
@ -510,18 +530,18 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
for mark in self.sort:
|
||||
# as we are not precise with our hand, reduce the precision
|
||||
# depending on the zoom.
|
||||
precision = {1 : '%3.0f', 2 : '%3.1f', 3 : '%3.1f', 4 : '%3.1f',
|
||||
5 : '%3.2f', 6 : '%3.2f', 7 : '%3.2f', 8 : '%3.3f',
|
||||
9 : '%3.3f', 10 : '%3.3f', 11 : '%3.3f', 12 : '%3.3f',
|
||||
13 : '%3.3f', 14 : '%3.4f', 15 : '%3.4f', 16 : '%3.4f',
|
||||
17 : '%3.4f', 18 : '%3.4f'
|
||||
precision = {1: '%3.0f', 2: '%3.1f', 3: '%3.1f', 4: '%3.1f',
|
||||
5: '%3.2f', 6: '%3.2f', 7: '%3.2f', 8: '%3.3f',
|
||||
9: '%3.3f', 10: '%3.3f', 11: '%3.3f', 12: '%3.3f',
|
||||
13: '%3.3f', 14: '%3.4f', 15: '%3.4f', 16: '%3.4f',
|
||||
17: '%3.4f', 18: '%3.4f'
|
||||
}.get(config.get("geography.zoom"), '%3.1f')
|
||||
shift = {1 : 5.0, 2 : 5.0, 3 : 3.0,
|
||||
4 : 1.0, 5 : 0.5, 6 : 0.3, 7 : 0.15,
|
||||
8 : 0.06, 9 : 0.03, 10 : 0.015,
|
||||
11 : 0.005, 12 : 0.003, 13 : 0.001,
|
||||
14 : 0.0005, 15 : 0.0003, 16 : 0.0001,
|
||||
17 : 0.0001, 18 : 0.0001
|
||||
shift = {1: 5.0, 2: 5.0, 3: 3.0,
|
||||
4: 1.0, 5: 0.5, 6: 0.3, 7: 0.15,
|
||||
8: 0.06, 9: 0.03, 10: 0.015,
|
||||
11: 0.005, 12: 0.003, 13: 0.001,
|
||||
14: 0.0005, 15: 0.0003, 16: 0.0001,
|
||||
17: 0.0001, 18: 0.0001
|
||||
}.get(config.get("geography.zoom"), 5.0)
|
||||
latp = precision % lat
|
||||
lonp = precision % lon
|
||||
@ -584,7 +604,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
if event_type is not None:
|
||||
value = self.geo_othermap.get(int(event_type), default_image)
|
||||
if differtype: # in case multiple evts
|
||||
value = default_image # we use default icon.
|
||||
value = default_image # we use default icon.
|
||||
self.marker_layer.add_marker((float(lat), float(lon)), value,
|
||||
count, color=color)
|
||||
|
||||
@ -619,8 +639,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
def _append_to_places_list(self, place, evttype, name, lat,
|
||||
longit, descr, year, icontype,
|
||||
gramps_id, place_id, event_id, family_id,
|
||||
color=None
|
||||
):
|
||||
color=None):
|
||||
"""
|
||||
Create a list of places with coordinates.
|
||||
"""
|
||||
@ -635,8 +654,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
self.place_list.append([place, name, evttype, lat,
|
||||
longit, descr, year, icontype,
|
||||
gramps_id, place_id, event_id, family_id,
|
||||
color
|
||||
])
|
||||
color])
|
||||
self.nbmarkers += 1
|
||||
tfa = float(lat)
|
||||
tfb = float(longit)
|
||||
@ -710,7 +728,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
lon = mark[4]
|
||||
icon = mark[7]
|
||||
colour = mark[12]
|
||||
else: # This marker already exists. add info.
|
||||
else: # This marker already exists. add info.
|
||||
count += 1
|
||||
if icon != mark[7]:
|
||||
differtype = True
|
||||
@ -799,7 +817,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
we start at zoom 1 until zoom y ( for this a preference )
|
||||
If all markers are present, continue to zoom.
|
||||
If some markers are missing : return to the zoom - 1
|
||||
The following is too complex. In some case, all markers are not present.
|
||||
The following is too complex. In some case, all markers are not present
|
||||
"""
|
||||
# Select the center of the map and the zoom
|
||||
current = osmgpsmap.MapPoint.new_degrees(self.minlat, self.minlon)
|
||||
@ -839,11 +857,11 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
mnam = _nd.display(mother) if mother else _("Unknown")
|
||||
return (fnam, mnam)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# KML functionalities
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
def load_kml_files(self, obj):
|
||||
"""
|
||||
obj can be an event, a person or a place
|
||||
@ -852,7 +870,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
if media_list:
|
||||
for media_ref in media_list:
|
||||
object_handle = media_ref.get_reference_handle()
|
||||
media_obj = self.dbstate.db.get_media_from_handle(object_handle)
|
||||
media_obj = self.dbstate.db.get_media_from_handle(
|
||||
object_handle)
|
||||
path = media_obj.get_path()
|
||||
dummy_name, extension = os.path.splitext(path)
|
||||
if extension == ".kml":
|
||||
@ -860,11 +879,11 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
if os.path.isfile(path):
|
||||
self.kml_layer.add_kml(path)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Printing functionalities
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def printview(self, *obj):
|
||||
"""
|
||||
Print or save the view that is currently shown
|
||||
@ -884,11 +903,11 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
prt = CairoPrintSave(widthpx, heightpx, self.osm.do_draw, self.osm)
|
||||
prt.run()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Specific functionalities
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def center_here(self, menu, event, lat, lon, mark):
|
||||
"""
|
||||
Center the map at the marker position
|
||||
@ -1062,8 +1081,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
|
||||
def link_place(self, menu, event, lat, lon):
|
||||
"""
|
||||
Link an existing place using longitude and latitude of location centered
|
||||
on the map
|
||||
Link an existing place using longitude and latitude of location
|
||||
centered on the map
|
||||
If we have a place history, we must show all places to avoid an empty
|
||||
place selection in the PlaceSelection.
|
||||
"""
|
||||
@ -1101,8 +1120,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
"You should eiher rename the places or merge them.\n\n"
|
||||
"%(bold_start)s"
|
||||
"I can't proceed with your request"
|
||||
"%(bold_end)s.\n") % {'bold_start' : '<b>',
|
||||
'bold_end' : '</b>',
|
||||
"%(bold_end)s.\n") % {'bold_start': '<b>',
|
||||
'bold_end': '</b>',
|
||||
'title': '<b>' + ptitle + '</b>',
|
||||
'gid': gids},
|
||||
parent=self.uistate.window)
|
||||
@ -1182,8 +1201,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
|
||||
def __link_place(self, parent, plat, plon):
|
||||
"""
|
||||
Link an existing place using longitude and latitude of location centered
|
||||
on the map
|
||||
Link an existing place using longitude and latitude of location
|
||||
centered on the map
|
||||
"""
|
||||
selector = SelectPlace(self.dbstate, self.uistate, [])
|
||||
place = selector.run()
|
||||
@ -1201,11 +1220,11 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
except WindowActiveError:
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Geography preferences
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
def _get_configure_page_funcs(self):
|
||||
"""
|
||||
The function which is used to create the configuration window.
|
||||
@ -1274,25 +1293,26 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
0, self.path_entry,
|
||||
config.get('geography.path'),
|
||||
self.set_tilepath, self.select_tilepath)
|
||||
configdialog.add_text(grid,
|
||||
_('If you have no more space in your file system.'
|
||||
' You can remove all tiles placed in the above'
|
||||
' path.\nBe careful! If you have no internet,'
|
||||
' you\'ll get no map.'),
|
||||
2, line_wrap=False)
|
||||
configdialog.add_text(
|
||||
grid,
|
||||
_('If you have no more space in your file system.'
|
||||
' You can remove all tiles placed in the above'
|
||||
' path.\nBe careful! If you have no internet,'
|
||||
' you\'ll get no map.'),
|
||||
2, line_wrap=False)
|
||||
configdialog.add_slider(grid, _('Zoom used when centering'),
|
||||
3, 'geography.zoom_when_center',
|
||||
(2, 16))
|
||||
configdialog.add_slider(grid, _('The maximum number of places to show'),
|
||||
4, 'geography.max_places',
|
||||
(1000, 10000))
|
||||
configdialog.add_checkbox(grid,
|
||||
_('Use keypad for shortcuts :\nEither we '
|
||||
'choose the + and - from the keypad if we '
|
||||
'select this,\nor we use the characters '
|
||||
'from the keyboard.'),
|
||||
5, 'geography.use-keypad',
|
||||
extra_callback=self.update_shortcuts)
|
||||
3, 'geography.zoom_when_center', (2, 16))
|
||||
configdialog.add_slider(grid,
|
||||
_('The maximum number of places to show'),
|
||||
4, 'geography.max_places', (1000, 10000))
|
||||
configdialog.add_checkbox(
|
||||
grid,
|
||||
_('Use keypad for shortcuts :\nEither we '
|
||||
'choose the + and - from the keypad if we '
|
||||
'select this,\nor we use the characters '
|
||||
'from the keyboard.'),
|
||||
5, 'geography.use-keypad',
|
||||
extra_callback=self.update_shortcuts)
|
||||
label = configdialog.add_text(
|
||||
grid,
|
||||
_('If you want to use a specific map provider,'
|
||||
@ -1309,10 +1329,9 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
start = label.get_text().find("http")
|
||||
end = label.get_text().find("http", start + 1)
|
||||
label.select_region(start, end)
|
||||
url = configdialog.add_entry(grid, _("Personal map"),
|
||||
7, 'geography.personal-map',
|
||||
self.choosen_map,
|
||||
)
|
||||
url = configdialog.add_entry(
|
||||
grid, _("Personal map"),
|
||||
7, 'geography.personal-map', self.choosen_map,)
|
||||
if config.get('geography.personal-map') != "":
|
||||
url.set_text(config.get('geography.personal-map'))
|
||||
return _('The map'), grid
|
||||
@ -1323,18 +1342,14 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
"""
|
||||
map_source = obj[0].get_text()
|
||||
name = constants.TILES_PATH[constants.PERSONAL]
|
||||
print(self.current_map, constants.PERSONAL,
|
||||
map_source, config.get('geography.personal-map'))
|
||||
config.set('geography.personal-map', map_source)
|
||||
self.clear_map(None, name)
|
||||
if map_source == "":
|
||||
print("reset osm")
|
||||
config.set("geography.map_service", constants.OPENSTREETMAP)
|
||||
self.change_map(self.osm, config.get("geography.map_service"))
|
||||
self.reload_tiles()
|
||||
return
|
||||
if map_source != config.get('geography.personal-map'):
|
||||
print("set personal")
|
||||
config.set("geography.map_service", constants.PERSONAL)
|
||||
self.change_new_map(name, map_source)
|
||||
self.reload_tiles()
|
||||
|
@ -25,22 +25,16 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.kmllayer")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
import cairo
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GObject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -57,14 +51,17 @@ from .libkml import Kml
|
||||
|
||||
try:
|
||||
import gi
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
from gi.repository import OsmGpsMap as osmgpsmap
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=no-member
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.kmllayer")
|
||||
|
||||
class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
@ -118,7 +115,8 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
color2 = Gdk.color_parse('blue')
|
||||
for polygons in self.polygons:
|
||||
for polygon in polygons:
|
||||
(name, ptype, color, transparency, points) = polygon
|
||||
(dummy_name, ptype, dummy_color,
|
||||
dummy_transparency, points) = polygon
|
||||
map_points = []
|
||||
for point in points:
|
||||
conv_pt = osmgpsmap.MapPoint.new_degrees(point[0], point[1])
|
||||
@ -155,7 +153,8 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
ctx.restore()
|
||||
for paths in self.paths:
|
||||
for path in paths:
|
||||
(name, ptype, color, transparency, points) = path
|
||||
(dummy_name, ptype, dummy_color,
|
||||
dummy_transparency, points) = path
|
||||
map_points = []
|
||||
for point in points:
|
||||
conv_pt = osmgpsmap.MapPoint.new_degrees(point[0], point[1])
|
||||
@ -185,7 +184,7 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
render the layer
|
||||
"""
|
||||
pass
|
||||
dummy_map = gpsmap
|
||||
|
||||
def do_busy(self):
|
||||
"""
|
||||
@ -197,6 +196,8 @@ class KmlLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
When we press a button.
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(KmlLayer)
|
||||
|
@ -26,19 +26,17 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
from gi.repository import GObject
|
||||
import logging
|
||||
import xml.etree.ElementTree as ETree
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.libkml")
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
|
||||
class Kml(GObject.GObject):
|
||||
"""
|
||||
This is the library used to read kml files
|
||||
@ -72,8 +70,8 @@ class Kml(GObject.GObject):
|
||||
root = self.tree.getroot()
|
||||
self.tag = root.tag.replace('}kml', '}')
|
||||
_LOG.debug("Tag version of kml file %s is %s", kml_file, self.tag)
|
||||
fname, extension = os.path.splitext(kml_file)
|
||||
fdir, self.kmlfile = os.path.split(fname)
|
||||
fname, dummy_extension = os.path.splitext(kml_file)
|
||||
dummy_fdir, self.kmlfile = os.path.split(fname)
|
||||
|
||||
def set_default(self):
|
||||
"""
|
||||
@ -103,7 +101,7 @@ class Kml(GObject.GObject):
|
||||
self.points = []
|
||||
for point in attributes.text.split():
|
||||
try:
|
||||
(longitude, latitude, altitude) = point.split(',')
|
||||
(longitude, latitude, dummy_altitude) = point.split(',')
|
||||
except:
|
||||
(longitude, latitude) = point.split(',')
|
||||
self.points.append((float(latitude), float(longitude)))
|
||||
|
@ -25,16 +25,10 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from math import pi
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.lifeway")
|
||||
from math import pi
|
||||
import cairo
|
||||
from gi.repository import GObject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -42,7 +36,6 @@ _LOG = logging.getLogger("maps.lifeway")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
import cairo
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -63,7 +56,12 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.lifeway")
|
||||
|
||||
class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
@ -122,16 +120,16 @@ class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
for point in lifeway[0]:
|
||||
conv_pt1 = osmgpsmap.MapPoint.new_degrees(point[0], point[1])
|
||||
coord_x1, coord_y1 = gpsmap.convert_geographic_to_screen(
|
||||
conv_pt1)
|
||||
conv_pt1)
|
||||
conv_pt2 = osmgpsmap.MapPoint.new_degrees(point[0]+rds,
|
||||
point[1])
|
||||
coord_x2, coord_y2 = gpsmap.convert_geographic_to_screen(
|
||||
conv_pt2)
|
||||
conv_pt2)
|
||||
coy = abs(coord_y2-coord_y1)
|
||||
conv_pt2 = osmgpsmap.MapPoint.new_degrees(point[0],
|
||||
point[1]+rds)
|
||||
coord_x2, coord_y2 = gpsmap.convert_geographic_to_screen(
|
||||
conv_pt2)
|
||||
conv_pt2)
|
||||
cox = abs(coord_x2-coord_x1)
|
||||
cox = cox if cox > 1.2 else 1.2
|
||||
coy = coy if coy > 1.2 else 1.2
|
||||
@ -192,7 +190,8 @@ class LifeWayLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
When we press a button.
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(LifeWayLayer)
|
||||
|
||||
|
@ -25,10 +25,11 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import time
|
||||
import logging
|
||||
from math import pi as PI
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gdk
|
||||
import time
|
||||
from math import pi as PI
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -36,7 +37,6 @@ from math import pi as PI
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.markerlayer")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -64,8 +64,6 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
This is the layer used to display the markers.
|
||||
@ -122,7 +120,7 @@ class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
if min_interval <= 0: # This to avoid divide by zero
|
||||
min_interval = 0.01
|
||||
_LOG.debug("%s", time.strftime("start drawing : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
for marker in self.markers:
|
||||
# the icon size in 48, so the standard icon size is 0.6 * 48 = 28.8
|
||||
size = 0.6
|
||||
@ -130,16 +128,16 @@ class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
if mark > self.nb_ref_by_places or max_interval > 3:
|
||||
# at maximum, we'll have an icon size = (0.6 + 0.2) * 48 = 38.4
|
||||
size += (0.2 * ((mark - self.nb_ref_by_places)
|
||||
/ max_interval))
|
||||
/ max_interval))
|
||||
else:
|
||||
# at minimum, we'll have an icon size = (0.6 - 0.2) * 48 = 19.2
|
||||
size -= (0.2 * ((self.nb_ref_by_places - mark)
|
||||
/ min_interval))
|
||||
/ min_interval))
|
||||
|
||||
conv_pt = osmgpsmap.MapPoint.new_degrees(float(marker[0][0]),
|
||||
float(marker[0][1]))
|
||||
coord_x, coord_y = gpsmap.convert_geographic_to_screen(conv_pt)
|
||||
if marker[3] == None:
|
||||
if marker[3] is None:
|
||||
# We use the standard icons.
|
||||
ctx.save()
|
||||
ctx.translate(coord_x, coord_y)
|
||||
@ -159,7 +157,7 @@ class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
draw_marker(ctx, float(coord_x), float(coord_y),
|
||||
size, marker[3][1])
|
||||
_LOG.debug("%s", time.strftime("end drawing : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
|
||||
def do_render(self, gpsmap):
|
||||
"""
|
||||
@ -177,11 +175,13 @@ class MarkerLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
When we press a button.
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(MarkerLayer)
|
||||
|
||||
def draw_marker(ctx, x1, y1, size, color):
|
||||
def draw_marker(ctx, x01, y01, size, color):
|
||||
width = 48.0 * size
|
||||
height = width / 2
|
||||
color = Gdk.color_parse(color)
|
||||
@ -189,39 +189,39 @@ def draw_marker(ctx, x1, y1, size, color):
|
||||
float(color.green / 65535.0),
|
||||
float(color.blue / 65535.0),
|
||||
1.0) # transparency
|
||||
ctx.set_line_width (2.0);
|
||||
ctx.move_to(x1, y1)
|
||||
ctx.line_to((x1 + (height/3)), (y1 - height*2))
|
||||
ctx.line_to((x1 - (height/3)), (y1 - height*2))
|
||||
ctx.set_line_width(2.0)
|
||||
ctx.move_to(x01, y01)
|
||||
ctx.line_to((x01 + (height/3)), (y01 - height*2))
|
||||
ctx.line_to((x01 - (height/3)), (y01 - height*2))
|
||||
ctx.fill()
|
||||
ctx.set_source_rgba(1.0, 0.0, 0.0, 0.5)
|
||||
ctx.move_to(x1, y1)
|
||||
ctx.line_to((x1 + (height/3)), (y1 - height*2))
|
||||
ctx.line_to((x1 - (height/3)), (y1 - height*2))
|
||||
ctx.line_to(x1, y1)
|
||||
ctx.move_to(x01, y01)
|
||||
ctx.line_to((x01 + (height/3)), (y01 - height*2))
|
||||
ctx.line_to((x01 - (height/3)), (y01 - height*2))
|
||||
ctx.line_to(x01, y01)
|
||||
ctx.stroke()
|
||||
ctx.save()
|
||||
ctx.translate(x1 + width/4 - (width/4) , y1 - height*2 - (width/4))
|
||||
ctx.translate(x01 + width/4 - (width/4), y01 - height*2 - (width/4))
|
||||
ctx.scale(width / 2., height / 2.)
|
||||
ctx.arc(0., 0., 1., 0., 2 * PI)
|
||||
ctx.fill_preserve()
|
||||
ctx.set_source_rgba(1.0, 0.0, 0.0, 0.5)
|
||||
ctx.set_line_width (2.0);
|
||||
ctx.set_line_width(2.0)
|
||||
ctx.arc(0., 0., 1., 0., 2 * PI)
|
||||
ctx.restore()
|
||||
ctx.stroke();
|
||||
ctx.stroke()
|
||||
ctx.save()
|
||||
ctx.set_source_rgba(float(color.red / 65535.0),
|
||||
float(color.green / 65535.0),
|
||||
float(color.blue / 65535.0),
|
||||
1.0) # transparency
|
||||
#ctx.translate(x1 + width/4 - 12.0 , y1 - height*2 - 12.0)
|
||||
ctx.translate(x1 + width/4 - (width/4) , y1 - height*2 - (width/4))
|
||||
#ctx.translate(x01 + width/4 - 12.0 , y01 - height*2 - 12.0)
|
||||
ctx.translate(x01 + width/4 - (width/4), y01 - height*2 - (width/4))
|
||||
ctx.scale(width / 2., height / 2.)
|
||||
ctx.arc(0., 0., 1., 0., 2 * PI)
|
||||
ctx.fill_preserve()
|
||||
ctx.set_source_rgba(1.0, 0.0, 0.0, 0.5)
|
||||
ctx.set_line_width (2.0);
|
||||
ctx.set_line_width(2.0)
|
||||
ctx.arc(0., 0., 1., 0., 2 * PI)
|
||||
ctx.restore()
|
||||
ctx.stroke();
|
||||
ctx.stroke()
|
||||
|
@ -25,15 +25,8 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.messagelayer")
|
||||
from gi.repository import GObject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -64,9 +57,12 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=no-member
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.messagelayer")
|
||||
|
||||
class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
@ -120,8 +116,8 @@ class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
Draw all the messages
|
||||
"""
|
||||
ctx.save()
|
||||
font_size = "%s %d" % (self.font, self.size)
|
||||
font = Pango.FontDescription(font_size)
|
||||
#font_size = "%s %d" % (self.font, self.size)
|
||||
#font = Pango.FontDescription(font_size)
|
||||
descr = Pango.font_description_from_string(self.font)
|
||||
descr.set_size(self.size * Pango.SCALE)
|
||||
color = Gdk.color_parse(self.color)
|
||||
@ -152,7 +148,7 @@ class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
render the layer
|
||||
"""
|
||||
pass
|
||||
dummy_map = gpsmap
|
||||
|
||||
def do_busy(self):
|
||||
"""
|
||||
@ -164,7 +160,8 @@ class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
When we press a button.
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(MessageLayer)
|
||||
|
||||
|
@ -20,37 +20,41 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import os
|
||||
from math import pi, sin, atanh, floor
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
import time
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.osmgps")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.plugins.lib.maps import constants
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.const import VERSION_DIR
|
||||
from gramps.gen.config import config
|
||||
from gramps.gui.dialog import ErrorDialog
|
||||
from gramps.gen.constfunc import get_env_var
|
||||
from .dummylayer import DummyLayer
|
||||
from .dummynogps import DummyMapNoGpsPoint
|
||||
from .selectionlayer import SelectionLayer
|
||||
@ -59,18 +63,15 @@ from .markerlayer import MarkerLayer
|
||||
from .datelayer import DateLayer
|
||||
from .messagelayer import MessageLayer
|
||||
from .kmllayer import KmlLayer
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from gramps.gen.config import config
|
||||
from gramps.gui.dialog import ErrorDialog
|
||||
from gramps.gen.constfunc import get_env_var
|
||||
from gramps.gen.const import VERSION_DIR
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# OsmGps
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
_LOG = logging.getLogger("maps.osmgps")
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
try:
|
||||
import gi
|
||||
@ -79,10 +80,6 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=maybe-no-member
|
||||
|
||||
def lon2pixel(zoom, longitude, size):
|
||||
"""
|
||||
pixel_x = (2^zoom * size * longitude) / 2PI + (2^zoom * size) / 2
|
||||
@ -125,6 +122,7 @@ class OsmGps:
|
||||
self.current_map = None
|
||||
self.places_found = None
|
||||
self.uistate = uistate
|
||||
self.zoom = config.get("geography.zoom")
|
||||
|
||||
def build_widget(self):
|
||||
"""
|
||||
@ -182,7 +180,7 @@ class OsmGps:
|
||||
except:
|
||||
ErrorDialog(_("Can't create "
|
||||
"tiles cache directory for '%s'.") %
|
||||
constants.MAP_TITLE[map_type],
|
||||
constants.MAP_TITLE[map_type],
|
||||
parent=self.uistate.window)
|
||||
config.set("geography.map_service", map_type)
|
||||
self.current_map = map_type
|
||||
@ -190,12 +188,14 @@ class OsmGps:
|
||||
if 0:
|
||||
self.osm = DummyMapNoGpsPoint()
|
||||
else:
|
||||
if http_proxy:
|
||||
self.osm = osmgpsmap.Map(proxy_uri=http_proxy)
|
||||
if map_type == constants.PERSONAL:
|
||||
self.osm = osmgpsmap.Map(repo_uri=map_source)
|
||||
else:
|
||||
self.osm = osmgpsmap.Map()
|
||||
self.osm = osmgpsmap.Map(
|
||||
map_source=constants.MAP_TYPE[map_type])
|
||||
if http_proxy:
|
||||
self.osm.set_property("proxy_uri", http_proxy)
|
||||
self.osm.set_property("tile_cache", tiles_path)
|
||||
self.osm.set_property("map_source", constants.MAP_TYPE[map_type])
|
||||
self.osm.props.tile_cache = osmgpsmap.MAP_CACHE_AUTO
|
||||
current_map = osmgpsmap.MapOsd(show_dpad=False, show_zoom=True)
|
||||
self.end_selection = None
|
||||
@ -244,19 +244,21 @@ class OsmGps:
|
||||
except:
|
||||
ErrorDialog(_("Can't create "
|
||||
"tiles cache directory for '%s'.") %
|
||||
constants.MAP_TITLE[self.current_map],
|
||||
constants.MAP_TITLE[self.current_map],
|
||||
parent=self.uistate.window)
|
||||
http_proxy = get_env_var('http_proxy')
|
||||
if 0:
|
||||
self.osm = DummyMapNoGpsPoint()
|
||||
else:
|
||||
if http_proxy:
|
||||
self.osm = osmgpsmap.Map(tile_cache=tiles_path,
|
||||
proxy_uri=http_proxy,
|
||||
repo_uri=map_source)
|
||||
map_type = int(config.get("geography.map_service"))
|
||||
if map_type == constants.PERSONAL:
|
||||
self.osm = osmgpsmap.Map(repo_uri=map_source)
|
||||
else:
|
||||
self.osm = osmgpsmap.Map(tile_cache=tiles_path,
|
||||
repo_uri=map_source)
|
||||
self.osm = osmgpsmap.Map(
|
||||
map_source=constants.MAP_TYPE[map_type])
|
||||
if http_proxy:
|
||||
self.osm.set_property("proxy_uri", http_proxy)
|
||||
self.osm.set_property("tile_cache", tiles_path)
|
||||
self.osm.props.tile_cache = osmgpsmap.MAP_CACHE_AUTO
|
||||
current_map = osmgpsmap.MapOsd(show_dpad=False, show_zoom=True)
|
||||
self.end_selection = None
|
||||
@ -327,8 +329,9 @@ class OsmGps:
|
||||
arg is mandatory because this function is also called by
|
||||
the checkbox button
|
||||
"""
|
||||
dummy_arg = arg
|
||||
config.set('geography.use-keypad',
|
||||
self._config.get('geography.use-keypad'))
|
||||
self._config.get('geography.use-keypad'))
|
||||
if config.get('geography.use-keypad'):
|
||||
self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN,
|
||||
Gdk.keyval_from_name("KP_Add"))
|
||||
@ -446,6 +449,7 @@ class OsmGps:
|
||||
"""
|
||||
save the zoom and the position
|
||||
"""
|
||||
dummy_zoom = zoom
|
||||
config.set("geography.zoom", self.osm.props.zoom)
|
||||
self.save_center(self.osm.props.latitude, self.osm.props.longitude)
|
||||
|
||||
@ -462,7 +466,7 @@ class OsmGps:
|
||||
if layer:
|
||||
self.osm.layer_remove(layer)
|
||||
self.selection_layer = self.add_selection_layer()
|
||||
if self.end_selection == None:
|
||||
if self.end_selection is None:
|
||||
self.selection_layer.add_rectangle(self.begin_selection,
|
||||
current)
|
||||
else:
|
||||
@ -498,6 +502,8 @@ class OsmGps:
|
||||
"""
|
||||
Zoom when in zone selection
|
||||
"""
|
||||
dummy_osm = osm
|
||||
dummy_evt = event
|
||||
if self.end_selection is not None:
|
||||
self._autozoom()
|
||||
return True
|
||||
@ -542,28 +548,28 @@ class OsmGps:
|
||||
return mark_selected
|
||||
oldplace = ""
|
||||
_LOG.debug("%s", time.strftime("start is_there_a_place_here : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
for mark in self.places_found:
|
||||
# as we are not precise with our hand, reduce the precision
|
||||
# depending on the zoom.
|
||||
if mark[0] != oldplace:
|
||||
oldplace = mark[0]
|
||||
precision = {
|
||||
1 : '%3.0f', 2 : '%3.1f', 3 : '%3.1f',
|
||||
4 : '%3.1f', 5 : '%3.2f', 6 : '%3.2f',
|
||||
7 : '%3.2f', 8 : '%3.3f', 9 : '%3.3f',
|
||||
10 : '%3.3f', 11 : '%3.3f', 12 : '%3.3f',
|
||||
13 : '%3.3f', 14 : '%3.4f', 15 : '%3.4f',
|
||||
16 : '%3.4f', 17 : '%3.4f', 18 : '%3.4f'
|
||||
}.get(config.get("geography.zoom"), '%3.1f')
|
||||
1 : '%3.0f', 2 : '%3.1f', 3 : '%3.1f',
|
||||
4 : '%3.1f', 5 : '%3.2f', 6 : '%3.2f',
|
||||
7 : '%3.2f', 8 : '%3.3f', 9 : '%3.3f',
|
||||
10 : '%3.3f', 11 : '%3.3f', 12 : '%3.3f',
|
||||
13 : '%3.3f', 14 : '%3.4f', 15 : '%3.4f',
|
||||
16 : '%3.4f', 17 : '%3.4f', 18 : '%3.4f'
|
||||
}.get(config.get("geography.zoom"), '%3.1f')
|
||||
shift = {
|
||||
1 : 5.0, 2 : 5.0, 3 : 3.0,
|
||||
4 : 1.0, 5 : 0.5, 6 : 0.3, 7 : 0.15,
|
||||
8 : 0.06, 9 : 0.03, 10 : 0.015,
|
||||
11 : 0.005, 12 : 0.003, 13 : 0.001,
|
||||
14 : 0.0005, 15 : 0.0003, 16 : 0.0001,
|
||||
17 : 0.0001, 18 : 0.0001
|
||||
}.get(config.get("geography.zoom"), 5.0)
|
||||
1 : 5.0, 2 : 5.0, 3 : 3.0,
|
||||
4 : 1.0, 5 : 0.5, 6 : 0.3, 7 : 0.15,
|
||||
8 : 0.06, 9 : 0.03, 10 : 0.015,
|
||||
11 : 0.005, 12 : 0.003, 13 : 0.001,
|
||||
14 : 0.0005, 15 : 0.0003, 16 : 0.0001,
|
||||
17 : 0.0001, 18 : 0.0001
|
||||
}.get(config.get("geography.zoom"), 5.0)
|
||||
latp = precision % lat
|
||||
lonp = precision % lon
|
||||
mlatp = precision % float(mark[1])
|
||||
@ -578,7 +584,7 @@ class OsmGps:
|
||||
if latok and lonok:
|
||||
mark_selected.append(mark)
|
||||
_LOG.debug("%s", time.strftime(" end is_there_a_place_here : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
return mark_selected
|
||||
|
||||
def build_nav_menu(self, osm, event, lat, lon):
|
||||
|
@ -25,46 +25,38 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
import re
|
||||
import math
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.placeselection")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gi
|
||||
from gi.repository import Gtk
|
||||
try:
|
||||
gi.require_version('GeocodeGlib', '1.0')
|
||||
from gi.repository import GeocodeGlib
|
||||
GEOCODEGLIB = True
|
||||
except:
|
||||
GEOCODEGLIB = False
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.errors import WindowActiveError
|
||||
from gramps.gui.managedwindow import ManagedWindow
|
||||
from gramps.gui.dialog import WarningDialog
|
||||
from .osmgps import OsmGps
|
||||
from gramps.gen.utils.location import get_main_location
|
||||
from gramps.gen.lib import PlaceType
|
||||
from gramps.gen.utils.place import conv_lat_lon
|
||||
from gramps.gen.display.place import displayer as _pd
|
||||
from .osmgps import OsmGps
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
try:
|
||||
gi.require_version('GeocodeGlib', '1.0')
|
||||
from gi.repository import GeocodeGlib
|
||||
GEOCODEGLIB = True
|
||||
except:
|
||||
GEOCODEGLIB = False
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -76,8 +68,13 @@ PLACE_STRING = '<span background="green">%s</span>'
|
||||
GEOCODE_REGEXP = re.compile('<span background="red">(.*)</span>')
|
||||
GEOCODE_STRING = '<span background="red">%s</span>'
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=no-member
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.placeselection")
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -162,8 +159,8 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
self.label2 = Gtk.Label()
|
||||
self.label2.set_markup('<span background="green" foreground="black"'
|
||||
'>%s</span>' %
|
||||
_('The green values in the row correspond '
|
||||
'to the current place values.'))
|
||||
_('The green values in the row correspond '
|
||||
'to the current place values.'))
|
||||
self.label2.set_valign(Gtk.Align.END)
|
||||
self.window.vbox.pack_start(self.label2, False, True, 0)
|
||||
self.window.set_default_size(400, 300)
|
||||
@ -249,7 +246,7 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
place = self.dbstate.db.get_place_from_gramps_id(gramps_id)
|
||||
place_name = place.name.get_value()
|
||||
parent_list = place.get_placeref_list()
|
||||
while len(parent_list) > 0:
|
||||
while parent_list:
|
||||
place = self.dbstate.db.get_place_from_handle(parent_list[0].ref)
|
||||
parent_list = place.get_placeref_list()
|
||||
if int(place.get_type()) == PlaceType.COUNTY:
|
||||
@ -280,7 +277,7 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
# place
|
||||
for entry in self.place_list:
|
||||
if (math.hypot(lat-float(entry[3]),
|
||||
lon-float(entry[4])) <= rds) == True:
|
||||
lon-float(entry[4])) <= rds):
|
||||
# Do we already have this place ? avoid duplicates
|
||||
(country, state, county,
|
||||
place, other) = self.get_location(entry[9])
|
||||
@ -291,7 +288,7 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
latn = place.get_latitude()
|
||||
lonn = place.get_longitude()
|
||||
if latn and lonn:
|
||||
latn, ignore = conv_lat_lon(latn, "0", "D.D8")
|
||||
latn, dummy_ignore = conv_lat_lon(latn, "0", "D.D8")
|
||||
if not latn:
|
||||
if not self.warning:
|
||||
self.close()
|
||||
@ -301,7 +298,7 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
WarningDialog(warn1, warn2, parent=self.uistate.window)
|
||||
self.warning = True
|
||||
continue
|
||||
ignore, lonn = conv_lat_lon("0", lonn, "D.D8")
|
||||
dummy_ignore, lonn = conv_lat_lon("0", lonn, "D.D8")
|
||||
if not lonn:
|
||||
if not self.warning:
|
||||
self.close()
|
||||
@ -312,7 +309,7 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
self.warning = True
|
||||
continue
|
||||
if (math.hypot(lat-float(latn),
|
||||
lon-float(lonn)) <= rds) == True:
|
||||
lon-float(lonn)) <= rds):
|
||||
(country, state, county,
|
||||
place, other) = self.get_location(place.get_gramps_id())
|
||||
if not [country, state, county,
|
||||
@ -324,9 +321,13 @@ class PlaceSelection(ManagedWindow, OsmGps):
|
||||
"""
|
||||
get location values and call the real function : add_place, edit_place
|
||||
"""
|
||||
dummy_obj = obj
|
||||
dummy_col = column
|
||||
dummy_fct = function
|
||||
#TODO : self.plist unsubscriptable
|
||||
self.function(self.plist[index], self.lat, self.lon)
|
||||
|
||||
def untag_text(text, tag):
|
||||
def untag_text(self, text, tag):
|
||||
"""
|
||||
suppress the green or red color tag.
|
||||
if tag = 0 : PLACE_REGEXP
|
||||
|
@ -26,15 +26,7 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from math import pi
|
||||
from gi.repository import GObject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("maps.selectionlayer")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -47,7 +39,7 @@ _LOG = logging.getLogger("maps.selectionlayer")
|
||||
# osmGpsMap
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
from gi.repository import GObject
|
||||
try:
|
||||
import gi
|
||||
gi.require_version('OsmGpsMap', '1.0')
|
||||
@ -55,7 +47,12 @@ try:
|
||||
except:
|
||||
raise
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("maps.selectionlayer")
|
||||
|
||||
class SelectionLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
@ -87,9 +84,9 @@ class SelectionLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
for circle in self.circles:
|
||||
top_left = osmgpsmap.MapPoint.new_degrees(circle[1] + circle[0],
|
||||
circle[2] - circle[0])
|
||||
circle[2] - circle[0])
|
||||
bottom_right = osmgpsmap.MapPoint.new_degrees(circle[1] - circle[0],
|
||||
circle[2] + circle[0])
|
||||
circle[2] + circle[0])
|
||||
center = osmgpsmap.MapPoint.new_degrees(circle[1], circle[2])
|
||||
crd_x, crd_y = gpsmap.convert_geographic_to_screen(top_left)
|
||||
crd_x2, crd_y2 = gpsmap.convert_geographic_to_screen(bottom_right)
|
||||
@ -141,7 +138,8 @@ class SelectionLayer(GObject.GObject, osmgpsmap.MapLayer):
|
||||
"""
|
||||
Someone press a button
|
||||
"""
|
||||
dummy_map = gpsmap
|
||||
dummy_evt = gdkeventbutton
|
||||
return False
|
||||
|
||||
GObject.type_register(SelectionLayer)
|
||||
|
||||
|
@ -23,31 +23,29 @@
|
||||
"""
|
||||
Geography for two persons
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
# -------------------------------------------------------------------------
|
||||
import operator
|
||||
from gi.repository import Gtk
|
||||
from math import hypot
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geoclose")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.lib import EventRoleType, EventType
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.datehandler import displayer, get_date
|
||||
@ -59,13 +57,14 @@ from gramps.plugins.lib.maps import constants
|
||||
from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
from gramps.gui.selectors import SelectorFactory
|
||||
from gramps.gen.utils.db import (get_birth_or_fallback, get_death_or_fallback)
|
||||
from gramps.gui.uimanager import ActionGroup
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("GeoGraphy.geoclose")
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
_UI_DEF = [
|
||||
'''
|
||||
@ -185,11 +184,12 @@ _UI_DEF = [
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoClose(GeoGraphyView):
|
||||
"""
|
||||
The view used to render person map.
|
||||
@ -219,9 +219,9 @@ class GeoClose(GeoGraphyView):
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
GeoGraphyView.__init__(self, _("Have they been able to meet?"),
|
||||
pdata, dbstate, uistate,
|
||||
PersonBookmarks,
|
||||
nav_group)
|
||||
pdata, dbstate, uistate,
|
||||
PersonBookmarks,
|
||||
nav_group)
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.place_list = []
|
||||
@ -316,16 +316,16 @@ class GeoClose(GeoGraphyView):
|
||||
if self.refperson:
|
||||
color = self._config.get('geography.color1')
|
||||
self.message_layer.add_message(
|
||||
_("Reference : %(name)s ( %(birth)s - %(death)s )") % {
|
||||
'name': _nd.display(self.refperson),
|
||||
'birth': self.birth(self.refperson),
|
||||
'death': self.death(self.refperson)})
|
||||
_("Reference : %(name)s ( %(birth)s - %(death)s )") % {
|
||||
'name': _nd.display(self.refperson),
|
||||
'birth': self.birth(self.refperson),
|
||||
'death': self.death(self.refperson)})
|
||||
if indiv1:
|
||||
self.message_layer.add_message(
|
||||
_("The other : %(name)s ( %(birth)s - %(death)s )") % {
|
||||
'name': _nd.display(indiv1),
|
||||
'birth': self.birth(indiv1),
|
||||
'death': self.death(indiv1)})
|
||||
_("The other : %(name)s ( %(birth)s - %(death)s )") % {
|
||||
'name': _nd.display(indiv1),
|
||||
'birth': self.birth(indiv1),
|
||||
'death': self.death(indiv1)})
|
||||
else:
|
||||
self.message_layer.add_message(_("The other person is unknown"))
|
||||
self._createmap(self.refperson, color, self.place_list_ref, True)
|
||||
@ -334,7 +334,7 @@ class GeoClose(GeoGraphyView):
|
||||
self.add_bookmark_from_popup(None, self.refperson_bookmark)
|
||||
else:
|
||||
self.message_layer.add_message(
|
||||
_("You must choose one reference person."))
|
||||
_("You must choose one reference person."))
|
||||
self.message_layer.add_message(_("Go to the person view and select "
|
||||
"the people you want to compare. "
|
||||
"Return to this view and use the"
|
||||
@ -436,8 +436,9 @@ class GeoClose(GeoGraphyView):
|
||||
points.append((startlat, startlon))
|
||||
self.lifeway_layer.add_way(points, color)
|
||||
if reference:
|
||||
self.lifeway_layer.add_way_ref(points, 'orange',
|
||||
float(self._config.get("geography.maximum_meeting_zone")) / 10)
|
||||
self.lifeway_layer.add_way_ref(
|
||||
points, 'orange',
|
||||
float(self._config.get("geography.maximum_meeting_zone")) / 10)
|
||||
return False
|
||||
|
||||
def possible_meeting(self, place_list_ref, place_list_active):
|
||||
@ -449,11 +450,13 @@ class GeoClose(GeoGraphyView):
|
||||
for ref in place_list_ref:
|
||||
for act in place_list_active:
|
||||
if (hypot(float(act[3])-float(ref[3]),
|
||||
float(act[4])-float(ref[4])) <= radius) == True:
|
||||
float(act[4])-float(ref[4])) <= radius):
|
||||
# we are in the meeting zone
|
||||
self.add_marker(None, None, act[3], act[4], act[7], True, 1)
|
||||
self.add_marker(None, None, act[3], act[4], act[7],
|
||||
True, 1)
|
||||
self.all_place_list.append(act)
|
||||
self.add_marker(None, None, ref[3], ref[4], ref[7], True, 1)
|
||||
self.add_marker(None, None, ref[3], ref[4], ref[7],
|
||||
True, 1)
|
||||
self.all_place_list.append(ref)
|
||||
|
||||
def _createmap(self, person, color, place_list, reference):
|
||||
@ -479,11 +482,11 @@ class GeoClose(GeoGraphyView):
|
||||
role = event_ref.get_role()
|
||||
try:
|
||||
date = event.get_date_object().to_calendar(self.cal)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
eyear = str("%04d" % date.get_year()) + \
|
||||
str("%02d" % date.get_month()) + \
|
||||
str("%02d" % date.get_day())
|
||||
str("%02d" % date.get_month()) + \
|
||||
str("%02d" % date.get_day())
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = dbstate.db.get_place_from_handle(place_handle)
|
||||
@ -495,8 +498,8 @@ class GeoClose(GeoGraphyView):
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
descr1 = _("%(eventtype)s : %(name)s") % {
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
# place.get_longitude and place.get_latitude return
|
||||
# one string. We have coordinates when the two values
|
||||
# contains non null string.
|
||||
@ -509,11 +512,10 @@ class GeoClose(GeoGraphyView):
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(
|
||||
place.gramps_id, descr)
|
||||
place.gramps_id, descr)
|
||||
family_list = person.get_family_handle_list()
|
||||
descr1 = " - "
|
||||
for family_hdl in family_list:
|
||||
@ -535,35 +537,35 @@ class GeoClose(GeoGraphyView):
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_ref:
|
||||
event = dbstate.db.get_event_from_handle(
|
||||
event_ref.ref)
|
||||
event_ref.ref)
|
||||
role = event_ref.get_role()
|
||||
if event.get_place_handle():
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = dbstate.db.get_place_from_handle(
|
||||
place_handle)
|
||||
place_handle)
|
||||
if place:
|
||||
longitude = place.get_longitude()
|
||||
latitude = place.get_latitude()
|
||||
latitude, longitude = conv_lat_lon(
|
||||
latitude, longitude, "D.D8")
|
||||
latitude, longitude, "D.D8")
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
eyear = str(
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
|
||||
if longitude and latitude:
|
||||
self._append_to_places_list(descr,
|
||||
evt, _nd.display(person),
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
self._append_to_places_list(
|
||||
descr,
|
||||
evt, _nd.display(person),
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(place.gramps_id, descr)
|
||||
|
||||
@ -650,7 +652,7 @@ class GeoClose(GeoGraphyView):
|
||||
add_item.show()
|
||||
menu.append(add_item)
|
||||
add_item = Gtk.MenuItem(
|
||||
label=_("Choose and bookmark the new reference person"))
|
||||
label=_("Choose and bookmark the new reference person"))
|
||||
add_item.connect("activate", self.select_person)
|
||||
add_item.show()
|
||||
menu.append(add_item)
|
||||
@ -672,18 +674,17 @@ class GeoClose(GeoGraphyView):
|
||||
grid.set_border_width(12)
|
||||
grid.set_column_spacing(6)
|
||||
grid.set_row_spacing(6)
|
||||
configdialog.add_text(grid,
|
||||
_('The meeting zone probability radius.\n'
|
||||
'The colored zone is approximative.\n'
|
||||
'The meeting zone is only shown for the reference person.\n'
|
||||
'The value 9 means about 42 miles or 67 kms.\n'
|
||||
'The value 1 means about 4.6 miles or 7.5 kms.\n'
|
||||
'The value is in tenth of degree.'),
|
||||
1, line_wrap=False)
|
||||
self.config_meeting_slider = configdialog.add_slider(grid,
|
||||
"",
|
||||
2, 'geography.maximum_meeting_zone',
|
||||
(1, 9))
|
||||
configdialog.add_text(
|
||||
grid,
|
||||
_('The meeting zone probability radius.\n'
|
||||
'The colored zone is approximative.\n'
|
||||
'The meeting zone is only shown for the reference person.\n'
|
||||
'The value 9 means about 42 miles or 67 kms.\n'
|
||||
'The value 1 means about 4.6 miles or 7.5 kms.\n'
|
||||
'The value is in tenth of degree.'),
|
||||
1, line_wrap=False)
|
||||
self.config_meeting_slider = configdialog.add_slider(
|
||||
grid, "", 2, 'geography.maximum_meeting_zone', (1, 9))
|
||||
return _('The selection parameters'), grid
|
||||
|
||||
def config_connect(self):
|
||||
@ -691,11 +692,10 @@ class GeoClose(GeoGraphyView):
|
||||
used to monitor changes in the ini file
|
||||
"""
|
||||
self._config.connect('geography.maximum_meeting_zone',
|
||||
self.cb_update_meeting_radius)
|
||||
self.cb_update_meeting_radius)
|
||||
|
||||
def cb_update_meeting_radius(self, client, cnxn_id, entry, data):
|
||||
"""
|
||||
Called when the radius change
|
||||
"""
|
||||
self.goto_handle(handle=None)
|
||||
|
||||
|
@ -23,31 +23,28 @@
|
||||
"""
|
||||
Geography for events
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import operator
|
||||
from gi.repository import Gdk
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
from gi.repository import Gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geoevents")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.lib import EventType
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.datehandler import displayer
|
||||
@ -58,11 +55,14 @@ from gramps.gui.views.bookmarks import EventBookmarks
|
||||
from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
from gramps.gui.utils import ProgressMeter
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
_LOG = logging.getLogger("GeoGraphy.geoevents")
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
_UI_DEF = ['''
|
||||
<placeholder id="CommonGo">
|
||||
@ -78,7 +78,7 @@ _UI_DEF = ['''
|
||||
</section>
|
||||
</placeholder>
|
||||
''',
|
||||
'''
|
||||
'''
|
||||
<section id='CommonEdit' groups='RW'>
|
||||
<item>
|
||||
<attribute name="action">win.PrintView</attribute>
|
||||
@ -86,7 +86,7 @@ _UI_DEF = ['''
|
||||
</item>
|
||||
</section>
|
||||
''',
|
||||
'''
|
||||
'''
|
||||
<section id="AddEditBook">
|
||||
<item>
|
||||
<attribute name="action">win.AddBook</attribute>
|
||||
@ -98,13 +98,14 @@ _UI_DEF = ['''
|
||||
</item>
|
||||
</section>
|
||||
''' % _('Organize Bookmarks'), # Following are the Toolbar items
|
||||
'''
|
||||
'''
|
||||
<placeholder id='CommonNavigation'>
|
||||
<child groups='RO'>
|
||||
<object class="GtkToolButton">
|
||||
<property name="icon-name">go-previous</property>
|
||||
<property name="action-name">win.Back</property>
|
||||
<property name="tooltip_text" translatable="yes">Go to the previous object in the history</property>
|
||||
<property name="tooltip_text"
|
||||
translatable="yes">Go to the previous object in the history</property>
|
||||
<property name="label" translatable="yes">_Back</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
@ -116,7 +117,8 @@ _UI_DEF = ['''
|
||||
<object class="GtkToolButton">
|
||||
<property name="icon-name">go-next</property>
|
||||
<property name="action-name">win.Forward</property>
|
||||
<property name="tooltip_text" translatable="yes">Go to the next object in the history</property>
|
||||
<property name="tooltip_text"
|
||||
translatable="yes">Go to the next object in the history</property>
|
||||
<property name="label" translatable="yes">_Forward</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
@ -126,13 +128,14 @@ _UI_DEF = ['''
|
||||
</child>
|
||||
</placeholder>
|
||||
''',
|
||||
'''
|
||||
'''
|
||||
<placeholder id='BarCommonEdit'>
|
||||
<child groups='RO'>
|
||||
<object class="GtkToolButton">
|
||||
<property name="icon-name">document-print</property>
|
||||
<property name="action-name">win.PrintView</property>
|
||||
<property name="tooltip_text" translatable="yes">Print or save the Map</property>
|
||||
<property name="tooltip_text"
|
||||
translatable="yes">Print or save the Map</property>
|
||||
<property name="label" translatable="yes">Print...</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
@ -147,11 +150,12 @@ _UI_DEF = ['''
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=maybe-no-member
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoEvents(GeoGraphyView):
|
||||
"""
|
||||
The view used to render events map.
|
||||
@ -160,9 +164,9 @@ class GeoEvents(GeoGraphyView):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
self.window_name = _('Events places map')
|
||||
GeoGraphyView.__init__(self, self.window_name,
|
||||
pdata, dbstate, uistate,
|
||||
EventBookmarks,
|
||||
nav_group)
|
||||
pdata, dbstate, uistate,
|
||||
EventBookmarks,
|
||||
nav_group)
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.place_list = []
|
||||
@ -272,9 +276,8 @@ class GeoEvents(GeoGraphyView):
|
||||
person_list = [
|
||||
dbstate.db.get_person_from_handle(ref_handle)
|
||||
for (ref_type, ref_handle) in
|
||||
dbstate.db.find_backlink_handles(event.handle)
|
||||
if ref_type == 'Person'
|
||||
]
|
||||
dbstate.db.find_backlink_handles(event.handle)
|
||||
if ref_type == 'Person']
|
||||
if person_list:
|
||||
for person in person_list:
|
||||
if descr2 == "":
|
||||
@ -287,24 +290,22 @@ class GeoEvents(GeoGraphyView):
|
||||
family_list = [
|
||||
dbstate.db.get_family_from_handle(ref_handle)
|
||||
for (ref_type, ref_handle) in
|
||||
dbstate.db.find_backlink_handles(event.handle)
|
||||
if ref_type == 'Family'
|
||||
]
|
||||
dbstate.db.find_backlink_handles(event.handle)
|
||||
if ref_type == 'Family']
|
||||
if family_list:
|
||||
for family in family_list:
|
||||
father = mother = None
|
||||
hdle = family.get_father_handle()
|
||||
if hdle:
|
||||
father = dbstate.db.get_person_from_handle(
|
||||
hdle)
|
||||
hdle)
|
||||
hdle = family.get_mother_handle()
|
||||
if hdle:
|
||||
mother = dbstate.db.get_person_from_handle(
|
||||
hdle)
|
||||
hdle)
|
||||
descr2 = ("%(father)s - %(mother)s") % {
|
||||
'father': _nd.display(father) if father is not None else "?",
|
||||
'mother': _nd.display(mother) if mother is not None else "?"
|
||||
}
|
||||
'mother': _nd.display(mother) if mother is not None else "?"}
|
||||
else:
|
||||
descr2 = _("incomplete or unreferenced event ?")
|
||||
self._append_to_places_list(descr1, None,
|
||||
@ -313,11 +314,10 @@ class GeoEvents(GeoGraphyView):
|
||||
descr2,
|
||||
eventyear,
|
||||
event.get_type(),
|
||||
None, # person.gramps_id
|
||||
None, # person.gramps_id
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
None
|
||||
)
|
||||
None)
|
||||
|
||||
def _createmap(self, obj):
|
||||
"""
|
||||
@ -354,7 +354,7 @@ class GeoEvents(GeoGraphyView):
|
||||
progress.step()
|
||||
progress.close()
|
||||
elif self.generic_filter:
|
||||
user=self.uistate.viewmanager.user
|
||||
user = self.uistate.viewmanager.user
|
||||
events_list = self.generic_filter.apply(dbstate.db, user=user)
|
||||
progress = ProgressMeter(self.window_name,
|
||||
can_cancel=False,
|
||||
@ -371,14 +371,12 @@ class GeoEvents(GeoGraphyView):
|
||||
event = dbstate.db.get_event_from_handle(obj)
|
||||
self._createmap_for_one_event(event)
|
||||
self.message_layer.add_message(
|
||||
_("Right click on the map and select 'show all events'"
|
||||
" to show all known events with coordinates. "
|
||||
"You can use the history to navigate on the map. "
|
||||
"You can use filtering."))
|
||||
self.sort = sorted(self.place_list,
|
||||
key=operator.itemgetter(3, 4, 6)
|
||||
)
|
||||
if self.nbmarkers > 500: # performance issue. Is it the good value ?
|
||||
_("Right click on the map and select 'show all events'"
|
||||
" to show all known events with coordinates. "
|
||||
"You can use the history to navigate on the map. "
|
||||
"You can use filtering."))
|
||||
self.sort = sorted(self.place_list, key=operator.itemgetter(3, 4, 6))
|
||||
if self.nbmarkers > 500: # performance issue. Is it the good value ?
|
||||
self.no_show_places_in_status_bar = True
|
||||
self._create_markers()
|
||||
|
||||
|
@ -23,47 +23,46 @@
|
||||
"""
|
||||
Geography for two families
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
# -------------------------------------------------------------------------
|
||||
import operator
|
||||
from gi.repository import Gtk
|
||||
from math import hypot
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geofamilyclose")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.lib import EventRoleType, EventType
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.datehandler import displayer
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gen.display.place import displayer as _pd
|
||||
from gramps.gen.utils.place import conv_lat_lon
|
||||
from gramps.gui.views.navigationview import NavigationView
|
||||
from gramps.gui.views.bookmarks import FamilyBookmarks
|
||||
from gramps.plugins.lib.maps import constants
|
||||
from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
from gramps.gui.selectors import SelectorFactory
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
_ = glocale.translation.gettext
|
||||
_LOG = logging.getLogger("GeoGraphy.geofamilyclose")
|
||||
|
||||
_UI_DEF = [
|
||||
'''
|
||||
@ -184,11 +183,11 @@ _UI_DEF = [
|
||||
# pylint: disable=unused-variable
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoFamClose(GeoGraphyView):
|
||||
"""
|
||||
The view used to render family's map.
|
||||
@ -362,11 +361,11 @@ class GeoFamClose(GeoGraphyView):
|
||||
self.add_bookmark_from_popup(None, self.reffamily_bookmark)
|
||||
else:
|
||||
self.message_layer.add_message(
|
||||
_("You must choose one reference family."))
|
||||
_("You must choose one reference family."))
|
||||
self.message_layer.add_message(
|
||||
_("Go to the family view and select "
|
||||
"the families you want to compare. "
|
||||
"Return to this view and use the history."))
|
||||
_("Go to the family view and select "
|
||||
"the families you want to compare. "
|
||||
"Return to this view and use the history."))
|
||||
if family is not None:
|
||||
self._possible_family_meeting(self.reffamily, family)
|
||||
self.uistate.modify_statusbar(self.dbstate)
|
||||
@ -429,9 +428,9 @@ class GeoFamClose(GeoGraphyView):
|
||||
points.append((startlat, startlon))
|
||||
self.lifeway_layer.add_way(points, color)
|
||||
if reference:
|
||||
self.lifeway_layer.add_way_ref(points, 'orange',
|
||||
float(
|
||||
self._config.get("geography.maximum_meeting_zone")) / 10)
|
||||
self.lifeway_layer.add_way_ref(
|
||||
points, 'orange', float(
|
||||
self._config.get("geography.maximum_meeting_zone")) / 10)
|
||||
return False
|
||||
|
||||
def _place_list_for_person(self, person):
|
||||
@ -455,11 +454,13 @@ class GeoFamClose(GeoGraphyView):
|
||||
for ref in self.place_list_ref:
|
||||
for act in self.place_list_active:
|
||||
if (hypot(float(act[3])-float(ref[3]),
|
||||
float(act[4])-float(ref[4])) <= radius) == True:
|
||||
float(act[4])-float(ref[4])) <= radius):
|
||||
# we are in the meeting zone
|
||||
self.add_marker(None, None, act[3], act[4], act[7], True, 1)
|
||||
self.add_marker(None, None, act[3], act[4], act[7],
|
||||
True, 1)
|
||||
self.all_place_list.append(act)
|
||||
self.add_marker(None, None, ref[3], ref[4], ref[7], True, 1)
|
||||
self.add_marker(None, None, ref[3], ref[4], ref[7],
|
||||
True, 1)
|
||||
self.all_place_list.append(ref)
|
||||
|
||||
def _expose_persone_to_family(self, ref_person, family):
|
||||
@ -470,16 +471,16 @@ class GeoFamClose(GeoGraphyView):
|
||||
dbstate = self.dbstate
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(
|
||||
family.get_father_handle())
|
||||
except:
|
||||
family.get_father_handle())
|
||||
except Exception:
|
||||
return
|
||||
if person is None: # family without father ?
|
||||
if person is None: # family without father ?
|
||||
person = dbstate.db.get_person_from_handle(
|
||||
family.get_mother_handle())
|
||||
family.get_mother_handle())
|
||||
if person is not None:
|
||||
family_list = person.get_family_handle_list()
|
||||
if len(family_list) > 0:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
@ -510,10 +511,10 @@ class GeoFamClose(GeoGraphyView):
|
||||
person = None
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(
|
||||
reference.get_father_handle())
|
||||
except:
|
||||
reference.get_father_handle())
|
||||
except Exception:
|
||||
return
|
||||
if person is None: # family without father ?
|
||||
if person is None: # family without father ?
|
||||
handle = reference.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
@ -540,13 +541,13 @@ class GeoFamClose(GeoGraphyView):
|
||||
child_ref_list = fam.get_child_ref_list()
|
||||
if child_ref_list:
|
||||
for child_ref in child_ref_list:
|
||||
child = dbstate.db.get_person_from_handle(child_ref.ref)
|
||||
child = dbstate.db.get_person_from_handle(
|
||||
child_ref.ref)
|
||||
if child:
|
||||
self._expose_persone_to_family(child, family)
|
||||
else:
|
||||
self._expose_persone_to_family(person, family)
|
||||
|
||||
|
||||
def _createmap_for_one_person(self, person, color, place_list, reference):
|
||||
"""
|
||||
Create all markers for each people's event in the database which has
|
||||
@ -563,7 +564,7 @@ class GeoFamClose(GeoGraphyView):
|
||||
role = event_ref.get_role()
|
||||
try:
|
||||
date = event.get_date_object().to_calendar(self.cal)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
eyear = str("%04d" % date.get_year()) + \
|
||||
str("%02d" % date.get_month()) + \
|
||||
@ -579,8 +580,8 @@ class GeoFamClose(GeoGraphyView):
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
descr1 = _("%(eventtype)s : %(name)s") % {
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
# place.get_longitude and place.get_latitude return
|
||||
# one string. We have coordinates when the two values
|
||||
# contains non null string.
|
||||
@ -593,17 +594,16 @@ class GeoFamClose(GeoGraphyView):
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(
|
||||
place.gramps_id, descr)
|
||||
place.gramps_id, descr)
|
||||
family_list = person.get_family_handle_list()
|
||||
descr1 = " - "
|
||||
for family_hdl in family_list:
|
||||
family = self.dbstate.db.get_family_from_handle(family_hdl)
|
||||
if family is not None:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fhandle = family_list[0] # first is primary
|
||||
father = mother = None
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
handle = fam.get_father_handle()
|
||||
@ -619,36 +619,36 @@ class GeoFamClose(GeoGraphyView):
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_ref:
|
||||
event = dbstate.db.get_event_from_handle(
|
||||
event_ref.ref)
|
||||
event_ref.ref)
|
||||
role = event_ref.get_role()
|
||||
if event.get_place_handle():
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = dbstate.db.get_place_from_handle(
|
||||
place_handle)
|
||||
place_handle)
|
||||
if place:
|
||||
longitude = place.get_longitude()
|
||||
latitude = place.get_latitude()
|
||||
latitude, longitude = conv_lat_lon(
|
||||
latitude, longitude, "D.D8")
|
||||
latitude, longitude, "D.D8")
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(
|
||||
event.get_type())
|
||||
event.get_type())
|
||||
eyear = str(
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
|
||||
if longitude and latitude:
|
||||
self._append_to_places_list(descr,
|
||||
evt, _nd.display(person),
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
self._append_to_places_list(
|
||||
descr, evt,
|
||||
_nd.display(person),
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(place.gramps_id, descr)
|
||||
|
||||
@ -668,11 +668,10 @@ class GeoFamClose(GeoGraphyView):
|
||||
person = None
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(
|
||||
family.get_father_handle())
|
||||
except:
|
||||
family.get_father_handle())
|
||||
except Exception:
|
||||
return
|
||||
family_id = family.gramps_id
|
||||
if person is None: # family without father ?
|
||||
if person is None: # family without father ?
|
||||
handle = family.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
@ -691,8 +690,8 @@ class GeoFamClose(GeoGraphyView):
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
comment = _("Father : %(id)s : %(name)s") % {
|
||||
'id': father.gramps_id,
|
||||
'name': _nd.display(father)}
|
||||
'id': father.gramps_id,
|
||||
'name': _nd.display(father)}
|
||||
self._createmap_for_one_person(father, color,
|
||||
place_list, reference)
|
||||
handle = fam.get_mother_handle()
|
||||
@ -700,8 +699,8 @@ class GeoFamClose(GeoGraphyView):
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
comment = _("Mother : %(id)s : %(name)s") % {
|
||||
'id': mother.gramps_id,
|
||||
'name': _nd.display(mother)}
|
||||
'id': mother.gramps_id,
|
||||
'name': _nd.display(mother)}
|
||||
self._createmap_for_one_person(mother, color,
|
||||
place_list, reference)
|
||||
index = 0
|
||||
@ -715,16 +714,14 @@ class GeoFamClose(GeoGraphyView):
|
||||
": %(name)s") % {
|
||||
'id' : child.gramps_id,
|
||||
'index' : index,
|
||||
'name' : _nd.display(child)
|
||||
}
|
||||
'name' : _nd.display(child)}
|
||||
self._createmap_for_one_person(child, color,
|
||||
place_list,
|
||||
reference)
|
||||
else:
|
||||
comment = _("Person : %(id)s %(name)s has no family.") % {
|
||||
'id' : person.gramps_id,
|
||||
'name' : _nd.display(person)
|
||||
}
|
||||
'id' : person.gramps_id,
|
||||
'name' : _nd.display(person)}
|
||||
self._createmap_for_one_person(person, color,
|
||||
place_list, reference)
|
||||
|
||||
@ -838,7 +835,7 @@ class GeoFamClose(GeoGraphyView):
|
||||
add_item.show()
|
||||
menu.append(add_item)
|
||||
add_item = Gtk.MenuItem(
|
||||
label=_("Choose and bookmark the new reference family"))
|
||||
label=_("Choose and bookmark the new reference family"))
|
||||
add_item.connect("activate", self.select_family)
|
||||
add_item.show()
|
||||
menu.append(add_item)
|
||||
@ -860,18 +857,18 @@ class GeoFamClose(GeoGraphyView):
|
||||
grid.set_border_width(12)
|
||||
grid.set_column_spacing(6)
|
||||
grid.set_row_spacing(6)
|
||||
configdialog.add_text(grid,
|
||||
_('The meeting zone probability radius.\n'
|
||||
'The colored zone is approximative.\n'
|
||||
'The meeting zone is only shown for the reference family.\n'
|
||||
'The value 9 means about 42 miles or 67 kms.\n'
|
||||
'The value 1 means about 4.6 miles or 7.5 kms.\n'
|
||||
'The value is in tenth of degree.'),
|
||||
1, line_wrap=False)
|
||||
self.config_meeting_slider = configdialog.add_slider(grid,
|
||||
"",
|
||||
2, 'geography.maximum_meeting_zone',
|
||||
(1, 9))
|
||||
configdialog.add_text(
|
||||
grid,
|
||||
_('The meeting zone probability radius.\n'
|
||||
'The colored zone is approximative.\n'
|
||||
'The meeting zone is only shown for the reference family.\n'
|
||||
'The value 9 means about 42 miles or 67 kms.\n'
|
||||
'The value 1 means about 4.6 miles or 7.5 kms.\n'
|
||||
'The value is in tenth of degree.'),
|
||||
1, line_wrap=False)
|
||||
self.config_meeting_slider = configdialog.add_slider(
|
||||
grid, "",
|
||||
2, 'geography.maximum_meeting_zone', (1, 9))
|
||||
return _('The selection parameters'), grid
|
||||
|
||||
def config_connect(self):
|
||||
@ -879,11 +876,10 @@ class GeoFamClose(GeoGraphyView):
|
||||
used to monitor changes in the ini file
|
||||
"""
|
||||
self._config.connect('geography.maximum_meeting_zone',
|
||||
self.cb_update_meeting_radius)
|
||||
self.cb_update_meeting_radius)
|
||||
|
||||
def cb_update_meeting_radius(self, client, cnxn_id, entry, data):
|
||||
"""
|
||||
Called when the radius change
|
||||
"""
|
||||
self.goto_handle(handle=None)
|
||||
|
||||
|
@ -23,31 +23,28 @@
|
||||
"""
|
||||
Geography for one family
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import operator
|
||||
from gi.repository import Gdk
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
from gi.repository import Gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geofamily")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.lib import EventRoleType, EventType
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.datehandler import displayer
|
||||
@ -57,11 +54,14 @@ from gramps.gen.utils.place import conv_lat_lon
|
||||
from gramps.gui.views.bookmarks import FamilyBookmarks
|
||||
from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("GeoGraphy.geofamily")
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
_UI_DEF = [
|
||||
'''
|
||||
@ -150,11 +150,11 @@ _UI_DEF = [
|
||||
# pylint: disable=unused-variable
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoFamily(GeoGraphyView):
|
||||
"""
|
||||
The view used to render family map.
|
||||
@ -162,9 +162,9 @@ class GeoFamily(GeoGraphyView):
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
GeoGraphyView.__init__(self, _('Family places map'),
|
||||
pdata, dbstate, uistate,
|
||||
FamilyBookmarks,
|
||||
nav_group)
|
||||
pdata, dbstate, uistate,
|
||||
FamilyBookmarks,
|
||||
nav_group)
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.place_list = []
|
||||
@ -218,7 +218,10 @@ class GeoFamily(GeoGraphyView):
|
||||
"""
|
||||
if self.osm is None:
|
||||
return
|
||||
self.build_tree()
|
||||
if self.uistate.get_active('Family'):
|
||||
self._createmap(self.uistate.get_active('Family'))
|
||||
else:
|
||||
self._createmap(self.uistate.get_active('Person'))
|
||||
|
||||
def build_tree(self):
|
||||
"""
|
||||
@ -226,12 +229,7 @@ class GeoFamily(GeoGraphyView):
|
||||
all handling of visibility is now in rebuild_trees, see that for more
|
||||
information.
|
||||
"""
|
||||
if not self.dbstate.is_open():
|
||||
return
|
||||
if self.uistate.get_active('Family'):
|
||||
self._createmap(self.uistate.get_active('Family'))
|
||||
else:
|
||||
self._createmap(self.uistate.get_active('Person'))
|
||||
pass
|
||||
|
||||
def _createpersonmarkers(self, dbstate, person, comment, fam_id):
|
||||
"""
|
||||
@ -258,15 +256,16 @@ class GeoFamily(GeoGraphyView):
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
descr1 = _("%(eventtype)s : %(name)s") % {
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
# place.get_longitude and place.get_latitude return
|
||||
# one string. We have coordinates when the two values
|
||||
# contains non null string.
|
||||
if longitude and latitude:
|
||||
if not self._present_in_places_list(2,
|
||||
str(descr1 + descr + str(evt))):
|
||||
self._append_to_places_list(descr,
|
||||
if not self._present_in_places_list(
|
||||
2, str(descr1 + descr + str(evt))):
|
||||
self._append_to_places_list(
|
||||
descr,
|
||||
str(descr1 + descr + str(evt)),
|
||||
_nd.display(person),
|
||||
latitude, longitude,
|
||||
@ -275,11 +274,10 @@ class GeoFamily(GeoGraphyView):
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
fam_id
|
||||
)
|
||||
fam_id)
|
||||
else:
|
||||
self._append_to_places_without_coord(
|
||||
place.gramps_id, descr)
|
||||
place.gramps_id, descr)
|
||||
family_list = person.get_family_handle_list()
|
||||
for family_hdl in family_list:
|
||||
family = self.dbstate.db.get_family_from_handle(family_hdl)
|
||||
@ -287,13 +285,13 @@ class GeoFamily(GeoGraphyView):
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_ref:
|
||||
event = dbstate.db.get_event_from_handle(
|
||||
event_ref.ref)
|
||||
event_ref.ref)
|
||||
role = event_ref.get_role()
|
||||
if event.get_place_handle():
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = dbstate.db.get_place_from_handle(
|
||||
place_handle)
|
||||
place_handle)
|
||||
if place:
|
||||
longitude = place.get_longitude()
|
||||
latitude = place.get_latitude()
|
||||
@ -311,19 +309,20 @@ class GeoFamily(GeoGraphyView):
|
||||
eyear = event.get_date_object().to_calendar(self.cal).get_year()
|
||||
if longitude and latitude:
|
||||
if not self._present_in_places_list(
|
||||
2, str(descr1 + descr + str(evt))):
|
||||
2, str(descr1 +
|
||||
descr + str(evt))):
|
||||
self._append_to_places_list(
|
||||
descr,
|
||||
str(descr1 + descr + str(evt)),
|
||||
_nd.display(person),
|
||||
latitude, longitude,
|
||||
role, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
family.gramps_id
|
||||
)
|
||||
descr,
|
||||
str(descr1 + descr + str(
|
||||
evt)),
|
||||
_nd.display(person),
|
||||
latitude, longitude,
|
||||
role, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
family.gramps_id)
|
||||
else:
|
||||
self._append_to_places_without_coord(place.gramps_id, descr)
|
||||
|
||||
@ -342,24 +341,24 @@ class GeoFamily(GeoGraphyView):
|
||||
mother = self.dbstate.db.get_person_from_handle(hdl)
|
||||
if father and mother:
|
||||
label = _("%(gramps_id)s : %(father)s and %(mother)s") % {
|
||||
'father' : _nd.display(father),
|
||||
'mother' : _nd.display(mother),
|
||||
'gramps_id' : family.gramps_id,
|
||||
'father': _nd.display(father),
|
||||
'mother': _nd.display(mother),
|
||||
'gramps_id': family.gramps_id,
|
||||
}
|
||||
elif father:
|
||||
label = "%(gramps_id)s : %(father)s" % {
|
||||
'father' : _nd.display(father),
|
||||
'gramps_id' : family.gramps_id,
|
||||
'father': _nd.display(father),
|
||||
'gramps_id': family.gramps_id,
|
||||
}
|
||||
elif mother:
|
||||
label = "%(gramps_id)s : %(mother)s" % {
|
||||
'mother' : _nd.display(mother),
|
||||
'gramps_id' : family.gramps_id,
|
||||
'mother': _nd.display(mother),
|
||||
'gramps_id': family.gramps_id,
|
||||
}
|
||||
else:
|
||||
# No translation for bare gramps_id
|
||||
label = "%(gramps_id)s :" % {
|
||||
'gramps_id' : family.gramps_id,
|
||||
'gramps_id': family.gramps_id,
|
||||
}
|
||||
return label
|
||||
|
||||
@ -369,7 +368,7 @@ class GeoFamily(GeoGraphyView):
|
||||
"""
|
||||
dbstate = self.dbstate
|
||||
self.message_layer.add_message(
|
||||
_("Family places for %s") % self.family_label(family))
|
||||
_("Family places for %s") % self.family_label(family))
|
||||
person = None
|
||||
if family:
|
||||
handle = family.get_father_handle()
|
||||
@ -378,7 +377,7 @@ class GeoFamily(GeoGraphyView):
|
||||
else:
|
||||
return
|
||||
family_id = family.gramps_id
|
||||
if person is None: # family without father ?
|
||||
if person is None: # family without father ?
|
||||
handle = family.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
@ -389,7 +388,7 @@ class GeoFamily(GeoGraphyView):
|
||||
if person is not None:
|
||||
family_list = person.get_family_handle_list()
|
||||
if len(family_list) > 0:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
@ -397,8 +396,8 @@ class GeoFamily(GeoGraphyView):
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
comment = _("Father : %(id)s : %(name)s") % {
|
||||
'id': father.gramps_id,
|
||||
'name': _nd.display(father)}
|
||||
'id': father.gramps_id,
|
||||
'name': _nd.display(father)}
|
||||
self._createpersonmarkers(dbstate, father,
|
||||
comment, family_id)
|
||||
handle = fam.get_mother_handle()
|
||||
@ -406,30 +405,29 @@ class GeoFamily(GeoGraphyView):
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
comment = _("Mother : %(id)s : %(name)s") % {
|
||||
'id': mother.gramps_id,
|
||||
'name': _nd.display(mother)}
|
||||
'id': mother.gramps_id,
|
||||
'name': _nd.display(mother)}
|
||||
self._createpersonmarkers(dbstate, mother,
|
||||
comment, family_id)
|
||||
index = 0
|
||||
child_ref_list = fam.get_child_ref_list()
|
||||
if child_ref_list:
|
||||
for child_ref in child_ref_list:
|
||||
child = dbstate.db.get_person_from_handle(child_ref.ref)
|
||||
child = dbstate.db.get_person_from_handle(
|
||||
child_ref.ref)
|
||||
if child:
|
||||
index += 1
|
||||
comment = _("Child : %(id)s - %(index)d "
|
||||
": %(name)s") % {
|
||||
'id' : child.gramps_id,
|
||||
'index' : index,
|
||||
'name' : _nd.display(child)
|
||||
}
|
||||
'id': child.gramps_id,
|
||||
'index': index,
|
||||
'name': _nd.display(child)}
|
||||
self._createpersonmarkers(dbstate, child,
|
||||
comment, family_id)
|
||||
else:
|
||||
comment = _("Person : %(id)s %(name)s has no family.") % {
|
||||
'id' : person.gramps_id,
|
||||
'name' : _nd.display(person)
|
||||
}
|
||||
'id': person.gramps_id,
|
||||
'name': _nd.display(person)}
|
||||
self._createpersonmarkers(dbstate, person, comment, family_id)
|
||||
|
||||
def _createmap(self, handle):
|
||||
|
@ -23,31 +23,30 @@
|
||||
"""
|
||||
Geography for one person and all his descendant
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
# -------------------------------------------------------------------------
|
||||
import operator
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geomoves")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.lib import EventRoleType, EventType
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.datehandler import displayer
|
||||
@ -58,11 +57,14 @@ from gramps.gui.views.bookmarks import PersonBookmarks
|
||||
from gramps.plugins.lib.maps import constants
|
||||
from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
_LOG = logging.getLogger("GeoGraphy.geomoves")
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
_UI_DEF = [
|
||||
'''
|
||||
@ -171,11 +173,11 @@ _UI_DEF = [
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView : GeoMoves
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoMoves(GeoGraphyView):
|
||||
"""
|
||||
The view used to render all places visited by one person and all
|
||||
@ -206,17 +208,16 @@ class GeoMoves(GeoGraphyView):
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
GeoGraphyView.__init__(self, _("Descendance of the active person."),
|
||||
pdata, dbstate, uistate,
|
||||
PersonBookmarks,
|
||||
nav_group)
|
||||
pdata, dbstate, uistate, PersonBookmarks,
|
||||
nav_group)
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.place_list = []
|
||||
self.place_without_coordinates = []
|
||||
self.minlat = self.maxlat = self.minlon = self.maxlon = 0.0
|
||||
self.started = False
|
||||
self.minyear = 9999
|
||||
self.maxyear = 0
|
||||
self.started = False
|
||||
self.nbplaces = 0
|
||||
self.nbmarkers = 0
|
||||
self.sort = []
|
||||
@ -249,7 +250,7 @@ class GeoMoves(GeoGraphyView):
|
||||
def get_viewtype_stock(self):
|
||||
"""Type of view in category
|
||||
"""
|
||||
return 'geo-show-family'
|
||||
return 'geo-show-family-down'
|
||||
|
||||
def additional_ui(self):
|
||||
"""
|
||||
@ -280,6 +281,10 @@ class GeoMoves(GeoGraphyView):
|
||||
self.remove_all_markers()
|
||||
self.lifeway_layer.clear_ways()
|
||||
self.date_layer.clear_dates()
|
||||
self.message_layer.clear_messages()
|
||||
self.message_layer.set_font_attributes(None, None, None)
|
||||
self.places_found = []
|
||||
self.place_without_coordinates = []
|
||||
active = self.get_active()
|
||||
if active:
|
||||
person = self.dbstate.db.get_person_from_handle(active)
|
||||
@ -334,6 +339,8 @@ class GeoMoves(GeoGraphyView):
|
||||
Create all markers for each people's event in the database which has
|
||||
a lat/lon.
|
||||
"""
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
self.place_list = []
|
||||
dbstate = self.dbstate
|
||||
if person is not None:
|
||||
@ -361,8 +368,8 @@ class GeoMoves(GeoGraphyView):
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
descr1 = _("%(eventtype)s : %(name)s") % {
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
# place.get_longitude and place.get_latitude return
|
||||
# one string. We have coordinates when the two values
|
||||
# contains non null string.
|
||||
@ -375,11 +382,10 @@ class GeoMoves(GeoGraphyView):
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(
|
||||
place.gramps_id, descr)
|
||||
place.gramps_id, descr)
|
||||
family_list = person.get_family_handle_list()
|
||||
descr1 = " - "
|
||||
for family_hdl in family_list:
|
||||
@ -401,38 +407,36 @@ class GeoMoves(GeoGraphyView):
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_ref:
|
||||
event = dbstate.db.get_event_from_handle(
|
||||
event_ref.ref)
|
||||
event_ref.ref)
|
||||
role = event_ref.get_role()
|
||||
if event.get_place_handle():
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = dbstate.db.get_place_from_handle(
|
||||
place_handle)
|
||||
place_handle)
|
||||
if place:
|
||||
longitude = place.get_longitude()
|
||||
latitude = place.get_latitude()
|
||||
latitude, longitude = conv_lat_lon(
|
||||
latitude, longitude, "D.D8")
|
||||
latitude, longitude, "D.D8")
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(
|
||||
event.get_type())
|
||||
evt = EventType(event.get_type())
|
||||
eyear = str(
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
|
||||
if longitude and latitude:
|
||||
self._append_to_places_list(
|
||||
descr,
|
||||
evt,
|
||||
person.gramps_id,
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
descr,
|
||||
evt,
|
||||
person.gramps_id,
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(place.gramps_id, descr)
|
||||
|
||||
@ -460,11 +464,13 @@ class GeoMoves(GeoGraphyView):
|
||||
"""
|
||||
Create all markers for one family : all event's places with a lat/lon.
|
||||
"""
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
dbstate = self.dbstate
|
||||
person = None
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(
|
||||
family.get_father_handle())
|
||||
family.get_father_handle())
|
||||
except:
|
||||
return
|
||||
family_id = family.gramps_id
|
||||
@ -509,6 +515,8 @@ class GeoMoves(GeoGraphyView):
|
||||
"""
|
||||
if maximum generation is not reached, show next level.
|
||||
"""
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
if level < curlevel:
|
||||
return
|
||||
self._prepare_for_one_family(family, level, curlevel+1)
|
||||
@ -525,7 +533,11 @@ class GeoMoves(GeoGraphyView):
|
||||
except:
|
||||
self.markers_by_level[curlevel] = []
|
||||
self.markers_by_level[curlevel].append(person)
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
for family in person.get_family_handle_list():
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
fam = self.dbstate.db.get_family_from_handle(family)
|
||||
self._createmap_for_one_level(fam, level, curlevel)
|
||||
if person not in self.markers_by_level[curlevel]:
|
||||
@ -558,7 +570,7 @@ class GeoMoves(GeoGraphyView):
|
||||
if not person:
|
||||
return
|
||||
self.message_layer.add_message(
|
||||
_("All descendance for %s") % _nd.display(person))
|
||||
_("All descendance for %s") % _nd.display(person))
|
||||
color = Gdk.color_parse(self._config.get('geography.color_base'))
|
||||
GLib.timeout_add(int(self._config.get("geography.generation_interval")),
|
||||
self.animate_moves, 0, person, color)
|
||||
@ -567,6 +579,8 @@ class GeoMoves(GeoGraphyView):
|
||||
"""
|
||||
Animate all moves for one generation.
|
||||
"""
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
self.markers_by_level = dict()
|
||||
self._createmap_for_next_level(person, index, 0)
|
||||
try:
|
||||
@ -619,19 +633,19 @@ class GeoMoves(GeoGraphyView):
|
||||
if level == index:
|
||||
pidx += 1
|
||||
self._createmap_for_one_person(plxp, color)
|
||||
color.red = (float(color.red - (index)*3000)%65535)
|
||||
color.red = (float(color.red - (index)*3000) % 65535)
|
||||
if index % 2:
|
||||
color.green = float((color.green + (index)*3000)%65535)
|
||||
color.green = float((color.green + (index)*3000) % 65535)
|
||||
else:
|
||||
color.blue = float((color.blue + (index)*3000)%65535)
|
||||
color.blue = float((color.blue + (index)*3000) % 65535)
|
||||
self._createmap_for_one_person(person, color)
|
||||
if index < int(self._config.get("geography.maximum_generations")):
|
||||
time_to_wait = int(
|
||||
self._config.get("geography.generation_interval"))
|
||||
self._config.get("geography.generation_interval"))
|
||||
self._create_markers()
|
||||
# process next generation in a few milliseconds
|
||||
GLib.timeout_add(int(time_to_wait), self.animate_moves,
|
||||
index+1, person, color)
|
||||
index+1, person, color)
|
||||
else:
|
||||
self.started = False
|
||||
return False
|
||||
@ -649,7 +663,7 @@ class GeoMoves(GeoGraphyView):
|
||||
# Be sure all markers are sorted by place then dates.
|
||||
for mark in sorted(marks, key=operator.itemgetter(0, 6)):
|
||||
if mark[10] in events:
|
||||
continue # avoid duplicate events
|
||||
continue # avoid duplicate events
|
||||
else:
|
||||
events.append(mark[10])
|
||||
if mark[0] != oldplace:
|
||||
@ -730,19 +744,20 @@ class GeoMoves(GeoGraphyView):
|
||||
grid.set_column_spacing(6)
|
||||
grid.set_row_spacing(6)
|
||||
configdialog.add_text(grid,
|
||||
_('The maximum number of generations.\n'),
|
||||
1, line_wrap=False)
|
||||
_('The maximum number of generations.\n'),
|
||||
1, line_wrap=False)
|
||||
configdialog.add_slider(grid,
|
||||
"",
|
||||
2, 'geography.maximum_generations',
|
||||
(1, 20))
|
||||
"",
|
||||
2, 'geography.maximum_generations',
|
||||
(1, 20))
|
||||
configdialog.add_text(grid,
|
||||
_('Time in milliseconds between drawing two generations.\n'),
|
||||
3, line_wrap=False)
|
||||
_('Time in milliseconds between drawing two'
|
||||
' generations.\n'),
|
||||
3, line_wrap=False)
|
||||
configdialog.add_slider(grid,
|
||||
"",
|
||||
4, 'geography.generation_interval',
|
||||
(500, 3000))
|
||||
"",
|
||||
4, 'geography.generation_interval',
|
||||
(500, 3000))
|
||||
return _('The parameters for moves'), grid
|
||||
|
||||
def config_connect(self):
|
||||
@ -750,11 +765,10 @@ class GeoMoves(GeoGraphyView):
|
||||
used to monitor changes in the ini file
|
||||
"""
|
||||
self._config.connect('geography.maximum_generations',
|
||||
self._maximum_generations)
|
||||
self._maximum_generations)
|
||||
|
||||
def _maximum_generations(self, client, cnxn_id, entry, data):
|
||||
"""
|
||||
Called when the number of nomber of generations change
|
||||
"""
|
||||
self.goto_handle(handle=None)
|
||||
|
||||
|
@ -23,32 +23,29 @@
|
||||
"""
|
||||
Geography for one person
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import operator
|
||||
from gi.repository import Gdk
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geoperson")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GLib
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.lib import EventRoleType, EventType
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.datehandler import displayer
|
||||
@ -59,11 +56,14 @@ from gramps.gui.views.bookmarks import PersonBookmarks
|
||||
from gramps.plugins.lib.maps import constants
|
||||
from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
_LOG = logging.getLogger("GeoGraphy.geoperson")
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
_UI_DEF = [
|
||||
'''
|
||||
@ -172,11 +172,11 @@ _UI_DEF = [
|
||||
# pylint: disable=unused-variable
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoPerson(GeoGraphyView):
|
||||
"""
|
||||
The view used to render person map.
|
||||
@ -210,9 +210,9 @@ class GeoPerson(GeoGraphyView):
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
GeoGraphyView.__init__(self, _("Person places map"),
|
||||
pdata, dbstate, uistate,
|
||||
PersonBookmarks,
|
||||
nav_group)
|
||||
pdata, dbstate, uistate,
|
||||
PersonBookmarks,
|
||||
nav_group)
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.place_list = []
|
||||
@ -278,17 +278,15 @@ class GeoPerson(GeoGraphyView):
|
||||
all handling of visibility is now in rebuild_trees, see that for more
|
||||
information.
|
||||
"""
|
||||
if not self.dbstate.is_open():
|
||||
return
|
||||
active = self.get_active()
|
||||
self._createmap(None)
|
||||
self.uistate.modify_statusbar(self.dbstate)
|
||||
pass
|
||||
|
||||
def animate(self, menu, marks, index, stepyear):
|
||||
"""
|
||||
Create all movements for the people's event.
|
||||
Yes, you can see the person moving.
|
||||
"""
|
||||
if self.stop: # no more database. stop to work
|
||||
return
|
||||
if len(marks) == 0:
|
||||
self.already_started = False
|
||||
return False
|
||||
@ -309,7 +307,7 @@ class GeoPerson(GeoGraphyView):
|
||||
max_lon_lat = float(self._config.get("geography.maximum_lon_lat")) / 10
|
||||
if stepyear < 9000:
|
||||
if ((abs(float(endlat) - float(startlat)) > max_lon_lat) or
|
||||
(abs(float(endlon) - float(startlon)) > max_lon_lat)):
|
||||
(abs(float(endlon) - float(startlon)) > max_lon_lat)):
|
||||
self.large_move = True
|
||||
stepyear = 9000
|
||||
else:
|
||||
@ -348,8 +346,8 @@ class GeoPerson(GeoGraphyView):
|
||||
# in this case, stepyear is >= 9000
|
||||
# large move means longitude or latitude differences greater than
|
||||
# geography.maximum_lon_lat degrees.
|
||||
GLib.timeout_add(int(self._config.get("geography.speed")), self.animate,
|
||||
menu, marks, i, stepyear)
|
||||
GLib.timeout_add(int(self._config.get("geography.speed")),
|
||||
self.animate, menu, marks, i, stepyear)
|
||||
return False
|
||||
|
||||
def _createmap(self, active):
|
||||
@ -383,7 +381,7 @@ class GeoPerson(GeoGraphyView):
|
||||
# For each event, if we have a place, set a marker.
|
||||
self.load_kml_files(person)
|
||||
self.message_layer.add_message(
|
||||
_("Person places for %s") % _nd.display(person))
|
||||
_("Person places for %s") % _nd.display(person))
|
||||
for event_ref in person.get_event_ref_list():
|
||||
if not event_ref:
|
||||
continue
|
||||
@ -391,7 +389,7 @@ class GeoPerson(GeoGraphyView):
|
||||
self.load_kml_files(event)
|
||||
role = event_ref.get_role()
|
||||
eyear = str(
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
|
||||
place_handle = event.get_place_handle()
|
||||
@ -405,8 +403,8 @@ class GeoPerson(GeoGraphyView):
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
descr1 = _("%(eventtype)s : %(name)s") % {
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
'eventtype': evt,
|
||||
'name': _nd.display(person)}
|
||||
self.load_kml_files(place)
|
||||
# place.get_longitude and place.get_latitude return
|
||||
# one string. We have coordinates when the two values
|
||||
@ -420,16 +418,15 @@ class GeoPerson(GeoGraphyView):
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(
|
||||
place.gramps_id, descr)
|
||||
place.gramps_id, descr)
|
||||
family_list = person.get_family_handle_list()
|
||||
for family_hdl in family_list:
|
||||
family = self.dbstate.db.get_family_from_handle(family_hdl)
|
||||
if family is not None:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
@ -446,14 +443,14 @@ class GeoPerson(GeoGraphyView):
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_ref:
|
||||
event = dbstate.db.get_event_from_handle(
|
||||
event_ref.ref)
|
||||
event_ref.ref)
|
||||
self.load_kml_files(event)
|
||||
role = event_ref.get_role()
|
||||
if event.get_place_handle():
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = dbstate.db.get_place_from_handle(
|
||||
place_handle)
|
||||
place_handle)
|
||||
if place:
|
||||
longitude = place.get_longitude()
|
||||
latitude = place.get_latitude()
|
||||
@ -464,21 +461,21 @@ class GeoPerson(GeoGraphyView):
|
||||
descr = _pd.display(dbstate.db, place)
|
||||
evt = EventType(event.get_type())
|
||||
eyear = str(
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
"%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \
|
||||
str("%02d" % event.get_date_object().to_calendar(self.cal).get_day())
|
||||
self.load_kml_files(place)
|
||||
if longitude and latitude:
|
||||
self._append_to_places_list(descr,
|
||||
evt, _nd.display(person),
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role
|
||||
)
|
||||
self._append_to_places_list(
|
||||
descr,
|
||||
evt, _nd.display(person),
|
||||
latitude, longitude,
|
||||
descr1, eyear,
|
||||
event.get_type(),
|
||||
person.gramps_id,
|
||||
place.gramps_id,
|
||||
event.gramps_id,
|
||||
role)
|
||||
else:
|
||||
self._append_to_places_without_coord(place.gramps_id, descr)
|
||||
|
||||
@ -605,27 +602,21 @@ class GeoPerson(GeoGraphyView):
|
||||
grid.set_border_width(12)
|
||||
grid.set_column_spacing(6)
|
||||
grid.set_row_spacing(6)
|
||||
configdialog.add_text(grid,
|
||||
_('Animation speed in milliseconds (big value means slower)'),
|
||||
1, line_wrap=False)
|
||||
configdialog.add_slider(grid,
|
||||
"",
|
||||
2, 'geography.speed',
|
||||
(100, 1000))
|
||||
configdialog.add_text(
|
||||
grid,
|
||||
_('Animation speed in milliseconds (big value means slower)'),
|
||||
1, line_wrap=False)
|
||||
configdialog.add_slider(grid, "", 2, 'geography.speed', (100, 1000))
|
||||
configdialog.add_text(
|
||||
grid,
|
||||
_('How many steps between two markers when we are on large move ?'),
|
||||
3, line_wrap=False)
|
||||
configdialog.add_slider(grid,
|
||||
"",
|
||||
4, 'geography.steps',
|
||||
(10, 100))
|
||||
configdialog.add_text(grid,
|
||||
_('The minimum latitude/longitude to select large move.\n'
|
||||
'The value is in tenth of degree.'),
|
||||
5, line_wrap=False)
|
||||
configdialog.add_slider(grid,
|
||||
"",
|
||||
6, 'geography.maximum_lon_lat',
|
||||
(5, 50))
|
||||
configdialog.add_slider(grid, "", 4, 'geography.steps', (10, 100))
|
||||
configdialog.add_text(
|
||||
grid,
|
||||
_('The minimum latitude/longitude to select large move.\n'
|
||||
'The value is in tenth of degree.'),
|
||||
5, line_wrap=False)
|
||||
configdialog.add_slider(grid, "", 6, 'geography.maximum_lon_lat',
|
||||
(5, 50))
|
||||
return _('The animation parameters'), grid
|
||||
|
@ -23,33 +23,30 @@
|
||||
"""
|
||||
Geography for places
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import time
|
||||
import operator
|
||||
from gi.repository import Gdk
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
from gi.repository import Gtk
|
||||
from collections import defaultdict
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger("GeoGraphy.geoplaces")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.lib import EventType
|
||||
from gramps.gen.lib import PlaceType
|
||||
from gramps.gen.config import config
|
||||
@ -60,11 +57,14 @@ from gramps.plugins.lib.maps.geography import GeoGraphyView
|
||||
from gramps.plugins.lib.maps import constants
|
||||
from gramps.gui.utils import ProgressMeter
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
KEY_TAB = Gdk.KEY_Tab
|
||||
_ = glocale.translation.gettext
|
||||
_LOG = logging.getLogger("GeoGraphy.geoplaces")
|
||||
|
||||
_UI_DEF = [
|
||||
'''
|
||||
@ -154,11 +154,12 @@ _UI_DEF = [
|
||||
# pylint: disable=unused-variable
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# GeoView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class GeoPlaces(GeoGraphyView):
|
||||
"""
|
||||
The view used to render places map.
|
||||
@ -207,9 +208,9 @@ class GeoPlaces(GeoGraphyView):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
self.window_name = _('Places map')
|
||||
GeoGraphyView.__init__(self, self.window_name,
|
||||
pdata, dbstate, uistate,
|
||||
PlaceBookmarks,
|
||||
nav_group)
|
||||
pdata, dbstate, uistate,
|
||||
PlaceBookmarks,
|
||||
nav_group)
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.place_list = []
|
||||
@ -270,7 +271,11 @@ class GeoPlaces(GeoGraphyView):
|
||||
if self.osm is None:
|
||||
return
|
||||
self.places_found = []
|
||||
self.build_tree()
|
||||
active = self.uistate.get_active('Place')
|
||||
if active:
|
||||
self._createmap(active)
|
||||
else:
|
||||
self._createmap(None)
|
||||
|
||||
def show_all_places(self, menu, event, lat, lon):
|
||||
"""
|
||||
@ -286,13 +291,7 @@ class GeoPlaces(GeoGraphyView):
|
||||
all handling of visibility is now in rebuild_trees, see that for more
|
||||
information.
|
||||
"""
|
||||
if not self.dbstate.is_open():
|
||||
return
|
||||
active = self.uistate.get_active('Place')
|
||||
if active:
|
||||
self._createmap(active)
|
||||
else:
|
||||
self._createmap(None)
|
||||
pass
|
||||
|
||||
def _create_one_place(self, place):
|
||||
"""
|
||||
@ -316,18 +315,17 @@ class GeoPlaces(GeoGraphyView):
|
||||
try:
|
||||
colour = (str(place.get_type()),
|
||||
self.plc_custom_color[str(place.get_type())])
|
||||
except:
|
||||
except Exception:
|
||||
colour = self.plc_color[PlaceType.CUSTOM + 1]
|
||||
self._append_to_places_list(descr, None, "",
|
||||
latitude, longitude,
|
||||
None, None,
|
||||
EventType.UNKNOWN,
|
||||
None, # person.gramps_id
|
||||
None, # person.gramps_id
|
||||
place.gramps_id,
|
||||
None, # event.gramps_id
|
||||
None, # family.gramps_id
|
||||
color=colour
|
||||
)
|
||||
None, # event.gramps_id
|
||||
None, # family.gramps_id
|
||||
color=colour)
|
||||
|
||||
def _createmap(self, place_x):
|
||||
"""
|
||||
@ -386,7 +384,7 @@ class GeoPlaces(GeoGraphyView):
|
||||
# base "villes de france" : 38101 places :
|
||||
# createmap : 8'50"; create_markers : 0'07" with pixbuf optimization
|
||||
# base "villes de france" : 38101 places :
|
||||
# gramps 3.4 python 2.7 (draw_markers are estimated when moving the map)
|
||||
# gramps 3.4 python 2.7 (draw_markers is estimated when moving the map)
|
||||
# 38101 places: createmap: 04'32";
|
||||
# create_markers: 0'04"; draw markers: N/A :: 0'03"
|
||||
# 65598 places: createmap: 10'03";
|
||||
@ -397,13 +395,13 @@ class GeoPlaces(GeoGraphyView):
|
||||
# 65598 places: createmap: 08'48";
|
||||
# create_markers: 0'01"; draw markers: 0'07"
|
||||
_LOG.debug("%s", time.strftime("start createmap : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
self.custom_places()
|
||||
if self.show_all:
|
||||
self.show_all = False
|
||||
try:
|
||||
places_handle = dbstate.db.get_place_handles()
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
progress = ProgressMeter(self.window_name,
|
||||
can_cancel=False,
|
||||
@ -416,7 +414,7 @@ class GeoPlaces(GeoGraphyView):
|
||||
progress.step()
|
||||
progress.close()
|
||||
elif self.generic_filter:
|
||||
user=self.uistate.viewmanager.user
|
||||
user = self.uistate.viewmanager.user
|
||||
place_list = self.generic_filter.apply(dbstate.db, user=user)
|
||||
progress = ProgressMeter(self.window_name,
|
||||
can_cancel=False,
|
||||
@ -430,55 +428,53 @@ class GeoPlaces(GeoGraphyView):
|
||||
progress.close()
|
||||
# reset completely the filter. It will be recreated next time.
|
||||
self.generic_filter = None
|
||||
elif place_x != None:
|
||||
elif place_x is not None:
|
||||
place = dbstate.db.get_place_from_handle(place_x)
|
||||
self._create_one_place(place)
|
||||
self.message_layer.add_message(
|
||||
_("Right click on the map and select 'show all places'"
|
||||
" to show all known places with coordinates. "
|
||||
"You can change the markers color depending on place type. "
|
||||
"You can use filtering."))
|
||||
_("Right click on the map and select 'show all places'"
|
||||
" to show all known places with coordinates. "
|
||||
"You can change the markers color depending on place type. "
|
||||
"You can use filtering."))
|
||||
if place.get_latitude() != "" and place.get_longitude() != "":
|
||||
latitude, longitude = conv_lat_lon(place.get_latitude(),
|
||||
place.get_longitude(),
|
||||
"D.D8")
|
||||
if latitude and longitude:
|
||||
zwc = int(config.get("geography.zoom_when_center"))
|
||||
self.osm.set_center_and_zoom(float(latitude),
|
||||
float(longitude),
|
||||
int(config.get(
|
||||
"geography.zoom_when_center")))
|
||||
zwc)
|
||||
else:
|
||||
self.message_layer.add_message(
|
||||
_("Right click on the map and select 'show all places'"
|
||||
" to show all known places with coordinates. "
|
||||
"You can use the history to navigate on the map. "
|
||||
"You can change the markers color depending on place type. "
|
||||
"You can use filtering."))
|
||||
_("Right click on the map and select 'show all places'"
|
||||
" to show all known places with coordinates. "
|
||||
"You can use the history to navigate on the map. "
|
||||
"You can change the markers color depending on place type. "
|
||||
"You can use filtering."))
|
||||
_LOG.debug(" stop createmap.")
|
||||
_LOG.debug("%s", time.strftime("begin sort : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
self.sort = sorted(self.place_list,
|
||||
key=operator.itemgetter(0)
|
||||
)
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
self.sort = sorted(self.place_list, key=operator.itemgetter(0))
|
||||
_LOG.debug("%s", time.strftime(" end sort : "
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
if self.nbmarkers > 500: # performance issue. Is it the good value ?
|
||||
"%a %d %b %Y %H:%M:%S", time.gmtime()))
|
||||
if self.nbmarkers > 500: # performance issue. Is it the good value ?
|
||||
self.message_layer.add_message(
|
||||
_("The place name in the status bar is disabled."))
|
||||
_("The place name in the status bar is disabled."))
|
||||
self.no_show_places_in_status_bar = True
|
||||
if self.nbplaces >= self._config.get("geography.max_places"):
|
||||
self.message_layer.set_font_attributes(None, None, "red")
|
||||
self.message_layer.add_message(
|
||||
_("The maximum number of places is reached (%d).") %
|
||||
self._config.get("geography.max_places"))
|
||||
_("The maximum number of places is reached (%d).") %
|
||||
self._config.get("geography.max_places"))
|
||||
self.message_layer.add_message(
|
||||
_("Some information are missing."))
|
||||
_("Some information are missing."))
|
||||
self.message_layer.add_message(
|
||||
_("Please, use filtering to reduce this number."))
|
||||
_("Please, use filtering to reduce this number."))
|
||||
self.message_layer.add_message(
|
||||
_("You can modify this value in the geography option."))
|
||||
_("You can modify this value in the geography option."))
|
||||
self.message_layer.add_message(
|
||||
_("In this case, it may take time to show all markers."))
|
||||
_("In this case, it may take time to show all markers."))
|
||||
|
||||
self._create_markers()
|
||||
|
||||
@ -589,82 +585,59 @@ class GeoPlaces(GeoGraphyView):
|
||||
grid.set_border_width(12)
|
||||
grid.set_column_spacing(6)
|
||||
grid.set_row_spacing(6)
|
||||
configdialog.add_color(grid,
|
||||
_("Unknown"),
|
||||
1, 'geography.color.unknown', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Custom"),
|
||||
2, 'geography.color.custom', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Locality"),
|
||||
3, 'geography.color.locality', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Street"),
|
||||
4, 'geography.color.street', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Neighborhood"),
|
||||
5, 'geography.color.neighborhood', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Borough"),
|
||||
6, 'geography.color.borough', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Village"),
|
||||
7, 'geography.color.village', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Hamlet"),
|
||||
8, 'geography.color.hamlet', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Farm"),
|
||||
9, 'geography.color.farm', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Building"),
|
||||
10, 'geography.color.building', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Number"),
|
||||
11, 'geography.color.number', col=1)
|
||||
configdialog.add_color(grid,
|
||||
_("Country"),
|
||||
1, 'geography.color.country', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("State"),
|
||||
2, 'geography.color.state', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("County"),
|
||||
3, 'geography.color.county', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("Province"),
|
||||
4, 'geography.color.province', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("Region"),
|
||||
5, 'geography.color.region', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("Department"),
|
||||
6, 'geography.color.department', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("District"),
|
||||
7, 'geography.color.district', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("Parish"),
|
||||
8, 'geography.color.parish', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("City"),
|
||||
9, 'geography.color.city', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("Town"),
|
||||
10, 'geography.color.town', col=4)
|
||||
configdialog.add_color(grid,
|
||||
_("Municipality"),
|
||||
11, 'geography.color.municipality', col=4)
|
||||
configdialog.add_color(grid, _("Unknown"),
|
||||
1, 'geography.color.unknown', col=1)
|
||||
configdialog.add_color(grid, _("Custom"),
|
||||
2, 'geography.color.custom', col=1)
|
||||
configdialog.add_color(grid, _("Locality"),
|
||||
3, 'geography.color.locality', col=1)
|
||||
configdialog.add_color(grid, _("Street"),
|
||||
4, 'geography.color.street', col=1)
|
||||
configdialog.add_color(grid, _("Neighborhood"),
|
||||
5, 'geography.color.neighborhood', col=1)
|
||||
configdialog.add_color(grid, _("Borough"),
|
||||
6, 'geography.color.borough', col=1)
|
||||
configdialog.add_color(grid, _("Village"),
|
||||
7, 'geography.color.village', col=1)
|
||||
configdialog.add_color(grid, _("Hamlet"),
|
||||
8, 'geography.color.hamlet', col=1)
|
||||
configdialog.add_color(grid, _("Farm"),
|
||||
9, 'geography.color.farm', col=1)
|
||||
configdialog.add_color(grid, _("Building"),
|
||||
10, 'geography.color.building', col=1)
|
||||
configdialog.add_color(grid, _("Number"),
|
||||
11, 'geography.color.number', col=1)
|
||||
configdialog.add_color(grid, _("Country"),
|
||||
1, 'geography.color.country', col=4)
|
||||
configdialog.add_color(grid, _("State"),
|
||||
2, 'geography.color.state', col=4)
|
||||
configdialog.add_color(grid, _("County"),
|
||||
3, 'geography.color.county', col=4)
|
||||
configdialog.add_color(grid, _("Province"),
|
||||
4, 'geography.color.province', col=4)
|
||||
configdialog.add_color(grid, _("Region"),
|
||||
5, 'geography.color.region', col=4)
|
||||
configdialog.add_color(grid, _("Department"),
|
||||
6, 'geography.color.department', col=4)
|
||||
configdialog.add_color(grid, _("District"),
|
||||
7, 'geography.color.district', col=4)
|
||||
configdialog.add_color(grid, _("Parish"),
|
||||
8, 'geography.color.parish', col=4)
|
||||
configdialog.add_color(grid, _("City"),
|
||||
9, 'geography.color.city', col=4)
|
||||
configdialog.add_color(grid, _("Town"),
|
||||
10, 'geography.color.town', col=4)
|
||||
configdialog.add_color(grid, _("Municipality"),
|
||||
11, 'geography.color.municipality', col=4)
|
||||
self.custom_places()
|
||||
if len(self.plc_custom_color) > 0:
|
||||
configdialog.add_text(grid, _("Custom places name"), 12)
|
||||
start = 13
|
||||
for color in self.plc_custom_color.keys():
|
||||
cust_col = 'geography.color.' + color.lower()
|
||||
row = start if start % 2 else start -1
|
||||
column = 1 if start %2 else 4
|
||||
configdialog.add_color(grid, color,
|
||||
row, cust_col, col=column)
|
||||
row = start if start % 2 else start - 1
|
||||
column = 1 if start % 2 else 4
|
||||
configdialog.add_color(grid, color, row, cust_col, col=column)
|
||||
start += 1
|
||||
return _('The places marker color'), grid
|
||||
|
||||
@ -679,7 +652,7 @@ class GeoPlaces(GeoGraphyView):
|
||||
cust_col = 'geography.color.' + str(place.get_type()).lower()
|
||||
try:
|
||||
color = self._config.get(cust_col)
|
||||
except:
|
||||
except Exception:
|
||||
color = '#008b00'
|
||||
self._config.register(cust_col, color)
|
||||
if str(place.get_type()) not in self.plc_custom_color.keys():
|
||||
|
Loading…
x
Reference in New Issue
Block a user