rustprooflabs / pgosm-flex

PgOSM Flex provides high quality OpenStreetMap datasets in PostGIS (Postgres) using the osm2pgsql Flex output.
MIT License
101 stars 20 forks source link

Import fails on 'osm.build_nested_admin_polygons' procedure missing #347

Closed asitemade4u closed 1 year ago

asitemade4u commented 1 year ago

What version of PgOSM Flex are you using?

Last version, using docker:latest The hash of the image is sha256:d6d41e431ded9dafb61be1efd6e178c8b9f4243556f4f0425bd7a7f719010436

Docker image

latest

What operating system, osm2pgsql, and PostgreSQL/PostGIS versions are you using?

What did you do exactly?

Here is the instructions I executed in the Terminal of the host (I obfuscated the user and the password for security reasons). Also, I have downloaded the osm.pbf file for the State of NY.

docker exec -it \
    -e POSTGRES_USER=<my_user> \
    -e POSTGRES_PASSWORD=<my_password> \
    -e POSTGRES_HOST=192.168.1.14 \
    -e POSTGRES_DB=gis \
    -e POSTGRES_PORT=5432 \
    pgo python3 docker/pgosm_flex.py \
    --ram=20 \
    --region=north-america/us \
    --subregion=new-york \
    --input-file=/mnt/pbf/nys.pbf \
    --layerset=parks \
    --force \
    --language=en

Lastly, here is the personalized layerset I am applying (parks.ini):

[layerset]
amenity=false
building_combined_point=false
building=false
indoor=false
infrastructure=false
landuse=true
leisure=false
natural=true
place=false
poi_combined_point=false
poi=false
public_transport=false
road_major=false
road=false
shop_combined_point=false
shop=false
tags=true
traffic=false
unitable=false
water=false

What did you expect to happen?

It to work ;o)) More seriously, to download the Parks in NYS.

What did happen instead?

I got an error on nested polygons:

2023-07-06 10:40:06,042:INFO:pgosm-flex:pgosm_flex:Calculating nested polygons
2023-07-06 10:40:06,042:INFO:pgosm-flex:db:Building nested polygons... (this can take a while)
2023-07-06 10:40:06,075:INFO:pgosm-flex:db:Nested polygon output: 
 ERROR:  procedure osm.build_nested_admin_polygons() does not exist
LINE 1: CALL osm.build_nested_admin_polygons();
             ^
HINT:  No procedure matches the given name and argument types. You might need to add explicit type casts.

I have a hunch (as the log says) that the procedure osm.build_nested_admin_polygons is just missing.

What did you do to try analyzing the problem?

Read the logs.

rustprooflabs commented 1 year ago

Hi @asitemade4u - Thank you for reporting this! This is a bug, sorry!

This issue affects any layersets that do not define place=true to include the function definition. To work around with current versions, try adding --skip-nested to your docker exec command. That should bypass the failing query. At least, it works in my quick test!

Source of the issue

The logic here is responsible for skipping the function call when necessary, apparently it's not working. It appears like it's trying to check for and avoid this issue (see here and here) but somehow it's not working as expected.

rustprooflabs commented 1 year ago

On a closer look I think I got it a bit wrong in my prior comment.

This affects layersets that define place=false. Omitting the place layer from the .ini file appears to succeed without requiring the --skip-nested workaround. Looks like this logic is being evaluated improperly.

rustprooflabs commented 1 year ago

This is fixed in main, just pushed an updated latest Docker image. This should fix your issue @asitemade4u!

asitemade4u commented 1 year ago

THANKS!