[fdo-users] DistanceOperations for sql server 2008

Giorgos Papadakis gpapadak at ims.forth.gr
Fri Feb 5 18:17:10 EST 2010


I am trying to create a spatial query on a sq server 2008 database table 
and get some points by distance
So

OSGeo.FDO.IConnectionManager mConnMgr = 
OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager();
             OSGeo.FDO.Connections.IConnection mProvConn = 
mConnMgr.CreateConnection("OSGeo.SQLServerSpatial.3.4");

             OSGeo.FDO.Connections.IConnectionInfo connInfo = 
mProvConn.ConnectionInfo;
             OSGeo.FDO.Connections.IConnectionPropertyDictionary 
connPropDict = connInfo.ConnectionProperties;
             connPropDict.SetProperty("Username", "sa");
             connPropDict.SetProperty("Password", "xxx");
             connPropDict.SetProperty("Service", "PC\\SQLEXPRESS2008");
             connPropDict.SetProperty("DataStore", "GeocodingXania");
             mProvConn.Open();

             OSGeo.FDO.Expression.Identifier qryPropName;
             qryPropName = new OSGeo.FDO.Expression.Identifier("DataPoint");

             OSGeo.FDO.Commands.Feature.ISelect selCmd = 
(OSGeo.FDO.Commands.Feature.ISelect)mProvConn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Select);

             FgfGeometryFactory geomFactory = new FgfGeometryFactory();
             selCmd.SetFeatureClassName("dbo:GeoData");

             IPoint poi = 
(OSGeo.FDO.Geometry.IPoint)geomFactory.CreateGeometry("POINT(503479 
3930380)");
             IGeometry geom = geomFactory.CreateGeometry(poi);

             //create the byte array required to create the expression
             byte[] byteArray;
             byteArray = geomFactory.GetFgf(geom);
             OSGeo.FDO.Expression.GeometryValue qryGeomVal = new 
OSGeo.FDO.Expression.GeometryValue(byteArray);
             //create the filter
             OSGeo.FDO.Filter.Filter fltr;
             fltr = new OSGeo.FDO.Filter.DistanceCondition(qryPropName, 
OSGeo.FDO.Filter.DistanceOperations.DistanceOperations_Within, 
qryGeomVal, 100);

             //set the filter on the query command
             Console.WriteLine(fltr.ToString());
             selCmd.SetFilter(fltr.ToString());
             IFeatureReader FDOReader = null;
             try
             {
                 FDOReader = selCmd.Execute();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }

The Console.WriteLine(fltr.ToString()); prints
GeoDataPoint WITHINDISTANCE GeomFromText('POINT (503479 3930380)') 100

but i catch this error
RDBMS: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax 
near 'WHERE'

DistanceOperations aren't supported by fdo from sql server 2008?

xterm





More information about the fdo-users mailing list