From 22b5c7a14c04897ef582d4a78f436e99c30eb498 Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Thu, 7 Jan 2016 09:53:57 +0100 Subject: [PATCH] Geography : change one place selection function by a method. --- gramps/plugins/lib/maps/placeselection.py | 53 +++++++++++------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/gramps/plugins/lib/maps/placeselection.py b/gramps/plugins/lib/maps/placeselection.py index f241bf8f7..d3bfde381 100644 --- a/gramps/plugins/lib/maps/placeselection.py +++ b/gramps/plugins/lib/maps/placeselection.py @@ -66,32 +66,6 @@ from gramps.gen.display.place import displayer as place_displayer PLACE_REGEXP = re.compile('(.*)') PLACE_STRING = '%s' -def match(self, lat, lon, radius): - """ - coordinates matching. - """ - rds = float(radius) - self.places = [] - - # place - for entry in self.place_list: - if (math.hypot(lat-float(entry[3]), - lon-float(entry[4])) <= rds) == True: - # Do we already have this place ? avoid duplicates - country, state, county, place, other = self.get_location(entry[9]) - if not [country, state, county, place, other] in self.places: - self.places.append([country, state, county, place, other]) - for place in self.dbstate.db.iter_places(): - latn = place.get_latitude() - lonn = place.get_longitude() - if latn and lonn: - if (math.hypot(lat-float(latn), - lon-float(lonn)) <= rds) == True: - country, state, county, place, other = self.get_location(place.get_gramps_id()) - if not [country, state, county, place, other] in self.places: - self.places.append([country, state, county, place, other]) - return self.places - #------------------------------------------------------------------------- # # PlaceSelection @@ -192,7 +166,7 @@ class PlaceSelection(ManagedWindow, OsmGps): """ self.radius = obj.get_value() if obj else 1.0 self.show_the_region(self.radius) - match(self, lat, lon, self.radius) + self.match(lat, lon) self.plist.clear() if self.oldvalue != None: # The old values are always in the first row. @@ -265,6 +239,31 @@ class PlaceSelection(ManagedWindow, OsmGps): parent_place = place.get_handle() return(country, state, county, place_name, other) + def match(self, lat, lon): + """ + coordinates matching. + """ + rds = float(self.radius) + self.places = [] + + # place + for entry in self.place_list: + if (math.hypot(lat-float(entry[3]), + lon-float(entry[4])) <= rds) == True: + # Do we already have this place ? avoid duplicates + country, state, county, place, other = self.get_location(entry[9]) + if not [country, state, county, place, other] in self.places: + self.places.append([country, state, county, place, other]) + for place in self.dbstate.db.iter_places(): + latn = place.get_latitude() + lonn = place.get_longitude() + if latn and lonn: + if (math.hypot(lat-float(latn), + lon-float(lonn)) <= rds) == True: + country, state, county, place, other = self.get_location(place.get_gramps_id()) + if not [country, state, county, place, other] in self.places: + self.places.append([country, state, county, place, other]) + def selection(self, obj, index, column, function): """ get location values and call the real function : add_place, edit_place