MSSQLSpatial incorrectly assumes an "image" type column to be geometry
|Reported by:||danhomerick||Owned by:||tamas|
When the geometry column is not explicitly named, the MS SQL Spatial format attempts to autodetect which column contains geometry data. The autodetection logic assumes that any "image" type column (a subtype of binary data) contains WKB. Because the "image" type, unlike the "geometry" and "geography" column types is not exclusive to spatial data, this assumption is risky.
At connection, the spatial storage format is specified (WKB, WKT, or Native), defaulting to Native. A patch is attached which propagates which storage format is being used down to the autodetection logic, and changes the logic so as to only make the risky assumption about an "image" column when the spatial data is stored in WKB. It also allows for WKB which is stored in a "varbinary" column type, since the "image" column type is deprecated (since SQL Server 2005 ).
A more comprehensive fix might be to attempt decoding some of the "image" column, in order to check that it actually contains WKB.
The patch does not address autodetecting a column containing WKT, which was also not addressed by the original code.
An alternate fix might be to remove autodetection of geometry columns entirely unless stored in the unambiguous "geometry" or "geography" types (i.e. native).
Change History (11)
comment:1 Changed 5 years ago by
|Component:||default → OGR_SF|