Пример #1
0
def get_osm_database_last_update():
    """Returns the timestamp of the last PostGIS database update, which is
    placed into the maposmatic_admin table in the PostGIS database by the
    planet-update incremental update script."""

    cursor = None

    try:
        db = gisdb.get()
        if db is None:
            return None

        cursor = db.cursor()
        if cursor is None:
            return None

        cursor.execute("""select last_update from maposmatic_admin""")
        last_update = cursor.fetchone()
        if last_update is None or len(last_update) != 1:
            return None

        return last_update[0]
    except:
        pass
    finally:
        # Close the DB cursor if necessary
        if cursor is not None and not cursor.closed:
            cursor.close()

    return None
Пример #2
0
def get_osm_database_last_update():
    """Returns the timestamp of the last PostGIS database update, which is
    placed into the maposmatic_admin table in the PostGIS database by the
    planet-update incremental update script."""

    cursor = None

    try:
        db = gisdb.get()
        if db is None:
            return None

        cursor = db.cursor()
        if cursor is None:
            return None

        cursor.execute("""select last_update from maposmatic_admin""")
        last_update = cursor.fetchone()
        if last_update is None or len(last_update) != 1:
            return None

        return last_update[0]
    except:
        pass
    finally:
        # Close the DB cursor if necessary
        if cursor is not None and not cursor.closed:
            cursor.close()

    return None
Пример #3
0
def _prepare_and_filter_entries(entries):
    """Try to retrieve additional OSM information for the given nominatim
    entries. Among the information, we try to determine the real ID in
    an OSM table for each of these entries. All these additional data
    are stored in the "ocitysmap_params" key of the entry."""

    if not www.settings.has_gis_database():
        return entries

    db = gisdb.get()
    if db is None:
        return entries

    place_tags = [
        'city', 'town', 'municipality', 'village', 'hamlet', 'suburb',
        'island', 'islet', 'locality', 'administrative'
    ]
    filtered_results = []

    cursor = db.cursor()
    for entry in entries:

        # Ignore uninteresting tags
        if not entry.get("type") in place_tags:
            continue

        # Our entry wil be part of the result
        filtered_results.append(entry)

        # Enrich the entry with more info
        _prepare_entry(cursor, entry)

    # Some cleanup
    cursor.close()

    return filtered_results
Пример #4
0
def _prepare_and_filter_entries(entries):
    """Try to retrieve additional OSM information for the given nominatim
    entries. Among the information, we try to determine the real ID in
    an OSM table for each of these entries. All these additional data
    are stored in the "ocitysmap_params" key of the entry."""

    if not www.settings.has_gis_database():
        return entries

    db = gisdb.get()
    if db is None:
        return entries

    place_tags = [ 'city', 'town', 'municipality',
                   'village', 'hamlet', 'suburb',
                   'island', 'islet', 'locality',
                   'administrative' ]
    filtered_results = []

    cursor = db.cursor()
    for entry in entries:

        # Ignore uninteresting tags
        if not entry.get("type") in place_tags:
            continue

        # Our entry wil be part of the result
        filtered_results.append(entry)

        # Enrich the entry with more info
        _prepare_entry(cursor, entry)

    # Some cleanup
    cursor.close()

    return filtered_results