mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
157 stars 90 forks source link

`ST_Estimated_Extent` renamed to `ST_EstimatedExtent` #237

Open marcotama opened 3 years ago

marcotama commented 3 years ago

Hi, I am using the generate_image.py script from the mapnik-stylesheets repo as I would like to generate some image files for printing. I opened an issue there, too, but I realised this is probably the right place.

I should emphasize that I barely know what I am doing: I don't work with GIS and I am winging it.

The problem I encountered is that, upon calling render, some PostGIS function is called that does not exist:

Traceback (most recent call last):
  File "/generate_image.py", line 70, in <module>
    mapnik.render(m, im)
RuntimeError: Postgis Plugin: ERROR:  function st_estimated_extent(unknown, unknown) does not exist
LINE 1: ..._YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Estimat...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
in executeQuery Full sql was: 'SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Estimated_Extent('planet_osm_polygon','way') as ext) as tmp'

This query, which returns the user functions

select n.nspname as function_schema,
       p.proname as function_name,
       l.lanname as function_language,
       pg_get_function_arguments(p.oid) as function_arguments,
       t.typname as return_type
from pg_proc p
left join pg_namespace n on p.pronamespace = n.oid
left join pg_language l on p.prolang = l.oid
left join pg_type t on t.oid = p.prorettype 
where n.nspname not in ('pg_catalog', 'information_schema') and p.proname like '%estimate%extent%'
order by function_schema,
         function_name;

returns

 function_schema |   function_name    | function_language |    function_arguments     | return_type
-----------------+--------------------+-------------------+---------------------------+-------------
 public          | st_estimatedextent | c                 | text, text, text, boolean | box2d
 public          | st_estimatedextent | c                 | text, text, text          | box2d
 public          | st_estimatedextent | c                 | text, text                | box2d
(3 rows)

It seems that the function was renamed at some point in the past. I was able to find a closed issue in the Mapnik repo but I am not sure how to take it from there.

Any help would be appreciated! FYI, I am running on Windows 10, PostgreSQL 13 and PostGIS 3.1.0.