From 6454018139607d61e53a7074ad10682c6f5d183f Mon Sep 17 00:00:00 2001 From: Ryan Lambert Date: Mon, 5 Jun 2023 19:38:30 -0600 Subject: [PATCH 1/3] Add shop tests (#338) Add tests for shop point/polygon counts. Includes moving test docs to main docs page, and overall improvements to the examples. --- docs/src/tests.md | 180 ++++++++++++++++-- tests/README.md | 94 +-------- .../shop_point_osm_type_subtype_count.out | 130 +++++++++++++ .../shop_polygon_osm_type_subtype_count.out | 49 +++++ .../sql/shop_point_osm_type_subtype_count.sql | 5 + .../shop_polygon_osm_type_subtype_count.sql | 5 + 6 files changed, 356 insertions(+), 107 deletions(-) create mode 100644 tests/expected/shop_point_osm_type_subtype_count.out create mode 100644 tests/expected/shop_polygon_osm_type_subtype_count.out create mode 100644 tests/sql/shop_point_osm_type_subtype_count.sql create mode 100644 tests/sql/shop_polygon_osm_type_subtype_count.sql diff --git a/docs/src/tests.md b/docs/src/tests.md index 87642764..54fb78d2 100644 --- a/docs/src/tests.md +++ b/docs/src/tests.md @@ -21,30 +21,185 @@ A simplified usage for quicker testing during development. make docker-exec-default unit-tests ``` - -## Python unit tests - -The Python unit tests are under `pgosm-flex/docker/tests/`. These tests use -Python's `unittest` module. The `make` process runs these using -`coverage run ...` and `coverage report ...`. -See the [Makefile](https://github.com/rustprooflabs/pgosm-flex/blob/main/Makefile) -for exact implementation. - - -## Data import tests +## Data Tests Under `pgosm-flex/tests`. The `run-output-tests.sh` script is ran by running `make`. The script loops over the `.sql` scripts under `pgosm-flex/tests/sql/`, runs the queries via `psql` using `--no-psqlrc -tA` and compares the output from the query against the expected output saved under `pgosm-flex/tests/expected`. +Running `make docker-exec-default unit-tests` should finish with this line +reporting data tests completed successfully. + + +```bash +Data output tests completed successfully. +``` + +If something in the Lua styles or SQL post-processing changes, the intention is +they will be reported by these tests. Note the second line of this section +reports the `docker exec` command to run in order to see the changes to the +data tests. + +```bash +FAILED TEST: sql/shop_polygon_osm_type_subtype_count.sql - See tmp/shop_polygon_osm_type_subtype_count.diff + docker exec -it pgosm /bin/bash -c "cat /app/tests/tmp/shop_polygon_osm_type_subtype_count.diff " +One or more data output tests failed. +``` + +The output from the `docker exec` command looks like the following. +Note the `-` and `+` lines showing the count of records with +`osm_type='shop'` and `osm_subtype='chemist'` changed from 1 to 2. + + +```bash +diff --git a/expected/shop_polygon_osm_type_subtype_count.out b/tmp/shop_polygon_osm_type_subtype_count.out +index 75c16c3..2385d8d 100644 +--- a/expected/shop_polygon_osm_type_subtype_count.out ++++ b/tmp/shop_polygon_osm_type_subtype_count.out +@@ -12,7 +12,7 @@ shop|books|1 + shop|car|4 + shop|car_parts|3 + shop|car_repair|7 +-shop|chemist|1 ++shop|chemist|2 + shop|clothes|8 + shop|convenience|35 + shop|copyshop|1 +``` + + +### Add / Update Data Tests + +This section provides guidance to adding/updating data tests for PgOSM Flex. +The SQL file to run is under `tests/sql/*.sql`, the expected results are saved +under `tests/expected/*.out`. + + +#### Load Test Data + +Load `data/district-of-columbia-2021-01-13.osm.pbf` with `run-all` +before running these tests. + + +> PBF sourced [from Geofabrik's download service](https://download.geofabrik.de/) on January 13, 2021. + +#### Craft Test Query + +Connect to the PgOSM Flex database with `data/district-of-columbia-2021-01-13.osm.pbf` +loaded. Write the query that provide results to test for. + +Important: Results must be ordered using `COLLATE "C"` to ensure consistent +ordering across systems. For example it should be written like this: + +```sql +SELECT osm_type COLLATE "C", COUNT(*) + FROM osm.amenity_point + GROUP BY osm_type COLLATE "C" + ORDER BY osm_type COLLATE "C" +; +``` + +Not like this: + +```sql +SELECT osm_type, COUNT(*) + FROM osm.amenity_point + GROUP BY osm_type + ORDER BY osm_type +; +``` +#### Create Expected Output + + +To create new tests, or to update existing tests use `psql --no-psqlrc -tA
`. +Example for amenity count of `osm_type`. + +Assuming [Quick Start](quick-start.md) instructions, set the env var for the Postgres +connection first. + +```bash +export PGOSM_CONN=postgresql://postgres:mysecretpassword@localhost:5433/pgosm +``` + +Run the query, save the output. + +```bash +psql --no-psqlrc -tA \ + -d $PGOSM_CONN \ + -f sql/amenity_osm_type_count.sql \ + > expected/amenity_osm_type_count.out +``` + +#### Validate New Tests + +Ensure the data tests work and are reported if values change via `make`. +The best way to ensure the test is working is manually change one value in the +generated `.out` file which should cause the following error message. +Setting the `.out` data back to right should return the message back to successful. + +```bash +FAILED TEST: sql/shop_polygon_osm_type_subtype_count.sql - See tmp/shop_polygon_osm_type_subtype_count.diff + docker exec -it pgosm /bin/bash -c "cat /app/tests/tmp/shop_polygon_osm_type_subtype_count.diff " +One or more data output tests failed. +``` + + + +---- + +### Create PBFs for areas w/ Failures + +Identify a feature related to the issue and load small region around +into JOSM (as if making an edit). + +Use JOSM's "Save As..." to save the `.osm` file. +Use `osmium-tool` (https://osmcode.org/osmium-tool/manual.html) +to convert to `.pbf` format. + +```bash +osmium cat .osm -o .osm.pbf +mv .osm.pbf ~/git/pgosm-flex/tests/data/extra-regions/ +``` + + +### Test for import failures + +Test for specific regions that have had failures due to unusual +tags and/or bugs in PgOSM-Flex. + + +Run extra region load tests. + + + +```bash +export PGOSM_CONN=pgosm_tests +export PGOSM_CONN_PG=postgres +./run-extra-loads.sh +``` > FIXME: At this time the `run-extra-loads.sh` script is not ran automatically. There are not any usage notes covering those random side tests. + +## Python unit tests + +The Python unit tests are under `pgosm-flex/docker/tests/`. These tests use +Python's `unittest` module. The `make` process runs these using +`coverage run ...` and `coverage report ...`. +See the [Makefile](https://github.com/rustprooflabs/pgosm-flex/blob/main/Makefile) +for exact implementation. + +These unit tests cover specific logic and functionality to how PgOSM Flex's Python +program runs. + +---- + + ## What is not tested Functionality of `osm2pgsql-replication` to actually update data. Challenge @@ -71,6 +226,3 @@ refresh fails. 2023-01-29 08:11:36,890:INFO:pgosm-flex:pgosm_flex:Skipping pg_dump 2023-01-29 08:11:36,890:WARNING:pgosm-flex:pgosm_flex:PgOSM Flex completed with errors. Details in output ``` - - - diff --git a/tests/README.md b/tests/README.md index 14de124d..202a77a8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,96 +1,4 @@ # PgOSM-Flex Tests - -Under development - See #112. - - -```bash -cd tests/ -``` - -Setup env var for connection string, defaults to `postgres` if not set. - -```bash -export POSTGRES_USER=your_db_user -``` - -If you are not setup to use `~/.pgpass` for authentication set -the password env var too. - -```bash -export POSTGRES_PASSWORD=mysecretpassword -``` - - -## Output Tests - -Load `data/district-of-columbia-2021-01-13.osm.pbf` with `run-all` -before running these tests. - - -Run output tests (need D.C. region loaded first). - -```bash -./run-output-tests.sh -``` - - -> PBF sourced [from Geofabrik's download service](https://download.geofabrik.de/) on January 13, 2021. - - -## Test for import failures - -Test for specific regions that have had failures due to unusual -tags and/or bugs in PgOSM-Flex. - - -Run extra region load tests. - - - -```bash -export PGOSM_CONN=pgosm_tests -export PGOSM_CONN_PG=postgres -./run-extra-loads.sh -``` - - -### Creating Tests - -Write query. Ensure results are ordered using `COLLATE "C"` to ensure consistent ordering across -systems. - - -### Creating expected output - - -To create new tests, or to update existing tests use `psql --no-psqlrc -tA
`. -Example for amenity count of `osm_type`. - -```bash -psql --no-psqlrc -tA \ - -d $PGOSM_CONN \ - -f sql/amenity_osm_type_count.sql \ - > expected/amenity_osm_type_count.out -``` - - - -## Create PBFs for areas w/ Failures - -Identify a feature related to the issue and load small region around -into JOSM (as if making an edit). - -Use JOSM's "Save As..." to save the `.osm` file. -Use `osmium-tool` (https://osmcode.org/osmium-tool/manual.html) -to convert to `.pbf` format. - -```bash -osmium cat .osm -o .osm.pbf -mv .osm.pbf ~/git/pgosm-flex/tests/data/extra-regions/ -``` - - - - +Documentation moved. See [https://pgosm-flex.com/tests.html](https://pgosm-flex.com/tests.html). diff --git a/tests/expected/shop_point_osm_type_subtype_count.out b/tests/expected/shop_point_osm_type_subtype_count.out new file mode 100644 index 00000000..0669f7e0 --- /dev/null +++ b/tests/expected/shop_point_osm_type_subtype_count.out @@ -0,0 +1,130 @@ +amenity|cafe|332 +amenity|car_rental|8 +amenity|pharmacy|68 +amenity|pub|97 +amenity|vending_machine|18 +shop|adult|1 +shop|alcohol|189 +shop|antiques|10 +shop|appliance|1 +shop|art|17 +shop|auction|1 +shop|auto|1 +shop|baby_goods|1 +shop|bag|4 +shop|bakery|31 +shop|beads|1 +shop|beauty|57 +shop|beauty_supply|1 +shop|bed|4 +shop|beverages|3 +shop|bicycle|18 +shop|bookmaker|8 +shop|books|27 +shop|boutique|2 +shop|butcher|3 +shop|camera|1 +shop|car|2 +shop|car_repair|20 +shop|charity|1 +shop|chemist|2 +shop|chocolate|1 +shop|clothes|162 +shop|coffee|2 +shop|computer|1 +shop|confectionery|6 +shop|convenience|212 +shop|copyshop|24 +shop|cosmetics|14 +shop|courier|1 +shop|craft|2 +shop|deli|16 +shop|department_store|17 +shop|doityourself|13 +shop|dollar_store|1 +shop|dry_cleaner|2 +shop|dry_cleaning|52 +shop|electronics|7 +shop|erotic|2 +shop|estate_agent|1 +shop|fashion_accessories|1 +shop|floor|1 +shop|florist|14 +shop|food|1 +shop|frame|3 +shop|funeral_directors|3 +shop|furniture|27 +shop|garden_centre|1 +shop|gift|34 +shop|greengrocer|6 +shop|grocery|1 +shop|hairdresser|139 +shop|handbag|1 +shop|handbags|1 +shop|hardware|6 +shop|hat|1 +shop|herbalist|1 +shop|hippie|1 +shop|hobby|1 +shop|home|2 +shop|houseware|4 +shop|interior_decoration|3 +shop|jewelry|17 +shop|kiosk|1 +shop|kitchen|2 +shop|lamp|1 +shop|laundry|12 +shop|locksmith|1 +shop|mall|2 +shop|massage|2 +shop|medical_supply|4 +shop|mobile_phone|49 +shop|money_lender|3 +shop|money_transfer;clothes|1 +shop|music|4 +shop|nail|1 +shop|nail_salon|2 +shop|newsagent|2 +shop|nutrition_supplements|5 +shop|optician|24 +shop|outdoor|2 +shop|paint|3 +shop|pawn|2 +shop|perfumery|1 +shop|pet|19 +shop|pet_grooming|1 +shop|photo|4 +shop|printing|1 +shop|publisher of Science, the scientific journal|1 +shop|religion|1 +shop|running|1 +shop|seafood|1 +shop|second_hand|9 +shop|shoe_repair|2 +shop|shoes|29 +shop|specialty|1 +shop|spices|1 +shop|sports|4 +shop|stationery|5 +shop|storage_rental|2 +shop|supermarket|73 +shop|tailor|7 +shop|tanning_salon|1 +shop|tarot|1 +shop|tattoo|9 +shop|tea|1 +shop|telecommunication|1 +shop|ticket|2 +shop|tobacco|6 +shop|toys|3 +shop|travel_agency|3 +shop|tyres|2 +shop|vacant|31 +shop|vacuum_cleaner|1 +shop|variety_store|3 +shop|video|3 +shop|video_games|1 +shop|watches|1 +shop|wig|1 +shop|wine|2 +shop|yes|10 diff --git a/tests/expected/shop_polygon_osm_type_subtype_count.out b/tests/expected/shop_polygon_osm_type_subtype_count.out new file mode 100644 index 00000000..75c16c39 --- /dev/null +++ b/tests/expected/shop_polygon_osm_type_subtype_count.out @@ -0,0 +1,49 @@ +amenity|cafe|10 +amenity|car_rental|1 +amenity|pharmacy|8 +amenity|pub|5 +shop|alcohol|15 +shop|art|1 +shop|art;paper|1 +shop|bakery|3 +shop|beauty|7 +shop|bicycle|1 +shop|books|1 +shop|car|4 +shop|car_parts|3 +shop|car_repair|7 +shop|chemist|1 +shop|clothes|8 +shop|convenience|35 +shop|copyshop|1 +shop|cosmetics|2 +shop|deli|1 +shop|department_store|5 +shop|doityourself|2 +shop|dry_cleaning|4 +shop|electronics|1 +shop|florist|1 +shop|frame|2 +shop|funeral_directors|4 +shop|garden_centre|1 +shop|gift|5 +shop|greengrocer|1 +shop|hairdresser|10 +shop|interior_decoration|2 +shop|laundry|5 +shop|mall|3 +shop|mobile_phone|1 +shop|paint|1 +shop|pet|1 +shop|religion|1 +shop|seafood|5 +shop|shoes|2 +shop|sports|2 +shop|supermarket|15 +shop|ticket|1 +shop|tobacco|2 +shop|tyres|1 +shop|vacant|8 +shop|variety_store|3 +shop|wholesale|1 +shop|yes|1 diff --git a/tests/sql/shop_point_osm_type_subtype_count.sql b/tests/sql/shop_point_osm_type_subtype_count.sql new file mode 100644 index 00000000..c543d5d6 --- /dev/null +++ b/tests/sql/shop_point_osm_type_subtype_count.sql @@ -0,0 +1,5 @@ +SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) + FROM osm.shop_point + GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" + ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" +; \ No newline at end of file diff --git a/tests/sql/shop_polygon_osm_type_subtype_count.sql b/tests/sql/shop_polygon_osm_type_subtype_count.sql new file mode 100644 index 00000000..75c6f5e5 --- /dev/null +++ b/tests/sql/shop_polygon_osm_type_subtype_count.sql @@ -0,0 +1,5 @@ +SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) + FROM osm.shop_polygon + GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" + ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" +; \ No newline at end of file From 767dd96c01c6f1768427a355c0846b730d0a6135 Mon Sep 17 00:00:00 2001 From: Ryan Lambert Date: Sat, 10 Jun 2023 07:50:49 -0600 Subject: [PATCH 2/3] Change "all" views to tables loaded via Flex style (#337) * Changing vbuilding_all view to building_combined_point table * Create PK, move helper into style folder * Starting to convert vshop_all. Current version has test errors due to moving code into shop_helper. Need to add more tests on original to help find the cause of the problem with this change. * Fix loading of shop polygons. Reset shop_polygon test output to actual. * Add detailed POI tests * Restructure POI loading in prep to migrate all view * Moving from vpoi_all mat view to poi_combined_point table * still failing on poi_combined_point * Fixed import problem by setting up ID column properly --- flex-config/layerset/basic.ini | 3 +- flex-config/layerset/default.ini | 3 + flex-config/layerset/everything.ini | 3 + flex-config/layerset/minimal.ini | 2 +- flex-config/run-sql.lua | 6 +- flex-config/run.lua | 15 + flex-config/sql/building.sql | 26 -- flex-config/sql/building_combined_point.sql | 27 ++ flex-config/sql/poi.sql | 31 -- flex-config/sql/poi_combined_point.sql | 16 + flex-config/sql/shop.sql | 29 -- flex-config/sql/shop_combined_point.sql | 21 ++ flex-config/style/building.lua | 82 +---- flex-config/style/building_combined_point.lua | 207 ++++++++++++ flex-config/style/building_helpers.lua | 77 +++++ flex-config/style/poi.lua | 172 +--------- flex-config/style/poi_combined_point.lua | 207 ++++++++++++ flex-config/style/poi_helpers.lua | 141 +++++++++ flex-config/style/shop.lua | 165 +++------- flex-config/style/shop_combined_point.lua | 143 +++++++++ flex-config/style/shop_helpers.lua | 33 ++ ...combined_point_osm_type_subtype_count.out} | 0 ...combined_point_osm_type_subtype_count.out} | 0 .../poi_line_osm_type_subtype_count.out | 6 + .../poi_point_osm_type_subtype_count.out | 295 ++++++++++++++++++ .../poi_polygon_osm_type_subtype_count.out | 176 +++++++++++ ...combined_point_osm_type_subtype_count.out} | 0 .../shop_polygon_osm_type_subtype_count.out | 2 +- ..._combined_point_osm_type_subtype_count.sql | 5 + ..._combined_point_osm_type_subtype_count.sql | 5 + ...ql => poi_line_osm_type_subtype_count.sql} | 2 +- ...l => poi_point_osm_type_subtype_count.sql} | 2 +- ...=> poi_polygon_osm_type_subtype_count.sql} | 2 +- ..._combined_point_osm_type_subtype_count.sql | 5 + 34 files changed, 1450 insertions(+), 459 deletions(-) create mode 100644 flex-config/sql/building_combined_point.sql create mode 100644 flex-config/sql/poi_combined_point.sql create mode 100644 flex-config/sql/shop_combined_point.sql create mode 100644 flex-config/style/building_combined_point.lua create mode 100644 flex-config/style/building_helpers.lua create mode 100644 flex-config/style/poi_combined_point.lua create mode 100644 flex-config/style/poi_helpers.lua create mode 100644 flex-config/style/shop_combined_point.lua create mode 100644 flex-config/style/shop_helpers.lua rename tests/expected/{vbuilding_all_osm_type_subtype_count.out => building_combined_point_osm_type_subtype_count.out} (100%) rename tests/expected/{vpoi_all_osm_type_subtype_count.out => poi_combined_point_osm_type_subtype_count.out} (100%) create mode 100644 tests/expected/poi_line_osm_type_subtype_count.out create mode 100644 tests/expected/poi_point_osm_type_subtype_count.out create mode 100644 tests/expected/poi_polygon_osm_type_subtype_count.out rename tests/expected/{vshop_all_osm_type_subtype_count.out => shop_combined_point_osm_type_subtype_count.out} (100%) create mode 100644 tests/sql/building_combined_point_osm_type_subtype_count.sql create mode 100644 tests/sql/poi_combined_point_osm_type_subtype_count.sql rename tests/sql/{vpoi_all_osm_type_subtype_count.sql => poi_line_osm_type_subtype_count.sql} (89%) rename tests/sql/{vshop_all_osm_type_subtype_count.sql => poi_point_osm_type_subtype_count.sql} (88%) rename tests/sql/{vbuilding_all_osm_type_subtype_count.sql => poi_polygon_osm_type_subtype_count.sql} (87%) create mode 100644 tests/sql/shop_combined_point_osm_type_subtype_count.sql diff --git a/flex-config/layerset/basic.ini b/flex-config/layerset/basic.ini index 758cab1f..c7ef4992 100644 --- a/flex-config/layerset/basic.ini +++ b/flex-config/layerset/basic.ini @@ -1,10 +1,11 @@ [layerset] amenity=false -building=true +building_combined_point=true landuse=true leisure=false natural=false place=true poi=false +poi_combined_point=true road_major=true unitable=true diff --git a/flex-config/layerset/default.ini b/flex-config/layerset/default.ini index fda791e5..4f19a488 100644 --- a/flex-config/layerset/default.ini +++ b/flex-config/layerset/default.ini @@ -1,6 +1,7 @@ [layerset] amenity=true building=true +building_combined_point=false indoor=true infrastructure=true landuse=true @@ -8,9 +9,11 @@ leisure=true natural=true place=true poi=true +poi_combined_point=false public_transport=true road=true shop=true +shop_combined_point=false tags=true traffic=true water=true \ No newline at end of file diff --git a/flex-config/layerset/everything.ini b/flex-config/layerset/everything.ini index cb1acc24..eb387a26 100644 --- a/flex-config/layerset/everything.ini +++ b/flex-config/layerset/everything.ini @@ -1,6 +1,7 @@ [layerset] amenity=true building=true +building_combined_point=true indoor=true infrastructure=true landuse=true @@ -8,10 +9,12 @@ leisure=true natural=true place=true poi=true +poi_combined_point=true public_transport=true road=true road_major=true shop=true +shop_combined_point=true tags=true traffic=true unitable=true diff --git a/flex-config/layerset/minimal.ini b/flex-config/layerset/minimal.ini index f941d72c..b68c5efb 100644 --- a/flex-config/layerset/minimal.ini +++ b/flex-config/layerset/minimal.ini @@ -1,4 +1,4 @@ [layerset] place=true -poi=true +poi_combined_point=true road_major=true diff --git a/flex-config/run-sql.lua b/flex-config/run-sql.lua index 6c65a509..32abaa16 100644 --- a/flex-config/run-sql.lua +++ b/flex-config/run-sql.lua @@ -13,10 +13,10 @@ else error('ENV VAR PGOSM_CONN must be set.') end -layers = {'amenity', 'building', 'indoor', 'infrastructure', 'landuse' - , 'leisure' +layers = {'amenity', 'building', 'building_combined_point', 'indoor' + , 'infrastructure', 'landuse', 'leisure' , 'natural', 'place', 'poi', 'public_transport' - , 'road', 'road_major', 'shop', 'tags' + , 'road', 'road_major', 'shop', 'shop_combined_point', 'tags' , 'traffic', 'unitable', 'water'} diff --git a/flex-config/run.lua b/flex-config/run.lua index 118bdaa2..7e4f7bf0 100644 --- a/flex-config/run.lua +++ b/flex-config/run.lua @@ -12,6 +12,11 @@ if conf['layerset']['building'] then require "style.building" end +if conf['layerset']['building_combined_point'] then + print('Including building_combined_point') + require "style.building_combined_point" +end + if conf['layerset']['indoor'] then print('Including indoor') require "style.indoor" @@ -47,6 +52,11 @@ if conf['layerset']['poi'] then require "style.poi" end +if conf['layerset']['poi_combined_point'] then + print('Including poi_combined_point') + require "style.poi_combined_point" +end + if conf['layerset']['public_transport'] then print('Including public_transport') require "style.public_transport" @@ -67,6 +77,11 @@ if conf['layerset']['shop'] then require "style.shop" end +if conf['layerset']['shop_combined_point'] then + print('Including shop_combined_point') + require "style.shop_combined_point" +end + if conf['layerset']['tags'] then print('Including tags') require "style.tags" diff --git a/flex-config/sql/building.sql b/flex-config/sql/building.sql index 1a91f2c5..c03deed1 100644 --- a/flex-config/sql/building.sql +++ b/flex-config/sql/building.sql @@ -39,32 +39,8 @@ ALTER TABLE osm.building_polygon ; - -CREATE VIEW osm.vbuilding_all AS -SELECT osm_id, 'N' AS geom_type, osm_type, osm_subtype, name, levels, - height, operator, wheelchair, wheelchair_desc, address, - geom - FROM osm.building_point -UNION -SELECT osm_id, 'W' AS geom_type, osm_type, osm_subtype, name, levels, - height, operator, wheelchair, wheelchair_desc, address, - ST_Centroid(geom) AS geom - FROM osm.building_polygon -; - -COMMENT ON VIEW osm.vbuilding_all IS 'Converts polygon buildings to point with ST_Centroid(), combines with source points using UNION.'; -COMMENT ON COLUMN osm.vbuilding_all.address IS 'Address combined from address parts in helpers.get_address().'; - COMMENT ON COLUMN osm.building_point.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; COMMENT ON COLUMN osm.building_polygon.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; -COMMENT ON COLUMN osm.vbuilding_all.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; -COMMENT ON COLUMN osm.vbuilding_all.name IS 'Best name option determined by helpers.get_name(). Keys with priority are: name, short_name, alt_name and loc_name. See pgosm-flex/flex-config/helpers.lua for full logic of selection.'; -COMMENT ON COLUMN osm.vbuilding_all.levels IS 'Number (#) of levels in the building.'; -COMMENT ON COLUMN osm.vbuilding_all.height IS 'Object height. Should be in meters (m) but is not enforced. Please fix data in OpenStreetMap.org if incorrect values are discovered.'; -COMMENT ON COLUMN osm.vbuilding_all.wheelchair IS 'Indicates if building is wheelchair accessible.'; -COMMENT ON COLUMN osm.vbuilding_all.geom_type IS 'Type of geometry. N(ode), W(ay) or R(elation). Unique along with osm_id'; -COMMENT ON COLUMN osm.vbuilding_all.geom IS 'Geometry loaded by osm2pgsql.'; -COMMENT ON COLUMN osm.vbuilding_all.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; COMMENT ON COLUMN osm.building_point.address IS 'Address combined from address parts in helpers.get_address().'; COMMENT ON COLUMN osm.building_polygon.address IS 'Address combined from address parts in helpers.get_address().'; @@ -72,8 +48,6 @@ COMMENT ON COLUMN osm.building_polygon.address IS 'Address combined from address COMMENT ON COLUMN osm.building_point.osm_type IS 'Values: building, building_part, office or address. All but address described in osm_subtype. Value is address if addr:* tags exist with no other major keys to group it in a more specific layer. See address_only_building() in building.lua'; COMMENT ON COLUMN osm.building_polygon.osm_type IS 'Values: building, building_part, office or address. All but address described in osm_subtype. Value is address if addr:* tags exist with no other major keys to group it in a more specific layer. See address_only_building() in building.lua'; -COMMENT ON COLUMN osm.vbuilding_all.osm_type IS 'Values: building, building_part, office or address. All but address described in osm_subtype. Value is address if addr:* tags exist with no other major keys to group it in a more specific layer. See address_only_building() in building.lua'; COMMENT ON COLUMN osm.building_point.osm_subtype IS 'Further describes osm_type for building, building_part, and office.'; COMMENT ON COLUMN osm.building_polygon.osm_subtype IS 'Further describes osm_type for building, building_part, and office.'; -COMMENT ON COLUMN osm.vbuilding_all.osm_subtype IS 'Further describes osm_type for building, building_part, and office.'; diff --git a/flex-config/sql/building_combined_point.sql b/flex-config/sql/building_combined_point.sql new file mode 100644 index 00000000..adacf100 --- /dev/null +++ b/flex-config/sql/building_combined_point.sql @@ -0,0 +1,27 @@ + +ALTER TABLE osm.building_combined_point + ADD CONSTRAINT pk_osm_building_combined_point_osm_id_geom_type + PRIMARY KEY (osm_id, geom_type) +; + + +COMMENT ON TABLE osm.building_combined_point IS 'Combined point and polygon buildings with polygons converted to pointss with centroid() in osm2pgsql Lua style.'; +COMMENT ON COLUMN osm.building_combined_point.address IS 'Address combined from address parts in helpers.get_address().'; + +COMMENT ON COLUMN osm.building_combined_point.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; +COMMENT ON COLUMN osm.building_combined_point.name IS 'Best name option determined by helpers.get_name(). Keys with priority are: name, short_name, alt_name and loc_name. See pgosm-flex/flex-config/helpers.lua for full logic of selection.'; +COMMENT ON COLUMN osm.building_combined_point.levels IS 'Number (#) of levels in the building.'; +COMMENT ON COLUMN osm.building_combined_point.height IS 'Object height. Should be in meters (m) but is not enforced. Please fix data in OpenStreetMap.org if incorrect values are discovered.'; +COMMENT ON COLUMN osm.building_combined_point.wheelchair IS 'Indicates if building is wheelchair accessible.'; +COMMENT ON COLUMN osm.building_combined_point.geom_type IS 'Type of geometry. N(ode), W(ay) or R(elation). Unique along with osm_id'; +COMMENT ON COLUMN osm.building_combined_point.geom IS 'Geometry loaded by osm2pgsql.'; +COMMENT ON COLUMN osm.building_combined_point.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; + +COMMENT ON COLUMN osm.building_combined_point.osm_type IS 'Values: building, building_part, office or address. All but address described in osm_subtype. Value is address if addr:* tags exist with no other major keys to group it in a more specific layer. See address_only_building() in building.lua'; +COMMENT ON COLUMN osm.building_combined_point.osm_subtype IS 'Further describes osm_type for building, building_part, and office.'; + +COMMENT ON COLUMN osm.building_point.housenumber IS 'Value from addr:housenumber tag'; +COMMENT ON COLUMN osm.building_point.street IS 'Value from addr:street tag'; +COMMENT ON COLUMN osm.building_point.city IS 'Value from addr:city tag'; +COMMENT ON COLUMN osm.building_point.state IS 'Value from addr:state tag'; +COMMENT ON COLUMN osm.building_point.postcode IS 'Value from addr:postcode tag'; diff --git a/flex-config/sql/poi.sql b/flex-config/sql/poi.sql index 3d6948c5..80128a67 100644 --- a/flex-config/sql/poi.sql +++ b/flex-config/sql/poi.sql @@ -62,34 +62,3 @@ COMMENT ON COLUMN osm.poi_line.address IS 'Address combined from address parts i COMMENT ON COLUMN osm.poi_polygon.address IS 'Address combined from address parts in helpers.get_address().'; COMMENT ON COLUMN osm.poi_polygon.member_ids IS 'Member IDs making up the full relation. NULL if not a relation.'; - -CREATE MATERIALIZED VIEW osm.vpoi_all AS -SELECT osm_id, 'N' AS geom_type, osm_type, osm_subtype, name, address, operator, geom - FROM osm.poi_point -UNION -SELECT osm_id, 'L' AS geom_type, osm_type, osm_subtype, name, address, operator, - ST_Centroid(geom) AS geom - FROM osm.poi_line -UNION -SELECT osm_id, 'W' AS geom_type, osm_type, osm_subtype, name, address, operator, - ST_Centroid(geom) AS geom - FROM osm.poi_polygon -; - - -CREATE UNIQUE INDEX uix_osm_vpoi_all_osm_id_geom_type - ON osm.vpoi_all (osm_id, geom_type); -CREATE INDEX gix_osm_vpoi_all - ON osm.vpoi_all USING GIST (geom); - -CREATE INDEX ix_osm_vpoi_all_osm_type ON osm.vpoi_all (osm_type); - - - -COMMENT ON MATERIALIZED VIEW osm.vpoi_all IS 'Cobmined POI view. Converts lines and polygons to point with ST_Centroid(), stacks using UNION'; - -COMMENT ON COLUMN osm.vpoi_all.osm_type IS 'Stores the OpenStreetMap key that included this feature in the layer. Value from key stored in osm_subtype.'; -COMMENT ON COLUMN osm.vpoi_all.address IS 'Address combined from address parts in helpers.get_address(). See base tables for individual address parts'; -COMMENT ON COLUMN osm.vpoi_all.geom_type IS 'Indicates source table, N (point) L (line) W (polygon). Using L for line differs from how osm2pgsql classifies lines ("W") in order to provide a direct link to which table the data comes from.'; -COMMENT ON COLUMN osm.vpoi_all.osm_subtype IS 'Value detail describing the key (osm_type).'; - diff --git a/flex-config/sql/poi_combined_point.sql b/flex-config/sql/poi_combined_point.sql new file mode 100644 index 00000000..77bcd013 --- /dev/null +++ b/flex-config/sql/poi_combined_point.sql @@ -0,0 +1,16 @@ +CREATE PRIMARY KEY pk_osm_poi_combined_point_osm_id_geom_type + ON osm.poi_combined_point (osm_id, geom_type); +CREATE INDEX gix_osm_poi_combined_point + ON osm.poi_combined_point USING GIST (geom); + +CREATE INDEX ix_osm_poi_combined_point_osm_type ON osm.poi_combined_point (osm_type); + + + +COMMENT ON TABLE osm.poi_combined_point IS 'Combined POI data. Lines and polygons converted to point with centroid() in osm2pgsql.'; + +COMMENT ON COLUMN osm.poi_combined_point.osm_type IS 'Stores the OpenStreetMap key that included this feature in the layer. Value from key stored in osm_subtype.'; +COMMENT ON COLUMN osm.poi_combined_point.address IS 'Address combined from address parts in helpers.get_address(). See base tables for individual address parts'; +COMMENT ON COLUMN osm.poi_combined_point.geom_type IS 'Indicates source table, N (point) L (line) W (polygon). Using L for line differs from how osm2pgsql classifies lines ("W") in order to provide a direct link to which table the data comes from.'; +COMMENT ON COLUMN osm.poi_combined_point.osm_subtype IS 'Value detail describing the key (osm_type).'; + diff --git a/flex-config/sql/shop.sql b/flex-config/sql/shop.sql index 3dd35f40..d0e1b639 100644 --- a/flex-config/sql/shop.sql +++ b/flex-config/sql/shop.sql @@ -61,32 +61,3 @@ COMMENT ON COLUMN osm.shop_polygon.phone IS 'Phone number associated with the fe COMMENT ON COLUMN osm.shop_point.address IS 'Address combined from address parts in helpers.get_address().'; COMMENT ON COLUMN osm.shop_polygon.address IS 'Address combined from address parts in helpers.get_address().'; - - -CREATE VIEW osm.vshop_all AS -SELECT osm_id, 'N' AS geom_type, osm_type, osm_subtype, name, - address, phone, wheelchair, wheelchair_desc, - operator, brand, website, geom - FROM osm.shop_point -UNION -SELECT osm_id, 'W' AS geom_type, osm_type, osm_subtype, name, - address, phone, wheelchair, wheelchair_desc, - operator, brand, website, - ST_Centroid(geom) AS geom - FROM osm.shop_polygon -; - -COMMENT ON VIEW osm.vshop_all IS 'Converts polygon shops to point with ST_Centroid(), combines with source points using UNION.'; -COMMENT ON COLUMN osm.vshop_all.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; -COMMENT ON COLUMN osm.vshop_all.osm_type IS 'Stores the OpenStreetMap key that included this feature in the layer. Value from key stored in osm_subtype.'; -COMMENT ON COLUMN osm.vshop_all.osm_subtype IS 'Value detail describing the key (osm_type).'; -COMMENT ON COLUMN osm.vshop_all.address IS 'Address combined from address parts in helpers.get_address().'; -COMMENT ON COLUMN osm.vshop_all.name IS 'Best name option determined by helpers.get_name(). Keys with priority are: name, short_name, alt_name and loc_name. See pgosm-flex/flex-config/helpers.lua for full logic of selection.'; -COMMENT ON COLUMN osm.vshop_all.geom IS 'Geometry, mix of points loaded by osm2pgsql and points calculated from the ST_Centroid() of the polygons loaded by osm2pgsql.'; - -COMMENT ON COLUMN osm.vshop_all.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; -COMMENT ON COLUMN osm.vshop_all.geom_type IS 'Type of geometry. N(ode), W(ay) or R(elation). Unique along with osm_id'; -COMMENT ON COLUMN osm.vshop_all.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; -COMMENT ON COLUMN osm.vshop_all.website IS 'Official website for the feature. https://wiki.openstreetmap.org/wiki/Key:website'; -COMMENT ON COLUMN osm.vshop_all.brand IS 'Identity of product, service or business. https://wiki.openstreetmap.org/wiki/Key:brand'; -COMMENT ON COLUMN osm.vshop_all.phone IS 'Phone number associated with the feature. https://wiki.openstreetmap.org/wiki/Key:phone'; diff --git a/flex-config/sql/shop_combined_point.sql b/flex-config/sql/shop_combined_point.sql new file mode 100644 index 00000000..012eccf8 --- /dev/null +++ b/flex-config/sql/shop_combined_point.sql @@ -0,0 +1,21 @@ + +COMMENT ON TABLE osm.shop_combined_point IS 'Converts polygon shops to point with ST_Centroid(), combines with source points using UNION.'; + +COMMENT ON COLUMN osm.shop_combined_point.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; +COMMENT ON COLUMN osm.shop_combined_point.osm_type IS 'Stores the OpenStreetMap key that included this feature in the layer. Value from key stored in osm_subtype.'; +COMMENT ON COLUMN osm.shop_combined_point.osm_subtype IS 'Value detail describing the key (osm_type).'; +COMMENT ON COLUMN osm.shop_combined_point.address IS 'Address combined from address parts in helpers.get_address().'; +COMMENT ON COLUMN osm.shop_combined_point.name IS 'Best name option determined by helpers.get_name(). Keys with priority are: name, short_name, alt_name and loc_name. See pgosm-flex/flex-config/helpers.lua for full logic of selection.'; +COMMENT ON COLUMN osm.shop_combined_point.geom IS 'Geometry, mix of points loaded by osm2pgsql and points calculated from the ST_Centroid() of the polygons loaded by osm2pgsql.'; + +COMMENT ON COLUMN osm.shop_combined_point.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.shop_combined_point.geom_type IS 'Type of geometry. N(ode), W(ay) or R(elation). Unique along with osm_id'; +COMMENT ON COLUMN osm.shop_combined_point.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; +COMMENT ON COLUMN osm.shop_combined_point.website IS 'Official website for the feature. https://wiki.openstreetmap.org/wiki/Key:website'; +COMMENT ON COLUMN osm.shop_combined_point.brand IS 'Identity of product, service or business. https://wiki.openstreetmap.org/wiki/Key:brand'; +COMMENT ON COLUMN osm.shop_combined_point.phone IS 'Phone number associated with the feature. https://wiki.openstreetmap.org/wiki/Key:phone'; + +ALTER TABLE osm.shop_combined_point + ADD CONSTRAINT pk_osm_shop_point_osm_id_geom_type + PRIMARY KEY (osm_id, geom_type) +; diff --git a/flex-config/style/building.lua b/flex-config/style/building.lua index 02a51389..b52e9f26 100644 --- a/flex-config/style/building.lua +++ b/flex-config/style/building.lua @@ -1,4 +1,5 @@ require "helpers" +require "style.building_helpers" local tables = {} @@ -61,78 +62,6 @@ tables.building_polygon = osm2pgsql.define_table({ }) -function address_only_building(tags) - -- Cannot have any of these tags - if tags.shop - or tags.amenity - or tags.building - or tags['building:part'] - or tags.landuse - or tags.leisure - or tags.office - or tags.tourism - or tags.boundary -- included in place layer - or tags.natural - or tags.aeroway - or tags.demolished - then - return false - end - - -- Opting to include any addr: tag that was not excluded explicitly above - -- This might be too wide of a net, but trying to be too picky risks - -- excluding potentially important data - for k, v in pairs(tags) do - if k ~= nil then - if starts_with(k, "addr:") then - return true - end - end - end - return false -end - - -local function get_osm_type_subtype(object) - local osm_type_table = {} - local address_only = address_only_building(object.tags) - - if object.tags.building then - osm_type_table['osm_type'] = 'building' - osm_type_table['osm_subtype'] = object.tags.building - elseif object.tags['building:part'] then - osm_type_table['osm_type'] = 'building_part' - osm_type_table['osm_subtype'] = object.tags['building:part'] - elseif object.tags.office then - osm_type_table['osm_type'] = 'office' - osm_type_table['osm_subtype'] = object.tags.office - elseif address_only then - osm_type_table['osm_type'] = 'address' - osm_type_table['osm_subtype'] = nil - elseif object.tags.entrance then - osm_type_table['osm_type'] = 'entrance' - osm_type_table['osm_subtype'] = object.tags.entrance - elseif object.tags.door then - osm_type_table['osm_type'] = 'door' - osm_type_table['osm_subtype'] = object.tags.door - else - osm_type_table['osm_type'] = 'unknown' - osm_type_table['osm_subtype'] = nil - end - - return osm_type_table -end - - -local building_first_level_keys = { - 'building', - 'building:part', - 'office', - 'door', - 'entrance' -} - -local is_first_level_building = make_check_in_list_func(building_first_level_keys) function building_process_node(object) local address_only = address_only_building(object.tags) @@ -143,7 +72,7 @@ function building_process_node(object) return end - local osm_types = get_osm_type_subtype(object) + local osm_types = get_osm_type_subtype_building(object) local name = get_name(object.tags) local housenumber = object.tags['addr:housenumber'] @@ -176,7 +105,6 @@ function building_process_node(object) geom = object:as_point() }) - end @@ -192,7 +120,7 @@ function building_process_way(object) if not object.is_closed then return end - local osm_types = get_osm_type_subtype(object) + local osm_types = get_osm_type_subtype_building(object) local name = get_name(object.tags) local housenumber = object.tags['addr:housenumber'] @@ -225,7 +153,6 @@ function building_process_way(object) geom = object:as_polygon() }) - end @@ -239,7 +166,7 @@ function building_process_relation(object) return end - local osm_types = get_osm_type_subtype(object) + local osm_types = get_osm_type_subtype_building(object) local name = get_name(object.tags) local housenumber = object.tags['addr:housenumber'] @@ -273,6 +200,7 @@ function building_process_relation(object) geom = object:as_multipolygon() }) end + end diff --git a/flex-config/style/building_combined_point.lua b/flex-config/style/building_combined_point.lua new file mode 100644 index 00000000..9614c15c --- /dev/null +++ b/flex-config/style/building_combined_point.lua @@ -0,0 +1,207 @@ +require "helpers" +require "style.building_helpers" + + +local tables = {} + + +tables.building_combined_point = osm2pgsql.define_table({ + name = 'building_combined_point', + schema = schema_name, + ids = { type = 'any', id_column = 'osm_id', type_column = 'geom_type' }, + columns = { + { column = 'osm_type', type = 'text' , not_null = true}, + { column = 'osm_subtype', type = 'text'}, + { column = 'name', type = 'text' }, + { column = 'levels', type = 'int'}, + { column = 'height', sql_type = 'numeric'}, + { column = 'housenumber', type = 'text'}, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, + { column = 'state', type = 'text'}, + { column = 'postcode', type = 'text'}, + { column = 'address', type = 'text', not_null = true}, + { column = 'wheelchair', type = 'text'}, + { column = 'wheelchair_desc', type = 'text'}, + { column = 'operator', type = 'text'}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, + }, + indexes = { + { column = 'geom', method = gist_type }, + { column = 'osm_type', method = 'btree' }, + { column = 'osm_subtype', method = 'btree', where = 'osm_subtype IS NOT NULL' }, + } +}) + +function building_combined_point_process_node(object) + local address_only = address_only_building(object.tags) + + if not is_first_level_building(object.tags) + and not address_only + then + return + end + + local osm_types = get_osm_type_subtype_building(object) + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local wheelchair = object.tags.wheelchair + local wheelchair_desc = get_wheelchair_desc(object.tags) + local levels = object.tags['building:levels'] + local height = parse_to_meters(object.tags['height']) + local operator = object.tags.operator + + tables.building_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + wheelchair_desc = wheelchair_desc, + levels = levels, + height = height, + operator = operator, + geom = object:as_point() + }) +end + + +function building_combined_point_process_way(object) + local address_only = address_only_building(object.tags) + + if not is_first_level_building(object.tags) + and not address_only + then + return + end + + if not object.is_closed then + return + end + local osm_types = get_osm_type_subtype_building(object) + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local wheelchair = object.tags.wheelchair + local wheelchair_desc = get_wheelchair_desc(object.tags) + local levels = object.tags['building:levels'] + local height = parse_to_meters(object.tags['height']) + local operator = object.tags.operator + + tables.building_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + wheelchair_desc = wheelchair_desc, + levels = levels, + height = height, + operator = operator, + geom = object:as_polygon():centroid() + }) + +end + + +function building_combined_point_process_relation(object) + local address_only = address_only_building(object.tags) + + if not is_first_level_building(object.tags) + and not address_only + then + return + end + + local osm_types = get_osm_type_subtype_building(object) + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local wheelchair = object.tags.wheelchair + local wheelchair_desc = get_wheelchair_desc(object.tags) + local levels = object.tags['building:levels'] + local height = parse_to_meters(object.tags['height']) + local operator = object.tags.operator + + if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then + tables.building_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + wheelchair_desc = wheelchair_desc, + levels = levels, + height = height, + operator = operator, + geom = object:as_multipolygon():centroid() + }) + end + +end + + +if osm2pgsql.process_way == nil then + osm2pgsql.process_way = building_combined_point_process_way +else + local nested = osm2pgsql.process_way + osm2pgsql.process_way = function(object) + local object_copy = deep_copy(object) + nested(object) + building_combined_point_process_way(object_copy) + end +end + + +if osm2pgsql.process_node == nil then + osm2pgsql.process_node = building_combined_point_process_node +else + local nested = osm2pgsql.process_node + osm2pgsql.process_node = function(object) + local object_copy = deep_copy(object) + nested(object) + building_combined_point_process_node(object_copy) + end +end + +if osm2pgsql.process_relation == nil then + osm2pgsql.process_relation = building_combined_point_process_relation +else + local nested = osm2pgsql.process_relation + osm2pgsql.process_relation = function(object) + local object_copy = deep_copy(object) + nested(object) + building_combined_point_process_relation(object_copy) + end +end diff --git a/flex-config/style/building_helpers.lua b/flex-config/style/building_helpers.lua new file mode 100644 index 00000000..d5326bbd --- /dev/null +++ b/flex-config/style/building_helpers.lua @@ -0,0 +1,77 @@ +-- building_helpers.lua provides commonly used functions +-- for the building layers + + +function address_only_building(tags) + -- Cannot have any of these tags + if tags.shop + or tags.amenity + or tags.building + or tags['building:part'] + or tags.landuse + or tags.leisure + or tags.office + or tags.tourism + or tags.boundary -- included in place layer + or tags.natural + or tags.aeroway + or tags.demolished + then + return false + end + + -- Opting to include any addr: tag that was not excluded explicitly above + -- This might be too wide of a net, but trying to be too picky risks + -- excluding potentially important data + for k, v in pairs(tags) do + if k ~= nil then + if starts_with(k, "addr:") then + return true + end + end + end + return false +end + + + +function get_osm_type_subtype_building(object) + local osm_type_table = {} + local address_only = address_only_building(object.tags) + + if object.tags.building then + osm_type_table['osm_type'] = 'building' + osm_type_table['osm_subtype'] = object.tags.building + elseif object.tags['building:part'] then + osm_type_table['osm_type'] = 'building_part' + osm_type_table['osm_subtype'] = object.tags['building:part'] + elseif object.tags.office then + osm_type_table['osm_type'] = 'office' + osm_type_table['osm_subtype'] = object.tags.office + elseif address_only then + osm_type_table['osm_type'] = 'address' + osm_type_table['osm_subtype'] = nil + elseif object.tags.entrance then + osm_type_table['osm_type'] = 'entrance' + osm_type_table['osm_subtype'] = object.tags.entrance + elseif object.tags.door then + osm_type_table['osm_type'] = 'door' + osm_type_table['osm_subtype'] = object.tags.door + else + osm_type_table['osm_type'] = 'unknown' + osm_type_table['osm_subtype'] = nil + end + + return osm_type_table +end + + +local building_first_level_keys = { + 'building', + 'building:part', + 'office', + 'door', + 'entrance' +} + +is_first_level_building = make_check_in_list_func(building_first_level_keys) diff --git a/flex-config/style/poi.lua b/flex-config/style/poi.lua index 5038c98f..3599d2c7 100644 --- a/flex-config/style/poi.lua +++ b/flex-config/style/poi.lua @@ -1,127 +1,8 @@ require "helpers" +require "style.poi_helpers" local tables = {} --- Keys to include for further checking. Not all values from each key will be preserved -local poi_first_level_keys = { - 'building', - 'shop', - 'amenity', - 'leisure', - 'man_made', - 'tourism', - 'landuse', - 'natural', - 'historic' -} - -local is_first_level_poi = make_check_in_list_func(poi_first_level_keys) - - -function building_poi(object) - local bldg_name = get_name(object.tags) - if (bldg_name ~= '' or object.tags.operator) then - return true - end - - return false -end - - -function landuse_poi(object) - if (object.tags.landuse == 'cemetery' - or object.tags.landuse == 'orchard' - or object.tags.landuse == 'railway' - or object.tags.landuse == 'village_green' - or object.tags.landuse == 'vineyard') then - return true - end - - return false - -end - - -function man_made_poi(object) - if (object.tags.man_made == 'beacon' - or object.tags.man_made == 'chimney' - or object.tags.man_made == 'communications_tower' - or object.tags.man_made == 'crane' - or object.tags.man_made == 'flagpole' - or object.tags.man_made == 'lighthouse' - or object.tags.man_made == 'mast' - or object.tags.man_made == 'obelisk' - or object.tags.man_made == 'observatory' - or object.tags.man_made == 'offshore_platform' - or object.tags.man_made == 'pier' - or object.tags.man_made == 'silo' - or object.tags.man_made == 'survey_point' - or object.tags.man_made == 'telescope' - or object.tags.man_made == 'tower' - or object.tags.man_made == 'water_tap' - or object.tags.man_made == 'water_tower' - or object.tags.man_made == 'water_well' - or object.tags.man_made == 'windmill' - or object.tags.man_made == 'works' - ) then - return true - end - - return false -end - -function natural_poi(object) - if (object.tags.natural == 'peak' - or object.tags.natural == 'glacier' - or object.tags.natural == 'reef' - or object.tags.natural == 'hot_spring' - or object.tags.natural == 'bay') then - return true - end - - return false -end - - -local function get_osm_type_subtype(object) - local osm_type_table = {} - - if object.tags.shop then - osm_type_table['osm_type'] = 'shop' - osm_type_table['osm_subtype'] = object:grab_tag('shop') - elseif object.tags.amenity then - osm_type_table['osm_type'] = 'amenity' - osm_type_table['osm_subtype'] = object:grab_tag('amenity') - elseif object.tags.building then - osm_type_table['osm_type'] = 'building' - osm_type_table['osm_subtype'] = object:grab_tag('building') - elseif object.tags.leisure then - osm_type_table['osm_type'] = 'leisure' - osm_type_table['osm_subtype'] = object:grab_tag('leisure') - elseif object.tags.landuse then - osm_type_table['osm_type'] = 'landuse' - osm_type_table['osm_subtype'] = object:grab_tag('landuse') - elseif object.tags.natural then - osm_type_table['osm_type'] = 'natural' - osm_type_table['osm_subtype'] = object:grab_tag('natural') - elseif object.tags.man_made then - osm_type_table['osm_type'] = 'man_made' - osm_type_table['osm_subtype'] = object:grab_tag('man_made') - elseif object.tags.tourism then - osm_type_table['osm_type'] = 'tourism' - osm_type_table['osm_subtype'] = object:grab_tag('tourism') - elseif object.tags.historic then - osm_type_table['osm_type'] = 'historic' - osm_type_table['osm_subtype'] = object.tags['historic'] - else - -- Cannot be NULL - osm_type_table['osm_type'] = 'Unknown' - osm_type_table['osm_subtype'] = 'Unknown' - end - - return osm_type_table -end - tables.poi_point = osm2pgsql.define_table({ name = 'poi_point', @@ -205,25 +86,11 @@ function poi_process_node(object) return end - if (object.tags.natural and not natural_poi(object)) then + if not second_level_tag_check_poi(object) then return end - if (object.tags.landuse and not landuse_poi(object)) then - return - end - - if (object.tags.building and not building_poi(object)) then - return - end - - - if (object.tags.man_made and not man_made_poi(object)) then - return - end - - - local osm_types = get_osm_type_subtype(object) + local osm_types = get_osm_type_subtype_poi(object) local name = get_name(object.tags) local housenumber = object.tags['addr:housenumber'] @@ -258,24 +125,11 @@ function poi_process_way(object) return end - -- Deeper checks for specific osm_type details - if (object.tags.natural and not natural_poi(object)) then - return - end - - if (object.tags.landuse and not landuse_poi(object)) then - return - end - - if (object.tags.building and not building_poi(object)) then + if not second_level_tag_check_poi(object) then return end - if (object.tags.man_made and not man_made_poi(object)) then - return - end - - local osm_types = get_osm_type_subtype(object) + local osm_types = get_osm_type_subtype_poi(object) local name = get_name(object.tags) local housenumber = object.tags['addr:housenumber'] @@ -327,25 +181,13 @@ function poi_process_relation(object) return end - -- Deeper checks for specific osm_type details - if (object.tags.natural and not natural_poi(object)) then + if not second_level_tag_check_poi(object) then return end - if (object.tags.landuse and not landuse_poi(object)) then - return - end - - if (object.tags.building and not building_poi(object)) then - return - end - - if (object.tags.man_made and not man_made_poi(object)) then - return - end -- Gets osm_type and osm_subtype - local osm_types = get_osm_type_subtype(object) + local osm_types = get_osm_type_subtype_poi(object) local name = get_name(object.tags) local housenumber = object.tags['addr:housenumber'] diff --git a/flex-config/style/poi_combined_point.lua b/flex-config/style/poi_combined_point.lua new file mode 100644 index 00000000..79ae2bbb --- /dev/null +++ b/flex-config/style/poi_combined_point.lua @@ -0,0 +1,207 @@ +require "helpers" +require "style.poi_helpers" + +local tables = {} + + +tables.poi_combined_point = osm2pgsql.define_table({ + name = 'poi_combined_point', + schema = schema_name, + ids = { type = 'any', id_column = 'osm_id', type_column = 'geom_type' }, + columns = { + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'housenumber', type = 'text'}, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, + { column = 'state', type = 'text'}, + { column = 'postcode', type = 'text'}, + { column = 'address', type = 'text', not_null = true}, + { column = 'operator', type = 'text'}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, + }, + indexes = { + { column = 'geom', method = gist_type }, + { column = 'osm_type', method = 'btree' }, + { column = 'osm_subtype', method = 'btree', where = 'osm_subtype IS NOT NULL ' }, + } +}) + + + + +function poi_process_node_combined(object) + -- Quickly remove any that don't match the 1st level of checks + if not is_first_level_poi(object.tags) then + return + end + + if not second_level_tag_check_poi(object) then + return + end + + local osm_types = get_osm_type_subtype_poi(object) + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + + local operator = object:grab_tag('operator') + + tables.poi_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + operator = operator, + geom = object:as_point() + }) + +end + + +function poi_process_way_combined(object) + -- Quickly remove any that don't match the 1st level of checks + if not is_first_level_poi(object.tags) then + return + end + + if not second_level_tag_check_poi(object) then + return + end + + local osm_types = get_osm_type_subtype_poi(object) + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local operator = object:grab_tag('operator') + + if object.is_closed then + tables.poi_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + operator = operator, + geom = object:as_polygon():centroid() + }) + else + tables.poi_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + operator = operator, + geom = object:as_linestring():centroid() + }) + end + +end + + + +function poi_process_relation_combined(object) + -- Quickly remove any that don't match the 1st level of checks + if not is_first_level_poi(object.tags) then + return + end + + if not second_level_tag_check_poi(object) then + return + end + + + -- Gets osm_type and osm_subtype + local osm_types = get_osm_type_subtype_poi(object) + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local operator = object:grab_tag('operator') + + local member_ids = osm2pgsql.way_member_ids(object) + + if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then + tables.poi_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + operator = operator, + member_ids = member_ids, + geom = object:as_multipolygon():centroid() + }) + end + +end + + +if osm2pgsql.process_node == nil then + osm2pgsql.process_node = poi_process_node_combined +else + local nested = osm2pgsql.process_node + osm2pgsql.process_node = function(object) + local object_copy = deep_copy(object) + nested(object) + poi_process_node_combined(object_copy) + end +end + + +if osm2pgsql.process_way == nil then + osm2pgsql.process_way = poi_process_way_combined +else + local nested = osm2pgsql.process_way + osm2pgsql.process_way = function(object) + local object_copy = deep_copy(object) + nested(object) + poi_process_way_combined(object_copy) + end +end + + +if osm2pgsql.process_relation == nil then + osm2pgsql.process_relation = poi_process_relation_combined +else + local nested = osm2pgsql.process_relation + osm2pgsql.process_relation = function(object) + local object_copy = deep_copy(object) + nested(object) + poi_process_relation_combined(object_copy) + end +end + diff --git a/flex-config/style/poi_helpers.lua b/flex-config/style/poi_helpers.lua new file mode 100644 index 00000000..c61a77e3 --- /dev/null +++ b/flex-config/style/poi_helpers.lua @@ -0,0 +1,141 @@ + +-- Keys to include for further checking. Not all values from each key will be preserved +local poi_first_level_keys = { + 'building', + 'shop', + 'amenity', + 'leisure', + 'man_made', + 'tourism', + 'landuse', + 'natural', + 'historic' +} + +is_first_level_poi = make_check_in_list_func(poi_first_level_keys) + + +local function building_poi(object) + local bldg_name = get_name(object.tags) + if (bldg_name ~= '' or object.tags.operator) then + return true + end + + return false +end + + +local function landuse_poi(object) + if (object.tags.landuse == 'cemetery' + or object.tags.landuse == 'orchard' + or object.tags.landuse == 'railway' + or object.tags.landuse == 'village_green' + or object.tags.landuse == 'vineyard') then + return true + end + + return false + +end + + +local function man_made_poi(object) + if (object.tags.man_made == 'beacon' + or object.tags.man_made == 'chimney' + or object.tags.man_made == 'communications_tower' + or object.tags.man_made == 'crane' + or object.tags.man_made == 'flagpole' + or object.tags.man_made == 'lighthouse' + or object.tags.man_made == 'mast' + or object.tags.man_made == 'obelisk' + or object.tags.man_made == 'observatory' + or object.tags.man_made == 'offshore_platform' + or object.tags.man_made == 'pier' + or object.tags.man_made == 'silo' + or object.tags.man_made == 'survey_point' + or object.tags.man_made == 'telescope' + or object.tags.man_made == 'tower' + or object.tags.man_made == 'water_tap' + or object.tags.man_made == 'water_tower' + or object.tags.man_made == 'water_well' + or object.tags.man_made == 'windmill' + or object.tags.man_made == 'works' + ) then + return true + end + + return false +end + +local function natural_poi(object) + if (object.tags.natural == 'peak' + or object.tags.natural == 'glacier' + or object.tags.natural == 'reef' + or object.tags.natural == 'hot_spring' + or object.tags.natural == 'bay') then + return true + end + + return false +end + + +function second_level_tag_check_poi(object) + if (object.tags.natural and not natural_poi(object)) then + return false + end + + if (object.tags.landuse and not landuse_poi(object)) then + return false + end + + if (object.tags.building and not building_poi(object)) then + return false + end + + if (object.tags.man_made and not man_made_poi(object)) then + return false + end + + return true +end + + +function get_osm_type_subtype_poi(object) + local osm_type_table = {} + + if object.tags.shop then + osm_type_table['osm_type'] = 'shop' + osm_type_table['osm_subtype'] = object:grab_tag('shop') + elseif object.tags.amenity then + osm_type_table['osm_type'] = 'amenity' + osm_type_table['osm_subtype'] = object:grab_tag('amenity') + elseif object.tags.building then + osm_type_table['osm_type'] = 'building' + osm_type_table['osm_subtype'] = object:grab_tag('building') + elseif object.tags.leisure then + osm_type_table['osm_type'] = 'leisure' + osm_type_table['osm_subtype'] = object:grab_tag('leisure') + elseif object.tags.landuse then + osm_type_table['osm_type'] = 'landuse' + osm_type_table['osm_subtype'] = object:grab_tag('landuse') + elseif object.tags.natural then + osm_type_table['osm_type'] = 'natural' + osm_type_table['osm_subtype'] = object:grab_tag('natural') + elseif object.tags.man_made then + osm_type_table['osm_type'] = 'man_made' + osm_type_table['osm_subtype'] = object:grab_tag('man_made') + elseif object.tags.tourism then + osm_type_table['osm_type'] = 'tourism' + osm_type_table['osm_subtype'] = object:grab_tag('tourism') + elseif object.tags.historic then + osm_type_table['osm_type'] = 'historic' + osm_type_table['osm_subtype'] = object.tags['historic'] + else + -- Cannot be NULL + osm_type_table['osm_type'] = 'Unknown' + osm_type_table['osm_subtype'] = 'Unknown' + end + + return osm_type_table +end diff --git a/flex-config/style/shop.lua b/flex-config/style/shop.lua index 2907be7a..f1d8d8e8 100644 --- a/flex-config/style/shop.lua +++ b/flex-config/style/shop.lua @@ -1,4 +1,5 @@ require "helpers" +require "style.shop_helpers" local tables = {} @@ -63,8 +64,7 @@ tables.shop_polygon = osm2pgsql.define_table({ function shop_process_node(object) - if not object.tags.shop - and not object.tags.amenity then + if not is_first_level_shop(object.tags) then return end @@ -82,71 +82,31 @@ function shop_process_node(object) local brand = object:grab_tag('brand') local website = object:grab_tag('website') - if object.tags.shop then - local osm_type = 'shop' - local osm_subtype = object:grab_tag('shop') - - tables.shop_point:insert({ - osm_type = osm_type, - osm_subtype = osm_subtype, - name = name, - housenumber = housenumber, - street = street, - city = city, - state = state, - postcode = postcode, - address = address, - wheelchair = wheelchair, - phone = phone, - operator = operator, - brand = brand, - website = website, - geom = object:as_point() - }) - - -- This creates overlap between this layer and amenity layer - elseif object.tags.amenity == 'vending_machine' - or object.tags.amenity == 'car_rental' - or object.tags.amenity == 'motorcycle_rental' - or object.tags.amenity == 'cafe' - or object.tags.amenity == 'phone_repair' - or object.tags.amenity == 'music_school' - or object.tags.amenity == 'pub' - or object.tags.amenity == 'pharmacy' - or object.tags.amenity == 'ticket_booth' - or object.tags.amenity == 'shop' - then - local osm_type = 'amenity' - local osm_subtype = object:grab_tag('amenity') - - tables.shop_point:insert({ - osm_type = osm_type, - osm_subtype = osm_subtype, - name = name, - housenumber = housenumber, - street = street, - city = city, - state = state, - postcode = postcode, - address = address, - wheelchair = wheelchair, - wheelchair_desc = wheelchair_desc, - phone = phone, - operator = operator, - brand = brand, - website = website, - geom = object:as_point() - }) - - end - + local osm_types = get_osm_type_subtype_shop(object) + + tables.shop_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + phone = phone, + operator = operator, + brand = brand, + website = website, + geom = object:as_point() + }) end function shop_process_way(object) - if not object.tags.shop - and not object.tags.amenity then + if not is_first_level_shop(object.tags) then return end @@ -164,66 +124,27 @@ function shop_process_way(object) local brand = object:grab_tag('brand') local website = object:grab_tag('website') - if object.tags.shop then - local osm_type = 'shop' - local osm_subtype = object:grab_tag('shop') - - if object.is_closed then - tables.shop_polygon:insert({ - osm_type = osm_type, - osm_subtype = osm_subtype, - name = name, - housenumber = housenumber, - street = street, - city = city, - state = state, - postcode = postcode, - address = address, - wheelchair = wheelchair, - wheelchair_desc = wheelchair_desc, - phone = phone, - operator = operator, - brand = brand, - website = website, - geom = object:as_polygon() - }) - end - - - elseif object.tags.amenity == 'vending_machine' - or object.tags.amenity == 'car_rental' - or object.tags.amenity == 'motorcycle_rental' - or object.tags.amenity == 'cafe' - or object.tags.amenity == 'phone_repair' - or object.tags.amenity == 'music_school' - or object.tags.amenity == 'pub' - or object.tags.amenity == 'pharmacy' - or object.tags.amenity == 'ticket_booth' - or object.tags.amenity == 'shop' - then - local osm_type = 'amenity' - local osm_subtype = object:grab_tag('amenity') - - if object.is_closed then - tables.shop_polygon:insert({ - osm_type = osm_type, - osm_subtype = osm_subtype, - name = name, - housenumber = housenumber, - street = street, - city = city, - state = state, - postcode = postcode, - address = address, - wheelchair = wheelchair, - wheelchair_desc = wheelchair_desc, - phone = phone, - operator = operator, - brand = brand, - website = website, - geom = object:as_polygon() - }) - end + local osm_types = get_osm_type_subtype_shop(object) + + if object.is_closed then + tables.shop_polygon:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + wheelchair_desc = wheelchair_desc, + phone = phone, + operator = operator, + brand = brand, + website = website, + geom = object:as_polygon() + }) end end diff --git a/flex-config/style/shop_combined_point.lua b/flex-config/style/shop_combined_point.lua new file mode 100644 index 00000000..9c3fdafd --- /dev/null +++ b/flex-config/style/shop_combined_point.lua @@ -0,0 +1,143 @@ +require "helpers" +require "style.shop_helpers" + +local tables = {} + +tables.shop_combined_point = osm2pgsql.define_table({ + name = 'shop_combined_point', + schema = schema_name, + ids = { type = 'any', id_column = 'osm_id', type_column = 'geom_type' }, + columns = { + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'housenumber', type = 'text'}, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, + { column = 'state', type = 'text'}, + { column = 'postcode', type = 'text'}, + { column = 'address', type = 'text', not_null = true}, + { column = 'phone', type = 'text'}, + { column = 'wheelchair', type = 'text'}, + { column = 'wheelchair_desc', type = 'text'}, + { column = 'operator', type = 'text'}, + { column = 'brand', type = 'text'}, + { column = 'website', type = 'text'}, + { column = 'geom', type = 'point' , projection = srid, not_null = true }, + }, + indexes = { + { column = 'geom', method = gist_type }, + { column = 'osm_type', method = 'btree' }, + { column = 'osm_subtype', method = 'btree', where = 'osm_subtype IS NOT NULL' }, + } +}) + + + +function shop_process_node_combined_point(object) + if not is_first_level_shop(object.tags) then + return + end + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local wheelchair = object.tags.wheelchair + local wheelchair_desc = get_wheelchair_desc(object.tags) + local phone = object:grab_tag('phone') + local operator = object:grab_tag('operator') + local brand = object:grab_tag('brand') + local website = object:grab_tag('website') + + local osm_types = get_osm_type_subtype_shop(object) + + tables.shop_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + phone = phone, + operator = operator, + brand = brand, + website = website, + geom = object:as_point() + }) + +end + + +function shop_process_way_combined_point(object) + if not is_first_level_shop(object.tags) then + return + end + + local name = get_name(object.tags) + local housenumber = object.tags['addr:housenumber'] + local street = object.tags['addr:street'] + local city = object.tags['addr:city'] + local state = object.tags['addr:state'] + local postcode = object.tags['addr:postcode'] + local address = get_address(object.tags) + local wheelchair = object.tags.wheelchair + local wheelchair_desc = get_wheelchair_desc(object.tags) + local phone = object:grab_tag('phone') + local operator = object:grab_tag('operator') + local brand = object:grab_tag('brand') + local website = object:grab_tag('website') + + local osm_types = get_osm_type_subtype_shop(object) + + tables.shop_combined_point:insert({ + osm_type = osm_types.osm_type, + osm_subtype = osm_types.osm_subtype, + name = name, + housenumber = housenumber, + street = street, + city = city, + state = state, + postcode = postcode, + address = address, + wheelchair = wheelchair, + wheelchair_desc = wheelchair_desc, + phone = phone, + operator = operator, + brand = brand, + website = website, + geom = object:as_polygon():centroid() + }) + +end + + +if osm2pgsql.process_node == nil then + osm2pgsql.process_node = shop_process_node_combined_point +else + local nested = osm2pgsql.process_node + osm2pgsql.process_node = function(object) + local object_copy = deep_copy(object) + nested(object) + shop_process_node_combined_point(object_copy) + end +end + + +if osm2pgsql.process_way == nil then + osm2pgsql.process_way = shop_process_way_combined_point +else + local nested = osm2pgsql.process_way + osm2pgsql.process_way = function(object) + local object_copy = deep_copy(object) + nested(object) + shop_process_way_combined_point(object_copy) + end +end diff --git a/flex-config/style/shop_helpers.lua b/flex-config/style/shop_helpers.lua new file mode 100644 index 00000000..ff128570 --- /dev/null +++ b/flex-config/style/shop_helpers.lua @@ -0,0 +1,33 @@ + +function get_osm_type_subtype_shop(object) + local osm_type_table = {} + + if object.tags.shop then + osm_type_table['osm_type'] = 'shop' + osm_type_table['osm_subtype'] = object:grab_tag('shop') + -- This creates overlap between this layer and amenity layer + elseif object.tags.amenity == 'vending_machine' + or object.tags.amenity == 'car_rental' + or object.tags.amenity == 'motorcycle_rental' + or object.tags.amenity == 'cafe' + or object.tags.amenity == 'phone_repair' + or object.tags.amenity == 'music_school' + or object.tags.amenity == 'pub' + or object.tags.amenity == 'pharmacy' + or object.tags.amenity == 'ticket_booth' + or object.tags.amenity == 'shop' + then + osm_type_table['osm_type'] = 'amenity' + osm_type_table['osm_subtype'] = object:grab_tag('amenity') + end + + return osm_type_table +end + +local shop_first_level_keys = { + 'shop', + 'amenity' +} + +is_first_level_shop = make_check_in_list_func(shop_first_level_keys) + diff --git a/tests/expected/vbuilding_all_osm_type_subtype_count.out b/tests/expected/building_combined_point_osm_type_subtype_count.out similarity index 100% rename from tests/expected/vbuilding_all_osm_type_subtype_count.out rename to tests/expected/building_combined_point_osm_type_subtype_count.out diff --git a/tests/expected/vpoi_all_osm_type_subtype_count.out b/tests/expected/poi_combined_point_osm_type_subtype_count.out similarity index 100% rename from tests/expected/vpoi_all_osm_type_subtype_count.out rename to tests/expected/poi_combined_point_osm_type_subtype_count.out diff --git a/tests/expected/poi_line_osm_type_subtype_count.out b/tests/expected/poi_line_osm_type_subtype_count.out new file mode 100644 index 00000000..719a29f4 --- /dev/null +++ b/tests/expected/poi_line_osm_type_subtype_count.out @@ -0,0 +1,6 @@ +amenity|bench|5 +amenity|parking|2 +building|yes|1 +historic|yes|5 +leisure|slipway|2 +man_made|pier|185 diff --git a/tests/expected/poi_point_osm_type_subtype_count.out b/tests/expected/poi_point_osm_type_subtype_count.out new file mode 100644 index 00000000..240e47d2 --- /dev/null +++ b/tests/expected/poi_point_osm_type_subtype_count.out @@ -0,0 +1,295 @@ +amenity|animal_boarding|2 +amenity|arts_centre|21 +amenity|atm|41 +amenity|bank|246 +amenity|bar|194 +amenity|bbq|2 +amenity|bench|523 +amenity|bicycle_parking|215 +amenity|bicycle_rental|315 +amenity|bicycle_repair_station|20 +amenity|biergarten|3 +amenity|border_control|1 +amenity|building|1 +amenity|bureau_de_change|1 +amenity|bus_station|9 +amenity|cafe|332 +amenity|car_rental|8 +amenity|car_sharing|43 +amenity|car_wash|4 +amenity|catering|8 +amenity|charging_station|9 +amenity|check_cashing|5 +amenity|childcare|3 +amenity|cinema|8 +amenity|clinic|29 +amenity|clock|3 +amenity|club|2 +amenity|college|2 +amenity|community_centre|11 +amenity|compressed_air|7 +amenity|convenience|6 +amenity|courthouse|4 +amenity|coworking|1 +amenity|coworking_space|2 +amenity|crypt|1 +amenity|dentist|20 +amenity|doctors|37 +amenity|dojo|1 +amenity|drinking_water|173 +amenity|dry_cleaner|5 +amenity|embassy|21 +amenity|events_venue|1 +amenity|fast_food|439 +amenity|ferry_terminal|6 +amenity|fire_station|19 +amenity|first_aid|1 +amenity|flower_planter|3 +amenity|food_court|7 +amenity|fountain|28 +amenity|fuel|53 +amenity|gallery|2 +amenity|government|1 +amenity|grave_yard|6 +amenity|historic:theatre|1 +amenity|hospital|1 +amenity|hospital (historic)|5 +amenity|ice_cream|19 +amenity|ice_cream;cafe|1 +amenity|internal_kindergarten|1 +amenity|internet_cafe|1 +amenity|kindergarten|161 +amenity|library|23 +amenity|marketplace|6 +amenity|money_transfer|7 +amenity|motorcycle_parking|3 +amenity|nail_salon|4 +amenity|nightclub|16 +amenity|nursing_home|7 +amenity|office|1 +amenity|other|2 +amenity|parking|122 +amenity|parking_entrance|40 +amenity|pharmacy|68 +amenity|place_of_worship|376 +amenity|police|25 +amenity|post_box|177 +amenity|post_office|55 +amenity|prep_school|2 +amenity|pub|97 +amenity|public_bookcase|14 +amenity|public_building|11 +amenity|recycling|33 +amenity|refuge|1 +amenity|restaurant|962 +amenity|school|358 +amenity|school (historic)|1 +amenity|shelter|3 +amenity|social_club|1 +amenity|social_facility|22 +amenity|spa|1 +amenity|stripclub|6 +amenity|studio|7 +amenity|tax_service|1 +amenity|taxi|2 +amenity|theatre|33 +amenity|theatre (historic)|1 +amenity|toilets|29 +amenity|tourist|22 +amenity|tutor|1 +amenity|university|9 +amenity|vending_machine|18 +amenity|veterinary|7 +amenity|waste_basket|180 +amenity|waste_disposal|1 +building|apartments|20 +building|church|1 +building|commercial|1 +building|office|3 +building|public|11 +building|residential|2 +building|retail|1 +building|university|1 +building|yes|469 +historic|Compass|1 +historic|boundary_stone|25 +historic|building|3 +historic|call_box|1 +historic|heritage|1 +historic|manor|1 +historic|memorial|51 +historic|monument|19 +historic|plaque|1 +historic|statue|1 +historic|tomb|4 +historic|yes|5 +landuse|cemetery|2 +leisure|bowling_alley|1 +leisure|carousel|1 +leisure|dance|1 +leisure|dog_park|2 +leisure|fitness_centre|41 +leisure|garden|15 +leisure|golf_course|1 +leisure|hackerspace|1 +leisure|ice_rink|1 +leisure|marina|1 +leisure|park|126 +leisure|picnic_table|41 +leisure|playground|35 +leisure|sauna|1 +leisure|slipway|14 +leisure|sports_centre|45 +leisure|swimming_pool|6 +leisure|tanning_salon|1 +man_made|chimney|2 +man_made|communications_tower|1 +man_made|flagpole|248 +man_made|mast|2 +man_made|pier|1 +man_made|silo|10 +man_made|survey_point|1 +man_made|tower|42 +man_made|works|1 +natural|bay|3 +natural|peak|16 +shop|adult|1 +shop|alcohol|189 +shop|antiques|10 +shop|appliance|1 +shop|art|17 +shop|auction|1 +shop|auto|1 +shop|baby_goods|1 +shop|bag|4 +shop|bakery|31 +shop|beads|1 +shop|beauty|57 +shop|beauty_supply|1 +shop|bed|4 +shop|beverages|3 +shop|bicycle|18 +shop|bookmaker|8 +shop|books|27 +shop|boutique|2 +shop|butcher|3 +shop|camera|1 +shop|car|2 +shop|car_repair|20 +shop|charity|1 +shop|chemist|2 +shop|chocolate|1 +shop|clothes|162 +shop|coffee|2 +shop|computer|1 +shop|confectionery|6 +shop|convenience|212 +shop|copyshop|24 +shop|cosmetics|14 +shop|courier|1 +shop|craft|2 +shop|deli|16 +shop|department_store|16 +shop|doityourself|13 +shop|dollar_store|1 +shop|dry_cleaner|2 +shop|dry_cleaning|52 +shop|electronics|7 +shop|erotic|2 +shop|estate_agent|1 +shop|fashion_accessories|1 +shop|floor|1 +shop|florist|14 +shop|food|1 +shop|frame|3 +shop|funeral_directors|3 +shop|furniture|27 +shop|garden_centre|1 +shop|gift|34 +shop|greengrocer|6 +shop|grocery|1 +shop|hairdresser|139 +shop|handbag|1 +shop|handbags|1 +shop|hardware|6 +shop|hat|1 +shop|herbalist|1 +shop|hippie|1 +shop|hobby|1 +shop|home|2 +shop|houseware|4 +shop|interior_decoration|3 +shop|jewelry|17 +shop|kiosk|1 +shop|kitchen|2 +shop|lamp|1 +shop|laundry|12 +shop|locksmith|1 +shop|mall|2 +shop|massage|2 +shop|medical_supply|4 +shop|mobile_phone|49 +shop|money_lender|3 +shop|money_transfer;clothes|1 +shop|music|4 +shop|nail|1 +shop|nail_salon|2 +shop|newsagent|2 +shop|nutrition_supplements|5 +shop|optician|24 +shop|outdoor|2 +shop|paint|3 +shop|pawn|2 +shop|perfumery|1 +shop|pet|19 +shop|pet_grooming|1 +shop|photo|4 +shop|printing|1 +shop|publisher of Science, the scientific journal|1 +shop|religion|1 +shop|running|1 +shop|seafood|1 +shop|second_hand|9 +shop|shoe_repair|2 +shop|shoes|29 +shop|specialty|1 +shop|spices|1 +shop|sports|4 +shop|stationery|5 +shop|storage_rental|2 +shop|supermarket|73 +shop|tailor|7 +shop|tanning_salon|1 +shop|tarot|1 +shop|tattoo|9 +shop|tea|1 +shop|telecommunication|1 +shop|ticket|2 +shop|tobacco|6 +shop|toys|3 +shop|travel_agency|3 +shop|tyres|2 +shop|vacant|31 +shop|vacuum_cleaner|1 +shop|variety_store|3 +shop|video|3 +shop|video_games|1 +shop|watches|1 +shop|wig|1 +shop|wine|2 +shop|yes|10 +tourism|apartment|3 +tourism|artwork|266 +tourism|attraction|91 +tourism|gallery|7 +tourism|guest_house|1 +tourism|hostel|4 +tourism|hotel|136 +tourism|information|53 +tourism|information;map|1 +tourism|museum|27 +tourism|picnic_site|33 +tourism|sightseeing|1 +tourism|tour_guide|1 +tourism|viewpoint|15 +tourism|zoo|1 diff --git a/tests/expected/poi_polygon_osm_type_subtype_count.out b/tests/expected/poi_polygon_osm_type_subtype_count.out new file mode 100644 index 00000000..886389d5 --- /dev/null +++ b/tests/expected/poi_polygon_osm_type_subtype_count.out @@ -0,0 +1,176 @@ +amenity|Gym|1 +amenity|Personal Training|1 +amenity|alcohol|1 +amenity|arts_centre|4 +amenity|bank|19 +amenity|bar|7 +amenity|bench|9 +amenity|bicycle_parking|2 +amenity|bicycle_rental|1 +amenity|bicycle_repair_station|1 +amenity|biergarten|1 +amenity|boat_rental|1 +amenity|cafe|10 +amenity|car_rental|1 +amenity|car_wash|1 +amenity|cinema|6 +amenity|clinic|2 +amenity|college|6 +amenity|community_centre|10 +amenity|conference_centre|1 +amenity|courthouse|4 +amenity|coworking_space|1 +amenity|dentist|2 +amenity|doctors|4 +amenity|embassy|44 +amenity|fast_food|42 +amenity|fire_station|20 +amenity|fountain|9 +amenity|fuel|35 +amenity|funeral_home|1 +amenity|hospital|12 +amenity|kindergarten|12 +amenity|library|30 +amenity|marketplace|4 +amenity|nightclub|3 +amenity|nursing_home|1 +amenity|office|1 +amenity|parking|6555 +amenity|parking_entrance|1 +amenity|parking_space|38 +amenity|pharmacy|7 +amenity|place_of_worship|233 +amenity|planetarium|1 +amenity|police|13 +amenity|post_office|8 +amenity|pub|4 +amenity|restaurant|74 +amenity|school|148 +amenity|shelter|4 +amenity|social_facility|4 +amenity|stripclub|1 +amenity|theatre|15 +amenity|toilets|11 +amenity|townhall|1 +amenity|university|43 +amenity|veterinary|2 +amenity|waste_disposal|1 +building|39|1 +building|44|1 +building|Gym|1 +building|Hotel|1 +building|Utility_Suubstation|1 +building|amenity=fire_station;building=government|1 +building|apartments|172 +building|burial_vault|21 +building|church|4 +building|civic|2 +building|college|3 +building|commercial|34 +building|condominium|3 +building|construction|2 +building|dormitory|28 +building|garage|2 +building|government|4 +building|greenhouse|1 +building|hospital|2 +building|hotel|6 +building|house|15 +building|industrial|3 +building|manufacture|1 +building|no|2 +building|office|45 +building|public|6 +building|residential|56 +building|retail|3 +building|roof|1 +building|school|30 +building|service|2 +building|stable|1 +building|temple|1 +building|terrace|3 +building|train_station|3 +building|university|147 +building|warehouse|1 +building|yes|942 +historic|archaeological_site|2 +historic|house|1 +historic|memorial|7 +historic|monument|9 +landuse|cemetery|24 +landuse|railway|2 +landuse|village_green|3 +leisure|bleachers|2 +leisure|dog_park|10 +leisure|events|1 +leisure|fitness_centre|1 +leisure|garden|182 +leisure|golf_course|4 +leisure|ice_rink|1 +leisure|marina|10 +leisure|miniature_golf|2 +leisure|nature_reserve|2 +leisure|outdoor_seating|5 +leisure|park|864 +leisure|picnic_table|3 +leisure|pitch|448 +leisure|playground|122 +leisure|sports_centre|8 +leisure|stadium|10 +leisure|swimming_pool|48 +leisure|track|26 +leisure|water_park|2 +leisure|yes|1 +man_made|chimney|6 +man_made|pier|28 +shop|alcohol|15 +shop|art|1 +shop|art;paper|1 +shop|bakery|3 +shop|beauty|7 +shop|bicycle|1 +shop|books|1 +shop|car|1 +shop|car_parts|3 +shop|car_repair|2 +shop|chemist|2 +shop|clothes|8 +shop|convenience|35 +shop|copyshop|1 +shop|cosmetics|2 +shop|deli|1 +shop|department_store|5 +shop|doityourself|2 +shop|dry_cleaning|3 +shop|electronics|1 +shop|florist|1 +shop|frame|2 +shop|funeral_directors|4 +shop|garden_centre|1 +shop|gift|5 +shop|greengrocer|1 +shop|hairdresser|10 +shop|interior_decoration|2 +shop|laundry|4 +shop|mall|2 +shop|mobile_phone|1 +shop|paint|1 +shop|pet|1 +shop|religion|1 +shop|seafood|4 +shop|shoes|2 +shop|sports|2 +shop|supermarket|15 +shop|ticket|1 +shop|tobacco|2 +shop|tyres|1 +shop|variety_store|3 +shop|wholesale|1 +shop|yes|1 +tourism|artwork|18 +tourism|attraction|41 +tourism|hotel|2 +tourism|information|2 +tourism|picnic_site|6 +tourism|yes|1 +tourism|zoo|3 diff --git a/tests/expected/vshop_all_osm_type_subtype_count.out b/tests/expected/shop_combined_point_osm_type_subtype_count.out similarity index 100% rename from tests/expected/vshop_all_osm_type_subtype_count.out rename to tests/expected/shop_combined_point_osm_type_subtype_count.out diff --git a/tests/expected/shop_polygon_osm_type_subtype_count.out b/tests/expected/shop_polygon_osm_type_subtype_count.out index 75c16c39..2385d8d2 100644 --- a/tests/expected/shop_polygon_osm_type_subtype_count.out +++ b/tests/expected/shop_polygon_osm_type_subtype_count.out @@ -12,7 +12,7 @@ shop|books|1 shop|car|4 shop|car_parts|3 shop|car_repair|7 -shop|chemist|1 +shop|chemist|2 shop|clothes|8 shop|convenience|35 shop|copyshop|1 diff --git a/tests/sql/building_combined_point_osm_type_subtype_count.sql b/tests/sql/building_combined_point_osm_type_subtype_count.sql new file mode 100644 index 00000000..32ed9cff --- /dev/null +++ b/tests/sql/building_combined_point_osm_type_subtype_count.sql @@ -0,0 +1,5 @@ +SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) + FROM osm.building_combined_point + GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" + ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" +; \ No newline at end of file diff --git a/tests/sql/poi_combined_point_osm_type_subtype_count.sql b/tests/sql/poi_combined_point_osm_type_subtype_count.sql new file mode 100644 index 00000000..b80a080f --- /dev/null +++ b/tests/sql/poi_combined_point_osm_type_subtype_count.sql @@ -0,0 +1,5 @@ +SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) + FROM osm.poi_combined_point + GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" + ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" +; \ No newline at end of file diff --git a/tests/sql/vpoi_all_osm_type_subtype_count.sql b/tests/sql/poi_line_osm_type_subtype_count.sql similarity index 89% rename from tests/sql/vpoi_all_osm_type_subtype_count.sql rename to tests/sql/poi_line_osm_type_subtype_count.sql index ebfbd955..95275a5d 100644 --- a/tests/sql/vpoi_all_osm_type_subtype_count.sql +++ b/tests/sql/poi_line_osm_type_subtype_count.sql @@ -1,5 +1,5 @@ SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) - FROM osm.vpoi_all + FROM osm.poi_line GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" ; \ No newline at end of file diff --git a/tests/sql/vshop_all_osm_type_subtype_count.sql b/tests/sql/poi_point_osm_type_subtype_count.sql similarity index 88% rename from tests/sql/vshop_all_osm_type_subtype_count.sql rename to tests/sql/poi_point_osm_type_subtype_count.sql index 27fc0344..dd16ee7e 100644 --- a/tests/sql/vshop_all_osm_type_subtype_count.sql +++ b/tests/sql/poi_point_osm_type_subtype_count.sql @@ -1,5 +1,5 @@ SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) - FROM osm.vshop_all + FROM osm.poi_point GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" ; \ No newline at end of file diff --git a/tests/sql/vbuilding_all_osm_type_subtype_count.sql b/tests/sql/poi_polygon_osm_type_subtype_count.sql similarity index 87% rename from tests/sql/vbuilding_all_osm_type_subtype_count.sql rename to tests/sql/poi_polygon_osm_type_subtype_count.sql index 15aeaa75..6e3d77b7 100644 --- a/tests/sql/vbuilding_all_osm_type_subtype_count.sql +++ b/tests/sql/poi_polygon_osm_type_subtype_count.sql @@ -1,5 +1,5 @@ SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) - FROM osm.vbuilding_all + FROM osm.poi_polygon GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" ; \ No newline at end of file diff --git a/tests/sql/shop_combined_point_osm_type_subtype_count.sql b/tests/sql/shop_combined_point_osm_type_subtype_count.sql new file mode 100644 index 00000000..b1b168be --- /dev/null +++ b/tests/sql/shop_combined_point_osm_type_subtype_count.sql @@ -0,0 +1,5 @@ +SELECT osm_type COLLATE "C", osm_subtype COLLATE "C", COUNT(*) + FROM osm.shop_combined_point + GROUP BY osm_type COLLATE "C", osm_subtype COLLATE "C" + ORDER BY osm_type COLLATE "C", osm_subtype COLLATE "C" +; \ No newline at end of file From 503bad73b4e5de1f52e8f90a9fb34c3f48adcb01 Mon Sep 17 00:00:00 2001 From: Ryan Lambert Date: Sun, 11 Jun 2023 14:58:01 -0600 Subject: [PATCH 3/3] Cleanup RE #320 (#340) * Remove refresh of MV that no longer exists. Make comments on new tables more consistent * Add missing comments. Install PgDD extension --- Dockerfile | 5 +++-- db/deploy/replication_functions.sql | 3 --- flex-config/sql/amenity.sql | 8 ++++++++ flex-config/sql/building.sql | 2 ++ flex-config/sql/building_combined_point.sql | 3 ++- flex-config/sql/poi_combined_point.sql | 2 +- flex-config/sql/public_transport.sql | 4 ++++ flex-config/sql/shop.sql | 4 ++++ flex-config/sql/shop_combined_point.sql | 9 ++++++++- 9 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index b5c79922..cd4489ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,8 +47,9 @@ RUN git clone --depth 1 --branch $OSM2PGSQL_BRANCH https://github.com/openstreet && apt autoremove -y \ && cd /tmp && rm -r /tmp/osm2pgsql - -COPY ./sqitch.conf /etc/sqitch/sqitch.conf +RUN wget https://github.com/rustprooflabs/pgdd/releases/download/0.5.0/pgdd_0.5.0_postgis_pg15_amd64.deb \ + && dpkg -i ./pgdd_0.5.0_postgis_pg15_amd64.deb \ + && rm ./pgdd_0.5.0_postgis_pg15_amd64.deb WORKDIR /app COPY . ./ diff --git a/db/deploy/replication_functions.sql b/db/deploy/replication_functions.sql index 8f6b8492..0faf8977 100644 --- a/db/deploy/replication_functions.sql +++ b/db/deploy/replication_functions.sql @@ -1,5 +1,3 @@ --- Deploy pgosm-flex:002 to pg --- requires: 001 BEGIN; @@ -22,7 +20,6 @@ CREATE OR REPLACE PROCEDURE osm.append_data_finish(skip_nested BOOLEAN = False) BEGIN REFRESH MATERIALIZED VIEW osm.vplace_polygon_subdivide; - REFRESH MATERIALIZED VIEW osm.vpoi_all; IF $1 = False THEN RAISE NOTICE 'Populating nested place table'; diff --git a/flex-config/sql/amenity.sql b/flex-config/sql/amenity.sql index 4008eccb..3f4b3cdc 100644 --- a/flex-config/sql/amenity.sql +++ b/flex-config/sql/amenity.sql @@ -58,3 +58,11 @@ COMMENT ON COLUMN osm.amenity_polygon.address IS 'Address combined from address COMMENT ON COLUMN osm.amenity_point.osm_subtype IS 'Further describes osm_type for amenities.'; COMMENT ON COLUMN osm.amenity_line.osm_subtype IS 'Further describes osm_type for amenities.'; COMMENT ON COLUMN osm.amenity_polygon.osm_subtype IS 'Further describes osm_type for amenities.'; + +COMMENT ON COLUMN osm.amenity_point.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.amenity_line.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.amenity_polygon.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; + +COMMENT ON COLUMN osm.amenity_point.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; +COMMENT ON COLUMN osm.amenity_line.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; +COMMENT ON COLUMN osm.amenity_polygon.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; diff --git a/flex-config/sql/building.sql b/flex-config/sql/building.sql index c03deed1..d7999873 100644 --- a/flex-config/sql/building.sql +++ b/flex-config/sql/building.sql @@ -9,6 +9,8 @@ COMMENT ON COLUMN osm.building_point.levels IS 'Number (#) of levels in the buil COMMENT ON COLUMN osm.building_polygon.wheelchair IS 'Indicates if building is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; COMMENT ON COLUMN osm.building_point.wheelchair IS 'Indicates if building is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.building_point.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; +COMMENT ON COLUMN osm.building_polygon.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; COMMENT ON COLUMN osm.building_point.housenumber IS 'Value from addr:housenumber tag'; COMMENT ON COLUMN osm.building_point.street IS 'Value from addr:street tag'; diff --git a/flex-config/sql/building_combined_point.sql b/flex-config/sql/building_combined_point.sql index adacf100..1eea134e 100644 --- a/flex-config/sql/building_combined_point.sql +++ b/flex-config/sql/building_combined_point.sql @@ -5,7 +5,7 @@ ALTER TABLE osm.building_combined_point ; -COMMENT ON TABLE osm.building_combined_point IS 'Combined point and polygon buildings with polygons converted to pointss with centroid() in osm2pgsql Lua style.'; +COMMENT ON TABLE osm.building_combined_point IS 'Combined building data as points. Building polygons are converted in osm2pgsql to points with centroid().'; COMMENT ON COLUMN osm.building_combined_point.address IS 'Address combined from address parts in helpers.get_address().'; COMMENT ON COLUMN osm.building_combined_point.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; @@ -13,6 +13,7 @@ COMMENT ON COLUMN osm.building_combined_point.name IS 'Best name option determin COMMENT ON COLUMN osm.building_combined_point.levels IS 'Number (#) of levels in the building.'; COMMENT ON COLUMN osm.building_combined_point.height IS 'Object height. Should be in meters (m) but is not enforced. Please fix data in OpenStreetMap.org if incorrect values are discovered.'; COMMENT ON COLUMN osm.building_combined_point.wheelchair IS 'Indicates if building is wheelchair accessible.'; +COMMENT ON COLUMN osm.building_combined_point.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; COMMENT ON COLUMN osm.building_combined_point.geom_type IS 'Type of geometry. N(ode), W(ay) or R(elation). Unique along with osm_id'; COMMENT ON COLUMN osm.building_combined_point.geom IS 'Geometry loaded by osm2pgsql.'; COMMENT ON COLUMN osm.building_combined_point.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; diff --git a/flex-config/sql/poi_combined_point.sql b/flex-config/sql/poi_combined_point.sql index 77bcd013..af627fcf 100644 --- a/flex-config/sql/poi_combined_point.sql +++ b/flex-config/sql/poi_combined_point.sql @@ -7,7 +7,7 @@ CREATE INDEX ix_osm_poi_combined_point_osm_type ON osm.poi_combined_point (osm_t -COMMENT ON TABLE osm.poi_combined_point IS 'Combined POI data. Lines and polygons converted to point with centroid() in osm2pgsql.'; +COMMENT ON TABLE osm.poi_combined_point IS 'Combined POI data as points. Lines and polygons converted to point in osm2pgsql with centroid().'; COMMENT ON COLUMN osm.poi_combined_point.osm_type IS 'Stores the OpenStreetMap key that included this feature in the layer. Value from key stored in osm_subtype.'; COMMENT ON COLUMN osm.poi_combined_point.address IS 'Address combined from address parts in helpers.get_address(). See base tables for individual address parts'; diff --git a/flex-config/sql/public_transport.sql b/flex-config/sql/public_transport.sql index f4043522..5965f372 100644 --- a/flex-config/sql/public_transport.sql +++ b/flex-config/sql/public_transport.sql @@ -41,6 +41,10 @@ COMMENT ON COLUMN osm.public_transport_point.wheelchair IS 'Indicates if feature COMMENT ON COLUMN osm.public_transport_line.wheelchair IS 'Indicates if feature is wheelchair accessible. Expected values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; COMMENT ON COLUMN osm.public_transport_polygon.wheelchair IS 'Indicates if feature is wheelchair accessible. Expected values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.public_transport_point.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; +COMMENT ON COLUMN osm.public_transport_line.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; +COMMENT ON COLUMN osm.public_transport_polygon.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; + COMMENT ON COLUMN osm.public_transport_point.ref IS 'Reference number or code. Best ref option determined by helpers.get_ref(). https://wiki.openstreetmap.org/wiki/Key:ref'; COMMENT ON COLUMN osm.public_transport_line.ref IS 'Reference number or code. Best ref option determined by helpers.get_ref(). https://wiki.openstreetmap.org/wiki/Key:ref'; COMMENT ON COLUMN osm.public_transport_polygon.ref IS 'Reference number or code. Best ref option determined by helpers.get_ref(). https://wiki.openstreetmap.org/wiki/Key:ref'; diff --git a/flex-config/sql/shop.sql b/flex-config/sql/shop.sql index d0e1b639..e94614f7 100644 --- a/flex-config/sql/shop.sql +++ b/flex-config/sql/shop.sql @@ -10,6 +10,10 @@ COMMENT ON COLUMN osm.shop_polygon.geom IS 'Geometry loaded by osm2pgsql.'; COMMENT ON COLUMN osm.shop_point.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; COMMENT ON COLUMN osm.shop_polygon.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.shop_point.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; +COMMENT ON COLUMN osm.shop_polygon.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; + + COMMENT ON COLUMN osm.shop_point.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; COMMENT ON COLUMN osm.shop_polygon.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; diff --git a/flex-config/sql/shop_combined_point.sql b/flex-config/sql/shop_combined_point.sql index 012eccf8..01d8b05e 100644 --- a/flex-config/sql/shop_combined_point.sql +++ b/flex-config/sql/shop_combined_point.sql @@ -1,5 +1,5 @@ -COMMENT ON TABLE osm.shop_combined_point IS 'Converts polygon shops to point with ST_Centroid(), combines with source points using UNION.'; +COMMENT ON TABLE osm.shop_combined_point IS 'Combines point and polygon shops as points. Polygons are converted to point in osm2pgsql with centroid().'; COMMENT ON COLUMN osm.shop_combined_point.osm_id IS 'OpenStreetMap ID. Unique along with geometry type.'; COMMENT ON COLUMN osm.shop_combined_point.osm_type IS 'Stores the OpenStreetMap key that included this feature in the layer. Value from key stored in osm_subtype.'; @@ -9,12 +9,19 @@ COMMENT ON COLUMN osm.shop_combined_point.name IS 'Best name option determined b COMMENT ON COLUMN osm.shop_combined_point.geom IS 'Geometry, mix of points loaded by osm2pgsql and points calculated from the ST_Centroid() of the polygons loaded by osm2pgsql.'; COMMENT ON COLUMN osm.shop_combined_point.wheelchair IS 'Indicates if feature is wheelchair accessible. Values: yes, no, limited. Per https://wiki.openstreetmap.org/wiki/Key:wheelchair'; +COMMENT ON COLUMN osm.shop_combined_point.wheelchair_desc IS 'Value from wheelchair:description Per https://wiki.openstreetmap.org/wiki/Key:wheelchair:description'; COMMENT ON COLUMN osm.shop_combined_point.geom_type IS 'Type of geometry. N(ode), W(ay) or R(elation). Unique along with osm_id'; COMMENT ON COLUMN osm.shop_combined_point.operator IS 'Entity in charge of operations. https://wiki.openstreetmap.org/wiki/Key:operator'; COMMENT ON COLUMN osm.shop_combined_point.website IS 'Official website for the feature. https://wiki.openstreetmap.org/wiki/Key:website'; COMMENT ON COLUMN osm.shop_combined_point.brand IS 'Identity of product, service or business. https://wiki.openstreetmap.org/wiki/Key:brand'; COMMENT ON COLUMN osm.shop_combined_point.phone IS 'Phone number associated with the feature. https://wiki.openstreetmap.org/wiki/Key:phone'; +COMMENT ON COLUMN osm.shop_combined_point.housenumber IS 'Value from addr:housenumber tag'; +COMMENT ON COLUMN osm.shop_combined_point.street IS 'Value from addr:street tag'; +COMMENT ON COLUMN osm.shop_combined_point.city IS 'Value from addr:city tag'; +COMMENT ON COLUMN osm.shop_combined_point.state IS 'Value from addr:state tag'; +COMMENT ON COLUMN osm.shop_combined_point.postcode IS 'Value from addr:postcode tag'; + ALTER TABLE osm.shop_combined_point ADD CONSTRAINT pk_osm_shop_point_osm_id_geom_type PRIMARY KEY (osm_id, geom_type)