[Tile-serving] [osm2pgsql-dev/osm2pgsql] Add support for node processing in second stage (PR #2252)

Sarah Hoffmann notifications at github.com
Wed Sep 18 15:33:43 UTC 2024


@lonvia commented on this pull request.



> @@ -0,0 +1,226 @@
+-- This config example file is released into the Public Domain.
+
+-- This file shows how to use multi-stage processing to bring tags from
+-- public transport relations into member nodes and ways. This allows
+-- advanced processing of public transport networks including stops.
+
+-- Nodes tagged as public transport stops are imported into the 'stops' table,
+-- ways tagged as highway or railway or imported into the 'lines' table. The
+-- public transport routes themselves will be in the 'routes' table, but
+-- without any geomtry. As a "bonus" public transport stop area relations

geomtry -> geometry

> +
+tables.stops = osm2pgsql.define_node_table('stops', {
+    { column = 'tags',     type = 'jsonb' },
+    { column = 'rel_refs', type = 'text' }, -- for the refs from the relations
+    { column = 'rel_ids',  sql_type = 'int8[]' }, -- array with integers (for relation IDs)
+    { column = 'geom',     type = 'point', not_null = true },
+})
+
+tables.lines = osm2pgsql.define_way_table('lines', {
+    { column = 'tags',     type = 'jsonb' },
+    { column = 'rel_refs', type = 'text' }, -- for the refs from the relations
+    { column = 'rel_ids',  sql_type = 'int8[]' }, -- array with integers (for relation IDs)
+    { column = 'geom',     type = 'linestring', not_null = true },
+})
+
+-- Tables don't have to have a geometry column

Tables -> Routes?

> +
+    local refs = {}
+    local ids = {}
+    for rel_id, rel_ref in pairs(d) do
+        refs[#refs + 1] = rel_ref
+        ids[#ids + 1] = rel_id
+    end
+    table.sort(refs)
+    table.sort(ids)
+
+    row.rel_refs = table.concat(unique_array(refs), separator)
+    row.rel_ids = '{' .. table.concat(unique_array(ids), ',') .. '}'
+end
+
+function osm2pgsql.process_node(object)
+    -- Wer are only interested in public transport stops here, and they are

Wer -> We

> @@ -0,0 +1,226 @@
+-- This config example file is released into the Public Domain.
+
+-- This file shows how to use multi-stage processing to bring tags from
+-- public transport relations into member nodes and ways. This allows
+-- advanced processing of public transport networks including stops.
+
+-- Nodes tagged as public transport stops are imported into the 'stops' table,

That would be only nodes that appear in a PT relation, right?

> +function osm2pgsql.select_relation_members(relation)
+    -- Only interested in public transport relations with refs
+    if wanted_relation(relation.tags) then
+        local node_ids = {}
+        for _, member in ipairs(relation.members) do
+            if member.type == 'n' and member.role == 'stop' then
+                node_ids[#node_ids + 1] = member.ref
+            end
+        end
+
+        local way_ids = {}
+        for _, member in ipairs(relation.members) do
+            if member.type == 'w' and member.role == '' then
+                way_ids[#way_ids + 1] = member.ref
+            end
+        end

Can't we do both in a single for-loop?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#pullrequestreview-2312617574
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/pull/2252/review/2312617574 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20240918/ea43a9a1/attachment.htm>


More information about the Tile-serving mailing list