florianf / tileoven

TileOven a maintained fork of TileMill
http://tilemill.com
BSD 3-Clause "New" or "Revised" License
104 stars 17 forks source link

Postgis plugin error: Layer fails on Tileoven but works on Tilemill #17

Open csytsma opened 6 years ago

csytsma commented 6 years ago

I have a layer with a Postgis query that works on Tilemill, but fails in Tileoven.

Here's the error:

Postgis Plugin: ERROR:  syntax error at or near "WHERE"
LINE 1: SELECT ST_SRID("way") AS srid FROM   ( WHERE "way" IS NOT NU...
                                               ^
in executeQuery Full sql was: 'SELECT ST_SRID("way") AS srid FROM       ( WHERE "way" IS NOT NULL LIMIT 1;'
  encountered during parsing of layer 'barrier_points' in Layer

Here's the query:

( SELECT way, 'barrier' AS type, 
    ( select degrees(ST_Azimuth(ST_StartPoint(inter), ST_EndPoint(inter))) from 
        ( select ST_Intersection(r.way, ST_Buffer(p.way, 100)) as inter 
            from planet_osm_line r 
            where r.highway in ('motorway', 'trunk', 'primary','secondary', 'tertiary', 'residential', 'service', 'track', 'path', 'cycleway', 'footpath','unknown') 
            and r.way && ST_Buffer(p.way, 100) order by ST_Distance(r.way, p.way) limit 1 ) rr ) 
    as angle 
    FROM planet_osm_point p 
    WHERE barrier IN ('gate', 'yes') ) 
AS data

Any ideas why?

florianf commented 6 years ago

It seems the error comes directly from mapnik. The call to

source = new mapnik.Datasource(mml.Layer[0].Datasource);

in Datasource.server.bones fails. This is a native function, so I'm out of ideas here. Maybe create a Postgres View?