[fdo-users] How to Create Spatial Filter

surrounded Rob.Sosnowski at itd.idaho.gov
Thu Oct 2 13:21:00 EDT 2008


I am trying to create a filter that will allow me to intersect a circle
geometry with a shapefile layer, returning only the features from the
shapefile that meet the intersection criteria.  The following code does not
produce errors, BUT the reader object has no values in it.  PLEASE LET ME
KNOW WHERE MY LOGIC IS WRONG OR IF YOU HAVE AN EXAMPLE SPATIAL QUERY THAT I
COULD TWEAK TO WORK FOR MY NEEDS.    THANKS .....


//CREATE CIRCLE GEOMETRY
FgfGeometryFactory gFac = new FgfGeometryFactory();
IDirectPosition startPos = gFac.CreatePositionXY(longitude - 1.0, latitude);
IDirectPosition midPos = gFac.CreatePositionXY(longitude, latitude + 1.0);
IDirectPosition endPos = gFac.CreatePositionXY(longitude - 1.0, latitude);
ICircularArcSegment pCircleSegs = gFac.CreateCircularArcSegment(startPos,
midPos, endPos);
CurveSegmentCollection pCSC = new CurveSegmentCollection();
pCSC.Add(pCircleSegs);         
IRing pRing = gFac.CreateRing(pCSC);
RingCollection pRC = new RingCollection();
pRC.Add(pRing);                    
ICurvePolygon pCPoly = gFac.CreateCurvePolygon(pRing, pRC);
//IEnvelope pEnv = pCPoly.Envelope;
IGeometry pGeom = gFac.CreateGeometry(pCPoly); 

//CONVERT GEOMETRY INTO BYTE ARRAY TO CREATE FILTER
byte[] pByte = gFac.GetFgf(pGeom);
OSGeo.FDO.Expression.GeometryValue pGVal = new GeometryValue(pByte); 

//BUILD THE SPATIAL FILTER                   
OSGeo.FDO.Expression.Identifier pPropName = new Identifier("Geometry");
IdentifierCollection pIDColl = sel.PropertyNames;
pIDColl.Add(pPropName);
OSGeo.FDO.Filter.Filter pPtLineFilter = new
OSGeo.FDO.Filter.SpatialCondition(pPropName,
OSGeo.FDO.Filter.SpatialOperations.SpatialOperations_Inside, pGVal);

OSGeo.FDO.Commands.Feature.IFeatureReader reader = sel.Execute();
while (reader.ReadNext())
{
    ....CODE....
}
-- 
View this message in context: http://n2.nabble.com/How-to-Create-Spatial-Filter-tp1134432p1134432.html
Sent from the FDO Users mailing list archive at Nabble.com.



More information about the fdo-users mailing list