[Tile-serving] [openstreetmap/osm2pgsql] Update/add some flex config example files using the new insert() (PR #1744)

Sarah Hoffmann notifications at github.com
Sat Aug 13 08:26:31 UTC 2022


@lonvia commented on this pull request.



> +
+function osm2pgsql.process_node(object)
+    local any, addr = get_address(object.tags)
+    if any then
+        addr.name = object.tags.name
+        addr.geom = object:as_point()
+        addrs:insert(addr)
+    end
+end
+
+function osm2pgsql.process_way(object)
+    if object.is_closed then
+        local any, addr = get_address(object.tags)
+        if any then
+            addr.name = object.tags.name
+            addr.geom = object:as_polygon():centroid()

A closed way is not necessarily a valid polygon. Can we have null here? Might be worth commenting what happens.

Same below for multipolygon.

> +    if object.tags.amenity == 'pub' then
+        tables.pubs:insert({
+            name = object.tags.name
+        })
+    end
+end
+
+function osm2pgsql.process_way(object)
+    if clean_tags(object.tags) then
+--        return
+    end
+
+    -- A closed way that also has the right tags for an area is a polygon.
+    if object.is_closed and has_area_tags(object.tags) then
+        -- Creating the polygon geometry takes time, so we do it once here
+        -- and later store it in the table and use it to calclate the area.

typo: calculate

>              tags = object.tags,
-            geom = { create = 'line' }
+            geom = object:as_multilinestring()

Shouldn't there be a line_merge to have the same result as before?

> +function osm2pgsql.process_relation(object)
+    if clean_tags(object.tags) then
+        return
+    end
+
+    local relation_type = object:grab_tag('type')
+
+    -- Store boundary relations as multilinestrings
+    if relation_type == 'boundary' then
+        tables.boundaries:insert({
+            type = object:grab_tag('boundary'),
+            tags = object.tags,
+            -- For relations there is no clear definition what their geometry
+            -- is, so you have to decide on the geometry transformation you
+            -- want. In this case we want the boundary as multilinestring
+            -- and we want lines merged as much as possibl.e

typo final dot

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

Message ID: <openstreetmap/osm2pgsql/pull/1744/review/1069374971 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20220813/bfd27b7d/attachment.htm>


More information about the Tile-serving mailing list