Skip to content

Include OSM object of 'type' area (or line) as center point - possibly along with the Polygon (or LineString).

Include OSM objects of 'type' area - i.e. closed Way and Multipolygon Relation - (or line) as center point.

See "# TODO" at https://gitlab.com/geometalab/transfer-praktikanten-2019/OSMDataSync/-/blob/master/OSMDataSync/synchronizer.py#L36

Following approach is a patch to the osm2geojson libary which requires to add "out center;" in the Overpass query in order to get a center object in the feature of the JSON response. This JSON center object can be used as point representation which fits to the QGIS layer type Point.

Another approach would be to use the usual Overpass query which potentially returns Points, Lines and Polygons and to calculate the center points of Lines and Polygons in the plugin.

This patch add's a point response and exits the function. A further enhancement would generate the point as well the originally included Polygon (or LineString).

https://gitlab.com/geometalab/transfer-praktikanten-2019/OSMDataSync/-/blob/master/OSMDataSync/dependencies/osm2geojson/main.py#L174

def way_to_shape(way, refs_index = {}):
    coords = []

    # PATCH
    # TODO center test: In case of 'center' exists return Point! (Future work: return Point _and_ way geometry!)
    if 'center' in way:
        center = way['center']
        return {
            'shape': Point(center['lon'], center['lat']),
            'properties': get_element_props(way)
        }
    # PATCH END

and

https://gitlab.com/geometalab/transfer-praktikanten-2019/OSMDataSync/-/blob/master/OSMDataSync/dependencies/osm2geojson/main.py#L297

def relation_to_shape(rel, refs_index):
    # PATCH 
    # TODO center test: In case of 'center' exists return Point! (Future work: return Point _and_ relation geometry!)
    if 'center' in rel:
        center = rel['center']
        return {
            'shape': Point(center['lon'], center['lat']),
            'properties': get_element_props(rel)
        }        
    # PATCH END
Edited by Stefan Keller