Hi,

I don't get to use sql server too much, so I don't have any definitive
answers for you.

But based upon ogrinfo the geom type & projection are unknown, and mapnik
needs to know what these are.

This may provide the answer for you-

http://woostuff.wordpress.com/2011/06/07/opening-ms-sql-server-2008-spatial-tables-in-qgis-correctly/

It would be nice to know if you get this working.

kind regards.



On Fri, Jun 17, 2011 at 2:41 AM, Alastair Aitchison <[email protected]>wrote:

> Dear all,****
>
> ** **
>
> Mapnik newbie here. After a few headaches, I’ve managed to compile Mapnik
> and its dependencies to run under Windows, and I can successfully run the
> rundemo.py script to create a beautiful map.  :)****
>
> However, I’m a bit stuck at the next step. My source data is held in SQL
> Server 2008 - in separate tables for polygon, polyline, and point layers,
> stored using the geometry datatype. ****
>
> ** **
>
> I didn’t expect Mapnik to have a dedicated MSSQL driver, but notice that it
> does have support for OGR datasources and, since GDAL 1.8 supports
> MSSQLSpatial as a datasource (
> http://www.gdal.org/ogr/drv_mssqlspatial.html), I thought I’d be able to
> connect via that. So, I tried defining a VRT virtual layer that retrieved
> the Well-Known Text of one layer, as follows:****
>
> ** **
>
> <OGRVRTDataSource>****
>
>   <OGRVRTLayer name="AASQLlayer">****
>
>     <SrcDataSource>
> MSSQL:server=.\SQLEXPRESS;database=OSVectorMap;trusted_connection=yes</
> SrcDataSource> ****
>
>     <SrcSQL>SELECT geom27700.STAsText() AS geomWKT FROM
> TG11_Settlement_Area</SrcSQL>****
>
>     <GeometryField encoding="WKT" field="geomWKT"/>****
>
>   </OGRVRTLayer>****
>
> </OGRVRTDataSource>****
>
> ** **
>
> Testing the OVF file above with ogrinfo seemed to suggest that the
> connection string was ok, and reported the following:****
>
> C:\OSGeo4W\apps\mapnik\alastair\python>ogrinfo -so -al mssql.ovf****
>
> INFO: Open of `mssql.ovf'****
>
>       using driver `VRT' successful.****
>
> ** **
>
> Layer name: AASQLlayer****
>
> Geometry: Unknown (any)****
>
> Feature Count: 1488****
>
> Extent: (610000.000001, 309999.999990) - (620000.000001, 319999.999992)***
> *
>
> Layer SRS WKT: (unknown)****
>
> geomWKT: String (0.0)****
>
> ** **
>
> I then used this VRT as the datasource of a new layer in the rundemo.py
> script:****
>
> new_lyr.datasource = mapnik.Ogr(file='MSSQL.ovf',layer="AASQLlayer")****
>
> ** **
>
> However, trying to render the map gave me the following error:****
>
> ERROR 1: Failed to open datasource
> `MSSQL:server=.\SQLEXPRESS;database=OSVectorM****
>
> ap;trusted_connection=yes'.****
>
> Traceback (most recent call last):****
>
>   File "rundemo.py", line 73, in <module>****
>
>     provlines_lyr.datasource =
> mapnik.Ogr(file='MSSQL.ovf',layer="AASQLlayer")****
>
>   File "C:\OSGeo4W\apps\Python25\lib\site-packages\mapnik\__init__.py",
> line 418****
>
> , in Ogr****
>
>     return CreateDatasource(keywords)****
>
> RuntimeError: Failed to open datasource
> `MSSQL:server=.\SQLEXPRESS;database=OSVe****
>
> ctorMap;trusted_connection=yes'.****
>
> ** **
>
> I’ve tried various combinations of changing the VRT to return WKT, WKB, or
> SQL Server’s own native geometry format – they all seem to validate ok with
> ogrinfo, but fail in mapnik.****
>
> ** **
>
> Could anyone please offer any advice as to how to connect mapnik to SQL
> Server? Thanks all for your time.****
>
> ** **
>
> ** **
>
> _______________________________________________
> 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

Reply via email to