diff --git a/src/DataViews/GeoView.py b/src/DataViews/GeoView.py index 17bb9ee74..091aef608 100644 --- a/src/DataViews/GeoView.py +++ b/src/DataViews/GeoView.py @@ -84,6 +84,82 @@ from HtmlRenderer import HtmlView GEOVIEW_SUBPATH = Utils.get_empty_tempdir('geoview') NB_MARKERS_PER_PAGE = 200 +#------------------------------------------------------------------------- +# +# Javascript template +# +#------------------------------------------------------------------------- + +_JAVASCRIPT = '''\n") self.mapview.write("\n") self.mapview.write("\n") + self.mapview.close() def _set_center_and_zoom(self, ptype): @@ -800,18 +890,15 @@ class GeoView(HtmlView): # Calculate the zoom. all places must be displayed on the map. zoomlat = _get_zoom_lat(maxlat) zoomlong = _get_zoom_long(maxlong) - if zoomlat < zoomlong: - self.zoom = zoomlat - else: - self.zoom = zoomlong + self.zoom = zoomlat if zoomlat < zoomlong else zoomlong self.zoom -= 1 if self.zoom < 2: self.zoom = 2 # We center the map on a point at the center of all markers self.centerlat = maxlat/2 self.centerlon = maxlong/2 - latit = 0.0 - longt = 0.0 + latit = longt = 0.0 + for mark in self.sort: cent = int(mark[6]) if cent: @@ -835,11 +922,11 @@ class GeoView(HtmlView): else: longt = self.minlon+self.centerlon # all maps: 0.0 for longitude and latitude means no location. - if latit == 0.0 and longt == 0.0: - latit = 0.00000001 - longt = 0.00000001 + if latit == longt == 0.0: + latit = longt = 0.00000001 + self.mustcenter = False - if latit != 0.0 or longt != 0.0: + if not (latit == longt == 0.0): self.latit = latit self.longt = longt self.mustcenter = True @@ -860,16 +947,7 @@ class GeoView(HtmlView): self._set_center_and_zoom(ptype) for page in range(0, pages, 1): self.nbpages += 1 - if ptype == 1: - ftype = "P" - elif ptype == 2: - ftype = "E" - elif ptype == 3: - ftype = "F" - elif ptype == 4: - ftype = "I" - else: - ftype = "X" + ftype = {1:'P', 2:'E', 3:'F', 4:'I'}.get(ptype, 'X') filename = os.path.join(GEOVIEW_SUBPATH, "GeoV-%c-%05d.html" % (ftype, self.nbpages)) @@ -928,34 +1006,16 @@ class GeoView(HtmlView): self.minyear = tfc if tfc > self.maxyear: self.maxyear = tfc - if tfa < 0.0: - tfa -= 0.00000001 - else: - tfa += 0.00000001 - if tfb < 0.0: - tfb -= 0.00000001 - else: - tfb += 0.00000001 - if self.minlat == 0.0: + tfa += 0.00000001 if tfa >= 0 else -0.00000001 + tfb += 0.00000001 if tfb >= 0 else -0.00000001 + if self.minlat == 0.0 or 0.0 > tfa < self.minlat: self.minlat = tfa - if tfa < self.minlat: - if tfa < 0.0: - self.minlat = tfa - if self.maxlat == 0.0: + if self.maxlat == 0.0 or 0.0 < tfa > self.maxlat: self.maxlat = tfa - if tfa > self.maxlat: - if tfa > 0.0: - self.maxlat = tfa - if self.minlon == 0.0: + if self.minlon == 0.0 or 0.0 > tfb < self.minlon: self.minlon = tfb - if tfb < self.minlon: - if tfb < 0.0: - self.minlon = tfb - if self.maxlon == 0.0: + if self.maxlon == 0.0 or 0.0 < tfb > self.maxlon: self.maxlon = tfb - if tfb > self.maxlon: - if tfb > 0.0: - self.maxlon = tfb def _create_markers(self, format, firstm, lastm): """ @@ -1169,12 +1229,12 @@ class GeoView(HtmlView): """ self.place_list = [] self.place_without_coordinates = [] - self.minlat = float(0.0) - self.maxlat = float(0.0) - self.minlon = float(0.0) - self.maxlon = float(0.0) - self.minyear = int(9999) - self.maxyear = int(0) + self.minlat = 0.0 + self.maxlat = 0.0 + self.minlon = 0.0 + self.maxlon = 0.0 + self.minyear = 9999 + self.maxyear = 0 latitude = "" longitude = "" self.center = True @@ -1211,12 +1271,12 @@ class GeoView(HtmlView): """ self.place_list = [] self.place_without_coordinates = [] - self.minlat = float(0.0) - self.maxlat = float(0.0) - self.minlon = float(0.0) - self.maxlon = float(0.0) - self.minyear = int(9999) - self.maxyear = int(0) + self.minlat = 0.0 + self.maxlat = 0.0 + self.minlon = 0.0 + self.maxlon = 0.0 + self.minyear = 9999 + self.maxyear = 0 latitude = "" longitude = "" self.center = True @@ -1293,12 +1353,12 @@ class GeoView(HtmlView): """ self.place_list = [] self.place_without_coordinates = [] - self.minlat = float(0.0) - self.maxlat = float(0.0) - self.minlon = float(0.0) - self.maxlon = float(0.0) - self.minyear = int(9999) - self.maxyear = int(0) + self.minlat = 0.0 + self.maxlat = 0.0 + self.minlon = 0.0 + self.maxlon = 0.0 + self.minyear = 9999 + self.maxyear = 0 self.center = True person = None if dbstate.active: @@ -1356,12 +1416,12 @@ class GeoView(HtmlView): """ self.place_list = [] self.place_without_coordinates = [] - self.minlat = float(0.0) - self.maxlat = float(0.0) - self.minlon = float(0.0) - self.maxlon = float(0.0) - self.minyear = int(9999) - self.maxyear = int(0) + self.minlat = 0.0 + self.maxlat = 0.0 + self.minlon = 0.0 + self.maxlon = 0.0 + self.minyear = 9999 + self.maxyear = 0 latitude = "" longitude = "" person = None