GeoView : Correction for empty databases.

Since page splitting, some incomplete markers.


svn: r11747
This commit is contained in:
Serge Noiraud 2009-01-27 19:13:42 +00:00
parent f8bd056bb3
commit 3369da1fdf

View File

@ -786,14 +786,14 @@ class GeoView(HtmlView):
self.mapview.write(" <div id='pages' font=-4 >%s<br>\n" % message) self.mapview.write(" <div id='pages' font=-4 >%s<br>\n" % message)
if curpage != 1: if curpage != 1:
priorfile=GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % (ftype,curpage-1) priorfile=GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % (ftype,curpage-1)
self.mapview.write(" <a href='%s' >--</a>" % priorfile) self.mapview.write("<a href='%s' >--</a>" % priorfile)
else: else:
self.mapview.write(" --") self.mapview.write(" --")
for page in range(1,maxpages+1,1): for page in range(1,maxpages+1,1):
if page == curpage: if page == curpage:
self.mapview.write(" %d" % page) self.mapview.write(" %d" % page)
else: else:
if ( page < curpage + 10 ) and ( page > curpage - 10 ): if ( page < curpage + 11 ) and ( page > curpage - 11 ):
nextfile=GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % (ftype,page) nextfile=GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % (ftype,page)
self.mapview.write(" <a href='%s' >%d</a>" % (nextfile, page)) self.mapview.write(" <a href='%s' >%d</a>" % (nextfile, page))
if curpage != maxpages: if curpage != maxpages:
@ -1085,7 +1085,7 @@ class GeoView(HtmlView):
self.mapview.write("overview: true, scale: true, map_type: true });\n") self.mapview.write("overview: true, scale: true, map_type: true });\n")
last = "" last = ""
indm=0 indm=0
divclose=1 divclose=True
self.yearinmarker = [] self.yearinmarker = []
InInterval = False InInterval = False
self.setattr = True self.setattr = True
@ -1099,18 +1099,30 @@ class GeoView(HtmlView):
InInterval = True InInterval = True
if InInterval: if InInterval:
if last != mark[0]: if last != mark[0]:
self.setattr = True if not divclose:
last = mark[0] if InInterval:
self.mapview.write("\nvar point = new LatLonPoint(%s,%s);"%(mark[3],mark[4])) self.mapview.write("</div>\");")
self.mapview.write("my_marker = new Marker(point);") divclose = True
self.mapview.write("gmarkers[%d]=my_marker;" % (indm % NB_MARKERS_PER_PAGE)) years = ""
if mark[2]:
for y in self.yearinmarker:
years += "%d " % y
years += "end"
self.mapview.write("my_marker.setAttribute('year','%s');" % years)
self.yearinmarker = []
self.mapview.write("mapstraction.addMarker(my_marker);")
indm += 1; indm += 1;
if ( indm > lastm ): if ( indm > lastm ):
InInterval = False if (indm % NB_MARKERS_PER_PAGE) == 0:
InInterval = False
last = mark[0]
if ( indm >= firstm ) and ( indm <= lastm ): if ( indm >= firstm ) and ( indm <= lastm ):
self.mapview.write("\nvar point = new LatLonPoint(%s,%s);"%(mark[3],mark[4]))
self.mapview.write("my_marker = new Marker(point);")
self.mapview.write("gmarkers[%d]=my_marker;" % (( indm - 1 ) % NB_MARKERS_PER_PAGE))
self.mapview.write("my_marker.setLabel(\"%s\");"%mark[0]) self.mapview.write("my_marker.setLabel(\"%s\");"%mark[0])
self.yearinmarker.append(mark[7]) self.yearinmarker.append(mark[7])
divclose=0 divclose=False
self.mapview.write("my_marker.setInfoBubble(\"<div style='white-space:nowrap;' >") self.mapview.write("my_marker.setInfoBubble(\"<div style='white-space:nowrap;' >")
if format == 1: if format == 1:
self.mapview.write("%s<br>____________<br><br>%s"%(mark[0],mark[5])) self.mapview.write("%s<br>____________<br><br>%s"%(mark[0],mark[5]))
@ -1124,62 +1136,18 @@ class GeoView(HtmlView):
self.mapview.write("<br>%s - %s" % (mark[7], mark[5])) self.mapview.write("<br>%s - %s" % (mark[7], mark[5]))
if self.isyearnotinmarker(self.yearinmarker,mark[7]): if self.isyearnotinmarker(self.yearinmarker,mark[7]):
self.yearinmarker.append(mark[7]) self.yearinmarker.append(mark[7])
cent = int(mark[6])
if cent:
self.centered = True
if float(mark[3]) == self.minlat:
if signminlat == 1:
latit = str(float(mark[3])+self.centerlat)
else:
latit = str(float(mark[3])-self.centerlat)
else:
if signminlat == 1:
latit = str(float(mark[3])-self.centerlat)
else:
latit = str(float(mark[3])+self.centerlat)
if float(mark[4]) == self.minlon:
if signminlon == 1:
longt = str(float(mark[4])+self.centerlon)
else:
longt = str(float(mark[4])-self.centerlon)
else:
if signminlon == 1:
longt = str(float(mark[4])-self.centerlon)
else:
longt = str(float(mark[4])+self.centerlon)
if divclose == 0:
if InInterval:
self.mapview.write("</div>\");")
years = ""
if mark[2]:
for y in self.yearinmarker:
years += "%d " % y
years += "end"
else: else:
indm += 1 indm += 1
if self.setattr: if self.nbmarkers > 0 and InInterval:
years="" years = ""
if mark[2]: if mark[2]:
for y in self.yearinmarker: for y in self.yearinmarker:
years += "%d " % y years += "%d " % y
years += "end" years += "end"
self.mapview.write("my_marker.setAttribute('year','%s');" % years) self.mapview.write("</div>\");")
self.yearinmarker = [] self.mapview.write("my_marker.setAttribute('year','%s');" % years)
self.mapview.write("mapstraction.addMarker(my_marker);") self.mapview.write("mapstraction.addMarker(my_marker);")
self.setattr = False if self.nbmarkers == 0:
if self.nbmarkers > 0:
if self.setattr:
years = ""
if mark[2]:
for y in self.yearinmarker:
years += "%d " % y
years += "end"
self.mapview.write("my_marker.setAttribute('year','%s');" % years)
self.yearinmarker = []
years=""
self.mapview.write("mapstraction.addMarker(my_marker);")
self.setattr = False
else:
# We have no valid geographic point to center the map. # We have no valid geographic point to center the map.
# So you'll see the street where I live. # So you'll see the street where I live.
# I think another place should be better : # I think another place should be better :
@ -1188,8 +1156,6 @@ class GeoView(HtmlView):
# I think we should put here all gramps developpers. # I think we should put here all gramps developpers.
# not only me ... # not only me ...
# #
#longitude = -1.568792
#latitude = 47.257971
longitude = 0.0 longitude = 0.0
latitude = 0.0 latitude = 0.0
self.mapview.write("\nvar point = new LatLonPoint(%s,%s);\n"%(latitude,longitude)) self.mapview.write("\nvar point = new LatLonPoint(%s,%s);\n"%(latitude,longitude))
@ -1202,7 +1168,6 @@ class GeoView(HtmlView):
self.mapview.write(_("This is why you see this map.")) self.mapview.write(_("This is why you see this map."))
self.mapview.write("</div>\");\n") self.mapview.write("</div>\");\n")
self.mapview.write(" mapstraction.addMarker(my_marker);") self.mapview.write(" mapstraction.addMarker(my_marker);")
self.setattr = False
self.mapview.write("\n </script>\n") self.mapview.write("\n </script>\n")
def createPersonMarkers(self,db,person,comment): def createPersonMarkers(self,db,person,comment):
@ -1366,9 +1331,10 @@ class GeoView(HtmlView):
self.minyear = int(9999) self.minyear = int(9999)
self.maxyear = int(0) self.maxyear = int(0)
self.center = True self.center = True
person = None
if db.active: if db.active:
person = db.active person = db.active
if person: if person is not None:
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
if len(family_list) > 0: if len(family_list) > 0:
fhandle = family_list[0] # first is primary fhandle = family_list[0] # first is primary
@ -1395,12 +1361,13 @@ class GeoView(HtmlView):
self.createPersonMarkers(db,child,comment) self.createPersonMarkers(db,child,comment)
if self.center: if self.center:
mess = _("Cannot center the map. No location with coordinates.") mess = _("Cannot center the map. No location with coordinates.")
self.create_pages(3, _("You have no active person to see this person's family places."),
mess)
else: else:
mess = "" mess = ""
self.create_pages(3, self.create_pages(3, ( _("All %s people's family places in the database with coordinates.") %
( _("All %s people's familiy places in the database with coordinates.") % _nd.display(person) ),
_nd.display(person) ), mess)
mess)
def createMapstractionPerson(self,db): def createMapstractionPerson(self,db):
""" """
@ -1417,10 +1384,11 @@ class GeoView(HtmlView):
latitude = "" latitude = ""
longitude = "" longitude = ""
person = None
if db.active: if db.active:
person = db.active person = db.active
self.center = True self.center = True
if person: if person is not None:
# For each event, if we have a place, set a marker. # For each event, if we have a place, set a marker.
for event_ref in person.get_event_ref_list(): for event_ref in person.get_event_ref_list():
if not event_ref: if not event_ref:
@ -1450,9 +1418,10 @@ class GeoView(HtmlView):
self.center = False self.center = False
if self.center: if self.center:
mess = _("Cannot center the map. No location with coordinates.") mess = _("Cannot center the map. No location with coordinates.")
self.create_pages(4, _("You have no active person to see this person's places."), mess)
else: else:
mess = "" mess = ""
self.create_pages(4,( _("All event places for %s.") % _nd.display(person) ) ,mess) self.create_pages(4,( _("All event places for %s.") % _nd.display(person) ), mess)
def createMapstractionNotImplemented(self,db): def createMapstractionNotImplemented(self,db):
""" """