Esempio n. 1
0
    def parse_format(self, database, place):
        """ Parse the place """

        if self.is_blank(place):
            return

        code = "elcuspn" + "oitxy"
        upper = code.upper()

        main_loc = get_main_location(database, place, date=self.date)
        location = Location()
        location.set_street(main_loc.get(PlaceType.STREET, ''))
        location.set_locality(main_loc.get(PlaceType.LOCALITY, ''))
        location.set_parish(main_loc.get(PlaceType.PARISH, ''))
        location.set_city(main_loc.get(PlaceType.CITY, ''))
        location.set_county(main_loc.get(PlaceType.COUNTY, ''))
        location.set_state(main_loc.get(PlaceType.STATE, ''))
        location.set_postal_code(main_loc.get(PlaceType.STREET, ''))
        location.set_country(main_loc.get(PlaceType.COUNTRY, ''))

        function = [
            location.get_street, location.get_locality, location.get_city,
            location.get_county, location.get_state, place.get_code,
            location.get_country, location.get_phone, location.get_parish,
            place.get_title, place.get_longitude, place.get_latitude
        ]

        return self.generic_format(place, code, upper, function)
Esempio n. 2
0
 def get_event_place(self, event):
     """ get the place of the event """
     place_text = ''
     place_handle = event.get_place_handle()
     if place_handle:
         place = self._db.get_place_from_handle(place_handle)
         if place:
             location = get_main_location(self._db, place)
             if location.get(PlaceType.HAMLET):
                 place_text = location.get(PlaceType.HAMLET)
             elif location.get(PlaceType.VILLAGE):
                 place_text = location.get(PlaceType.VILLAGE)
             elif location.get(PlaceType.TOWN):
                 place_text = location.get(PlaceType.TOWN)
             elif location.get(PlaceType.CITY):
                  place_text = location.get(PlaceType.CITY)
             elif location.get(PlaceType.PARISH):
                 place_text = location.get(PlaceType.PARISH)
             elif location.get(PlaceType.COUNTY):
                 place_text = location.get(PlaceType.COUNTY)
             elif location.get(PlaceType.PROVINCE):
                 place_text = location.get(PlaceType.PROVINCE)
             elif location.get(PlaceType.REGION):
                 place_text = location.get(PlaceType.REGION)
             elif location.get(PlaceType.STATE):
                 place_text = location.get(PlaceType.STATE)
             elif location.get(PlaceType.COUNTRY):
                 place_text = location.get(PlaceType.COUNTRY)
             place_text = place_text.replace('<', '&#60;')
             place_text = place_text.replace('>', '&#62;')
     return place_text
Esempio n. 3
0
    def slider_change(self, obj, lat, lon):
        """
        Display on the map a circle in which we select all the places inside this region.
        """
        self.radius = obj.get_value() if obj else 1.0
        self.show_the_region(self.radius)
        match(self, lat, lon, self.radius)
        self.plist.clear()
        if self.oldvalue != None:
            # The old values are always in the first row.
            # In this case, we change the color of the row.
            # display the associated message
            self.label2.show()
            place = self.dbstate.db.get_place_from_handle(self.oldvalue)
            loc = get_main_location(self.dbstate.db, place)
            self.plist.append(
                (PLACE_STRING % loc.get(PlaceType.COUNTRY, ''),
                 PLACE_STRING % loc.get(PlaceType.STATE, ''),
                 PLACE_STRING % loc.get(PlaceType.COUNTY, ''), self.oldvalue))
        for place in self.places:
            if not place[0]:
                _LOG.info('No hierarchy yet: %s' % place)
                continue
            p = (place[0].value, place[1], place[2], place[3])
            self.plist.append(p)
        # here, we could add value from geography names services ...

        # if we found no place, we must create a default place.
        self.plist.append((_("New place with empty fields"), "", "...", None))
Esempio n. 4
0
    def __write_place(self, handle, place_nbr):
        """
        This procedure writes out the details of a single place
        """
        place = self.database.get_place_from_handle(handle)
        location = get_main_location(self.database, place)

        place_details = [
            self._("Gramps ID: %s ") % place.get_gramps_id(),
            self._("Street: %s ") % location.get(PlaceType.STREET, ''),
            self._("Parish: %s ") % location.get(PlaceType.PARISH, ''),
            self._("Locality: %s ") % location.get(PlaceType.LOCALITY, ''),
            self._("City: %s ") % location.get(PlaceType.CITY, ''),
            self._("County: %s ") % location.get(PlaceType.COUNTY, ''),
            self._("State: %s") % location.get(PlaceType.STATE, ''),
            self._("Country: %s ") % location.get(PlaceType.COUNTRY, '')]
        self.doc.start_paragraph("PLC-PlaceTitle")
        place_title = place_displayer.display(self.database, place)
        self.doc.write_text(("%(nbr)s. %(place)s") %
                                {'nbr' : place_nbr,
                                 'place' : place_title})
        self.doc.end_paragraph()

        for item in place_details:
            self.doc.start_paragraph("PLC-PlaceDetails")
            self.doc.write_text(item)
            self.doc.end_paragraph()
Esempio n. 5
0
    def calc_url(self):
        """ Determine the url to use
            Logic: use lat lon if present
                   otherwise use city and country if present
                   otherwise use description of the place
        """
        place = self._get_first_place()[0]
        latitude, longitude = self._lat_lon(place)
        if longitude and latitude:
            self.url = "http://www.openstreetmap.org/" \
                        "?lat=%s&lon=%s&zoom=15" % (latitude, longitude)

            return

        location = get_main_location(self.database, place)
        city = location.get(PlaceType.CITY)
        country = location.get(PlaceType.COUNTRY)
        if city and country:
            self.url = "http://nominatim.openstreetmap.org/"\
                        "search.php?q=%s%%2C%s" % (city, country)
            return

        titledescr = place_displayer.display(self.database, place)
        self.url = "http://nominatim.openstreetmap.org/"\
                        "search.php?q=%s" % '+'.join(titledescr.split())
Esempio n. 6
0
    def slider_change(self, obj, lat, lon):
        """
        Display on the map a circle in which we select all the places
        inside this region.
        """
        self.radius = obj.get_value() if obj else 1.0
        self.show_the_region(self.radius)
        self.match(lat, lon)
        self.plist.clear()
        if self.oldvalue != None:
            # The old values are always in the first row.
            # In this case, we change the color of the row.
            # display the associated message
            self.label2.show()
            place = self.dbstate.db.get_place_from_handle(self.oldvalue)
            loc = get_main_location(self.dbstate.db, place)
            self.plist.append((PLACE_STRING % loc.get(PlaceType.COUNTRY, ''),
                               PLACE_STRING % loc.get(PlaceType.STATE, ''),
                               PLACE_STRING % loc.get(PlaceType.COUNTY, ''),
                               PLACE_STRING % _('Other'),
                               self.oldvalue)
                             )
        for place in self.places:
            self.plist.append((place[0], place[1],
                               place[2], place[3], place[4]))
        # here, we could add value from geography names services ...

        # if we found no place, we must create a default place.
        self.plist.append((_("New place with empty fields"), "",
                           "...", "", None))
Esempio n. 7
0
    def __write_place(self, handle, place_nbr):
        """
        This procedure writes out the details of a single place
        """
        place = self.database.get_place_from_handle(handle)
        location = get_main_location(self.database, place)

        place_details = [
            self._("Gramps ID: %s ") % place.get_gramps_id(),
            self._("Street: %s ") % location.get(PlaceType.STREET, ''),
            self._("Parish: %s ") % location.get(PlaceType.PARISH, ''),
            self._("Locality: %s ") % location.get(PlaceType.LOCALITY, ''),
            self._("City: %s ") % location.get(PlaceType.CITY, ''),
            self._("County: %s ") % location.get(PlaceType.COUNTY, ''),
            self._("State: %s") % location.get(PlaceType.STATE, ''),
            self._("Country: %s ") % location.get(PlaceType.COUNTRY, '')]
        self.doc.start_paragraph("PLC-PlaceTitle")
        place_title = place_displayer.display(self.database, place)
        self.doc.write_text(("%(nbr)s. %(place)s") % 
                                {'nbr' : place_nbr,
                                 'place' : place_title})
        self.doc.end_paragraph()

        for item in place_details:
            self.doc.start_paragraph("PLC-PlaceDetails")
            self.doc.write_text(item) 
            self.doc.end_paragraph()
