[Tile-serving] [openstreetmap/osm2pgsql] Refactor middle (#1371)

Sarah Hoffmann notifications at github.com
Tue Dec 15 16:37:19 UTC 2020


@lonvia commented on this pull request.



>  void osmdata_t::node(osmium::Node const &node)
 {
+    if (!m_bbox.valid() || node.deleted() || m_bbox.contains(node.location())) {

contains() is now called twice. Not the cheapest of functions.

More importantly: you either need to move the node.location().valid() check to the front of the function or make sure that mid can handle invalid locations. I'd be in favour of the first solution. (Bonus points for adding a test for input with invalid locations.)

> @@ -314,6 +314,46 @@ std::size_t middle_query_pgsql_t::get_way_node_locations_db(
     return count;
 }
 
+void middle_pgsql_t::node(osmium::Node const &node)
+{
+    if (node.deleted()) {
+        node_delete(node.id());
+    } else {
+        if (m_options->append) {
+            node_delete(node.id());
+            node_set(node);
+        } else {
+            node_set(node);

Any particular reason why you don't move the node_set() outside the if? Dto for the other two functions.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/1371#pullrequestreview-552624016
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20201215/35f18b5e/attachment.htm>


More information about the Tile-serving mailing list