From ee5c9936ad51790b1db39339300c8bc28670245c Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Tue, 21 Oct 2025 13:39:02 +0200 Subject: [PATCH 1/3] added a geometry or type filter to all topic filters and fixed cases where the geom filter does not apply to the whole filter --- ohsome_quality_api/topics/presets.yaml | 63 +++++++++++++------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/ohsome_quality_api/topics/presets.yaml b/ohsome_quality_api/topics/presets.yaml index cc67bbb6c..079434efd 100644 --- a/ohsome_quality_api/topics/presets.yaml +++ b/ohsome_quality_api/topics/presets.yaml @@ -152,7 +152,7 @@ cycleway: endpoint: elements aggregation_type: length filter: >- - (cycleway=* and cycleway!=no) + ((cycleway=* and cycleway!=no) or (cycleway:both=*) or (cycleway:right=*) or (cycleway:left=*) @@ -164,7 +164,7 @@ cycleway: or (highway=cycleway) or (highway=path and bicycle=designated) or (bicycle_road=yes) - or (cyclestreet=yes) + or (cyclestreet=yes)) and geometry:line indicators: - mapping-saturation @@ -181,8 +181,8 @@ power_lines: endpoint: elements aggregation_type: length filter: >- - (power=line) - or (power=minor_line) + ((power=line) + or (power=minor_line)) and geometry:line indicators: - attribute-completeness @@ -200,7 +200,7 @@ power_substations: endpoint: elements aggregation_type: count filter: >- - power=substation + power=substation and (type:way or type:node) indicators: - attribute-completeness - mapping-saturation @@ -215,7 +215,6 @@ footpath: description: >- All linear OSM features commonly used for walking, including dedicated pedestrian paths, shared-use paths, and roads where foot traffic is allowed or sidewalks exist. - endpoint: elements aggregation_type: length filter: >- @@ -307,7 +306,7 @@ schools: description: Count of schools. endpoint: elements aggregation_type: count - filter: amenity=school + filter: amenity=school and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dschool indicators: - mapping-saturation @@ -324,7 +323,7 @@ kindergarten: description: Count of kindergartens. endpoint: elements aggregation_type: count - filter: amenity=kindergarten + filter: amenity=kindergarten and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dkindergarten indicators: - mapping-saturation @@ -340,7 +339,7 @@ clinics: description: Count of clinics. endpoint: elements aggregation_type: count - filter: amenity=clinic or healthcare=clinic + filter: (amenity=clinic or healthcare=clinic) and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Global_Healthsites_Mapping_Project indicators: - mapping-saturation @@ -356,7 +355,7 @@ doctors: description: Count of doctors. endpoint: elements aggregation_type: count - filter: amenity=doctors or healthcare=doctor + filter: (amenity=doctors or healthcare=doctor) and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Global_Healthsites_Mapping_Project indicators: - mapping-saturation @@ -372,7 +371,7 @@ bus-stops: description: Count of bus stops. endpoint: elements aggregation_type: count - filter: highway=bus_stop + filter: highway=bus_stop and type:node source: https://wiki.openstreetmap.org/wiki/Tag:highway%3Dbus_stop indicators: - mapping-saturation @@ -388,7 +387,7 @@ tram-stops: description: Count of tram stops. endpoint: elements aggregation_type: count - filter: railway=tram_stop + filter: railway=tram_stop and type:node source: https://wiki.openstreetmap.org/wiki/Tag:railway%3Dtram_stop indicators: - mapping-saturation @@ -404,7 +403,7 @@ public-transport-stops: description: Count of public transport stops. endpoint: elements aggregation_type: count - filter: public_transport=platform + filter: public_transport=platform and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -419,7 +418,7 @@ subway-stations: description: Count of subway stops. endpoint: elements aggregation_type: count - filter: station=subway + filter: station=subway and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:station%3Dsubway indicators: - mapping-saturation @@ -435,7 +434,7 @@ supermarkets: description: Count of supermarkets. endpoint: elements aggregation_type: count - filter: shop=supermarket or shop=convenience + filter: (shop=supermarket or shop=convenience) and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:shop%3Dsupermarket indicators: - mapping-saturation @@ -451,7 +450,7 @@ marketplaces: description: Count of marketplaces. endpoint: elements aggregation_type: count - filter: amenity=marketplace + filter: amenity=marketplace and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dmarketplace indicators: - mapping-saturation @@ -467,7 +466,7 @@ parks: description: Count of parks. endpoint: elements aggregation_type: count - filter: leisure=park + filter: leisure=park and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dpark indicators: - mapping-saturation @@ -483,7 +482,7 @@ sports-pitch: description: Count of sports pitches (an area designed for practising a particular sport). endpoint: elements aggregation_type: count - filter: leisure=pitch + filter: leisure=pitch and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dpitch indicators: - mapping-saturation @@ -499,7 +498,7 @@ forests: description: Count of forests. endpoint: elements aggregation_type: count - filter: landuse=forest + filter: landuse=forest and geometry:polygon source: https://wiki.openstreetmap.org/wiki/Forest indicators: - mapping-saturation @@ -543,7 +542,7 @@ fitness-centres: description: Count of fitness centres. endpoint: elements aggregation_type: count - filter: leisure in (fitness_centre, sports_centre) + filter: leisure in (fitness_centre, sports_centre) and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Gym_/_Fitness_centre indicators: - mapping-saturation @@ -559,7 +558,7 @@ fire-stations: description: Count of firestations. endpoint: elements aggregation_type: count - filter: amenity=fire_station + filter: amenity=fire_station and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dfire_station indicators: - mapping-saturation @@ -574,7 +573,7 @@ hospitals: description: Count of hospitals. endpoint: elements aggregation_type: count - filter: amenity=hospital or healthcare=hospital + filter: (amenity=hospital or healthcare=hospital) and (type:way or type:node) source: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dhospital indicators: - mapping-saturation @@ -596,10 +595,10 @@ roads-unicef: aggregation_type: length filter: >- highway in (motorway, motorway_link, motorroad, trunk, trunk_link, primary, primary_link, secondary, secondary_link, - tertiary, tertiary_link, unclassified, residential, living_street, service, road, track) + tertiary, tertiary_link, unclassified, residential, living_street, service, road, track) and geometry:line ratio_filter: >- (highway in (motorway, motorway_link, motorroad, trunk, trunk_link, primary, primary_link, secondary, - secondary_link, tertiary, tertiary_link, unclassified, residential, living_street, service, road, track)) and name=* + secondary_link, tertiary, tertiary_link, unclassified, residential, living_street, service, road, track)) and name=* and geometry:line source: https://heigit.atlassian.net/wiki/spaces/GIS/pages/756645935/2024-10-01+Unicef+education+access indicators: - mapping-saturation @@ -615,7 +614,7 @@ healthcare-primary: description: Count of hospitals. endpoint: elements aggregation_type: count - filter: amenity in (clinic, doctors, health_post) or healthcare in (clinic, doctors, doctor, midwife, nurse, center) + filter: (amenity in (clinic, doctors, health_post) or healthcare in (clinic, doctors, doctor, midwife, nurse, center)) and (type:way or type:node) source: https://heigit.atlassian.net/wiki/spaces/GIS/pages/756645935/2024-10-01+Unicef+education+access indicators: - mapping-saturation @@ -755,7 +754,7 @@ local-food-shops: description: Count of local food shops. endpoint: elements aggregation_type: count - filter: shop=bakery or shop=butcher or shop=greengrocer or shop=seafood or shop=cheese or shop=dairy + filter: (shop=bakery or shop=butcher or shop=greengrocer or shop=seafood or shop=cheese or shop=dairy) and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -768,7 +767,7 @@ fast-food-restaurants: description: Count of fast food restaurants. endpoint: elements aggregation_type: count - filter: amenity=fast_food + filter: amenity=fast_food and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -781,7 +780,7 @@ restaurants: description: Count of restaurants. endpoint: elements aggregation_type: count - filter: amenity=restaurant or amenity=cafe + filter: (amenity=restaurant or amenity=cafe) and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -794,7 +793,7 @@ convenience-stores: description: Count of convenience stores. endpoint: elements aggregation_type: count - filter: shop=convenience + filter: shop=convenience and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -807,7 +806,7 @@ pubs-and-biergartens: description: Count of pubs and biergartens. endpoint: elements aggregation_type: count - filter: amenity=pub or amenity=biergarten or amenity=bar + filter: (amenity=pub or amenity=biergarten or amenity=bar) and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -820,7 +819,7 @@ alcohol-and-beverages: description: Count of shops selling alcohol. endpoint: elements aggregation_type: count - filter: shop=alcohol or shop=beverages + filter: (shop=alcohol or shop=beverages) and (type:way or type:node) indicators: - mapping-saturation - currentness @@ -833,7 +832,7 @@ sweets-and-pasteries: description: Count of shops selling sweets and pastries. endpoint: elements aggregation_type: count - filter: shop=pastry or amenity=ice_cream or shop=confectionery + filter: (shop=pastry or amenity=ice_cream or shop=confectionery) and (type:way or type:node) indicators: - mapping-saturation - currentness From c688bf59e40ce903883e24cf4ef9c14a93139def Mon Sep 17 00:00:00 2001 From: Matthias Schaub Date: Mon, 10 Nov 2025 10:24:19 +0100 Subject: [PATCH 2/3] tests: update cassettes --- .../indicators/test_currentness.yaml | 80 ++++++++++++++++++ ...n--test_no_subway_stations.cassette.pickle | Bin 8259 -> 17835 bytes 2 files changed, 80 insertions(+) diff --git a/tests/integrationtests/fixtures/vcr_cassettes/indicators/test_currentness.yaml b/tests/integrationtests/fixtures/vcr_cassettes/indicators/test_currentness.yaml index b152a9bf8..53bb56e12 100644 --- a/tests/integrationtests/fixtures/vcr_cassettes/indicators/test_currentness.yaml +++ b/tests/integrationtests/fixtures/vcr_cassettes/indicators/test_currentness.yaml @@ -2823,4 +2823,84 @@ interactions: status: code: 404 message: Not Found +- request: + body: filter=station%3Dsubway+and+%28type%3Away+or+type%3Anode%29&bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22type%22%3A+%22Feature%22%2C+%22geometry%22%3A+%7B%22type%22%3A+%22MultiPolygon%22%2C+%22coordinates%22%3A+%5B%5B%5B%5B7.818124%2C+13.859122%5D%2C+%5B7.835312%2C+13.859122%5D%2C+%5B7.835312%2C+13.872538%5D%2C+%5B7.818124%2C+13.872538%5D%2C+%5B7.818124%2C+13.859122%5D%5D%5D%5D%7D%2C+%22properties%22%3A+%7B%7D%7D%5D%7D&time=2008-08-20%2F2025-08-01%2FP1M&contributionType=geometryChange%2Ccreation%2CtagChange + headers: + accept: + - '*/*' + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '545' + content-type: + - application/x-www-form-urlencoded + host: + - api.ohsome.org + user-agent: + - ohsome-quality-api/1.12.0 + method: POST + uri: https://api.ohsome.org/v1/contributions/latest/count + response: + body: + string: !!binary | + H4sIAAAAAAAA/6yby04UURgG9z7FZNZcug834R2MC4kLjQs0rUwC9KSnMRrCA/kaPpnDoG6sL56T + VDIbyKFqfha1+x5eLBbLq3meVh/v59V4t1xcLB62v9v+9n66efppeT3P683F4eF4vRlvh4Nx+nL4 + aVx/n1ZfrufNcu/58Tx8m3evf/5YvF4Pd2/maRjmV1frxafx7pk+Tpvl9vHj3k65Xr0dps1v47I/ + 6LuD4x1sOQ2b+5sd7P2fr/J5Gm8vV7fDZr66Xe/+oHTdy/3tp3SXXXex+7z7+11GenuOb79e3dwP + T6+6g2735f6nZAwq+05RBgwre0fJGFYWR8kYUJ7vd8aVEcNK48qIYeWRo2QMK48dJWNYeeIoGcPK + U0fJGFaeOUrGsJLj2Kysbuy509iIQaXS2IhhpVOf+saeO42NmH+V23+H0diMYaVwZcawUmhsxrBS + aGzGsFJobMawUmhsxrBSaGzGsFJobMawUmhsxqDSaGzGsNKpT3Vjn9469alvbO80NmJYaVwZMaw0 + GhsxrDQaGzGsNBobMaw0GhsxrDQaGzGsNBobMaw0GhsxqFQaGzGsdOpT39jeaWzEgLI4jY0YVhpX + RgwrjcZGDCuNxkYMK43GRgwrjcZGDCuNxkYMK43GRgwrjcZGDCqVxkYMK5361De2OI2NGFAeOY2N + GFYaV0YMK43GRgwrjcZGDCuNxkYMK43GRgwrjcZGDCuNxkYMK43GRgwqlcZGDCud+tQ39shpbMSA + 8thpbMSw0rgyYlhpNDZiWGk0NmJYaTQ2YlhpNDZiWGk0NmJYaTQ2YlhpNDZiUKk0NmJY6dSnvrHH + TmMjBpQnTmMjhpXGlRHDSqOxEcNKo7ERw0qjsRHDSqOxEcNKo7ERw0qjsRHDSqOxEYNKpbERw0qn + PvWNPXEaGzGgPHUaGzGsNK6MGFYajY0YVhqNjRhWGo2NGFYajY0YVhqNjRhWGo2NGFYajY0YVCqN + jRhWOvWpb+yp09iIAeWZ09iIYaVxZcSw0mhsxLDSaGzEsNJobMSw0mhsxLDSaGzEsNJobMSw0mhs + xKBSaWzEsNKpT31jz5zGRgwoXzqNjRhWGldGDCuNxkYMK43GRgwrjcZGDCuNxkYMK43GRgwrjcY2 + 7Lx6Z+eVMahUGtuw8+qdnVfGsNKpT31jnZ1XxrDSuLJh59U7O6+MYaXR2IadV+/svDKGlUZjG3Ze + vbPzyhhWGo1t2Hn1zs4rY1CpNLZh59U7O6+MYaVTn+rGFmfnlTGsFK7MGFYKjc0YVgqNzRhWCo3N + GFYKjc0YVgqNzRhWCo3NGFYKjc0YVBqNzRhWOvWpbmxxdl4ZA0pn55UxrDSubNh5FWfnlTGsNBrb + sPMqzs4rY1hpNLZh51WcnVfGsNJobMPOqzg7r4xBpdLYhp1XcXZeGcNKpz71jXV2XhnDSuPKhp1X + cXZeGcNKo7ENO6/i7LwyhpVGYxt2XsXZeWUMK43GNuy8irPzyhhUKo1t2HkVZ+eVMax06lPfWGfn + lTGsNK5s2HkVZ+eVMaw0Gtuw8yrOzitjWGk0tmHnVZydV8aw0mhsw86rODuvjEGl0tiGnVdxdl4Z + w0qnPvWNdXZeGcNK48qGnVdxdl4Zw0qjsQ07r+LsvDKGlUZjG3Zexdl5ZQwrjcY27LyKs/PKGFQq + jW3YeRVn55UxrHTqU99YZ+eVMaw0rmzYeRVn55UxrDQa27DzKs7OK2NYaTS2YedVqndeiw8vHn8B + AAD//wMAQUyMudJbAAA= + headers: + access-control-allow-credentials: + - 'true' + access-control-allow-headers: + - Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization + access-control-allow-methods: + - POST, GET + access-control-allow-origin: + - '*' + access-control-max-age: + - '3600' + cache-control: + - no-transform, public, max-age=31556926 + connection: + - Keep-Alive + content-encoding: + - gzip + content-type: + - application/json + date: + - Mon, 10 Nov 2025 09:17:49 GMT + keep-alive: + - timeout=5, max=100 + server: + - Apache/2.4.58 (Ubuntu) + strict-transport-security: + - max-age=63072000; includeSubdomains; + transfer-encoding: + - chunked + vary: + - accept-encoding + status: + code: 200 + message: '' version: 1 diff --git a/tests/integrationtests/indicators/test_currentness.py--TestCalculation--test_no_subway_stations.cassette.pickle b/tests/integrationtests/indicators/test_currentness.py--TestCalculation--test_no_subway_stations.cassette.pickle index 14e278e0784639cf05f2909f3eefb0111c9dd274..fa635100301b52004a70b639e7ffa8f786cbd46b 100644 GIT binary patch literal 17835 zcmeI2OK%%x6ovz|q;BUd7C-n0Xa5uVLmj%)Ew~*D&)MW?sY0 zYnXWrGp}LhHO#z*nb$D$I%ZzS%CT8Bm z%$t~b6EkmN<}J*;g_*Z7^A={_!pvKkc?&adVdgE&yoH&!F!MHM-p0(^n0XsBZ)4_d z%)E`6w=wfJX5Plk+n9M9Gw)#L9n8FgnRhVr4rboL%sZHQ2Q%+r<{iwugPC_Q^DbuI z#mu{yc^5P9V&+}Uyo;H4G4n2F-o?zjn0Xg7?_uUW%)E!0_b~GwX5Pchdzg6-Gw)&M zJ%=?&mA2aV`=6%e(kD2!|^FC(Y$ISbfc^@+$VCDnNe1Mq`F!KRs zKETWenE3!RA7JJK%zS{E4>0o~WgGaq8+L(F`LnGZ4ZA!a_r%!ioy5HlZP z<|E8}gqe>p^ATn~!pujQ`3N%~Vdf*ue1w^gF!M2HKE}+)nE4npA7kcY%zTWQk1_Kx zWFwz3CDMLQpxN4`1L?bL&vz38X@Qt%-D+1yO0?#)jt zxaz2kzkPNw5??0fQ~EOOrEa7)HFe8T&+Jkzs}4>5hZIfq)GQv^#k^5)m426~>=Vb% zn@dMlP6JqS?Iq{OoXQvlRj^%ke0Bl+oM8Idl|M8yvpc|1SzBLZZ=WXx`zf4(_?Nb3^G1<(8a-W7EzbxTjA|^`+X{c@*7Br?(#c5RJ_Cio{jqzMVTgwhNJ1 zTm?7Z({Ej^`P%;G<^fIgV`KB` zl~%!R1v_g-VsHOFyL$(Byqnh1#dM;XWshcD>8-l6`J4JiJL_)rlf>Dcx6-Kx_tiI# z<|lY|V}}B@Fz%>V8~#o7b+dC060)_0{WZ8)wsjkaujJW$*9rKiBX7%NKK2-g5OT z|MH^uHK&_Z*(qPuUd4|Ee9r?OKjhgLT}ORTJKtgS&iVI~Za=L9PkJbv-P!UF3T zJpNO!%oKyb5P4#=L)10khse{LA0p3ieuzBD`62Q==ZDBsogX64c7BLF;rSu*oacwg zRpf`Rylpw~Ly~Jpodq_DnhX4pX@)e)HLCTB)y~7 z37;hC9W_w+BuVe6jlw5MdPmI^K1tF$YN@bE)K%e!B)y~F3ZEqD9d%gvBuVe6&%!53 zdPm(BK1tF$>bdYqlHO70g-xR73qK_39kpQiBuVe65yK}*dPnUTK1tF$YRd3QlHO5k zhE1aG3_m349rbAVBuVe6Q^O}odPn^lK1tF$>e}#0lHO78hEJ08jygDO5;bx7AxZD3 zmBS}VdPfZ%K1tF$YU}VxlHO5shfk99j#@ly5_Ng_AxZD3*TW}CdPf}}K1tF$>ih6X zlHO7Ghfk99j(R|RlB9Rk31X9|8N?4sdPglGK1tF$Y7Fs7lHO5!h)KyS&lHO7Oh)Bn?zkFen`?g>OJvElHO4VicgaCj`~o1 zlB9RkjpCCey`!EKpCsuWb*9)PYEJP(lHO5^icgaCjv7^blB9RkuHuv4(YrUI)IaB< b)VU~iE=v8cqSU$k^p@RpE>w}EA Date: Mon, 10 Nov 2025 10:31:38 +0100 Subject: [PATCH 3/3] refactor: add osm type to poi filter definition --- ohsome_quality_api/topics/presets.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ohsome_quality_api/topics/presets.yaml b/ohsome_quality_api/topics/presets.yaml index 079434efd..8be6f763a 100644 --- a/ohsome_quality_api/topics/presets.yaml +++ b/ohsome_quality_api/topics/presets.yaml @@ -246,7 +246,7 @@ poi: aggregation_type: count source: https://github.com/GIScience/openpoiservice/blob/master/openpoiservice/server/categories/categories.yml filter: >- - (aeroway in (aerodrome, helipad, heliport)) + ((aeroway in (aerodrome, helipad, heliport)) or (amenity in (animal_boarding, animal_shelter, arts_centre, atm, baby_hatch, bank, bar, bbq, bench, bicycle_parking, bicycle_rental, bicycle_repair_station, biergarten, boat_sharing, brothel, bureau_de_change, bus_station, bus_stop, cafe, car_sharing, car_wash, casino, charging_station, cinema, clinic, clock, college, @@ -292,7 +292,8 @@ poi: tyres, variety_store, video, video_games, watches, weapons, wine, pet)) or (tourism in (alpine_hut, apartment, aquarium, artwork, attraction, camp_site, caravan_site, chalet, gallery, museum, guest_house, hostel, hotel, motel, picnic_site, theme_park, viewpoint, - wilderness_hut, zoo)) + wilderness_hut, zoo))) + and (type:way or type:node) indicators: - mapping-saturation - currentness