Esempio n. 8
0
    def _place(self, place, dateobj, level):
        """
        PLACE_STRUCTURE:=
            n PLAC <PLACE_NAME> {1:1}
            +1 FORM <PLACE_HIERARCHY> {0:1}
            +1 FONE <PLACE_PHONETIC_VARIATION> {0:M}  # not used
            +2 TYPE <PHONETIC_TYPE> {1:1}
            +1 ROMN <PLACE_ROMANIZED_VARIATION> {0:M} # not used
            +2 TYPE <ROMANIZED_TYPE> {1:1}
            +1 MAP {0:1}
            +2 LATI <PLACE_LATITUDE> {1:1}
            +2 LONG <PLACE_LONGITUDE> {1:1}
            +1 <<NOTE_STRUCTURE>> {0:M}
        """
        if place is None:
            return
        place_name = _pd.display(self.dbase, place, dateobj)
        self._writeln(level, "PLAC", place_name.replace('\r', ' '), limit=120)
        longitude = place.get_longitude()
        latitude = place.get_latitude()
        if longitude and latitude:
            (latitude, longitude) = conv_lat_lon(latitude, longitude, "GEDCOM")
        if longitude and latitude:
            self._writeln(level + 1, "MAP")
            self._writeln(level + 2, 'LATI', latitude)
            self._writeln(level + 2, 'LONG', longitude)

        # The Gedcom standard shows that an optional address structure can
        # be written out in the event detail.
        # http://homepages.rootsweb.com/~pmcbride/gedcom/55gcch2.htm#EVENT_DETAIL
        location = get_main_location(self.dbase, place)
        street = location.get(PlaceType.STREET)
        locality = location.get(PlaceType.LOCALITY)
        city = location.get(PlaceType.CITY)
        state = location.get(PlaceType.STATE)
        country = location.get(PlaceType.COUNTRY)
        postal_code = place.get_code()

        if street or locality or city or state or postal_code or country:
            self._writeln(level, "ADDR", street)
            if street:
                self._writeln(level + 1, 'ADR1', street)
            if locality:
                self._writeln(level + 1, 'ADR2', locality)
            if city:
                self._writeln(level + 1, 'CITY', city)
            if state:
                self._writeln(level + 1, 'STAE', state)
            if postal_code:
                self._writeln(level + 1, 'POST', postal_code)
            if country:
                self._writeln(level + 1, 'CTRY', country)
        if self.placenote:
            LOG.debug("PLACENOTE")
            self._note_references(place.get_note_list(), level)
        else:
            LOG.debug(" PAS PLACENOTE")
            self._note_references(place.get_note_list(), level + 1)
Esempio n. 9
0
def _build_city(db, place):
    """ Builds description string for city parameter in url """
    location = get_main_location(db, place)
    county = location.get(PlaceType.COUNTY)
    # Build a title description string that will work for Eniro
    city_descr = _build_area(db, place)
    if county:
        city_descr += ', ' + county
    return _strip_leading_comma(city_descr)
Esempio n. 10
0
def _build_city(db, place):
    """ Builds description string for city parameter in url """
    location = get_main_location(db, place)
    county = location.get(PlaceType.COUNTY)
    # Build a title description string that will work for Eniro
    city_descr = _build_area(db, place)
    if county:
        city_descr += ', ' + county
    return _strip_leading_comma(city_descr)
Esempio n. 11
0
def _build_city(db, place):
    """ Builds description string for city parameter in url """
    location = get_main_location(db, place)
    county = location.get(PlaceType.COUNTY)
    # Build a title description string that will work for Eniro
    city_descr = _build_area(db, place)
    if county:
        # TODO for Arabic, should the next line's comma be translated?
        city_descr += ', ' + county
    return _strip_leading_comma(city_descr)
Esempio n. 12
0
def _build_city(db, place):
    """ Builds description string for city parameter in url """
    location = get_main_location(db, place)
    county = location.get(PlaceType.COUNTY)
    # Build a title description string that will work for Eniro
    city_descr = _build_area(db, place)
    if county:
        # TODO for Arabic, should the next line's comma be translated?
        city_descr += ', ' + county
    return _strip_leading_comma(city_descr)
Esempio n. 13
0
    def write_kml_point_data(self):
        """
        Writes the point data of the kml/kmz file.
        """
        self.kml_file.write('<Document>\n')
        self.kml_file.write('    <name>GrampsPlaces</name>\n')
        for place, descr in self._all_places():
            latitude, longitude = self._lat_lon(place)
            if latitude == None or longitude == None:
                location = get_main_location(self.database, place)
                LOG.warning(" %s : Missing coordinates(latitude/longitude): \
                             Skipping entry: " % (location))
                continue
            if not descr:
                descr = place_displayer.display(self.database, place)
            location = get_main_location(self.database, place)
            parish_descr = location.get(PlaceType.PARISH)
            if parish_descr == None:
                parish_descr = ""
            city = location.get(PlaceType.CITY)
            county = location.get(PlaceType.COUNTY)
            city_county_descr = _combine(city, county)

            state = location.get(PlaceType.STATE)
            country = location.get(PlaceType.COUNTRY)
            state_country_descr = _combine(state, country)
            id = place.get_gramps_id()

            self.kml_file.write('    <Placemark id="%s">\n' % id)
            self.kml_file.write("        <name>%s</name>\n" % descr)
            self.kml_file.write("        <description>\n")
            self.kml_file.write("            <![CDATA[\n")
            self.kml_file.write("              %s\n" % parish_descr)
            self.kml_file.write("              %s\n" % city_county_descr)
            self.kml_file.write("              %s\n" % state_country_descr)
            self.kml_file.write("            ]]>\n")
            self.kml_file.write("        </description>\n")
            self.kml_file.write("        <Point>\n")
            self.kml_file.write("            <coordinates>%s" % longitude)
            self.kml_file.write(",%s</coordinates>\n" % latitude)
            self.kml_file.write("        </Point>\n")
            self.kml_file.write("    </Placemark>\n")
        self.kml_file.write("</Document>\n")
    def write_kml_point_data(self):
        """
        Writes the point data of the kml/kmz file.
        """
        self.kml_file.write('<Document>\n')
        self.kml_file.write('    <name>GrampsPlaces</name>\n')
        for place, descr in self._all_places():
            latitude, longitude = self._lat_lon(place)
            if latitude == None or longitude == None:
                location = get_main_location(self.database, place)
                LOG.warning(" %s : Missing coordinates(latitude/longitude): \
                             Skipping entry: " % (location))
                continue
            if not descr:
                descr = place_displayer.display(self.database, place)
            location = get_main_location(self.database, place)
            parish_descr = location.get(PlaceType.PARISH)
            if parish_descr == None:
                parish_descr = ""
            city = location.get(PlaceType.CITY)
            county = location.get(PlaceType.COUNTY)
            city_county_descr = _combine(city, county)

            state = location.get(PlaceType.STATE)
            country = location.get(PlaceType.COUNTRY)
            state_country_descr = _combine(state, country)
            id = place.get_gramps_id()

            self.kml_file.write('    <Placemark id="%s">\n' % id)
            self.kml_file.write("        <name>%s</name>\n" % descr)
            self.kml_file.write("        <description>\n")
            self.kml_file.write("            <![CDATA[\n")
            self.kml_file.write("              %s\n" %  parish_descr)
            self.kml_file.write("              %s\n" %  city_county_descr)
            self.kml_file.write("              %s\n" %  state_country_descr)
            self.kml_file.write("            ]]>\n")
            self.kml_file.write("        </description>\n")
            self.kml_file.write("        <Point>\n")
            self.kml_file.write("            <coordinates>%s" % longitude)
            self.kml_file.write(",%s</coordinates>\n" % latitude)
            self.kml_file.write("        </Point>\n")
            self.kml_file.write("    </Placemark>\n")
        self.kml_file.write("</Document>\n")
Esempio n. 15
0
def _build_area(db, place):
    """ Builds string for area parameter in url """
    location = get_main_location(db, place)
    street = location.get(PlaceType.STREET)
    city = location.get(PlaceType.CITY)
    # Build a title description string that will work for Eniro
    area_descr = ""
    if street:
        area_descr += street.strip()
    if city:
        area_descr += ', ' + city
    return _strip_leading_comma(area_descr)
Esempio n. 16
0
def _build_area(db, place):
    """ Builds string for area parameter in url """
    location = get_main_location(db, place)
    street = location.get(PlaceType.STREET)
    city = location.get(PlaceType.CITY)
    # Build a title description string that will work for Eniro
    area_descr = ""
    if street:
        area_descr += street.strip() 
    if city:
        area_descr += ', ' + city 
    return _strip_leading_comma(area_descr)
Esempio n. 17
0
 def __output_place(self, ldatec, tbody, first_place, pname, place_handle,
                    letter, bucket_link):
     place = self.r_db.get_place_from_handle(place_handle)
     if place:
         if place.get_change_time() > ldatec:
             ldatec = place.get_change_time()
         plc_title = pname
         main_location = get_main_location(self.r_db, place)
         if not plc_title or plc_title == " ":
             letter = "&nbsp;"
         trow = Html("tr")
         tbody += trow
         tcell = Html("td", class_="ColumnLetter", inline=True)
         trow += tcell
         if first_place:
             # or primary_difference(letter, prev_letter, self.rlocale):
             first_place = False
             # prev_letter = letter
             trow.attr = 'class = "BeginLetter"'
             ttle = self._("Places beginning " "with letter %s") % letter
             tcell += Html("a",
                           letter,
                           name=letter,
                           title=ttle,
                           id_=bucket_link)
         else:
             tcell += "&nbsp;"
         trow += Html("td",
                      self.place_link(place.get_handle(), plc_title,
                                      place.get_gramps_id()),
                      class_="ColumnName")
         trow.extend(
             Html("td", data or "&nbsp;", class_=colclass, inline=True)
             for (colclass, data) in [[
                 "ColumnState",
                 main_location.get(PlaceType.STATE, '')
             ], ["ColumnCountry",
                 main_location.get(PlaceType.COUNTRY, '')]])
         if self.display_coordinates:
             tcell1 = Html("td", class_="ColumnLatitude", inline=True)
             tcell2 = Html("td", class_="ColumnLongitude", inline=True)
             trow += tcell1, tcell2
             if place.lat and place.long:
                 latitude, longitude = conv_lat_lon(place.lat, place.long,
                                                    "DEG")
                 tcell1 += latitude
                 tcell2 += longitude
             else:
                 tcell1 += '&nbsp;'
                 tcell2 += '&nbsp;'
     return (ldatec, first_place)
Esempio n. 18
0
 def get_event_place(self, event):
     place_text = None
     place_handle = event.get_place_handle()
     if place_handle:
         place = self._db.get_place_from_handle(place_handle)
         if place:
             location = get_main_location(self._db, place)
             if location.get(PlaceType.CITY):
                 place_text = location.get(PlaceType.CITY)
             elif location.get(PlaceType.STATE):
                 place_text = location.get(PlaceType.STATE)
             elif location.get(PlaceType.COUNTRY):
                 place_text = location.get(PlaceType.COUNTRY)
     return place_text
Esempio n. 19
0
 def get_event_place(self, event):
     place_text = None
     place_handle = event.get_place_handle()
     if place_handle:
         place = self._db.get_place_from_handle(place_handle)
         if place:
             location = get_main_location(self._db, place)
             if location.get(PlaceType.CITY):
                 place_text = location.get(PlaceType.CITY)
             elif location.get(PlaceType.STATE):
                 place_text = location.get(PlaceType.STATE)
             elif location.get(PlaceType.COUNTRY):
                 place_text = location.get(PlaceType.COUNTRY)
     return place_text
Esempio n. 20
0
def place_to_dict(db, p):
    """Return a dictionary with information about the place."""
    return {
        'handle': p.handle,
        'name': p.name.value,
        'geolocation': geolocation(p),
        'gramps_id': p.gramps_id,
        'type_string': p.place_type.string,
        'type_value': p.place_type.value,
        'media': [{
            'ref': r.ref,
            'rect': r.rect
        } for r in p.get_media_list()],
        'hierarchy': get_main_location(db, p),
        'citations': get_citation_ids(db, p),
        'notes': get_note_ids(db, p),
    }
Esempio n. 21
0
def _build_title(db, place):
    """ Builds descrition string for title parameter in url """
    descr = place_displayer.display(db, place)
    location = get_main_location(db, place)
    parish = location.get(PlaceType.PARISH)
    city = location.get(PlaceType.CITY)
    state = location.get(PlaceType.STATE)
    title_descr = ""
    if descr:
        title_descr += descr.strip()
    if parish:
        title_descr += ', ' + parish.strip() + _(" parish")
    if city:
        title_descr += ', ' + city.strip()
    if state:
        title_descr += ', ' + state.strip() + _(" state")
    return _strip_leading_comma(title_descr)
Esempio n. 22
0
    def generate_place_dictionary(self, place):
        db = self.dbstate.get_database()
        location = get_main_location(db, place)
        place_dict = dict()

        for key in self._place_keys:
            place_type = self._place_types.get(key.lower())
            if place_type:
                value = location.get(place_type)
            elif key == "code":
                value = place.get_code()
            else:
                value = ""
            if not value: value = ""

            place_dict[key] = value
        return place_dict
Esempio n. 23
0
def _build_title(db, place):
    """ Builds descrition string for title parameter in url """
    descr = place.get_title()
    location = get_main_location(db, place)
    parish = location.get(PlaceType.PARISH)
    city = location.get(PlaceType.CITY)
    state = location.get(PlaceType.STATE)
    title_descr = ""
    if descr:
        title_descr += descr.strip()
    if parish:
        title_descr += ', ' + parish.strip() + _(" parish")
    if city:
        title_descr += ', ' + city.strip()
    if state:
        title_descr += ', ' + state.strip() + _(" state")
    return _strip_leading_comma(title_descr)
Esempio n. 24
0
    def __write_place(self, handle, place_nbr):
        """
        This procedure writes out the details of a single place
        """
        place = self.database.get_place_from_handle(handle)
        location = get_main_location(self.database, place)
        city = ''
        for pl_type in [PlaceType.HAMLET, PlaceType.VILLAGE,
                            PlaceType.TOWN, PlaceType.CITY]:
            if location.get(pl_type):
                city = location.get(pl_type)
                break

        place_title = _pd.display(self.database, place)
        if city == '' and place_title:
            return place_title

        return city
Esempio n. 25
0
def _build_title(db, place):
    """ Builds descrition string for title parameter in url """
    descr = place_displayer.display(db, place)
    location = get_main_location(db, place)
    parish = location.get(PlaceType.PARISH)
    city = location.get(PlaceType.CITY)
    state = location.get(PlaceType.STATE)
    title_descr = ""
    if descr:
        title_descr += descr.strip()
    if parish:
        # TODO for Arabic, should the next line's comma be translated?
        title_descr += ', ' + parish.strip() + _(" parish")
    if city:
        # TODO for Arabic, should the next line's comma be translated?
        title_descr += ', ' + city.strip()
    if state:
        # TODO for Arabic, should the next line's comma be translated?
        title_descr += ', ' + state.strip() + _(" state")
    return _strip_leading_comma(title_descr)
Esempio n. 26
0
    def __write_place(self, handle, place_nbr):
        """
        This procedure writes out the details of a single place
        """
        place = self.database.get_place_from_handle(handle)
        location = get_main_location(self.database, place)
        city = ''
        for pl_type in [
                PlaceType.HAMLET, PlaceType.VILLAGE, PlaceType.TOWN,
                PlaceType.CITY
        ]:
            if location.get(pl_type):
                city = location.get(pl_type)
                break

        place_title = _pd.display(self.database, place)
        if city == '' and place_title:
            return place_title

        return city
Esempio n. 27
0
    def slider_change(self, obj, lat, lon):
        """
        Display on the map a circle in which we select all the places
        inside this region.
        """
        self.radius = obj.get_value() if obj else 1.0
        self.show_the_region(self.radius)
        self.match(lat, lon)
        self.plist.clear()
        if self.oldvalue != None:
            # The old values are always in the first row.
            # In this case, we change the color of the row.
            # display the associated message
            self.label2.show()
            place = self.dbstate.db.get_place_from_handle(self.oldvalue)
            loc = get_main_location(self.dbstate.db, place)
            self.plist.append((PLACE_STRING % loc.get(PlaceType.COUNTRY, ''),
                               PLACE_STRING % loc.get(PlaceType.STATE, ''),
                               PLACE_STRING % loc.get(PlaceType.COUNTY, ''),
                               PLACE_STRING % _('Other'),
                               self.oldvalue)
                             )
        for place in self.places:
            self.plist.append((place[0], place[1],
                               place[2], place[3], place[4]))
        # here, we could add value from geography names services ...
        if GEOCODEGLIB:
            loc = GeocodeGlib.Location.new(lat, lon, 0)
            obj = GeocodeGlib.Reverse.new_for_location(loc)
            try:
                result = GeocodeGlib.Reverse.resolve(obj)
                self.plist.append((GEOCODE_STRING % result.get_country(),
                                   GEOCODE_STRING % result.get_state(),
                                   GEOCODE_STRING % result.get_town(),
                                   GEOCODE_STRING % result.get_name(), ''))
            except:
                pass

        # if we found no place, we must create a default place.
        self.plist.append((_("New place with empty fields"), "",
                           "...", "", None))
Esempio n. 28
0
    def __write_place(self, handle, place_nbr):
        """
        This procedure writes out the details of a single place
        """
        place = self.database.get_place_from_handle(handle)
        location = get_main_location(self.database, place)

        place_details = [
            self._("Gramps ID: %s ") % place.get_gramps_id(),
            self._("Street: %s ") % location.get(PlaceType.STREET, ''),
            self._("Parish: %s ") % location.get(PlaceType.PARISH, ''),
            self._("Locality: %s ") % location.get(PlaceType.LOCALITY, ''),
            self._("City: %s ") % location.get(PlaceType.CITY, ''),
            self._("County: %s ") % location.get(PlaceType.COUNTY, ''),
            self._("State: %s") % location.get(PlaceType.STATE, ''),
            self._("Country: %s ") % location.get(PlaceType.COUNTRY, '')]
        place_names = ''
        all_names = place.get_all_names()
        if len(all_names) > 1 or __debug__:
            for place_name in all_names:
                if place_names != '':
                    # translators: needed for Arabic, ignore otherwise
                    place_names += self._(", ")
                place_names += '%s' % place_name.get_value()
                if place_name.get_language() != '' or __debug__:
                    place_names += ' (%s)' % place_name.get_language()
            place_details += [self._("places|All Names: %s") % place_names,]
        self.doc.start_paragraph("PLC-PlaceTitle")
        place_title = place_displayer.display(self.database, place)
        self.doc.write_text(("%(nbr)s. %(place)s") %
                                {'nbr' : place_nbr,
                                 'place' : place_title})
        self.doc.end_paragraph()

        for item in place_details:
            self.doc.start_paragraph("PLC-PlaceDetails")
            self.doc.write_text(item)
            self.doc.end_paragraph()
Esempio n. 29
0
    def calc_url(self):
        """ Determine the url to use on maps.google.com
            Logic: use lat lon if present
                   otherwise use city and country if present
                   otherwise use description of the place
        """
        place = self._get_first_place()[0]
        latitude, longitude = self._lat_lon(place)
        if longitude and latitude:
            self.url = "http://maps.google.com/maps/mm?sll=%s,%s&z=15" % (
                latitude, longitude)
            return

        location = get_main_location(self.database, place)
        city = location.get(PlaceType.CITY)
        country = location.get(PlaceType.COUNTRY)
        if city and country:
            self.url = "http://maps.google.com/maps?q=%s,%s" % (city, country)
            return

        titledescr = place_displayer.display(self.database, place)
        self.url = "http://maps.google.com/maps?q=%s" % \
                                            '+'.join(titledescr.split())
Esempio n. 30
0
    def calc_url(self):
        """ Determine the url to use on maps.google.com
            Logic: use lat lon if present
                   otherwise use city and country if present
                   otherwise use description of the place
        """
        place = self._get_first_place()[0]
        latitude, longitude = self._lat_lon(place)
        if longitude and latitude:
            self.url = "http://maps.google.com/maps/mm?sll=%s,%s&z=15" % (latitude,
                                                               longitude)
            return

        location = get_main_location(self.database, place)
        city = location.get(PlaceType.CITY)
        country = location.get(PlaceType.COUNTRY)
        if city and country:
            self.url = "http://maps.google.com/maps?q=%s,%s" % (city, country)
            return

        titledescr = place_displayer.display(self.database, place)
        self.url = "http://maps.google.com/maps?q=%s" % \
                                            '+'.join(titledescr.split())
Esempio n. 31
0
    def parse_format(self, database, place):
        """ Parse the place """

        if self.is_blank(place):
            return

        code = "elcuspn" + "oitxy"
        upper = code.upper()

        main_loc = get_main_location(database, place, date=self.date)
        location = Location()
        location.set_street(main_loc.get(PlaceType.STREET, ''))
        location.set_locality(main_loc.get(PlaceType.LOCALITY, ''))
        location.set_parish(main_loc.get(PlaceType.PARISH, ''))
        location.set_city(main_loc.get(PlaceType.CITY, ''))
        location.set_county(main_loc.get(PlaceType.COUNTY, ''))
        location.set_state(main_loc.get(PlaceType.STATE, ''))
        location.set_postal_code(main_loc.get(PlaceType.STREET, ''))
        location.set_country(main_loc.get(PlaceType.COUNTRY, ''))

        function = [location.get_street,
                    location.get_locality,
                    location.get_city,
                    location.get_county,
                    location.get_state,
                    place.get_code,
                    location.get_country,

                    location.get_phone,
                    location.get_parish,
                    place.get_title,
                    place.get_longitude,
                    place.get_latitude
                   ]

        return self.generic_format(place, code, upper, function)
Esempio n. 32
0
    def writePeople(self):

        self.doc.add_comment('')

        # If we're going to attempt to include images, then use the HTML style
        # of .gv file.
        bUseHtmlOutput = False
        if self._incimages:
            bUseHtmlOutput = True

        # loop through all the people we need to output
        for handle in sorted(self._people):  # enable a diff
            person = self._db.get_person_from_handle(handle)
            name = self._name_display.display(person)
            p_id = person.get_gramps_id()

            # figure out what colour to use
            gender = person.get_gender()
            colour = self._colorunknown
            if gender == Person.MALE:
                colour = self._colormales
            elif gender == Person.FEMALE:
                colour = self._colorfemales

            # see if we have surname colours that match this person
            surname = person.get_primary_name().get_surname().encode(
                'iso-8859-1', 'xmlcharrefreplace')
            if surname in self._surnamecolors:
                colour = self._surnamecolors[surname]

            # see if we have a birth/death or fallback dates we can use
            if self._incdates or self._incplaces:
                bth_event = get_birth_or_fallback(self._db, person)
                dth_event = get_death_or_fallback(self._db, person)
            else:
                bth_event = None
                dth_event = None

            # output the birth or fallback event
            birthStr = None
            if bth_event and self._incdates:
                date = bth_event.get_date_object()
                if self._just_years and date.get_year_valid():
                    birthStr = '%i' % date.get_year()
                else:
                    birthStr = self._get_date(date)

            # get birth place (one of:  city, state, or country) we can use
            birthplace = None
            if bth_event and self._incplaces:
                place = self._db.get_place_from_handle(
                    bth_event.get_place_handle())
                if place:
                    location = get_main_location(self._db, place)
                    if location.get(PlaceType.CITY):
                        birthplace = location.get(PlaceType.CITY)
                    elif location.get(PlaceType.STATE):
                        birthplace = location.get(PlaceType.STATE)
                    elif location.get(PlaceType.COUNTRY):
                        birthplace = location.get(PlaceType.COUNTRY)

            # see if we have a deceased date we can use
            deathStr = None
            if dth_event and self._incdates:
                date = dth_event.get_date_object()
                if self._just_years and date.get_year_valid():
                    deathStr = '%i' % date.get_year()
                else:
                    deathStr = self._get_date(date)

            # get death place (one of:  city, state, or country) we can use
            deathplace = None
            if dth_event and self._incplaces:
                place = self._db.get_place_from_handle(
                    dth_event.get_place_handle())
                if place:
                    location = get_main_location(self._db, place)
                    if location.get(PlaceType.CITY):
                        deathplace = location.get(PlaceType.CITY)
                    elif location.get(PlaceType.STATE):
                        deathplace = location.get(PlaceType.STATE)
                    elif location.get(PlaceType.COUNTRY):
                        deathplace = location.get(PlaceType.COUNTRY)

            # see if we have an image to use for this person
            imagePath = None
            if self._incimages:
                mediaList = person.get_media_list()
                if len(mediaList) > 0:
                    mediaHandle = mediaList[0].get_reference_handle()
                    media = self._db.get_object_from_handle(mediaHandle)
                    mediaMimeType = media.get_mime_type()
                    if mediaMimeType[0:5] == "image":
                        imagePath = get_thumbnail_path(
                            media_path_full(self._db, media.get_path()),
                            rectangle=mediaList[0].get_rectangle())

            # put the label together and output this person
            label = ""
            lineDelimiter = '\\n'
            if bUseHtmlOutput:
                lineDelimiter = '<BR/>'

            # if we have an image, then start an HTML table;
            # remember to close the table afterwards!
            if imagePath:
                label = ('<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0" '
                         'CELLBORDER="0"><TR><TD><IMG SRC="%s"/></TD>' %
                         imagePath)
                if self._imageonside == 0:
                    label += '</TR><TR>'
                label += '<TD>'

            # at the very least, the label must have the person's name
            label += name
            if self.includeid == 1:  # same line
                label += " (%s)" % p_id
            elif self.includeid == 2:  # own line
                label += "%s(%s)" % (lineDelimiter, p_id)

            if birthStr or deathStr:
                label += '%s(' % lineDelimiter
                if birthStr:
                    label += '%s' % birthStr
                label += ' - '
                if deathStr:
                    label += '%s' % deathStr
                label += ')'
            if birthplace or deathplace:
                if birthplace == deathplace:
                    deathplace = None  # no need to print the same name twice
                label += '%s' % lineDelimiter
                if birthplace:
                    label += '%s' % birthplace
                if birthplace and deathplace:
                    label += ' / '
                if deathplace:
                    label += '%s' % deathplace

            # see if we have a table that needs to be terminated
            if imagePath:
                label += '</TD></TR></TABLE>'

            shape = "box"
            style = "solid"
            border = colour
            fill = colour

            # do not use colour if this is B&W outline
            if self._colorize == 'outline':
                border = ""
                fill = ""

            if gender == person.FEMALE and self._useroundedcorners:
                style = "rounded"
            elif gender == person.UNKNOWN:
                shape = "hexagon"

            # if we're filling the entire node:
            if self._colorize == 'filled':
                style += ",filled"
                border = ""

            # we're done -- add the node
            self.doc.add_node(p_id,
                              label=label,
                              shape=shape,
                              color=border,
                              style=style,
                              fillcolor=fill,
                              htmloutput=bUseHtmlOutput)
Esempio n. 33
0
    def writePeople(self):

        self.doc.add_comment('')

        # If we're going to attempt to include images, then use the HTML style
        # of .gv file.
        bUseHtmlOutput = False
        if self._incimages:
            bUseHtmlOutput = True

        # TODO there could be improvement and is still something wrong (wrong order)
        # also people should be sorted by their marriage - so first marriage, then 2nd marriage
        def personSorter(handle):
            person = self._db.get_person_from_handle(handle)
            fHandle = person.get_main_parents_family_handle()
            if fHandle:
                family = self._db.get_family_from_handle(fHandle)
                if family:
                    childList = family.get_child_ref_list()
                    childListRef = []
                    for ch in childList:
                        childListRef.append(ch.ref)
                    try:
                        return childListRef.index(person.get_handle())
                    except:
                        pass
            return 0

        sorted_people = sorted(self._people, key=personSorter)
        for handle in sorted_people:
            person = self._db.get_person_from_handle(handle)
            name = self._name_display.display(person)

            # figure out what colour to use
            gender = person.get_gender()
            colour = self._colorunknown
            if gender == Person.MALE:
                colour = self._colormales
            elif gender == Person.FEMALE:
                colour = self._colorfemales

            # see if we have surname colours that match this person
            surname = person.get_primary_name().get_surname().encode(
                'iso-8859-1', 'xmlcharrefreplace')
            if surname in self._surnamecolors:
                colour = self._surnamecolors[surname]

            # see if we have a birth/death or fallback dates we can use
            if self._incdates or self._incplaces:
                bth_event = get_birth_or_fallback(self._db, person)
                dth_event = get_death_or_fallback(self._db, person)
            else:
                bth_event = None
                dth_event = None

            # output the birth or fallback event
            birthStr = None
            if bth_event and self._incdates:
                if not bth_event.private or self._incprivate:
                    date = bth_event.get_date_object()
                    if self._just_years and date.get_year_valid():
                        birthStr = '%i' % date.get_year()
                    else:
                        birthStr = self._get_date(date)

            # get birth place (one of:  city, state, or country) we can use
            birthplace = None
            if bth_event and self._incplaces:
                if not bth_event.private or self._incprivate:
                    place = self._db.get_place_from_handle(
                        bth_event.get_place_handle())
                    if place:
                        location = get_main_location(self._db, place)
                        if location.get(PlaceType.CITY):
                            birthplace = location.get(PlaceType.CITY)
                        elif location.get(PlaceType.STATE):
                            birthplace = location.get(PlaceType.STATE)
                        elif location.get(PlaceType.COUNTRY):
                            birthplace = location.get(PlaceType.COUNTRY)

            # see if we have a deceased date we can use
            deathStr = None
            if dth_event and self._incdates:
                if not dth_event.private or self._incprivate:
                    date = dth_event.get_date_object()
                    if self._just_years and date.get_year_valid():
                        deathStr = '%i' % date.get_year()
                    else:
                        deathStr = self._get_date(date)

            # get death place (one of:  city, state, or country) we can use
            deathplace = None
            if dth_event and self._incplaces:
                if not dth_event.private or self._incprivate:
                    place = self._db.get_place_from_handle(
                        dth_event.get_place_handle())
                    if place:
                        location = get_main_location(self._db, place)
                        if location.get(PlaceType.CITY):
                            deathplace = location.get(PlaceType.CITY)
                        elif location.get(PlaceType.STATE):
                            deathplace = location.get(PlaceType.STATE)
                        elif location.get(PlaceType.COUNTRY):
                            deathplace = location.get(PlaceType.COUNTRY)

            occupations = self.getOccupations(person)

            # see if we have an image to use for this person
            imagePath = None
            if self._incimages:
                mediaList = person.get_media_list()
                if len(mediaList) > 0:
                    mediaHandle = mediaList[0].get_reference_handle()
                    media = self._db.get_object_from_handle(mediaHandle)
                    mediaMimeType = media.get_mime_type()
                    if mediaMimeType[0:5] == "image":
                        imagePath = get_thumbnail_path(
                            media_path_full(self._db, media.get_path()),
                            rectangle=mediaList[0].get_rectangle())

            # put the label together and output this person
            label = ""
            lineDelimiter = '\\n'
            if bUseHtmlOutput:
                lineDelimiter = '<BR/>'

            # if we have an image, then start an HTML table;
            # remember to close the table afterwards!
            if imagePath:
                label = ('<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0" '
                         'CELLBORDER="0"><TR><TD><IMG SRC="%s"/></TD>' %
                         imagePath)
                if self._imageonside == 0:
                    label += '</TR><TR>'
                label += '<TD>'

            # at the very least, the label must have the person's name
            label += name
            print name
            if birthStr or deathStr:
                label += '%s(' % lineDelimiter
                if birthStr:
                    label += '%s' % birthStr
                label += ' - '
                if deathStr:
                    label += '%s' % deathStr
                label += ')'
            if birthplace or deathplace:
                if birthplace == deathplace:
                    deathplace = None  # no need to print the same name twice
                label += '%s' % lineDelimiter
                if birthplace:
                    label += '%s' % birthplace
                if birthplace and deathplace:
                    label += ' / '
                if deathplace:
                    label += '%s' % deathplace

            if len(occupations) > 0:
                plural = ''
                if len(occupations) > 1:
                    plural = 'e'
                label += '%s Beruf%s: %s' % (lineDelimiter, plural,
                                             ', '.join(occupations))

            for family_handle in person.get_family_handle_list():
                if family_handle not in self._families:
                    # label += '<small>'
                    family = self._db.get_family_from_handle(family_handle)

                    children = []
                    grandChildren = []
                    for childRef in family.get_child_ref_list():
                        child = self._db.get_person_from_handle(childRef.ref)
                        if (child.private
                                and self._incprivate) or not child.private:
                            children.append(self.getNameAndBirthDeath(child))
                            for family_handle2 in child.get_family_handle_list(
                            ):
                                family2 = self._db.get_family_from_handle(
                                    family_handle2)
                                for childRef2 in family2.get_child_ref_list():
                                    child2 = self._db.get_person_from_handle(
                                        childRef2.ref)
                                    if (child2.private and self._incprivate
                                        ) or not child2.private:
                                        grandChildren.append(
                                            self.getNameAndBirthDeath(child2))

                    if len(children) > 0:
                        # label += '<div style="text-align:left">'
                        label += lineDelimiter + 'Mehr Kinder: ' + unicode(
                            len(children))
                        if len(children) < 3:
                            for i in children:
                                if i:
                                    label += lineDelimiter + i
                        if len(grandChildren) > 0:
                            label += lineDelimiter + 'Enkel: ' + unicode(
                                len(grandChildren))
                            if len(grandChildren) < 3:
                                for i in grandChildren:
                                    if i:
                                        label += lineDelimiter + i
                        # label += '</small>'
                        # label += '</div>'

            # see if we have a table that needs to be terminated
            if imagePath:
                label += '</TD></TR></TABLE>'

            shape = "box"
            style = "solid"
            border = colour
            fill = colour

            # do not use colour if this is B&W outline
            if self._colorize == 'outline':
                border = ""
                fill = ""

            if gender == person.FEMALE and self._useroundedcorners:
                style = "rounded"
            elif gender == person.UNKNOWN:
                shape = "hexagon"

            # if we're filling the entire node:
            if self._colorize == 'filled':
                style += ",filled"
                border = ""

            # we're done -- add the node
            self.doc.add_node(person.get_gramps_id(),
                              label=label,
                              shape=shape,
                              color=border,
                              style=style,
                              fillcolor=fill,
                              htmloutput=bUseHtmlOutput)
Esempio n. 34
0
    def placelistpage(self, report, title, place_handles):
        """
        Create a place index

        @param: report        -- The instance of the main report class for
                                 this report
        @param: title         -- Is the title of the web page
        @param: place_handles -- The handle for the place to add
        """
        BasePage.__init__(self, report, title)

        output_file, sio = self.report.create_file("places")
        placelistpage, head, body = self.write_header(self._("Places"))
        ldatec = 0
        prev_letter = " "

        # begin places division
        with Html("div", class_="content", id="Places") as placelist:
            body += placelist

            # place list page message
            msg = self._("This page contains an index of all the places in the "
                         "database, sorted by their title. "
                         "Clicking on a place&#8217;s "
                         "title will take you to that place&#8217;s page.")
            placelist += Html("p", msg, id="description")

            # begin alphabet navigation
            index_list = get_first_letters(self.r_db, place_handles,
                                           _KEYPLACE, rlocale=self.rlocale)
            alpha_nav = alphabet_navigation(index_list, self.rlocale)
            if alpha_nav is not None:
                placelist += alpha_nav

            # begin places table and table head
            with Html("table",
                      class_="infolist primobjlist placelist") as table:
                placelist += table

                # begin table head
                thead = Html("thead")
                table += thead

                trow = Html("tr")
                thead += trow

                if self.display_coordinates:
                    trow.extend(
                        Html("th", label, class_=colclass, inline=True)
                        for (label, colclass) in [
                            [self._("Letter"), "ColumnLetter"],
                            [self._("Place Name | Name"), "ColumnName"],
                            [self._("State/ Province"), "ColumnState"],
                            [self._("Country"), "ColumnCountry"],
                            [self._("Latitude"), "ColumnLatitude"],
                            [self._("Longitude"), "ColumnLongitude"]
                        ]
                    )
                else:
                    trow.extend(
                        Html("th", label, class_=colclass, inline=True)
                        for (label, colclass) in [
                            [self._("Letter"), "ColumnLetter"],
                            [self._("Place Name | Name"), "ColumnName"],
                            [self._("State/ Province"), "ColumnState"],
                            [self._("Country"), "ColumnCountry"]
                        ]
                    )

                # bug 9495 : incomplete display of place hierarchy labels
                def sort_by_place_name(obj):
                    """ sort by lower case place name. """
                    name = self.report.obj_dict[Place][obj][1]
                    return name.lower()

                handle_list = sorted(place_handles,
                                     key=lambda x: sort_by_place_name(x))
                first = True

                # begin table body
                tbody = Html("tbody")
                table += tbody

                for place_handle in handle_list:
                    place = self.r_db.get_place_from_handle(place_handle)
                    if place:
                        if place.get_change_time() > ldatec:
                            ldatec = place.get_change_time()
                        plc_title = self.report.obj_dict[Place][place_handle][1]
                        main_location = get_main_location(self.r_db, place)

                        if plc_title and plc_title != " ":
                            letter = get_index_letter(first_letter(plc_title),
                                                      index_list,
                                                      self.rlocale)
                        else:
                            letter = '&nbsp;'

                        trow = Html("tr")
                        tbody += trow

                        tcell = Html("td", class_="ColumnLetter", inline=True)
                        trow += tcell
                        if first or primary_difference(letter, prev_letter,
                                                       self.rlocale):
                            first = False
                            prev_letter = letter
                            trow.attr = 'class = "BeginLetter"'

                            ttle = self._("Places beginning "
                                          "with letter %s") % letter
                            tcell += Html("a", letter, name=letter, title=ttle)
                        else:
                            tcell += "&nbsp;"

                        trow += Html("td",
                                     self.place_link(
                                         place.get_handle(),
                                         plc_title, place.get_gramps_id()),
                                     class_="ColumnName")

                        trow.extend(
                            Html("td", data or "&nbsp;", class_=colclass,
                                 inline=True)
                            for (colclass, data) in [
                                ["ColumnState",
                                 main_location.get(PlaceType.STATE, '')],
                                ["ColumnCountry",
                                 main_location.get(PlaceType.COUNTRY, '')]
                            ]
                        )

                        if self.display_coordinates:
                            tcell1 = Html("td", class_="ColumnLatitude",
                                          inline=True)
                            tcell2 = Html("td", class_="ColumnLongitude",
                                          inline=True)
                            trow += (tcell1, tcell2)

                            if place.lat and place.long:
                                latitude, longitude = conv_lat_lon(place.lat,
                                                                   place.long,
                                                                   "DEG")
                                tcell1 += latitude
                                tcell2 += longitude
                            else:
                                tcell1 += '&nbsp;'
                                tcell2 += '&nbsp;'

        # add clearline for proper styling
        # add footer section
        footer = self.write_footer(ldatec)
        body += (FULLCLEAR, footer)

        # send page out for processing
        # and close the file
        self.xhtml_writer(placelistpage, output_file, sio, ldatec)
