From: BenoƮt Fontaine Date: Wed, 10 Jan 2018 12:38:09 +0000 (+0100) Subject: Add map coordinates. Works with normalized places. X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=4b30234792299b4dd450c5c11e3d0c1e053d3120;p=gamesguru%2Fgetmyancestors.git Add map coordinates. Works with normalized places. --- diff --git a/getmyancestors.py b/getmyancestors.py index 5bb5312..1ec6cab 100755 --- a/getmyancestors.py +++ b/getmyancestors.py @@ -342,7 +342,7 @@ class Source: class Fact: def __init__(self, data=None, tree=None): - self.value = self.type = self.date = self.place = self.note = None + self.value = self.type = self.date = self.place = self.note = self.map = None if data: if 'value' in data: self.value = data['value'] @@ -357,7 +357,10 @@ class Fact: if 'date' in data: self.date = data['date']['original'] if 'place' in data: - self.place = data['place']['original'] + place = data['place'] + self.place = place['original'] + if 'description' in place and place['description'][1:] in tree.places: + self.map = tree.places[place['description'][1:]] if 'changeMessage' in data['attribution']: self.note = Note(data['attribution']['changeMessage'], tree) if self.type == 'http://gedcomx.org/Death' and not (self.date or self.place): @@ -379,6 +382,9 @@ class Fact: file.write('2 DATE ' + self.date + '\n') if self.place: file.write('2 PLAC ' + self.place + '\n') + if self.map: + latitude, longitude = self.map + file.write('3 MAP\n4 LATI ' + latitude + '\n4 LONG ' + longitude + '\n') if self.note: self.note.link(file, 2) @@ -754,6 +760,7 @@ class Tree: self.fam = dict() self.notes = list() self.sources = dict() + self.places = dict() # add individuals to the family tree def add_indis(self, fids): @@ -771,6 +778,10 @@ class Tree: print(len(new_fids)) data = self.fs.get_url('https://familysearch.org/platform/tree/persons.json?pids=' + ','.join(new_fids[:MAX_PERSONS])) if data: + if 'places' in data: + for place in data['places']: + if place['id'] not in self.places: + self.places[place['id']] = (str(place['latitude']), str(place['longitude'])) loop.run_until_complete(add_datas(loop, data)) if 'childAndParentsRelationships' in data: for rel in data['childAndParentsRelationships']: diff --git a/mergemyancestors.py b/mergemyancestors.py index 1771249..f8841e8 100755 --- a/mergemyancestors.py +++ b/mergemyancestors.py @@ -191,38 +191,6 @@ class Gedcom: self.indi[self.num].birthnames.add(name) self.flag = True - def __get_birt(self): - while self.__get_line() and self.level > 1: - if self.tag == 'DATE': - self.indi[self.num].birtdate = self.data - elif self.tag == 'PLAC': - self.indi[self.num].birtplac = self.data - self.flag = True - - def __get_chr(self): - while self.__get_line() and self.level > 1: - if self.tag == 'DATE': - self.indi[self.num].chrdate = self.data - elif self.tag == 'PLAC': - self.indi[self.num].chrplac = self.data - self.flag = True - - def __get_deat(self): - while self.__get_line() and self.level > 1: - if self.tag == 'DATE': - self.indi[self.num].deatdate = self.data - elif self.tag == 'PLAC': - self.indi[self.num].deatplac = self.data - self.flag = True - - def __get_buri(self): - while self.__get_line() and self.level > 1: - if self.tag == 'DATE': - self.indi[self.num].buridate = self.data - elif self.tag == 'PLAC': - self.indi[self.num].buriplac = self.data - self.flag = True - def __get_fact(self): fact = Fact() if self.tag != 'EVEN': @@ -235,6 +203,8 @@ class Gedcom: fact.date = self.data elif self.tag == 'PLAC': fact.place = self.data + elif self.tag == 'MAP': + fact.map = self.__get_map() elif self.tag == 'NOTE': if self.data[:12] == 'Description:': fact.value = self.data[13:] @@ -248,6 +218,17 @@ class Gedcom: self.flag = True return fact + def __get_map(self): + latitude = None + longitude = None + while self.__get_line() and self.level > 3: + if self.tag == 'LATI': + latitude = self.data + elif self.tag == 'LONG': + longitude = self.data + self.flag = True + return (latitude, longitude) + def __get_text(self): text = self.data while self.__get_line():