Skip to content

Conversation

@talespaiva
Copy link
Contributor

When making queries that return relations and geometries (out geom;) the member's attributes were not present in the RelationMember object, making it impossible to retrieve the geometries of these members. This could not be fixed by using resolve() because it's Overpass QL clause (out body;). Besides, the data (geometries in this case) is already on the response, so new resolve queries for each member would cause unnecessary overhead.

This change allows the following snippet to work (it creates a WKT representation of the relation):

relation_geometry = 'MULTIPOLYGON('
for i, member in enumerate(relation.members):
    coords = '(('
    for j, point in enumerate(member.attributes['geometry']):
        coords += str(point['lon']) + " " + str(point['lat'])
        if j < len(member.attributes['geometry'])-1:
            coords += ','

    coords += '))'
    if i < len(relation.members)-1:
        coords += ','

    relation_geometry += coords

relation_geometry += ')'

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 94.257% when pulling a992b57 on talespaiva:master into 933541f on DinoTools:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 94.257% when pulling cb131a1 on talespaiva:master into 933541f on DinoTools:master.

@phibos phibos added this to the 0.4 milestone Nov 22, 2016
@phibos phibos self-assigned this Nov 22, 2016
@phibos
Copy link
Member

phibos commented Nov 22, 2016

I'm currently preparing the next release and I'm reviewing your PR.

@phibos phibos mentioned this pull request Nov 26, 2016
@phibos phibos merged commit cb131a1 into DinoTools:master Nov 27, 2016
@phibos
Copy link
Member

phibos commented Nov 27, 2016

Thanks for contributing. I have merged your code into the master branch and I have added support for the DOM and the SAX parser. But the geometry is now an property of the RelationMember() class.

You have to modify the following example.

for point in member.attributes['geometry']:
    print(point["lat"], point["lon"])

New code should look like the example below and should use the geometry property.

for point in member.geometry:
    print(point.lat, point.lon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants