Skip to content

Views on relations #1

Description

@sigfrido

Allow user to define views on relations.
We should be able to specify geometry (multilinestring, multipoint or geometrycollection), and which roles to include in the geometry collection.

An example for routes:

CREATE OR REPLACE VIEW osm_views.routes AS
SELECT r.id,
g.geom,
r.tags -> 'ref'::text AS ref,
r.tags -> 'route'::text AS route,
r.tags -> 'from'::text AS inizio,
r.tags -> 'to'::text AS fine,
r.tags -> 'name'::text AS nome,
r.tags -> 'operator'::text AS operator,
r.tags -> 'network'::text AS network,
r.tags
FROM relations r
LEFT JOIN ( SELECT m.relation_id,
st_collect(w.linestring) AS geom
FROM relation_members m
LEFT JOIN ways w ON m.member_type = 'W'::bpchar AND m.member_id = w.id
GROUP BY m.relation_id) g ON r.id = g.relation_id
WHERE (r.tags -> 'type'::text) = 'route'::text
ORDER BY r.tags -> 'ref'::text;

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions