On Jan 8, 2011, at 9:12 PM, Luca Delucchi wrote:
> Hi everybody, and good 2011!
> I'm working to create an interface to mapnik to create simple map to
> use for example on blankets [0] or map guide [1]. I have a problem
> with postgis datasource in python, I would like to query the table to
> order the ways by length of the geom [2]; I try to connect at
> datasource with this code
>
> query = 'liguria_line ORDER BY st_LENGTH(way) DESC'
> datasource_line = PostGIS(host = 'localhost', dbname='liguria_osm',
> user = 'lucadelu', password='luca13',table =
> query,srid='4326',geometry_field='way',extent='8.9340,44.4070,8.9871,44.4601')
>
Yes, you need to help mapnik position to bbox query (WHERE "way" &&....).
Try:
query = 'liguria_line where way && !bbox! ORDER BY st_LENGTH(way) DESC'
The above !bbox! substitution only works in Mapnik >= 0.7.0.
> but when I try to render the image I obtain this error
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "rendmap.py", line 155, in rendering
> render_to_file(self.mapnikMap,outputPath,imageType)
> RuntimeError: PSQL error:
> ERROR: syntax error at or near "WHERE"
> LINE 1: ...y" from liguria_line ORDER BY st_LENGTH(way) DESC WHERE "way...
> ^
> Full sql was: 'SELECT AsBinary("way") AS
> geom,"natural","tunnel","waterway" from liguria_line ORDER BY
> st_LENGTH(way) DESC WHERE "way" && SetSRID('BOX3D(8.933999999999999
> 44.407,8.965381556556284 44.43836517418686)'::box3d, 4326)'
>
> the problem maybe is that "ORDER BY st_LENGTH(way) DESC" it should be
> after the "WHERE "way" && ...."
>
> someone can help me?
>
> regards
> Luca
>
> [0] http://pistilsf.com/about/
> [1]
> http://www.mexconnect.com/photos/6639-cua-p-cuautla-map-strong-courtesy-of-lonely-planet-tra
> [2] http://mike.teczno.com/notes/mapnik.html
> _______________________________________________
> Mapnik-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/mapnik-users
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users