I have an OVF layer defined as follows:
<OGRVRTDataSource>
<OGRVRTLayer name="UserPoint">
<SrcDataSource>ODBC:un/pw@CLO</SrcDataSource>
<SrcSQL>select PKey as FID, Feature from PointData</SrcSQL>
<GeometryField encoding="WKB" field="Feature"/>
<FID>FID</FID>
</OGRVRTLayer>
</OGRVRTDataSource>
The ODBC connection is to a SQL Express 2008 database. The PointData table is defined as follows:
CREATE TABLE [dbo].[PointData](
[PKey] [int] IDENTITY(1,1) NOT NULL,
[Feature] [geometry] NULL,
CONSTRAINT [PK_PointData] PRIMARY KEY CLUSTERED
(
[PKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
This query
select *, Feature.STAsText() from pointdata
yields
1 0x00000000010C0000000000C062400000000000C06240 POINT (150 150)
"ogrinfo test.ovf --debug on" runs for a very long time returning many lines of this sort of stuff:
ERROR 4: Update access not supported for VRT datasources.
OGR_ODBC: EstablishSession(DSN:"CLO", userid:"un", password:"pw")
ODBC: SQLConnect(CLO)
ODBC: CatalogNameL: (null)
Schema name: (null)
OGR_ODBC: Table PointData has no identified FID column.
OGR_ODBC: Table UserMapData has no identified FID column.
OGR_ODBC: Table CHECK_CONSTRAINTS has no identified FID column.
before finally saying:
OGR: OGROpen(ODBC:un/pw@CLO/02C79D10) succeeded as ODBC.
ODBC: ExecuteSQL(select PKey as FID, Feature from PointData) called.
OGR_ODBC: Table SELECT has no identified FID column.
OGR: OGROpen(test.ovf/00E17090) succeeded as VRT.
Had to open data source read-only.
INFO: Open of `test.ovf'
using driver `VRT' successful.
OGR: GetLayerCount() = 1
1: UserPoint
OGR: ReleaseDataSource(ODBC:un/pw@CLO/02C79D10) dereferenced and now destroying.
ODBC: SQLDisconnect()
GDAL version is 1.6.0.
I have tried using no FID tag and using SrcLayer instead of SrcSQL. Anybody know what I could do to make it see the FID? I'm guessing it would be a lot faster if it didn't check every table in the database for an FID...
Thanks in advance for your assistance.