AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FDO/Oracle: execute spatial query against Feature Source

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
502 Views, 3 Replies

FDO/Oracle: execute spatial query against Feature Source

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
3 REPLIES 3
Message 2 of 4
JohnNoZ
in reply to: Anonymous

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.
Message 3 of 4
DerrickOswald
in reply to: Anonymous

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);
}
Message 4 of 4

Hi dear Derrick.

I've read this post looking some solution to ArcSDE connection.

Do u have some sample code to create a connection to ArcSDE?

Thx,

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost