Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Render with docker fails due to unknown Postgis function (need sfcgal support) #8

Open
Cubedsheep opened this issue Mar 8, 2022 · 5 comments

Comments

@Cubedsheep
Copy link

Cubedsheep commented Mar 8, 2022

When I try to render a map with the docker container, the python script fails with the following error:

Traceback (most recent call last):
  File "makeMap.py", line 52, in <module>
    make_map('OAM_20000.pdf', 20000, 617124,6400092)
  File "makeMap.py", line 34, in make_map
    load_map(m, mapnik_file)
RuntimeError: Postgis Plugin: ERROR:  function st_approximatemedialaxis(geometry) does not exist
LINE 1: ...ND name IS NOT NULL UNION ALL SELECT ST_LineMerge(ST_Approxi...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
in executeQuery Full sql was: 'SELECT * FROM ( SELECT way, waterway AS type, replace(name, 'Ruisseau', 'Rau') AS name FROM planet_osm_line WHERE waterway IN ('canal', 'river', 'stream') AND name IS NOT NULL UNION ALL SELECT ST_LineMerge(ST_ApproximateMedialAxis(ST_SimplifyPreserveTopology(ST_MakePolygon(ST_ExteriorRing(way)), 50))) AS way, water AS type, replace(replace(name, 'Etang', '\xc9tg'), '\xc9tang', '\xc9tg') AS name FROM planet_osm_polygon WHERE water IN ('pond', 'lake', 'basin', 'reservoir') AND name IS NOT NULL AND way_area > 10000 ) AS data LIMIT 0'
  encountered during parsing of layer 'waterway_label' in Layer of 'osm2pgsql/OpenArdenneMap.xml' 

I suspect the cause is an outdated Postgis version or a missing Plugin, but I'm not sure how to find and fix the broken component.

I also removed the layers concerning height contours and hillshades because I first wanted to try rendering just the osm data by removing the respective entries in the .mss stylesheets and projeckt-docker.mml sourcefile.

@Cubedsheep
Copy link
Author

Problem seems to be outdated plugins. Removing the layer for waterway labels results in a different error when rendering the map to file:

12980.741837992511
9178.770578476433
BBOX = 610633.6290810037,6395502.614710762,623614.3709189963,6404681.385289238
Scale = 1.995818782012536
Traceback (most recent call last):
  File "makeMap.py", line 52, in <module>
    make_map('OAM_20000.pdf', 20000, 617124,6400092)
  File "makeMap.py", line 50, in make_map
    render_to_file(m, map_output)
RuntimeError: Postgis Plugin: ERROR:  The GEOS version this PostGIS binary was compiled against (35) doesn't support 'ST_OrientedEnvelope' function (3.6.0+ required)
in executeQuery Full sql was: 'SELECT ST_AsBinary("way") AS geom,"building","orientation" FROM ( SELECT way, building, name, area, CAST(degrees( CASE WHEN ST_Distance(ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 1), ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 2)) > ST_Distance(ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 2), ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 3)) THEN ST_Azimuth(ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 1), ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 2)) ELSE ST_Azimuth(ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 2), ST_PointN(ST_ExteriorRing(ST_OrientedEnvelope(l.way)), 3)) END ) AS VARCHAR(255)) AS orientation FROM planet_osm_polygon AS l WHERE "building" IN ('church','chapel') ) AS data WHERE "way" && ST_SetSRID('BOX3D(610632.5994115043 6395502.614710758,623615.4005884957 6404681.385289236)'::box3d, 900913)'

@nobohan
Copy link
Owner

nobohan commented Mar 9, 2022

Hello. Yes, sorry the db container on the docker-compose configuration is not compatible with latest developments of some layers, particularly regarding the use of some PostGIS functions that need the SFCGAL extension.

I'm trying to find a new PostGIS image with SFCGAL support but I could not find a good one so far.

nobohan added a commit that referenced this issue Mar 9, 2022
@nobohan
Copy link
Owner

nobohan commented Mar 9, 2022

So I pushed a fix on master that makes the things work, except ST_ApproximateMedialAxis is not used anymore. It means that you won't have curved labels in water areas!

@Cubedsheep
Copy link
Author

I rebuilt the docker container with your fix and now the map renders correctly for me!

Concerning the PostGIS image, does the official PostGIS image work?

@nobohan
Copy link
Owner

nobohan commented Mar 9, 2022

Fine!

The official PostGIS image is in used now, see

image: postgis/postgis:13-3.2-alpine

But it seems it does not support sfcgal. However, when installing postgis on Ubuntu20.10, it comes with sfcgla support directly.

I'll reopen to add sfcgal in the docker container.

@nobohan nobohan reopened this Mar 9, 2022
@nobohan nobohan changed the title Render with docker fails due to unknown Postgis function Render with docker fails due to unknown Postgis function (need sfcgal support) Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants