The following code is an example of a simple rectangular query...
public void readFDO ()
{
Autodesk.Gis.Map.FdoEnabler.Query query;
string source;
Autodesk.Gis.Map.FdoEnabler.ClassName cls;
Autodesk.Gis.Map.FdoEnabler.QueryElement element;
Autodesk.Gis.Map.FdoEnabler.SpatialWhereComponent where;
Autodesk.Gis.Map.FdoEnabler.ObjectIdExCollection collection;
Autodesk.AutoCAD.ApplicationServices.Document document;
try
{
query = Autodesk.Gis.Map.FdoEnabler.Query.Create (getContext ());
query.Name = "myQuery";
source = getFeatureSourceName ();
if (null != source)
{
query.AddFeatureSource (source);
cls = getFeatureClassName (source);
if (null != cls)
{
where = Autodesk.Gis.Map.FdoEnabler.SpatialWhereComponent.Create ();
where.BoundaryType = Autodesk.Gis.Map.FdoEnabler.SpatialBoundaryType.Polygon;
where.IsInside = true;
where.GeometryPropertyName = getGeometryProperty (source, cls);
where.BoundaryGeometry = ?????;
element = Autodesk.Gis.Map.FdoEnabler.QueryElement.Create (cls);
query.AddQueryElement (element);
element.AddCondition (where, false);
collection = new Autodesk.Gis.Map.FdoEnabler.ObjectIdExCollection ();
query.Execute (collection);
}
}
}
catch (Autodesk.Gis.Map.MapFdoEnablerException err)
{
GetEditor().WriteMessage (err.Message);
}
}
The difficult part is getting the polygon value for the BoundaryGeometry, which is an IntPtr so we're talking unmanaged code.
You can use the following code, but it has to be wrapped to make it available to .net:
#include
void* MakePolygonGeometry (double x1, double y1, double x2, double y2)
{
int type;
int dimensionality;
int parts;
int count;
double* coordinates;
GisByteArray* ret;
ret = GisByteArray::Create ();
type = 3; // GisGeometryType_Polygon
dimensionality = 0; // GisDimensionality_XY -- affects # of doubles for coordinates
parts = 1; // only one part
count = 5; // four corners and back to start
coordinates = new double[2 * count];
coordinates[0] = x1;
coordinates[1] = y1;
coordinates[2] = x2;
coordinates[3] = y1;
coordinates[4] = x2;
coordinates[5] = y2;
coordinates[6] = x1;
coordinates[7] = y2;
coordinates[8] = x1;
coordinates[9] = y1;
ret = GisByteArray::Append (ret, sizeof(type), (GisByte*)&type);
ret = GisByteArray::Append (ret, sizeof(dimensionality), (GisByte*)&dimensionality);
ret = GisByteArray::Append (ret, sizeof(parts), (GisByte*)&parts);
ret = GisByteArray::Append (ret, sizeof(count), (GisByte*)&count);
ret = GisByteArray::Append (ret, sizeof(double) * 2 * count, (GisByte*)coordinates);
return (ret);
}