From b9b069b6201779beb8d04d923b50ec972fac4e42 Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Mon, 26 Feb 2007 19:59:53 +0000 Subject: [PATCH] * src/GrampsDbUtils/_GedcomParse.py: Parse MAP/LATI/LONG * src/GrampsDbUtils/_GedcomTokens.py: Add MAP,LATI,LONG svn: r8249 --- ChangeLog | 4 ++- src/GrampsDbUtils/_GedcomParse.py | 42 ++++++++++++++++++++++++++++++ src/GrampsDbUtils/_GedcomTokens.py | 5 ++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a21287ab9..00c7633d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,9 @@ * src/RelLib/_AttributeType.py: Add WITNESS (used by GEDCOM parser to import textual event witness information * src/GrampsDbUtils/_GedcomParse.py: Support for some types of Witness - data + data; Parse MAP/LATI/LONG + * src/GrampsDbUtils/_GedcomTokens.py: Add MAP,LATI,LONG + 2007-02-26 Don Allingham * src/GrampsDbUtils/_GedcomParse.py: encode file name properly diff --git a/src/GrampsDbUtils/_GedcomParse.py b/src/GrampsDbUtils/_GedcomParse.py index fdcf4c47e..9448cb144 100644 --- a/src/GrampsDbUtils/_GedcomParse.py +++ b/src/GrampsDbUtils/_GedcomParse.py @@ -742,6 +742,12 @@ class GedcomParser(UpdateCallback): TOKEN_OBJE : self.func_event_place_object, TOKEN_SOUR : self.func_event_place_sour, TOKEN__LOC : self.func_ignore, + TOKEN_MAP : self.func_place_map, + } + + self.place_map_tbl = { + TOKEN_LATI : self.func_place_lati, + TOKEN_LONG : self.func_place_long, } self.repo_ref_tbl = { @@ -2910,6 +2916,42 @@ class GedcomParser(UpdateCallback): """ state.place.add_source_reference(self.handle_source(line, state.level)) + def func_place_map(self, line, state): + """ + + n MAP + n+1 LONG + n+1 LATI + + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + sub_state = GedcomUtils.CurrentState() + sub_state.level = state.level + 1 + sub_state.place = state.place + self.parse_level(sub_state, self.place_map_tbl, self.func_undefined) + state.place = sub_state.place + + def func_place_lati(self, line, state): + """ + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + state.place.set_latitude( line.data) + + def func_place_long(self, line, state): + """ + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + state.place.set_longitude( line.data) + def func_event_addr(self, line, state): """ @param line: The current line in GedLine format diff --git a/src/GrampsDbUtils/_GedcomTokens.py b/src/GrampsDbUtils/_GedcomTokens.py index 12ff20217..00ee76d20 100644 --- a/src/GrampsDbUtils/_GedcomTokens.py +++ b/src/GrampsDbUtils/_GedcomTokens.py @@ -135,6 +135,9 @@ TOKEN_GEVENT = 116 TOKEN_RNOTE = 117 TOKEN_GATTR = 118 TOKEN_ATTR = 119 +TOKEN_MAP = 120 +TOKEN_LATI = 121 +TOKEN_LONG = 122 tokens = { "HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI, @@ -232,4 +235,6 @@ tokens = { "CONL" : TOKEN_CONL, "RESN" : TOKEN_RESN, "_MEDI" : TOKEN_MEDI, "_MASTER" : TOKEN_IGNORE, "_LEVEL" : TOKEN_IGNORE,"_PUBLISHER" : TOKEN_IGNORE, + "MAP" : TOKEN_MAP, "LATI" : TOKEN_LATI, + "LONG" : TOKEN_LONG, }