Example #1
0
def load_osm_boundary(filename):
    """Loads a boundary relation from an OSM file. The file must also
    contain all the nodes and way used by the boundary. Only the first boundary
    is read."""
    reporting = Reporting()
    elem_count = count_elements(filename, "node")
    elem_count += count_elements(filename, "way")
    elem_count += 1
    reporting.progress_start(u"Ładuję %s" % (filename,), elem_count)
    nodes = []
    ways = []
    relation = None
    for event, elem in ElementTree.iterparse(filename):
        if event != 'end':
            continue
        if elem.tag == 'node':
            nodes.append(elem)
        elif elem.tag == 'way':
            ways.append(elem)
        elif elem.tag == 'relation' and not relation:
            relation = elem
        else:
            continue
        reporting.progress()
    reporting.progress_stop()
    if not relation:
        reproting.output_msg("errors", u"Nie znaleziono relacji")
        raise ValueError, "Relation not found"
    reporting.output_msg("stats", u"Załadowano relację, %i dróg i %i węzłów." 
                    % (len(ways), len(nodes)))
    boundary = OSM_Boundary(relation, ways, nodes)
    return boundary
Example #2
0
def load_terc():
    reporting = Reporting()
    row_count = count_elements("data/TERC.xml", "row")
    reporting.progress_start(u"Ładowanie data/TERC.xml", row_count)
    for event, elem in ElementTree.iterparse("data/TERC.xml"):
        if event == 'end' and elem.tag == 'row':
            load_terc_object(elem)
            reporting.progress()
    reporting.progress_stop()
    reporting.output_msg("stats", u"Załadowano %i województw, %i powiatów i %i gmin" % (
            Wojewodztwo.count(), Powiat.count(), Gmina.count()))
Example #3
0
def load_simc():
    load_wmrodz()
    reporting = Reporting()
    row_count = count_elements("data/SIMC.xml", "row")
    reporting.progress_start(u"Ładowanie data/SIMC.xml", row_count)
    for event, elem in ElementTree.iterparse("data/SIMC.xml"):
        if event == 'end' and elem.tag == 'row':
            SIMC_Place.from_element(elem)
            reporting.progress()
    reporting.progress_stop()
    reporting.output_msg("stats", u"Załadowano %i miejscowości" % (SIMC_Place.count(),))
    SIMC_Place.link_parents()
Example #4
0
def load_osm():
    reporting = Reporting()
    row_count = count_elements("data/data.osm", "node")
    reporting.progress_start(u"Ładuję data/data.osm", row_count)
    for event, elem in ElementTree.iterparse("data/data.osm"):
        if event == 'end' and elem.tag == 'node':
            osm_place = OSM_Place(elem)
            reporting.progress()
    reporting.progress_stop()
    reporting.output_msg("stats", u"Załadowano %i miejsc." 
                    u"Dopasowano %i województw, %i powiatów i %i gmin." % (
                    OSM_Place.count(), OSM_Place.woj_matched,
                                OSM_Place.pow_matched, OSM_Place.gmi_matched))