Esempio n. 35
0
    def placelistpage(self, report, title, place_handles):
        """
        Create a place index

        @param: report        -- The instance of the main report class for
                                 this report
        @param: title         -- Is the title of the web page
        @param: place_handles -- The handle for the place to add
        """
        BasePage.__init__(self, report, title)

        output_file, sio = self.report.create_file("places")
        result = self.write_header(self._("Places"))
        placelistpage, dummy_head, dummy_body, outerwrapper = result
        ldatec = 0
        prev_letter = " "

        # begin places division
        with Html("div", class_="content", id="Places") as placelist:
            outerwrapper += placelist

            # place list page message
            msg = self._(
                "This page contains an index of all the places in the "
                "database, sorted by their title. "
                "Clicking on a place&#8217;s "
                "title will take you to that place&#8217;s page.")
            placelist += Html("p", msg, id="description")

            # begin alphabet navigation
            index_list = get_first_letters(self.r_db,
                                           place_handles,
                                           _KEYPLACE,
                                           rlocale=self.rlocale)
            alpha_nav = alphabet_navigation(index_list, self.rlocale)
            if alpha_nav is not None:
                placelist += alpha_nav

            # begin places table and table head
            with Html("table",
                      class_="infolist primobjlist placelist") as table:
                placelist += table

                # begin table head
                thead = Html("thead")
                table += thead

                trow = Html("tr")
                thead += trow

                if self.display_coordinates:
                    trow.extend(
                        Html("th", label, class_=colclass, inline=True)
                        for (label, colclass
                             ) in [[self._("Letter"), "ColumnLetter"],
                                   [self._("Place Name | Name"), "ColumnName"],
                                   [self._("State/ Province"), "ColumnState"],
                                   [self._("Country"), "ColumnCountry"],
                                   [self._("Latitude"), "ColumnLatitude"],
                                   [self._("Longitude"), "ColumnLongitude"]])
                else:
                    trow.extend(
                        Html("th", label, class_=colclass, inline=True)
                        for (label, colclass
                             ) in [[self._("Letter"), "ColumnLetter"],
                                   [self._("Place Name | Name"), "ColumnName"],
                                   [self._("State/ Province"), "ColumnState"],
                                   [self._("Country"), "ColumnCountry"]])

                # bug 9495 : incomplete display of place hierarchy labels
                def sort_by_place_name(obj):
                    """ sort by lower case place name. """
                    name = self.report.obj_dict[Place][obj][1]
                    return name.lower()

                handle_list = sorted(place_handles,
                                     key=lambda x: sort_by_place_name(x))
                first = True

                # begin table body
                tbody = Html("tbody")
                table += tbody

                for place_handle in handle_list:
                    place = self.r_db.get_place_from_handle(place_handle)
                    if place:
                        if place.get_change_time() > ldatec:
                            ldatec = place.get_change_time()
                        plc_title = self.report.obj_dict[Place][place_handle][
                            1]
                        main_location = get_main_location(self.r_db, place)

                        if plc_title and plc_title != " ":
                            letter = get_index_letter(first_letter(plc_title),
                                                      index_list, self.rlocale)
                        else:
                            letter = '&nbsp;'

                        trow = Html("tr")
                        tbody += trow

                        tcell = Html("td", class_="ColumnLetter", inline=True)
                        trow += tcell
                        if first or primary_difference(letter, prev_letter,
                                                       self.rlocale):
                            first = False
                            prev_letter = letter
                            trow.attr = 'class = "BeginLetter"'

                            ttle = self._("Places beginning "
                                          "with letter %s") % letter
                            tcell += Html("a", letter, name=letter, title=ttle)
                        else:
                            tcell += "&nbsp;"

                        trow += Html("td",
                                     self.place_link(place.get_handle(),
                                                     plc_title,
                                                     place.get_gramps_id()),
                                     class_="ColumnName")

                        trow.extend(
                            Html("td",
                                 data or "&nbsp;",
                                 class_=colclass,
                                 inline=True) for (colclass, data) in
                            [[
                                "ColumnState",
                                main_location.get(PlaceType.STATE, '')
                            ],
                             [
                                 "ColumnCountry",
                                 main_location.get(PlaceType.COUNTRY, '')
                             ]])

                        if self.display_coordinates:
                            tcell1 = Html("td",
                                          class_="ColumnLatitude",
                                          inline=True)
                            tcell2 = Html("td",
                                          class_="ColumnLongitude",
                                          inline=True)
                            trow += (tcell1, tcell2)

                            if place.lat and place.long:
                                latitude, longitude = conv_lat_lon(
                                    place.lat, place.long, "DEG")
                                tcell1 += latitude
                                tcell2 += longitude
                            else:
                                tcell1 += '&nbsp;'
                                tcell2 += '&nbsp;'

        # add clearline for proper styling
        # add footer section
        footer = self.write_footer(ldatec)
        outerwrapper += (FULLCLEAR, footer)

        # send page out for processing
        # and close the file
        self.xhtml_writer(placelistpage, output_file, sio, ldatec)
Esempio n. 36
0
    def calc_url(self):
        """ Determine the url to use on maps.google.com
            Logic: valid for places within Sweden and
                   Denmark, only if lat lon avalible
                   use lat lon if present
                   otherwise use city and country if present
                   otherwise use description of the place
        """
        place = self._get_first_place()[0]
        path = ""
        # First see if we are in or near Sweden or Denmark
        # Change country to upper case
        location = get_main_location(self.database, place)
        country = location.get(PlaceType.COUNTRY, '').upper().strip()
        country_given = (country in MAP_NAMES_SWEDEN or \
                        country in MAP_NAMES_DENMARK) and (country != "")
        # if no country given, check if we might be in the vicinity defined by
        # 54 33' 0" < lat < 66 9' 0", 54.55 and 69.05
        # 8 3' 0" < long < 24 9' 0", 8.05 and 24.15
        latitude, longitude = self._lat_lon(place)
        if latitude is None or longitude is None:
            coord_ok = False
        else:
            latitude = float(latitude)
            longitude = float(longitude)
            # Check if coordinates are inside Sweden and Denmark
            if (54.55 < latitude < 69.05) and (8.05 < longitude < 24.15):
                coord_ok = True
            else:
                msg2 = _("Latitude not within '54.55' to '69.05'\n") + \
                       _("Longitude not within '8.05' to '24.15'")
                WarningDialog(_("Eniro map not available"), msg2,
                              parent=self.uistate.window)
                return

        if coord_ok:
            place_title = _build_title(self.database, place)
            place_city =  _build_city(self.database, place)
            x_coord, y_coord = self._lat_lon(place, format="RT90")
            # Set zoom level to 5 if Sweden/Denmark, others 3
            zoom = 5
            if not country_given:
                zoom = 3
            path = "http://www.eniro.se/partner.fcgi?pis=1&x=%s&y=%s" \
                   "&zoom_level=%i&map_size=0&title=%s&city=%s&partner=gramps"
            # Note x and y are swapped!
            path = path % (y_coord , x_coord, zoom, place_title, place_city)
            self.url = path.replace(" ","%20")
            return

        place_area = _build_area(self.database, place)
        if country_given and place_area:
            if country in MAP_NAMES_SWEDEN:
                path = "http://kartor.eniro.se/query?&what=map_adr&mop=aq" \
                       "&geo_area=%s&partner=gramps"
                path = path % (place_area)
                self.url = path.replace(" ","%20")
                return
            else:
                WarningDialog(_("Eniro map not available"),
                              _("Coordinates needed in Denmark"),
                              parent=self.uistate.window)
                self.url = ""
                return

        WarningDialog(_("Eniro map not available"),
                      _("Latitude and longitude,\n"
                        "or street and city needed"),
                      parent=self.uistate.window)
        return
