Narweb: Add a comment if invalid lat/long

Fixes #12565
This commit is contained in:
SNoiraud 2022-02-15 10:52:10 +01:00 committed by Nick Hall
parent 3df33ec3e1
commit c2dd597a7f
2 changed files with 26 additions and 3 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: