[gdal-dev] Ogr: ExecuteSQL with MSSQL and geometry column
Chaitanya kumar CH
chaitanya.ch at gmail.com
Tue Jul 17 21:33:14 PDT 2012
The name 'SELECT' is intentional. We can't set it to the table's name. The
select command could be a complex one involving multiple tables.
The result layer has the native OGR format. The geometry is separate from
the attributes/fields. So, there will be no geometry column in it. You can
access the geometry like with any other ogr feature.
For a table, the geometry type is determined by reading the
dbo.geometry_columns table. For the result layer there is no easy way to do
it and is set to wkbUnknown. In any case, you should be able to use those
geometry objects like any other.
On Tue, Jul 17, 2012 at 8:07 PM, Benjamin <benjamin.lux at maxsea.fr> wrote:
> I code an application with a warper C# of Ogr.
> I have a MSSQL data base which work fine with Ogr (except this issue).
> I have a table dbo.MY_TABLE with 3 fields (D, CHART_ID, WKB_GEOMETRY).
> To minimise my acces to SQL Serveur (Driver MSSQLSpatial) I want to copy a
> request SQL into a Spatial Layer (with a geometry column) based on a Memory
> To obtain my layer I call ExecuteSQL().
> string options = "Tables=dbo.MY_TABLE(WKB_GEOMETRY);GeometryFormat=wkb;"
> serverDataSource = Ogr.Open("MSSQL:" + connectionString + options), 0);
> string request = "SELECT * FROM MY_TABLE WHERE CHART_ID = 'ID'"
> Layer serverLayer = serverDataSource.ExecuteSQL(request, null, "");
> I see that my layer name is "SELECT", it have 39 features but my result
> doesn't contain geometry column !
> Why ?
> serverLayer.GetGeometryColumn() returns "" and serverLayer.GetGeomType()
> returns "wkbUnknown".
> And the layer serverLayer ( or a layer provide by a Memory Driver) have any
> method "ChoseGeometryField" or "SetGeometryColumn" (or I have missed it).
> If I call serverDataSource.GetLayerByName("MY_TABLE").GetGeometryColumn()
> work fine and result "WKB_GEOMETRY".
> Any suggests ?
> View this message in context:
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
Chaitanya kumar CH.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev