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
if self.placemappages:
if place and (place.lat and place.long):
latitude, longitude = conv_lat_lon(place.get_latitude(), latitude, longitude = conv_lat_lon(place.get_latitude(),
place.get_longitude(), place.get_longitude(),
"D.D8") "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 place and (place.lat and place.long):
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()
if self.mapservice == "Google":
with Html("script", type="text/javascript", with Html("script", type="text/javascript",
indent=False) as jsc: indent=False) as jsc:
scripts += jsc if self.mapservice == "Google":
# 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
@ -535,8 +537,6 @@ class PlacePages(BasePage):
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),
@ -544,8 +544,6 @@ class PlacePages(BasePage):
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