fix diff updates of nodes with dropped tags

master
Oliver Tonnhofer 2014-08-08 12:24:28 +02:00
parent 2bd6c1c4cf
commit aaa9181134
4 changed files with 40 additions and 0 deletions

View File

@ -152,6 +152,7 @@ For:
return err
}
if !elem.Add {
// no new or modified elem -> remove from cache
if elem.Rel != nil {
if err := osmCache.Relations.DeleteRelation(elem.Rel.Id); err != nil {
return err
@ -169,6 +170,11 @@ For:
return err
}
}
} else if elem.Node != nil && elem.Node.Tags == nil {
// handle modifies where a node drops all tags
if err := osmCache.Nodes.DeleteNode(elem.Node.Id); err != nil {
return err
}
}
}
if elem.Add {

View File

@ -176,4 +176,11 @@
<node id="64007" version="1" timestamp="2011-11-11T00:11:11Z" lat="0" lon="20.06"/>
<node id="64008" version="1" timestamp="2011-11-11T00:11:11Z" lat="0" lon="20.10"/>
</modify>
<!-- add remove tags from nodes/coords -->
<node id="70001" version="2" timestamp="2011-11-11T00:11:11Z" lat="0.01" lon="20.00"/>
<node id="70002" version="2" timestamp="2011-11-11T00:11:11Z" lat="0.02" lon="20.00">
<tag k="amenity" v="police"/>
</node>
</osmChange>

View File

@ -932,4 +932,11 @@
<nd ref="64008"/>
<tag k="highway" v="residential"/>
</way>
<!-- add remove tags from nodes/coords -->
<node id="70001" version="1" timestamp="2011-11-11T00:11:11Z" lat="0.01" lon="20.00">
<tag k="amenity" v="police"/>
</node>
<node id="70002" version="1" timestamp="2011-11-11T00:11:11Z" lat="0.02" lon="20.00"/>
</osm>

View File

@ -265,6 +265,15 @@ def test_updated_nodes1():
road = t.query_row(t.db_conf, 'osm_roads', 60000)
t.assert_almost_equal(road['geometry'].length, 14035.61150207768)
def test_update_node_to_coord_1():
"""Node is inserted with tag."""
coords = t.cache_query(nodes=(70001, 70002))
assert coords['nodes']["70001"]["tags"] == {"amenity": "police"}
assert "tags" not in coords['nodes']["70002"]
assert t.query_row(t.db_conf, 'osm_amenities', 70001)
assert not t.query_row(t.db_conf, 'osm_amenities', 70002)
#######################################################################
def test_update():
"""Diff import applies"""
@ -413,6 +422,17 @@ def test_updated_way2():
# new length 0.1 degree
t.assert_almost_equal(road['geometry'].length, 20037508.342789244/180.0/10.0)
def test_update_node_to_coord_2():
"""Node is becomes coord after tags are removed."""
coords = t.cache_query(nodes=(70001, 70002))
assert "tags" not in coords['nodes']["70001"]
assert coords['nodes']["70002"]["tags"] == {"amenity": "police"}
assert not t.query_row(t.db_conf, 'osm_amenities', 70001)
assert t.query_row(t.db_conf, 'osm_amenities', 70002)
#######################################################################
def test_deploy_and_revert_deploy():
"""Revert deploy succeeds"""