Example #1
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
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
Example #4
0
def sentence_from_changeset(cset):
    """Take a changeset object and return a sentence"""
    user = elements.get_user(cset)
    if len(cset['actions']) == 1:
        name, eles = cset['actions'][0]
        if name == 'create':
            action = 'created'
        elif name == 'modify':
            action = 'modified'
        else:
            action = 'deleted'
    else:
        action = 'edited'
        eles = []
        for i in cset['actions']:
            eles.extend(i[1])
    elements.add_local_way_references(eles)
    elements.add_local_relation_references(eles)
    elements.add_remote_ways(eles)
    elements.add_remote_relations(eles)
    eles = elements.remove_unnecessary_items(eles)
    eles = elements.sort_elements(eles)
    ele_features = zip(eles, db.matchEach(eles))
    sorted_ef = elements.sort_by_num_features(ele_features)
    grouped_features = elements.feature_grouper(sorted_ef)
    sorted_features = elements.sort_grouped(grouped_features)
    english_list = grouped_to_english(sorted_features)
    return "%s %s %s" % (user, action, english_list)
def sentence_from_changeset(cset):
    """Take a changeset object and return a sentence"""
    user = elements.get_user(cset)
    if len(cset['actions']) == 1:
        name,eles = cset['actions'][0]
        if name == 'create':
            action = 'created'
        elif name == 'modify':
            action = 'modified'
        else:
            action = 'deleted'
    else:
        action = 'edited'
        eles = []
        for i in cset['actions']:
            eles.extend(i[1])
    elements.add_local_way_references(eles)
    elements.add_local_relation_references(eles)
    elements.add_remote_ways(eles)
    elements.add_remote_relations(eles)
    eles = elements.remove_unnecessary_items(eles)
    eles = elements.sort_elements(eles)
    ele_features = zip(eles, db.matchEach(eles))
    sorted_ef = elements.sort_by_num_features(ele_features)
    grouped_features = elements.feature_grouper(sorted_ef)
    sorted_features = elements.sort_grouped(grouped_features)
    english_list =  grouped_to_english(sorted_features)
    return "%s %s %s" % (user, action, english_list)