<p></p>
<p><b>@lonvia</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#discussion_r1765013599">flex-config/public-transport.lua</a>:</p>
<pre style='color:#555'>> @@ -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
</pre>
<p dir="auto">geomtry -> geometry</p>
<hr>
<p>In <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#discussion_r1765015789">flex-config/public-transport.lua</a>:</p>
<pre style='color:#555'>> +
+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
</pre>
<p dir="auto">Tables -> Routes?</p>
<hr>
<p>In <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#discussion_r1765020407">flex-config/public-transport.lua</a>:</p>
<pre style='color:#555'>> +
+ 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
</pre>
<p dir="auto">Wer -> We</p>
<hr>
<p>In <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#discussion_r1765022265">flex-config/public-transport.lua</a>:</p>
<pre style='color:#555'>> @@ -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,
</pre>
<p dir="auto">That would be only nodes that appear in a PT relation, right?</p>
<hr>
<p>In <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#discussion_r1765034421">flex-config/public-transport.lua</a>:</p>
<pre style='color:#555'>> +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
</pre>
<p dir="auto">Can't we do both in a single for-loop?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#pullrequestreview-2312617574">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353Q4CVIFVMENCAB4PK3ZXGMNPAVCNFSM6AAAAABOLXTICWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGMJSGYYTONJXGQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AA6353Q757TXJY7OZW2ZL43ZXGMNPA5CNFSM6AAAAABOLXTICWWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUJ267GM.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><osm2pgsql-dev/osm2pgsql/pull/2252/review/2312617574</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#pullrequestreview-2312617574",
"url": "https://github.com/osm2pgsql-dev/osm2pgsql/pull/2252#pullrequestreview-2312617574",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>