[gdal-dev] OGR 1.11 upgrade -> Geometry gone after layer.SetFeature() (MSSQL)

Even Rouault even.rouault at mines-paris.org
Thu May 15 10:54:29 PDT 2014


Le jeudi 15 mai 2014 14:01:58, Niels Kjøller Hansen a écrit :
> Hi Even,
> 
> Thank you for responding so fast. I am not sure, however, how to use
> ogr2ogr and ogrinfo to further diagnose my problem.

Well,  "ogrinfo the_syntax_to_open_a_mssql_db -al" and you'll see if there are 
geometries in it, before and after running your script.

> 
> I have tried stepping through batch file, where the Python script is a
> part..
> 
> Ogr2ogr loads the file into dbo.table_name as it should (although with
> wrong character set)
> The I run the python script:
> 
> C:\> python fix_mssql_encoding.py --schema=dbo --table=table_name --quiet
> 
> Afterwards, the encoding is fixed, but the geometry is all
> NULL-values. I use SQL Manager from Microsoft to monitor the table
> while doing the read/write.
> 
> It took me a bit of time isolating the problem to my script.
> 
> It seems that handling the geometry changed from 1.10 to 1.11? Should
> I do some 'transaction-stuff' instead of JUST doing the
> layer.SetFeature(feature)?

The notion of geometry field is new to 1.11 but has been added in a backward 
compatible way, so the MSSQL driver should not (in theory) be impacted by it.
So I would rather suspect a change in the driver itself, but it is hard to 
tell.
I've no way of testing MSSQL myself to help.

If you can find a simple way of reproducing the bug, it might be worth opening 
a ticket for that.

> 
> - Niels
> 
> 2014-05-15 13:39 GMT+02:00 Even Rouault <even.rouault at mines-paris.org>:
> > Niels,
> > 
> > you could use ogr2ogr and ogrinfo to check where the issue appears in
> > your processing.
> > 
> > Even
> > 
> >> Hello all
> >> 
> >> I have been running a python script daily, which takes a table from a
> >> MSSQL database, identifies which fields are strings, and does some
> >> character set fixing (utf8 to latin1)
> >> 
> >> The trouble is, that after an upgrade to GDAL/OGR 1.11, the table ends
> >> up with an empty geometry column. When I try to run through the script
> >> in the python terminal, a call to 'feature.GetGeomFieldCount()'
> >> returns 0
> >> 
> >> And this is before doing something to the feature. It is my guess that
> >> the feature doesn't get the geometry, and when I write it (using
> >> layer.SetFeature(feature)), It empties the column.
> >> 
> >> Am I doing something wrong? The entire script is here:
> >> http://osgeo.codepad.org/Yn5xAdE6 (mostly, comments are in Danish,
> >> sorry about that)
> >> 
> >> Other ways of succesfully importing utf8 sources (gml) in to a
> >> MSSQL-database (latin1) is also greatly appreciated, although I would
> >> still like to be able to do string manipulation in the database :)
> >> 
> >> Regards,
> >> Niels
> >> _______________________________________________
> >> gdal-dev mailing list
> >> gdal-dev at lists.osgeo.org
> >> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list