Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Change "all" views to tables loaded via Flex style #337

Merged
merged 9 commits into from
Jun 10, 2023

Conversation

rustprooflabs
Copy link
Owner

@rustprooflabs rustprooflabs commented Jun 4, 2023

Closes #320

The views have turned into tables and are not always created.

Pros / Cons / Inter-tangled

Enables loading combined point table w/out requiring load of full polygon data. This can be considerable size savings when larger polygons are involved in the source data but being simplified before loading to Postgres.

vbuilding_all and vshop_all were views doing combining, probably wasn't good for general querying performance beyond small regional data. New table structure is only points, and fully indexed.

Requires duplicating a bit of logic. The negative impact is minimized by moving common logic into new helper methods. E.g. building and building_combined_point leverage common logic in building_helper.

Increased data size with layerset=everything with more data materialized to tables. Because of additional overhead not loading in default. However, this opens the opportunity to consider loading more _combined_points layers into lightweight layersets. Going to consider adding a place_combined_point layer option. Some of those polygons are huge, and if all you need is a centroid.

Additional Change Notes

Layerset: Basic

  • Remove building_polygon
  • Add building_combined_point
  • Add poi_combined_point

Layerset: Everything

  • Add building_combined_point
  • Add poi_combined_point
  • Add shop_combined_point

Layerset: Minimal

  • Change poi to poi_combined_point

@rustprooflabs rustprooflabs added enhancement New feature or request breaking Breaking change labels Jun 4, 2023
@rustprooflabs rustprooflabs added this to the 0.9.0 milestone Jun 4, 2023
@rustprooflabs rustprooflabs mentioned this pull request Jun 6, 2023
@rustprooflabs rustprooflabs force-pushed the rework-combined-points branch from 2aa1c80 to 43e0d6f Compare June 6, 2023 01:39
@rustprooflabs
Copy link
Owner Author

Rebased and force pushed after #338.

@rustprooflabs
Copy link
Owner Author

rustprooflabs commented Jun 6, 2023

Problem is in the shop_polygon table, that helps narrow it down. Hooray for a couple more tests (and docs about them!)

FAILED TEST: sql/shop_combined_point_osm_type_subtype_count.sql - See tmp/shop_combined_point_osm_type_subtype_count.diff
  docker exec -it pgosm /bin/bash -c "cat /app/tests/tmp/shop_combined_point_osm_type_subtype_count.diff " 
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 " 

@rustprooflabs rustprooflabs changed the base branch from main to dev June 6, 2023 01:44
@rustprooflabs
Copy link
Owner Author

Cleaned up shops, started on POIs.

@rustprooflabs rustprooflabs marked this pull request as ready for review June 9, 2023 01:30
@rustprooflabs
Copy link
Owner Author

Unsure why I'm getting this error

2023-06-08 20:00:31,822:INFO:pgosm-flex:helpers:2023-06-08 20:00:31  ERROR: Failed to execute Lua function 'osm2pgsql.process_way': ./style/poi_combined_point.lua:96: Error in 'insert': Trying to add way to table 'poi_combined_point'.
2023-06-08 20:00:31,822:INFO:pgosm-flex:helpers:
2023-06-08 20:00:31,822:INFO:pgosm-flex:helpers:stack traceback:
2023-06-08 20:00:31,822:INFO:pgosm-flex:helpers:[C]: in method 'insert'
2023-06-08 20:00:31,822:INFO:pgosm-flex:helpers:./style/poi_combined_point.lua:96: in function 'poi_process_way_combined'.
2023-06-08 20:00:31,828:ERROR:pgosm-flex:pgosm_flex:Failed to run osm2pgsql. Return code: 1
Failed to run osm2pgsql. Return code: 1 - Check the log output for details

@rustprooflabs
Copy link
Owner Author

rustprooflabs commented Jun 9, 2023

The error in #337 (comment) is quite unexpected. I believe I'm doing everything the same as the building_combined_point and shop_combined_point but it's failing.

The poi_combined_point table has the geom defined as a point`.

{ column = 'geom', type = 'point', projection = srid, not_null = true},

It fails adding rows on both polygons and lines (confirmed by commenting out the polygon portion...) which use these lines respectively.

geom = object:as_polygon():centroid()

and

geom = object:as_linestring():centroid()

The the error is Trying to add way to table 'poi_combined_point'. which makes it seem like the centroid() function is not working. It shouldn't be a way at the time of insert, it should be a centroid. Right??

@rustprooflabs
Copy link
Owner Author

Problem wasn't the geom column, it was the ids definition. 🤦

c508c2f

@rustprooflabs rustprooflabs merged commit 767dd96 into dev Jun 10, 2023
@rustprooflabs rustprooflabs deleted the rework-combined-points branch June 10, 2023 13:58
rustprooflabs added a commit that referenced this pull request Jun 11, 2023
* 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.

* 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

* 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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
breaking Breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace _all views with tables build using centroid()
1 participant