AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

*Warren M
Message 1 of 3 (186 Views)

FDO/Oracle: execute spatial query against Feature Source

186 Views, 2 Replies
09-13-2005 03:29 PM
Hello all,

I'm getting my feet wet with the dotNet FDO api...

I'm curious to know if there is a way to execute an actual spatial query
against the Feature Source. In other words, not using Map's UI... at
least I couldn't find a emthod via the Map UI to do this???

For example:
I can create the exact query I require in the Oracle Spatial Index Advisor
performing an SDO_RELATE operation to return all lines within a polygon. I
would like to know if it's possible to execute similar queries against the
Feature Source. Or, am I missing something, and way out to lunch on
this... Which is completely possible ;-)

Warren M
Active Member
Posts: 7
Registered: ‎02-09-2005
Message 2 of 3 (186 Views)

Re: FDO/Oracle: execute spatial query against Feature Source

11-03-2005 05:56 PM in reply to: *Warren M
Hi Warren,

To query a feature source using the Map UI, you attach the feature source in the Display Manager, and then go to the "New" drop down on Display Manager to select "Query Feature Source". There are other ways to define the query in Display Manager, but that one is documented in the Autodesk Map 3D 2006 and ESRI ArcSDE Basics white paper.

As far as creating a query programmatically, I have been told that in ARX you can use the AcMapFdoEnabler class to do this. However, I have not found any examples. Also, if you want to render out the entities yourself, you can use the lower level APIs (GisPtr, FDOFilter, etc).

Hope that this helps.
New Member
Posts: 1
Registered: ‎11-07-2005
Message 3 of 3 (186 Views)

Re: FDO/Oracle: execute spatial query against Feature Source

11-07-2005 05:20 PM in reply to: *Warren M
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;

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:


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);
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.