[fdo-users] DistanceOperations for sql server 2008
Dan Stoica
dan.stoica at autodesk.com
Fri Feb 5 20:15:22 EST 2010
Distance operations are not supported. Please see GetDistanceOperations on filter capabilities.
I had a quick look and it doesn't seem that SqlServer 2008 supports natively the "distance" operator. Am I wrong?
Dan.
-----Original Message-----
From: fdo-users-bounces at lists.osgeo.org [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Giorgos Papadakis
Sent: Friday, February 05, 2010 6:17 PM
To: fdo-users at lists.osgeo.org
Subject: [fdo-users] DistanceOperations for sql server 2008
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
_______________________________________________
fdo-users mailing list
fdo-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-users
More information about the fdo-users
mailing list