Esempio n. 37
0
    def run(self, db):
        """
        Performs the actual extraction of information
        """

        self.progress = ProgressMeter(_('Checking Place Titles'), '')
        self.progress.set_pass(_('Looking for place fields'),
                               self.db.get_number_of_places())

        self.name_list = []
        self.place_import = PlaceImport(db)

        for place in db.iter_places():
            descr = place_displayer.display(db, place)
            self.progress.step()

            loc = get_main_location(db, place)
            location = ((loc.get(PlaceType.STREET, '')),
                        (loc.get(PlaceType.LOCALITY, '')),
                        (loc.get(PlaceType.PARISH, '')),
                        (loc.get(PlaceType.CITY, '')),
                        (loc.get(PlaceType.COUNTY, '')),
                        (loc.get(PlaceType.STATE, '')),
                        (loc.get(PlaceType.COUNTRY, '')))
            self.place_import.store_location(location, place.handle)

            if len(place.get_placeref_list()) == 0:

                match = CITY_STATE_ZIP.match(descr.strip())
                if match:
                    data = match.groups()
                    city = data[0]
                    state = data[2]
                    postal = data[5]

                    val = " ".join(state.strip().split()).upper()
                    if state:
                        new_state = STATE_MAP.get(val.upper())
                        if new_state:
                            self.name_list.append(
                                (place.handle, (city, new_state[0], postal,
                                          COUNTRY[new_state[1]])))
                    continue

                # Check if there is a left parant. in the string, might be Swedish laen.
                match = CITY_LAEN.match(descr.strip().replace(","," "))
                if match:
                    data = match.groups()
                    city = data[0]
                    state = '(' + data[1] + ')'
                    postal = None
                    val = " ".join(state.strip().split()).upper()
                    if state:
                        new_state = STATE_MAP.get(val.upper())
                        if new_state:
                            self.name_list.append(
                                (place.handle, (city, new_state[0], postal,
                                          COUNTRY[new_state[1]])))
                    continue
                match = CITY_STATE.match(descr.strip())
                if match:
                    data = match.groups()
                    city = data[0]
                    state = data[1]
                    postal = None
                    if state:
                        m0 = STATE_ZIP.match(state)
                        if m0:
                            (state, postal) = m0.groups()

                    val = " ".join(state.strip().split()).upper()
                    if state:
                        new_state = STATE_MAP.get(val.upper())
                        if new_state:
                            self.name_list.append(
                                (place.handle, (city, new_state[0], postal,
                                          COUNTRY[new_state[1]])))
                    continue

                val = " ".join(descr.strip().split()).upper()
                new_state = STATE_MAP.get(val)
                if new_state:
                    self.name_list.append(
                        (place.handle, (None, new_state[0], None,
                                  COUNTRY[new_state[1]])))
        self.progress.close()

        if self.name_list:
            self.display()
        else:
            self.close()
            from gramps.gui.dialog import OkDialog
            OkDialog(_('No modifications made'),
                     _("No place information could be extracted."))
Esempio n. 38
0
    def writeFamilies(self):

        self.doc.add_comment('')
        ngettext = self._locale.translation.ngettext  # to see "nearby" comments

        # loop through all the families we need to output
        for family_handle in sorted(self._families):  # enable a diff
            family = self._db.get_family_from_handle(family_handle)
            fgid = family.get_gramps_id()

            # figure out a wedding date or placename we can use
            weddingDate = None
            weddingPlace = None
            if self._incdates or self._incplaces:
                for event_ref in family.get_event_ref_list():
                    event = self._db.get_event_from_handle(event_ref.ref)
                    if event.get_type() == EventType.MARRIAGE and \
                    (event_ref.get_role() == EventRoleType.FAMILY or
                    event_ref.get_role() == EventRoleType.PRIMARY ):
                        # get the wedding date
                        if self._incdates:
                            date = event.get_date_object()
                            if self._just_years and date.get_year_valid():
                                weddingDate = '%i' % date.get_year()
                            else:
                                weddingDate = self._get_date(date)
                        # get the wedding location
                        if self._incplaces:
                            place = self._db.get_place_from_handle(
                                event.get_place_handle())
                            if place:
                                location = get_main_location(self._db, place)
                                if location.get(PlaceType.CITY):
                                    weddingPlace = location.get(PlaceType.CITY)
                                elif location.get(PlaceType.STATE):
                                    weddingPlace = location.get(
                                        PlaceType.STATE)
                                elif location.get(PlaceType.COUNTRY):
                                    weddingPlace = location.get(
                                        PlaceType.COUNTRY)
                        break

            # figure out the number of children (if any)
            childrenStr = None
            if self._incchildcount:
                child_count = len(family.get_child_ref_list())
                if child_count >= 1:
                    # translators: leave all/any {...} untranslated
                    childrenStr = ngettext(
                        "{number_of} child", "{number_of} children",
                        child_count).format(number_of=child_count)

            label = ''
            fgid_already = False
            if weddingDate:
                if label != '':
                    label += '\\n'
                label += '%s' % weddingDate
                if self.includeid == 1 and not fgid_already:  # same line
                    label += " (%s)" % fgid
                    fgid_already = True
            if weddingPlace:
                if label != '':
                    label += '\\n'
                label += '%s' % weddingPlace
                if self.includeid == 1 and not fgid_already:  # same line
                    label += " (%s)" % fgid
                    fgid_already = True
            if self.includeid == 1 and not label:
                label = "(%s)" % fgid
                fgid_already = True
            elif self.includeid == 2 and not label:  # own line
                label = "(%s)" % fgid
                fgid_already = True
            elif self.includeid == 2 and label and not fgid_already:
                label += "\\n(%s)" % fgid
                fgid_already = True
            if childrenStr:
                if label != '':
                    label += '\\n'
                label += '%s' % childrenStr
                if self.includeid == 1 and not fgid_already:  # same line
                    label += " (%s)" % fgid
                    fgid_already = True

            shape = "ellipse"
            style = "solid"
            border = self._colorfamilies
            fill = self._colorfamilies

            # do not use colour if this is B&W outline
            if self._colorize == 'outline':
                border = ""
                fill = ""

            # if we're filling the entire node:
            if self._colorize == 'filled':
                style += ",filled"
                border = ""

            # we're done -- add the node
            self.doc.add_node(fgid, label, shape, border, style, fill)

        # now that we have the families written, go ahead and link the parents and children to the families
        for family_handle in self._families:

            # get the parents for this family
            family = self._db.get_family_from_handle(family_handle)
            fgid = family.get_gramps_id()
            father_handle = family.get_father_handle()
            mother_handle = family.get_mother_handle()

            self.doc.add_comment('')

            if self._usesubgraphs and father_handle and mother_handle:
                self.doc.start_subgraph(fgid)

            # see if we have a father to link to this family
            if father_handle:
                if father_handle in self._people:
                    father = self._db.get_person_from_handle(father_handle)
                    comment = "father: %s" % father.get_primary_name(
                    ).get_regular_name()
                    self.doc.add_link(father.get_gramps_id(),
                                      fgid,
                                      comment=comment)

            # see if we have a mother to link to this family
            if mother_handle:
                if mother_handle in self._people:
                    mother = self._db.get_person_from_handle(mother_handle)
                    comment = "mother: %s" % mother.get_primary_name(
                    ).get_regular_name()
                    self.doc.add_link(mother.get_gramps_id(),
                                      fgid,
                                      comment=comment)

            if self._usesubgraphs and father_handle and mother_handle:
                self.doc.end_subgraph()

            # link the children to the family
            for childRef in family.get_child_ref_list():
                if childRef.ref in self._people:
                    child = self._db.get_person_from_handle(childRef.ref)
                    comment = "child:  %s" % child.get_primary_name(
                    ).get_regular_name()
                    self.doc.add_link(fgid,
                                      child.get_gramps_id(),
                                      comment=comment)
Esempio n. 39
0
    def writeFamilies(self):

        self.doc.add_comment('')
        ngettext = self._locale.translation.ngettext # to see "nearby" comments

        # loop through all the families we need to output
        for family_handle in sorted(self._families): # enable a diff
            family = self._db.get_family_from_handle(family_handle)
            fgid = family.get_gramps_id()

            # figure out a wedding date or placename we can use
            weddingDate = None
            weddingPlace = None
            if self._incdates or self._incplaces:
                for event_ref in family.get_event_ref_list():
                    event = self._db.get_event_from_handle(event_ref.ref)
                    if event.get_type() == EventType.MARRIAGE and \
                    (event_ref.get_role() == EventRoleType.FAMILY or 
                    event_ref.get_role() == EventRoleType.PRIMARY ):
                        # get the wedding date
                        if self._incdates:
                            date = event.get_date_object()
                            if self._just_years and date.get_year_valid():
                                weddingDate = '%i' % date.get_year()
                            else:
                                weddingDate = self._get_date(date)
                        # get the wedding location
                        if self._incplaces:
                            place = self._db.get_place_from_handle(
                                                   event.get_place_handle())
                            if place:
                                location = get_main_location(self._db, place)
                                if location.get(PlaceType.CITY):
                                    weddingPlace = location.get(PlaceType.CITY)
                                elif location.get(PlaceType.STATE):
                                    weddingPlace = location.get(PlaceType.STATE)
                                elif location.get(PlaceType.COUNTRY):
                                    weddingPlace = location.get(PlaceType.COUNTRY)
                        break

            # figure out the number of children (if any)
            childrenStr = None
            if self._incchildcount:
                child_count = len(family.get_child_ref_list())
                if child_count >= 1:
                    # translators: leave all/any {...} untranslated
                    childrenStr = ngettext("{number_of} child",
                                           "{number_of} children", child_count
                                          ).format(number_of=child_count)

            label = ''
            fgid_already = False
            if weddingDate:
                if label != '':
                    label += '\\n'
                label += '%s' % weddingDate
                if self.includeid == 1 and not fgid_already: # same line
                    label += " (%s)" % fgid
                    fgid_already = True
            if weddingPlace:
                if label != '':
                    label += '\\n'
                label += '%s' % weddingPlace
                if self.includeid == 1 and not fgid_already: # same line
                    label += " (%s)" % fgid
                    fgid_already = True
            if self.includeid == 1 and not label:
                label = "(%s)" % fgid
                fgid_already = True
            elif self.includeid == 2 and not label: # own line
                label = "(%s)" % fgid
                fgid_already = True
            elif self.includeid == 2 and label and not fgid_already:
                label += "\\n(%s)" % fgid
                fgid_already = True
            if childrenStr:
                if label != '':
                    label += '\\n'
                label += '%s' % childrenStr
                if self.includeid == 1 and not fgid_already: # same line
                    label += " (%s)" % fgid
                    fgid_already = True

            shape   = "ellipse"
            style   = "solid"
            border  = self._colorfamilies
            fill    = self._colorfamilies

            # do not use colour if this is B&W outline
            if self._colorize == 'outline':
                border  = ""
                fill    = ""

            # if we're filling the entire node:
            if self._colorize == 'filled':
                style += ",filled"
                border = ""

            # we're done -- add the node
            self.doc.add_node(fgid, label, shape, border, style, fill)

        # now that we have the families written, go ahead and link the parents and children to the families
        for family_handle in self._families:

            # get the parents for this family
            family = self._db.get_family_from_handle(family_handle)
            fgid = family.get_gramps_id()
            father_handle = family.get_father_handle()
            mother_handle = family.get_mother_handle()

            self.doc.add_comment('')

            if self._usesubgraphs and father_handle and mother_handle:
                self.doc.start_subgraph(fgid)

            # see if we have a father to link to this family
            if father_handle:
                if father_handle in self._people:
                    father = self._db.get_person_from_handle(father_handle)
                    comment = "father: %s" % father.get_primary_name().get_regular_name()
                    self.doc.add_link(father.get_gramps_id(), fgid, comment=comment)

            # see if we have a mother to link to this family
            if mother_handle:
                if mother_handle in self._people:
                    mother = self._db.get_person_from_handle(mother_handle)
                    comment = "mother: %s" % mother.get_primary_name().get_regular_name()
                    self.doc.add_link(mother.get_gramps_id(), fgid, comment=comment)

            if self._usesubgraphs and father_handle and mother_handle:
                self.doc.end_subgraph()

            # link the children to the family
            for childRef in family.get_child_ref_list():
                if childRef.ref in self._people:
                    child = self._db.get_person_from_handle(childRef.ref)
                    comment = "child:  %s" % child.get_primary_name().get_regular_name()
                    self.doc.add_link(fgid, child.get_gramps_id(), comment=comment)
