From: Sarah Hoffmann Date: Sun, 18 Jan 2015 20:22:14 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~491 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/45a52249135d25d86c853e2146eaebe808764245?hp=d6fa3ce8ff49fe56f24d10975e83c8b4b65e5f79 Merge remote-tracking branch 'upstream/master' --- diff --git a/sql/functions.sql b/sql/functions.sql index 577e02bf..b4ecdad8 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -474,31 +474,6 @@ END; $$ LANGUAGE plpgsql IMMUTABLE; -CREATE OR REPLACE FUNCTION get_word_score(wordscores wordscore[], words text[]) RETURNS integer - AS $$ -DECLARE - idxword integer; - idxscores integer; - result integer; -BEGIN - IF (wordscores is null OR words is null) THEN - RETURN 0; - END IF; - - result := 0; - FOR idxword in 1 .. array_upper(words, 1) LOOP - FOR idxscores in 1 .. array_upper(wordscores, 1) LOOP - IF wordscores[idxscores].word = words[idxword] THEN - result := result + wordscores[idxscores].score; - END IF; - END LOOP; - END LOOP; - - RETURN result; -END; -$$ -LANGUAGE plpgsql IMMUTABLE; - CREATE OR REPLACE FUNCTION get_country_code(place geometry) RETURNS TEXT AS $$ DECLARE @@ -1253,8 +1228,6 @@ DECLARE search_maxdistance FLOAT[]; search_mindistance FLOAT[]; address_havelevel BOOLEAN[]; --- search_scores wordscore[]; --- search_scores_pos INTEGER; i INTEGER; iMax FLOAT; @@ -2337,29 +2310,6 @@ END; $$ LANGUAGE plpgsql IMMUTABLE; ---CREATE OR REPLACE FUNCTION get_connected_ways(way_ids INTEGER[]) RETURNS SETOF planet_osm_ways --- AS $$ ---DECLARE --- searchnodes INTEGER[]; --- location RECORD; --- j INTEGER; ---BEGIN --- --- searchnodes := '{}'; --- FOR j IN 1..array_upper(way_ids, 1) LOOP --- FOR location IN --- select nodes from planet_osm_ways where id = way_ids[j] LIMIT 1 --- LOOP --- IF not (ARRAY[location.nodes] <@ searchnodes) THEN --- searchnodes := searchnodes || location.nodes; --- END IF; --- END LOOP; --- END LOOP; --- --- RETURN QUERY select * from planet_osm_ways where nodes && searchnodes and NOT ARRAY[id] <@ way_ids; ---END; ---$$ ---LANGUAGE plpgsql IMMUTABLE; CREATE OR REPLACE FUNCTION get_address_postcode(for_place_id BIGINT) RETURNS TEXT AS $$ diff --git a/tests/features/osm2pgsql/import/tags.feature b/tests/features/osm2pgsql/import/tags.feature index 37940756..d9046eec 100644 --- a/tests/features/osm2pgsql/import/tags.feature +++ b/tests/features/osm2pgsql/import/tags.feature @@ -46,6 +46,7 @@ Feature: Tag evaluation | short_name | short_name:CH | operator + | addr:housename Scenario Outline: Ignored name tags Given the osm nodes: @@ -63,7 +64,8 @@ Feature: Tag evaluation | ref:de | ref_de | my:ref - : br:name + | br:name + | name:prefix Scenario: Special character in name tag Given the osm nodes: @@ -77,3 +79,374 @@ Feature: Tag evaluation | N1 | 'name:_de' : 'Foo', 'name' : 'real' | N2 | 'name:_de' : 'Foo', 'name' : 'real' | N3 | 'name:_de' : 'Foo', 'name:\\\\' : 'real' + + Scenario Outline: Included places + Given the osm nodes: + | id | tags + | 1 | '' : '', 'name' : 'real' + When loading osm data + Then table place contains + | object | name + | N1 | 'name' : 'real' + + Examples: + | key | value + | emergency | phone + | tourism | information + | historic | castle + | military | barracks + | natural | water + | highway | residential + | aerialway | station + | aeroway | way + | boundary | administrative + | bridge | yes + | craft | butcher + | leisure | playground + | office | bookmaker + | railway | rail + | shop | bookshop + | tunnel | yes + | waterway | stream + | landuse | cemetry + | mountain_pass | yes + + + Scenario Outline: Excluded places + Given the osm nodes: + | id | tags + | 1 | '' : '', 'name' : 'real' + | 2 | 'highway' : 'motorway', 'name' : 'To Hell' + When loading osm data + Then table place has no entry for N1 + + Examples: + | key | value + | emergency | yes + | emergency | no + | tourism | yes + | tourism | no + | historic | yes + | historic | no + | military | yes + | military | no + | natural | yes + | natural | no + | highway | no + | highway | turning_circle + | highway | traffic_signals + | highway | mini_roundabout + | highway | noexit + | highway | crossing + | aerialway | no + | aeroway | no + | amenity | no + | boundary | no + | bridge | no + | craft | no + | leisure | no + | office | no + | railway | no + | shop | no + | tunnel | no + | waterway | riverbank + + + Scenario: Boundary with place tag + Given the osm nodes: + | id | geometry + | 200 | 0 0 + | 201 | 0 1 + | 202 | 1 1 + | 203 | 1 0 + And the osm ways: + | id | tags | nodes + | 2 | 'boundary' : 'administrative', 'place' : 'city' | 200 201 202 203 200 + | 20 | 'place' : 'city' | 200 201 202 203 200 + | 40 | 'place' : 'city', 'boundary' : 'statistical' | 200 201 202 203 200 + When loading osm data + Then table place contains + | object | class | type | extratags + | W2 | boundary | administrative | 'place' : 'city' + | W20 | place | city | + | W40:boundary | boundary | statistical | + | W40:place | place | city | + And table place has no entry for W2:place + + Scenario Outline: Tags that describe a house + Given the osm nodes: + | id | tags + | 100 | '' : '' + | 999 | 'amenity' : 'prison', '' : '' + When loading osm data + Then table place contains + | object | class | type + | N100 | place | house + | N999 | amenity | prison + And table place has no entry for N100: + And table place has no entry for N999: + And table place has no entry for N999:place + + Examples: + | key | value + | addr:housename | My Mansion + | addr:housenumber | 456 + | addr:conscriptionnumber | 4 + | addr:streetnumber | 4568765 + + Scenario: Only named with no other interesting tag + Given the osm nodes: + | id | tags + | 1 | 'landuse' : 'meadow' + | 2 | 'landuse' : 'residential', 'name' : 'important' + | 3 | 'landuse' : 'residential', 'name' : 'important', 'place' : 'hamlet' + When loading osm data + Then table place contains + | object | class | type + | N2 | landuse | residential + | N3 | place | hamlet + And table place has no entry for N1 + And table place has no entry for N3:landuse + + Scenario Outline: Import of postal codes + Given the osm nodes: + | id | tags + | 10 | 'highway' : 'secondary', '' : '' + | 11 | '' : '' + When loading osm data + Then table place contains + | object | class | type | postcode + | N10 | highway | secondary | + | N11 | place | postcode | + And table place has no entry for N10:place + + Examples: + | key | value + | postal_code | 45736 + | post_code | gf4 65g + | postcode | xxx + | addr:postcode | 564 + | tiger:zip_left | 00011 + | tiger:zip_right | 09123 + + Scenario: Import of street and place + Given the osm nodes: + | id | tags + | 10 | 'amenity' : 'hospital', 'addr:street' : 'Foo St' + | 20 | 'amenity' : 'hospital', 'addr:place' : 'Foo Town' + When loading osm data + Then table place contains + | object | class | type | street | addr_place + | N10 | amenity | hospital | Foo St | None + | N20 | amenity | hospital | None | Foo Town + + + Scenario Outline: Import of country + Given the osm nodes: + | id | tags + | 10 | 'place' : 'village', '' : '' + When loading osm data + Then table place contains + | object | class | type | country_code + | N10 | place | village | + + Examples: + | key | value + | country_code_iso3166_1_alpha_2 | gb + | country_code_iso3166_1 | UK + | country_code_iso3166 | de + | country_code | us + | iso3166-1:alpha2 | aU + | iso3166-1 | 12 + | ISO3166-1 | XX + | iso3166 | Nl + | is_in:country_code | __ + | addr:country | .. + | addr:country_code | cv + + Scenario Outline: Ignore country codes with wrong length + Given the osm nodes: + | id | tags + | 10 | 'place' : 'village', 'country_code' : '' + When loading osm data + Then table place contains + | object | class | type | country_code + | N10 | place | village | None + + Examples: + | value + | X + | x + | ger + | dkeufr + | d e + + Scenario: Import of house numbers + Given the osm nodes: + | id | tags + | 10 | 'building' : 'yes', 'addr:housenumber' : '4b' + | 11 | 'building' : 'yes', 'addr:conscriptionnumber' : '003' + | 12 | 'building' : 'yes', 'addr:streetnumber' : '2345' + | 13 | 'building' : 'yes', 'addr:conscriptionnumber' : '3', 'addr:streetnumber' : '111' + When loading osm data + Then table place contains + | object | class | type | housenumber + | N10 | place | house | 4b + | N11 | place | house | 003 + | N12 | place | house | 2345 + | N13 | place | house | 3/111 + + Scenario: Import of address interpolations + Given the osm nodes: + | id | tags + | 10 | 'addr:interpolation' : 'odd' + | 11 | 'addr:housenumber' : '10', 'addr:interpolation' : 'odd' + | 12 | 'addr:interpolation' : 'odd', 'addr:housenumber' : '23' + When loading osm data + Then table place contains + | object | class | type | housenumber + | N10 | place | houses | odd + | N11 | place | houses | odd + | N12 | place | houses | odd + + Scenario: Shorten tiger:county tags + Given the osm nodes: + | id | tags + | 10 | 'place' : 'village', 'tiger:county' : 'Feebourgh, AL' + | 11 | 'place' : 'village', 'addr:state' : 'Alabama', 'tiger:county' : 'Feebourgh, AL' + When loading osm data + Then table place contains + | object | class | type | isin + | N10 | place | village | Feebourgh county + | N11 | place | village | Alabama,Feebourgh county + + Scenario Outline: Import of address tags + Given the osm nodes: + | id | tags + | 10 | 'place' : 'village', '' : '' + When loading osm data + Then table place contains + | object | class | type | isin + | N10 | place | village | + + Examples: + | key | value + | is_in | Stockholm, Sweden + | is_in:country | Xanadu + | addr:suburb | hinein + | addr:county | le havre + | addr:city | Sydney + | addr:state | Jura + + Scenario: Import of admin level + Given the osm nodes: + | id | tags + | 10 | 'amenity' : 'hospital', 'admin_level' : '3' + | 11 | 'amenity' : 'hospital', 'admin_level' : 'b' + When loading osm data + Then table place contains + | object | class | type | admin_level + | N10 | amenity | hospital | 3 + | N11 | amenity | hospital | 0 + + Scenario: Import of extra tags + Given the osm nodes: + | id | tags + | 10 | 'tourism' : 'hotel', '' : 'foo' + When loading osm data + Then table place contains + | object | class | type | extratags + | N10 | tourism | hotel | '' : 'foo' + + Examples: + | key + | tracktype + | traffic_calming + | service + | cuisine + | capital + | dispensing + | religion + | denomination + | sport + | internet_access + | lanes + | surface + | smoothness + | width + | est_width + | incline + | opening_hours + | food_hours + | collection_times + | service_times + | smoking_hours + | disused + | wheelchair + | sac_scale + | trail_visibility + | mtb:scale + | mtb:description + | wood + | drive_thru + | drive_in + | access + | vehicle + | bicyle + | foot + | goods + | hgv + | motor_vehicle + | motor_car + | access:foot + | contact:phone + | drink:mate + | oneway + | date_on + | date_off + | day_on + | day_off + | hour_on + | hour_off + | maxweight + | maxheight + | maxspeed + | disused + | toll + | charge + | population + | description + | image + | attribution + | fax + | email + | url + | website + | phone + | tel + | real_ale + | smoking + | food + | camera + | brewery + | locality + | wikipedia + | wikipedia:de + + Scenario: buildings + Given the osm nodes: + | id | tags + | 10 | 'tourism' : 'hotel', 'building' : 'yes' + | 11 | 'building' : 'house' + | 12 | 'building' : 'shed', 'addr:housenumber' : '1' + | 13 | 'building' : 'yes', 'name' : 'Das Haus' + | 14 | 'building' : 'yes', 'addr:postcode' : '12345' + When loading osm data + Then table place contains + | object | class | type + | N10 | tourism | hotel + | N12 | place | house + | N13 | building| yes + | N14 | building| yes + And table place has no entry for N10:building + And table place has no entry for N11