Select to view content in your preferred language

Features to ILayer, symbology and oracle sdo

1534
6
06-17-2010 03:38 AM
LiorY
by
Deactivated User
1. I Have FeatureClass (SDE Table). I want to create ILayer object that will contain some of the features, according to filter.
So I Created a IQueryFilter, and i got IFetureCursor with the features i need. But now how i convert it to an ILayer object?
I thought about creating new featureclass (IFeatureWorkspace.CrateFeatureClass), and add those features to it, but it seems a lot of work, and i need to take care each time to delete this FC (because it's temporary FC). I'm sure there is an easier way.

2. I have Layer of points. I want to chenge the symbology, so i created IPictureMarkerSymbol, but when
i used the CreateSymbolFromPicture method (the path is valid and bmp file), i see in debug mode that the Picture property is set to "Catastrophic failure..."

3. Is there a converter which convert SDO Geometry to ESRI's IGeometry?
0 Kudos
6 Replies
AlexanderGray
Honored Contributor
I think there is some confusion here.
1.  There is no such thing as an ILayer object.  ILayer is an interface.  There is a class FeatureLayer that can be cocreated (new) into an object.  The FeatureLayer class implements the ILayer interface.  The FeatureLayer also implements the IfeatureLayer interface that has a write property of featureclass.  This is where you set a reference to your featureclass.  The FeatureLayer class also implements an interface called Ifeaturelayerdefinition where you can put a where clause to filter the featureclass.

2. There a quite a few intermediate steps to setting a symbol to a point layer.  I suggest looking and the SimpleRenderer class and the Create Picture Marker Symbol Snippet in the documentation.

3. SDO Geometry is a storage format for shapes in Oracle.  IGeometry is an interface on geometry classes suchs PolygonClass, PointClass etc.  An IGeometry is not a storage format.  It is part of the arcobjects API that allows you to manipulate the geometry in memory.  Arcobjects takes care of reading the SDO Geometry into memory and allows you access to that space in memory throught the IGeometry.  There is no conversion possible since IGeometry is not a data format.
0 Kudos
StefanOffermann
Deactivated User
Hi,

just let me add some things to Alexanders good posting. First, you describe three problems in one thread. For the sake of simplicity, open one thread per problem.

1) The normal approach is to create a feature layer and set the feature class as data source of the layer. By setting a definition query, you can filter out some features based on a SQL query.

Here are some steps to write the desired code:
Create an FeatureLayer object using the new keyword, cast to IFeatureLayer interface.
Open the feature class from your SDE workspace and set it to the FeatureClass property of the created IFeatureLayer object.
Cast the IFeatureLayer object to IFeatureLayerDefinition and set the desired Definition Query by using the DefinitionExpression property.
You can then add the IFeatureLayer object to the FocusMap.

3) Do you want to access the geometry of the feature class? The geometry of a feature class (a point, a line, a polygon, ...) can be retrieved by the Shape property of the IFeature class. When you open a feature class from an Oracle SDE workspace, the Shape could be stored in the geodatabase using the SDO_Geometry format. In ArcObjects, you are normally not interested of the exact format type.

Second note: When you read the Shape property, you get an object of type IGeometry. You would normally cast it to the corresponding geometry class, eg IPoint, IPolyLine, IPolygon ...

I hope this helps. Best regards, Stefan
0 Kudos
KirkKuykendall
Deactivated User
0 Kudos
LiorY
by
Deactivated User
First, thanx for all the replies.

Second,
About question #2, I looked in the documentation, but i don't see nothing wrong with my code
About question #3, My intention was that after i made a "select" command, say "select shape from layer where sdo_distance(...)", I want to get those shapes and do actions with them, so I want to convert it to Arcobjects...I'm sure it's possible...
0 Kudos
KirkKuykendall
Deactivated User
For question 2, please post your code.

question 3: If I were going to work with SDO geometry as a featurelayer in 9.3.1 or earilier, I would write a plugindatasource.  See this sample.

Instead of having it read from a text file though, I'd have it read from Oracle.

I'd use Oracle's SDO_UTIL.TO_WKBGEOMETRY to convert into WKB, then use IWkb.ImportFromWkb to convert into IGeometry.
IWkb is implemented by point, polyline and polyline classes (even though this is not documented).

Again, at 10.0 the QueryLayers do all this for you.
0 Kudos
LiorY
by
Deactivated User
I will take a look on this WKB...

about the code, here it is:
==============================================
string path = @"C:\pic.bmp";
IPictureMarkerSymbol sym = new PictureMarkerSymbolClass();
sym.CreateMarkerSymbolFromFile(esriIPictureBitmap, path);
==============================================

Now, when i'm debugging it, after the last line, when i watch the sym.Picture property i see the catastrophic failure exception...
0 Kudos