[fdo-users] Problems with FDO: Creating a spatial Filter
hanko
hana.jaborova at spatialtechnology.se
Mon May 31 08:51:08 EDT 2010
I'm using OSGeo.KingOracle.3.4 provider. Current Culture of my application
is {sv-SE}
I'm attempting to create a spatial filter. I'm hitting a problem with the
code below:
1.
using (FgfGeometryFactory geomFactory = new FgfGeometryFactory())
{
//create a geometry
IPolygon poly =
(OSGeo.FDO.Geometry.IPolygon)geomFactory.CreateGeometry("POLYGON(( 1.23
4.56, 2.34 4.56, 2.34 5.78, 1.23 5.78,1.23 4.56))");
//create the byte array required to create the expression
byte[] byteArray = geomFactory.GetFgf(poly);
OSGeo.FDO.Expression.GeometryValue qryGeomVal = new
OSGeo.FDO.Expression.GeometryValue(byteArray);
//create the filter
OSGeo.FDO.Filter.Filter fltr;
fltr = new OSGeo.FDO.Filter.SpatialCondition("Geom",
OSGeo.FDO.Filter.SpatialOperations.SpatialOperations_Intersects,
qryGeomVal);
string filterStr = fltr.ToString();
//set the filter on the query command
select.SetFilter(fltr.ToString());
}
Value of filterStr in the debugger is:
"Geom INTERSECTS GeomFromText('POLYGON ((1 4, 2 4, 2 5, 1 5, 1 4))')"
(decimal part of number disappeared )
2.
using (FgfGeometryFactory geomFactory = new FgfGeometryFactory())
{
//create a geometry from a poly
IDirectPosition pos1 = geomFactory.CreatePositionXY(1.23, 4.56);
IDirectPosition pos2 = geomFactory.CreatePositionXY(2.34, 4.56);
IDirectPosition pos3 = geomFactory.CreatePositionXY(2.34, 5.78);
IDirectPosition pos4 = geomFactory.CreatePositionXY(1.23, 5.78);
IDirectPosition pos5 = geomFactory.CreatePositionXY(1.23, 4.56);
DirectPositionCollection coll = new DirectPositionCollection();
coll.Add(pos1);
coll.Add(pos2);
coll.Add(pos3);
coll.Add(pos4);
coll.Add(pos5);
ILinearRing ring = (ILinearRing)geomFactory.CreateLinearRing(coll);
IPolygon poly =
(OSGeo.FDO.Geometry.IPolygon)geomFactory.CreatePolygon(ring, null);
//create the byte array required to create the expression
byte[] byteArray = geomFactory.GetFgf(poly);
OSGeo.FDO.Expression.GeometryValue qryGeomVal = new
OSGeo.FDO.Expression.GeometryValue(byteArray);
//create the filter
OSGeo.FDO.Filter.Filter fltr;
fltr = new OSGeo.FDO.Filter.SpatialCondition("Geom",
OSGeo.FDO.Filter.SpatialOperations.SpatialOperations_Intersects,
qryGeomVal);
string filterStr = fltr.ToString();
//set the filter on the query command
select.SetFilter(fltr.ToString());
}
Value of filterStr in the debugger is:
"Geom INTERSECTS GeomFromText('POLYGON ((1,23 4,56, 2,34 4,56, 2,34 5,78,
1,23 5,78, 1,23 4,56))')" (dot was replaced by comma)
Any ideas?
Cheers
Hanko
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Problems-with-FDO-Creating-a-spatial-Filter-tp5121675p5121675.html
Sent from the FDO Users mailing list archive at Nabble.com.
More information about the fdo-users
mailing list