Merge pull request #1341 from SNoiraud/B12565

This commit is contained in:
Nick Hall 2022-03-18 18:51:30 +00:00
commit d01deb2cc9
2 changed files with 33 additions and 15 deletions

View File

@ -2878,6 +2878,16 @@ class BasePage:
tbody += trow tbody += trow
data = place.get_latitude() data = place.get_latitude()
v_lat, v_lon = conv_lat_lon(data, "0.0", "D.D8")
if not v_lat:
data += self._(":")
# We use the same message as in:
# gramps/gui/editors/editplace.py
# gramps/gui/editors/editplaceref.py
data += self._("Invalid latitude\n(syntax: 18\\u00b09'48.21\"S,"
" -18.2412 or -18:9:48.21)")
# We need to convert "\\u00b0" to "°" for html
data = data.replace("\\u00b0", "°")
if data != "": if data != "":
trow = Html('tr') + ( trow = Html('tr') + (
Html("td", self._("Latitude"), class_="ColumnAttribute", Html("td", self._("Latitude"), class_="ColumnAttribute",
@ -2886,6 +2896,16 @@ class BasePage:
) )
tbody += trow tbody += trow
data = place.get_longitude() data = place.get_longitude()
v_lat, v_lon = conv_lat_lon("0.0", data, "D.D8")
if not v_lon:
data += self._(":")
# We use the same message as in:
# gramps/gui/editors/editplace.py
# gramps/gui/editors/editplaceref.py
data += self._("Invalid longitude\n(syntax: 18\\u00b09'48.21\"E,"
" -18.2412 or -18:9:48.21)")
# We need to convert "\\u00b0" to "°" for html
data = data.replace("\\u00b0", "°")
if data != "": if data != "":
trow = Html('tr') + ( trow = Html('tr') + (
Html("td", self._("Longitude"), class_="ColumnAttribute", Html("td", self._("Longitude"), class_="ColumnAttribute",

View File

@ -495,11 +495,14 @@ class PlacePages(BasePage):
# Begin inline javascript code because jsc is a # Begin inline javascript code because jsc is a
# docstring, it does NOT have to be properly indented # docstring, it does NOT have to be properly indented
latitude, longitude = conv_lat_lon(place.get_latitude(),
place.get_longitude(),
"D.D8")
if not (latitude and longitude):
# We have incorrect longitude and/or latitude for this place.
latitude = longitude = 0.0
if self.placemappages: if self.placemappages:
if place and (place.lat and place.long): if place and (place.lat and place.long):
latitude, longitude = conv_lat_lon(place.get_latitude(),
place.get_longitude(),
"D.D8")
tracelife = " " tracelife = " "
if self.create_media and media_list: if self.create_media and media_list:
for fmedia in media_list: for fmedia in media_list:
@ -520,11 +523,10 @@ class PlacePages(BasePage):
if photo_hdle in self.report.obj_dict[Media]: if photo_hdle in self.report.obj_dict[Media]:
tracelife += str(imglnk) tracelife += str(imglnk)
break # We show only the first image break # We show only the first image
scripts = Html() with Html("script", type="text/javascript",
if self.mapservice == "Google": indent=False) as jsc:
with Html("script", type="text/javascript", if self.mapservice == "Google":
indent=False) as jsc: # scripts += jsc
scripts += jsc
# Google adds Latitude/ Longitude to its maps... # Google adds Latitude/ Longitude to its maps...
plce = placetitle.replace("'", "\\'") plce = placetitle.replace("'", "\\'")
jsc += MARKER_PATH % marker_path jsc += MARKER_PATH % marker_path
@ -534,18 +536,14 @@ class PlacePages(BasePage):
1, tracelife]], 1, tracelife]],
latitude, longitude, latitude, longitude,
10) 10)
elif self.mapservice == "OpenStreetMap": elif self.mapservice == "OpenStreetMap":
with Html("script", type="text/javascript") as jsc:
scripts += jsc
jsc += MARKER_PATH % marker_path jsc += MARKER_PATH % marker_path
jsc += OSM_MARKERS % ([[float(longitude), jsc += OSM_MARKERS % ([[float(longitude),
float(latitude), float(latitude),
placetitle, tracelife]], placetitle, tracelife]],
longitude, latitude, 10) longitude, latitude, 10)
jsc += OPENLAYER jsc += OPENLAYER
else: # STAMEN else: # STAMEN
with Html("script", type="text/javascript") as jsc:
scripts += jsc
jsc += MARKER_PATH % marker_path jsc += MARKER_PATH % marker_path
jsc += STAMEN_MARKERS % ([[float(longitude), jsc += STAMEN_MARKERS % ([[float(longitude),
float(latitude), float(latitude),
@ -553,7 +551,7 @@ class PlacePages(BasePage):
self.stamenopts, self.stamenopts,
longitude, latitude, 10) longitude, latitude, 10)
jsc += OPENLAYER jsc += OPENLAYER
placedetail += scripts placedetail += jsc
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section