def changeset(id):
    """Gets a changeset from the OSM API and returns it in a complete
    form ready to use

    """
    # First get the changeset metadata
    data = osmapi.getChangeset(id)
    xml = et.XML(data)
    root = xml.find('changeset')
    changeset = parser.parseChangeset(root)
    # Now get the OSM change for it
    data = osmapi.getChange(id)
    xml = et.XML(data)
    change = parser.parseChange(xml)
    changeset['actions'] = change
    # Now collect all the objects in this changeset for processing
    eles = []
    for i in changeset['actions']:
        eles.extend(i[1])
    # Add changeset tags to objects
    for ele in eles:
        ele['_changeset_tags'] = changeset['tags']
    # Make internal references based on info we already have
    elements.add_local_way_references(eles)
    elements.add_local_relation_references(eles)
    # Now collect the rest from remote data
    elements.add_remote_ways(eles)
    elements.add_remote_relations(eles)
    # Remove tagless items we have parent objects for
    eles = elements.remove_unnecessary_items(eles)
    # Sort elements
    eles = elements.sort_elements(eles)
    changeset['elements'] = eles
    return changeset
Beispiel #2
0
def changeset(id):
    """Gets a changeset from the OSM API and returns it in a complete
    form ready to use

    """
    # First get the changeset metadata
    data = osmapi.getChangeset(id)
    xml = et.XML(data.encode('utf-8'))
    root = xml.find('changeset')
    changeset = parser.parseChangeset(root)
    # Now get the OSM change for it
    data = osmapi.getChange(id)
    xml = et.XML(data.encode('utf-8'))
    change = parser.parseChange(xml)
    changeset['actions'] = change
    # Now collect all the objects in this changeset for processing
    for i in changeset['actions']:
        eles = i[1]        
        # Make internal references based on info we already have
        elements.add_local_way_references(eles)
        elements.add_local_relation_references(eles)
        # Now collect the rest from remote data
        elements.add_remote_ways(eles)
        elements.add_remote_relations(eles)
        elements.remove_unnecessary_items(eles)
        elements.sort_elements(eles)
    return changeset
def changeset(id):
    """Gets a changeset from the OSM API and returns it in a complete
    form ready to use

    """
    # First get the changeset metadata
    data = osmapi.getChangeset(id)
    xml = et.XML(data)
    root = xml.find('changeset')
    changeset = parser.parseChangeset(root)
    # Now get the OSM change for it
    data = osmapi.getChange(id)
    xml = et.XML(data)
    change = parser.parseChange(xml)
    changeset['actions'] = change
    # Now collect all the objects in this changeset for processing
    eles = []
    for i in changeset['actions']:
        eles.extend(i[1])
    # Add changeset tags to objects
    for ele in eles:
        ele['_changeset_tags'] = changeset['tags']
    # Make internal references based on info we already have
    elements.add_local_way_references(eles)
    elements.add_local_relation_references(eles)
    # Now collect the rest from remote data
    elements.add_remote_ways(eles)
    elements.add_remote_relations(eles)
    # Remove tagless items we have parent objects for
    eles = elements.remove_unnecessary_items(eles)
    # Sort elements
    eles = elements.sort_elements(eles)
    changeset['elements'] = eles
    return changeset