parent
45f4b711a3
commit
6d24ab7d75
@ -48,6 +48,7 @@ from gi.repository import OsmGpsMap as osmgpsmap
|
|||||||
# Gramps Modules
|
# Gramps Modules
|
||||||
#
|
#
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
from gramps.gen.db import DbTxn
|
||||||
from gramps.gen.lib import EventType, Place, PlaceRef, PlaceName
|
from gramps.gen.lib import EventType, Place, PlaceRef, PlaceName
|
||||||
from gramps.gen.display.name import displayer as _nd
|
from gramps.gen.display.name import displayer as _nd
|
||||||
from gramps.gen.display.place import displayer as _pd
|
from gramps.gen.display.place import displayer as _pd
|
||||||
@ -1049,7 +1050,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
if val:
|
if val:
|
||||||
kmlfile = Kml(val)
|
kmlfile = Kml(val)
|
||||||
points = kmlfile.add_points()
|
points = kmlfile.add_points()
|
||||||
for place in points:
|
kml.destroy()
|
||||||
|
def init_place(place):
|
||||||
(name, coords) = place
|
(name, coords) = place
|
||||||
latlong = coords.pop()
|
latlong = coords.pop()
|
||||||
(lat, lon) = latlong
|
(lat, lon) = latlong
|
||||||
@ -1060,10 +1062,36 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
new_place.set_title(name)
|
new_place.set_title(name)
|
||||||
new_place.set_latitude(str(lat))
|
new_place.set_latitude(str(lat))
|
||||||
new_place.set_longitude(str(lon))
|
new_place.set_longitude(str(lon))
|
||||||
|
return new_place
|
||||||
|
|
||||||
|
nb_pts = len(points)
|
||||||
|
if nb_pts > 5:
|
||||||
|
from gramps.gui.dialog import WarningDialog
|
||||||
|
ngettext = glocale.translation.ngettext
|
||||||
|
warn_msg = _("You will need to edit each place manually "
|
||||||
|
"to add place type, ...\n")
|
||||||
|
warn_msg += ngettext("You have {places_nb} place to edit.",
|
||||||
|
"You have {places_nb} places to edit.",
|
||||||
|
nb_pts).format(places_nb=nb_pts)
|
||||||
|
WarningDialog(
|
||||||
|
_('You have more than 5 places in this kml file.'),
|
||||||
|
warn_msg, parent=self.uistate.window)
|
||||||
|
with DbTxn("Add Places from Kml",
|
||||||
|
self.dbstate.db) as trans:
|
||||||
|
# add places without editing them. You need to
|
||||||
|
# manually edit them to add place type, enclosing...
|
||||||
|
for place in points:
|
||||||
|
n_place = init_place(place)
|
||||||
|
self.dbstate.db.add_place(n_place, trans)
|
||||||
|
else:
|
||||||
|
for place in points:
|
||||||
|
n_place = init_place(place)
|
||||||
try:
|
try:
|
||||||
EditPlace(self.dbstate, self.uistate, [], new_place)
|
EditPlace(self.dbstate, self.uistate, [],
|
||||||
|
n_place)
|
||||||
except WindowActiveError:
|
except WindowActiveError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
kml.destroy()
|
kml.destroy()
|
||||||
|
|
||||||
def place_exists(self, place_name):
|
def place_exists(self, place_name):
|
||||||
|
Loading…
Reference in New Issue
Block a user