[Tile-serving] [osm2pgsql-dev/osm2pgsql] New feature: Check location of OSM objects against list of regions (PR #2333)

Sarah Hoffmann notifications at github.com
Fri May 30 09:54:01 UTC 2025


@lonvia commented on this pull request.



> +    }
+    log_info("Added {} regions to locator '{}'.", result.num_tuples(), name());
+}
+
+void locator_t::build_index()
+{
+    log_debug("Building index for locator '{}'", name());
+    std::vector<idx_value_t> m_data;
+    m_data.reserve(m_regions.size());
+
+    std::size_t n = 0;
+    for (auto const &region : m_regions) {
+        m_data.emplace_back(region.box(), n++);
+    }
+
+    m_rtree.insert(m_data.cbegin(), m_data.cend());

I don't think m_rtree gets cleared ever. So this function may produce duplicates in the index if someone calls locator.add() some time during the import in one of the callbacks.

> +    Scenario: Define a locator without name is okay
+        Given the OSM data
+            """
+            """
+        And the lua style
+            """
+            local regions = osm2pgsql.define_locator({})
+            print('NAME[' .. regions:name() .. ']')
+            """
+        When running osm2pgsql flex
+        Then the standard output contains
+            """
+            NAME[]
+            """
+
+    Scenario: Define a locator without name is okay

Title not adapted.

> @@ -128,8 +128,10 @@ def setup_lua_tagtransform(context):
 def setup_inline_lua_style(context):
     outfile = context.workdir / 'inline_style.lua'
     outfile.write_text(context.text)
-    context.osm2pgsql_params.extend(('-S', str(outfile)))
-
+    if '-S' in context.osm2pgsql_params:
+        context.osm2pgsql_params[context.osm2pgsql_params.index('-S') + 1] = str(outfile)
+    else:
+        context.osm2pgsql_params.extend(('-S', str(outfile)))

Please 'fix' the function below (setup_style_file()) in the same way.

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

Message ID: <osm2pgsql-dev/osm2pgsql/pull/2333/review/2880771123 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20250530/3adc4a86/attachment-0001.htm>


More information about the Tile-serving mailing list