Esempio n. 40
0
    def writePeople(self):

        self.doc.add_comment('')

        # If we're going to attempt to include images, then use the HTML style 
        # of .gv file.
        bUseHtmlOutput = False
        if self._incimages:
            bUseHtmlOutput = True

        # loop through all the people we need to output
        for handle in sorted(self._people): # enable a diff
            person = self._db.get_person_from_handle(handle)
            name = self._name_display.display(person)
            p_id = person.get_gramps_id()

            # figure out what colour to use
            gender = person.get_gender()
            colour = self._colorunknown
            if gender == Person.MALE:
                colour = self._colormales
            elif gender == Person.FEMALE:
                colour = self._colorfemales

            # see if we have surname colours that match this person
            surname = person.get_primary_name().get_surname().encode('iso-8859-1','xmlcharrefreplace')
            if surname in self._surnamecolors:
                colour = self._surnamecolors[surname]

            # see if we have a birth/death or fallback dates we can use
            if self._incdates or self._incplaces:
                bth_event = get_birth_or_fallback(self._db, person)
                dth_event = get_death_or_fallback(self._db, person)
            else:
                bth_event = None
                dth_event = None

            # output the birth or fallback event
            birthStr = None
            if bth_event and self._incdates:
                date = bth_event.get_date_object()
                if self._just_years and date.get_year_valid():
                    birthStr = '%i' % date.get_year()
                else:
                    birthStr = self._get_date(date)

            # get birth place (one of:  city, state, or country) we can use
            birthplace = None
            if bth_event and self._incplaces:
                place = self._db.get_place_from_handle(
                                             bth_event.get_place_handle())
                if place:
                    location = get_main_location(self._db, place)
                    if location.get(PlaceType.CITY):
                        birthplace = location.get(PlaceType.CITY)
                    elif location.get(PlaceType.STATE):
                        birthplace = location.get(PlaceType.STATE)
                    elif location.get(PlaceType.COUNTRY):
                        birthplace = location.get(PlaceType.COUNTRY)

            # see if we have a deceased date we can use
            deathStr = None
            if dth_event and self._incdates:
                date = dth_event.get_date_object()
                if self._just_years and date.get_year_valid():
                    deathStr = '%i' % date.get_year()
                else:
                    deathStr = self._get_date(date)

            # get death place (one of:  city, state, or country) we can use
            deathplace = None
            if dth_event and self._incplaces:
                place = self._db.get_place_from_handle(
                                             dth_event.get_place_handle())
                if place:
                    location = get_main_location(self._db, place)
                    if location.get(PlaceType.CITY):
                        deathplace = location.get(PlaceType.CITY)
                    elif location.get(PlaceType.STATE):
                        deathplace = location.get(PlaceType.STATE)
                    elif location.get(PlaceType.COUNTRY):
                        deathplace = location.get(PlaceType.COUNTRY)

            # see if we have an image to use for this person
            imagePath = None
            if self._incimages:
                mediaList = person.get_media_list()
                if len(mediaList) > 0:
                    mediaHandle = mediaList[0].get_reference_handle()
                    media = self._db.get_object_from_handle(mediaHandle)
                    mediaMimeType = media.get_mime_type()
                    if mediaMimeType[0:5] == "image":
                        imagePath = get_thumbnail_path(
                                        media_path_full(self._db, 
                                                        media.get_path()),
                                        rectangle=mediaList[0].get_rectangle())

            # put the label together and output this person
            label = ""
            lineDelimiter = '\\n'
            if bUseHtmlOutput:
                lineDelimiter = '<BR/>'

            # if we have an image, then start an HTML table;
            # remember to close the table afterwards!
            if imagePath:
                label = ('<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0" '
                         'CELLBORDER="0"><TR><TD><IMG SRC="%s"/></TD>'
                            % imagePath
                        )
                if self._imageonside == 0:
                    label += '</TR><TR>'
                label += '<TD>'

            # at the very least, the label must have the person's name
            label += name
            if self.includeid == 1: # same line
                label += " (%s)" % p_id
            elif self.includeid == 2: # own line
                label += "%s(%s)" % (lineDelimiter, p_id)

            if birthStr or deathStr:
                label += '%s(' % lineDelimiter
                if birthStr:
                    label += '%s' % birthStr
                label += ' - '
                if deathStr:
                    label += '%s' % deathStr
                label += ')'
            if birthplace or deathplace:
                if birthplace == deathplace:
                    deathplace = None    # no need to print the same name twice
                label += '%s' % lineDelimiter
                if birthplace:
                    label += '%s' % birthplace
                if birthplace and deathplace:
                    label += ' / '
                if deathplace:
                    label += '%s' % deathplace

            # see if we have a table that needs to be terminated
            if imagePath:
                label += '</TD></TR></TABLE>'

            shape   = "box"
            style   = "solid"
            border  = colour
            fill    = colour

            # do not use colour if this is B&W outline
            if self._colorize == 'outline':
                border  = ""
                fill    = ""

            if gender == person.FEMALE and self._useroundedcorners:
                style = "rounded"
            elif gender == person.UNKNOWN:
                shape = "hexagon"

            # if we're filling the entire node:
            if self._colorize == 'filled':
                style += ",filled"
                border = ""

            # we're done -- add the node
            self.doc.add_node(p_id,
                 label=label,
                 shape=shape,
                 color=border,
                 style=style,
                 fillcolor=fill,
                 htmloutput=bUseHtmlOutput)
Esempio n. 41
0
    def calc_url(self):
        """ Determine the url to use on maps.google.com
            Logic: valid for places within Sweden and
                   Denmark, only if lat lon avalible
                   use lat lon if present
                   otherwise use city and country if present
                   otherwise use description of the place
        """
        place = self._get_first_place()[0]
        path = ""
        # First see if we are in or near Sweden or Denmark
        # Change country to upper case
        location = get_main_location(self.database, place)
        country = location.get(PlaceType.COUNTRY, '').upper().strip()
        country_given = (country in MAP_NAMES_SWEDEN or \
                        country in MAP_NAMES_DENMARK) and (country != "")
        # if no country given, check if we might be in the vicinity defined by
        # 54 33' 0" < lat < 66 9' 0", 54.55 and 69.05
        # 8 3' 0" < long < 24 9' 0", 8.05 and 24.15 
        latitude, longitude = self._lat_lon(place)
        if latitude is None or longitude is None:
            coord_ok = False
        else:
            latitude = float(latitude) 
            longitude = float(longitude)
            # Check if coordinates are inside Sweden and Denmark
            if (54.55 < latitude < 69.05) and (8.05 < longitude < 24.15):
                coord_ok = True
            else:
                msg2 = _("Latitude not within '54.55' to '69.05'\n") + \
                       _("Longitude not within '8.05' to '24.15'")
                WarningDialog(_("Eniro map not available"), msg2 )
                return

        if coord_ok:
            place_title = _build_title(self.database, place)
            place_city =  _build_city(self.database, place)
            x_coord, y_coord = self._lat_lon(place, format="RT90")
            # Set zoom level to 5 if Sweden/Denmark, others 3
            zoom = 5
            if not country_given:
                zoom = 3
            path = "http://www.eniro.se/partner.fcgi?pis=1&x=%s&y=%s" \
                   "&zoom_level=%i&map_size=0&title=%s&city=%s&partner=gramps"
            # Note x and y are swapped!
            path = path % (y_coord , x_coord, zoom, place_title, place_city)
            self.url = path.replace(" ","%20")
            return

        place_area = _build_area(self.database, place)
        if country_given and place_area:
            if country in MAP_NAMES_SWEDEN:
                path = "http://kartor.eniro.se/query?&what=map_adr&mop=aq" \
                       "&geo_area=%s&partner=gramps"
                path = path % (place_area)
                self.url = path.replace(" ","%20")
                return
            else:
                WarningDialog(_("Eniro map not available"), \
                              _("Coordinates needed in Denmark") )
                self.url = ""
                return

        WarningDialog(_("Eniro map not available"), 
                      _("Latitude and longitude,\n" \
                    "or street and city needed") )
        return