omniscale / imposm3

Imposm imports OpenStreetMap data into PostGIS
http://imposm.org/docs/imposm3/latest/
Apache License 2.0
710 stars 156 forks source link

Deleted features doesn't mark tile as expired #197

Closed zdila closed 4 years ago

zdila commented 5 years ago

Context

If the changeset contains delete-only operation (eg. deleted a building) then it's import doesn't generate expired tile.

Expected Behavior

Expired tile should be generated.

Actual Behavior

Expired tile is not generated.

Steps to Reproduce

  1. have ~/go/bin/imposm run -connection postgis://gis:secret@localhost/gis -mapping mapping.yaml -limitto limit.geojson -cachedir ./cache -diffdir ./diff -expiretiles-zoom 15 -expiretiles-dir ./expires running
  2. delete single building from OSM
  3. osm changeset is applied to the DB by imposm3 but it is not reflected in ./expires dir

Context

We are trying to have a map rendered by mapnik in sync with OSM data.

Your Environment

olt commented 5 years ago

Can you provide more information?

A delete of a way should be handled by Imposm and there is a test case: https://github.com/omniscale/imposm3/blob/master/test/expire_tiles.osc#L40...L43 https://github.com/omniscale/imposm3/blob/master/test/expire_tiles_test.go#L103

zdila commented 5 years ago

Please extract files from https://drive.google.com/open?id=1eIfafN_gosS0rhBFn1JhdGm0FYTzgsFV:

Steps:

  1. run ~/go/bin/imposm import -connection postgis://gis:gis@localhost/gis -mapping mapping.yaml -read building.osm.pbf -diff -write -cachedir ./cache -diffdir ./diff -overwritecache
  2. run ~/go/bin/imposm import -connection postgis://gis:gis@localhost/gis -mapping mapping.yaml -deployproduction
  3. check that single building is present in osm_buildings table
  4. run ~/go/bin/imposm diff -connection postgis://gis:gis@localhost/gis -mapping mapping.yaml -cachedir ./cache -diffdir ./diff -expiretiles-dir ./expires 230.osc.gz
  5. check that there is no building in osm_buildings table but no expires dir is created even if it should
  6. run ~/go/bin/imposm diff -connection postgis://gis:gis@localhost/gis -mapping mapping.yaml -cachedir ./cache -diffdir ./diff -expiretiles-dir ./expires 277.osc.gz
  7. check that new building is created in osm_buildings table and expires is created with correct *.tiles file
zdila commented 4 years ago

@olt Is there anything else I can provide?

(Even maybe some microfunding, or credits at https://www.freemap.sk/ (credits modal is not ready yet))?

Thanks

zdila commented 4 years ago

@olt I did some more tests and narrowed down the conditions. I found that tile is not marked as dirty if you not only delete a way but also all its nodes. If you apply following patch then the test will fail:

diff --git a/test/expire_tiles.osc b/test/expire_tiles.osc
index b2d4772..19255c4 100644
--- a/test/expire_tiles.osc
+++ b/test/expire_tiles.osc
@@ -37,7 +37,13 @@
     </way>
   </modify>

-  <!-- delete way -->
+  <!-- delete way including its nodes -->
+  <delete>
+    <node id="20201" version="1" timestamp="2011-11-11T00:11:11Z" lat="2.0" lon="2.0001" />
+  </delete>
+  <delete>
+    <node id="20202" version="1" timestamp="2011-11-11T00:11:11Z" lat="2.0" lon="2.0002" />
+  </delete>
   <delete>
     <way id="20251" version="1" timestamp="2011-11-11T00:11:11Z" />
   </delete>

Failed test:

...
--- FAIL: TestExpireTiles (0.73s)
    --- FAIL: TestExpireTiles/CheckExpireFile (0.00s)
        expire_tiles_test.go:164: missing expire tile for delete way {8283 8100 14}
FAIL
FAIL    github.com/omniscale/imposm3/test   0.745s
olt commented 4 years ago

Thanks for creating the failing test case. Imposm assumed that the changesets are always in a "consistent" order. This is now fixed.

zdila commented 4 years ago

Thank you!