Geography : limit the number of places shown to a configurable value.
display a message over the map when this limit is reached. svn: r19852
This commit is contained in:
parent
df06be53df
commit
d6b20e48ec
@ -117,6 +117,7 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
('geography.center-lon', 0.0),
|
||||
|
||||
('geography.map_service', constants.OPENSTREETMAP),
|
||||
('geography.max_places', 5000),
|
||||
)
|
||||
|
||||
def __init__(self, title, pdata, dbstate, uistate,
|
||||
@ -435,7 +436,10 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
Create a list of places with coordinates.
|
||||
"""
|
||||
found = any(p[0] == place for p in self.places_found)
|
||||
if not found:
|
||||
if not found and self.nbplaces < self._config.get("geography.max_places"):
|
||||
# We only show the first "geography.max_places".
|
||||
# over 3000 or 4000 places, the geography become unusable.
|
||||
# In this case, filter the places ...
|
||||
self.nbplaces += 1
|
||||
self.places_found.append([place, lat, longit])
|
||||
self.place_list.append([place, name, evttype, lat,
|
||||
@ -912,6 +916,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
self._config.set('geography.path', config.get('geography.path'))
|
||||
self._config.set('geography.zoom_when_center',
|
||||
config.get('geography.zoom_when_center'))
|
||||
self._config.set('geography.max_places',
|
||||
self._config.get('geography.max_places'))
|
||||
table = gtk.Table(1, 1)
|
||||
table.set_border_width(12)
|
||||
table.set_col_spacings(6)
|
||||
@ -930,6 +936,10 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
_('Zoom used when centering'),
|
||||
4, 'geography.zoom_when_center',
|
||||
(2, 16))
|
||||
configdialog.add_slider(table,
|
||||
_('The maximum number of places to show'),
|
||||
5, 'geography.max_places',
|
||||
(1000, 10000))
|
||||
# there is no button. I need to found a solution for this.
|
||||
# it can be very dangerous ! if someone put / in geography.path ...
|
||||
# perhaps we need some contrôl on this path :
|
||||
|
@ -128,7 +128,7 @@ class MessageLayer(gobject.GObject, osmgpsmap.GpsMapLayer):
|
||||
ctx.set_source_rgba(float(color.red / 65535.0),
|
||||
float(color.green / 65535.0),
|
||||
float(color.blue / 65535.0),
|
||||
0.6) # transparency
|
||||
0.9) # transparency
|
||||
coord_x = 100
|
||||
coord_y = int(self.size) # Show the first line under the zoom button
|
||||
(d_width, d_height) = drawable.get_size()
|
||||
|
@ -115,6 +115,7 @@ class GeoClose(GeoGraphyView):
|
||||
('geography.center-lon', 0.0),
|
||||
|
||||
('geography.map_service', constants.OPENSTREETMAP),
|
||||
('geography.max_places', 5000),
|
||||
|
||||
# specific to geoclose :
|
||||
|
||||
|
@ -201,6 +201,8 @@ class GeoEvents(GeoGraphyView):
|
||||
a lat/lon.
|
||||
"""
|
||||
dbstate = self.dbstate
|
||||
if self.nbplaces >= self._config.get("geography.max_places"):
|
||||
return
|
||||
descr = descr2 = ""
|
||||
place_handle = event.get_place_handle()
|
||||
eventyear = event.get_date_object().to_calendar(self.cal).get_year()
|
||||
|
@ -115,6 +115,7 @@ class GeoFamClose(GeoGraphyView):
|
||||
('geography.center-lon', 0.0),
|
||||
|
||||
('geography.map_service', constants.OPENSTREETMAP),
|
||||
('geography.max_places', 5000),
|
||||
|
||||
# specific to geoclose :
|
||||
|
||||
|
@ -117,6 +117,7 @@ class GeoMoves(GeoGraphyView):
|
||||
('geography.center-lon', 0.0),
|
||||
|
||||
('geography.map_service', constants.OPENSTREETMAP),
|
||||
('geography.max_places', 5000),
|
||||
|
||||
# specific to geoclose :
|
||||
|
||||
|
@ -131,6 +131,7 @@ class GeoPerson(GeoGraphyView):
|
||||
#('geography.gps_increment', GPS_INCREMENT),
|
||||
|
||||
('geography.map_service', constants.OPENSTREETMAP),
|
||||
('geography.max_places', 5000),
|
||||
|
||||
# specific to geoperson :
|
||||
|
||||
|
@ -201,6 +201,8 @@ class GeoPlaces(GeoGraphyView):
|
||||
"""
|
||||
if place is None:
|
||||
return
|
||||
if self.nbplaces >= self._config.get("geography.max_places"):
|
||||
return
|
||||
descr = place.get_title()
|
||||
longitude = place.get_longitude()
|
||||
latitude = place.get_latitude()
|
||||
@ -240,7 +242,9 @@ class GeoPlaces(GeoGraphyView):
|
||||
latitude = ""
|
||||
longitude = ""
|
||||
self.nbmarkers = 0
|
||||
self.nbplaces = 0
|
||||
self.message_layer.clear_messages()
|
||||
self.message_layer.clear_font_attributes()
|
||||
self.no_show_places_in_status_bar = False
|
||||
# base "villes de france" : 38101 places :
|
||||
# createmap : 8'50"; create_markers : 1'23"
|
||||
@ -281,8 +285,22 @@ class GeoPlaces(GeoGraphyView):
|
||||
_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 ?
|
||||
self.message_layer.add_message(_("The place name in the status bar is disabled."))
|
||||
self.message_layer.add_message(
|
||||
_("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")))
|
||||
self.message_layer.add_message(
|
||||
_("Some information are missing."))
|
||||
self.message_layer.add_message(
|
||||
_("Please, use filtering to reduce this number."))
|
||||
self.message_layer.add_message(
|
||||
_("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."))
|
||||
|
||||
self._create_markers()
|
||||
|
||||
@ -354,7 +372,8 @@ class GeoPlaces(GeoGraphyView):
|
||||
oldplace = mark[0]
|
||||
modify = gtk.MenuItem(mark[0])
|
||||
modify.show()
|
||||
modify.connect("activate", self.goto_place, float(mark[3]), float(mark[4]))
|
||||
modify.connect("activate", self.goto_place,
|
||||
float(mark[3]), float(mark[4]))
|
||||
itemoption.append(modify)
|
||||
|
||||
def goto_place(self, obj, lat, lon):
|
||||
|
Loading…
Reference in New Issue
Block a user