Finding in layer

441
6
12-08-2010 03:43 AM
AnatoliiTerentiev
Occasional Contributor III
(arcgis engine in vs 2005 + c#)
I have axMapControl with document .mxd, wich has several groupped layers. And try to make searching in layer elements with certain value of attribute. Now I try use next code:
            ESRI.ArcGIS.esriSystem.IArray pArray;
            ESRI.ArcGIS.Carto.IFind pfind;
            ESRI.ArcGIS.Carto.IFeatureLayer layer;
            layer = (ESRI.ArcGIS.Carto.IFeatureLayer)axMapControl1.get_Layer(6) as ESRI.ArcGIS.Carto.IFeatureLayer;
            pfind = (ESRI.ArcGIS.Carto.IFind)layer;
            pArray = pfind.Find("???????", true, pfind.FindFields, axMapControl1.ActiveView.ScreenDisplay.CancelTracker);
            int i = pArray.Count;

But needed layer included in some group.
Did anybody help me - how i can get access to layer of certain group?
Thanks for any help or reference
0 Kudos
6 Replies
SteveFang
New Contributor III
Look at ICompositelayer.
0 Kudos
AnatoliiTerentiev
Occasional Contributor III
Thank you very much! This cod works -
            ESRI.ArcGIS.esriSystem.IArray pArray;
            ESRI.ArcGIS.Carto.IFind pfind;
            ESRI.ArcGIS.Carto.IFeatureLayer layer;
            ESRI.ArcGIS.Carto.ICompositeLayer layer1;

            layer1 = axMapControl1.get_Layer(0) as ESRI.ArcGIS.Carto.ICompositeLayer; // в�?б�?ал г�?�?пп�?

            layer = layer1.get_Layer(1) as ESRI.ArcGIS.Carto.IFeatureLayer ;  // в�?б�?ал слой
            pfind = (ESRI.ArcGIS.Carto.IFind)layer;

            pArray = pfind.Find("�?�?яжа", true, pfind.FindFields, axMapControl1.ActiveView.ScreenDisplay.CancelTracker);
// на�?ел населенн�?й п�?нк�? "Moscow" .

But it is intresting - how I can point to find string in certain field. It gives an error, when I try like that -


 string[] s = pfind.FindFields as string[];
            pArray = pfind.Find("Point", true, s[6], axMapControl1.ActiveView.ScreenDisplay.CancelTracker);


I now, than string "Moscow" is in field "pointName".
And the two more questions.
2. How I can get value of  the field "shape" of shape type in pArray, and
3. how I can get coordinate of the center of the shape
Thank you for any advice or reference!
0 Kudos
AnatoliiTerentiev
Occasional Contributor III
The goal is to find in  layer (as IFeatureLayer)
I try as following way
            ESRI.ArcGIS.Geodatabase.IQueryFilter qf = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            qf.WhereClause = "Name='moscow'";
            layer.FeatureClass.Select(qf, ESRI.ArcGIS.Geodatabase.esriSelectionType.esriSelectionTypeIDSet,
                ESRI.ArcGIS.Geodatabase.esriSelectionOption.esriSelectionOptionNormal, ESRI.ArcGIS.Geodatabase.IWorkspace selectionContainer);

But I can"t find how to set a value of the last parameter - selectionContainer.
Can't anybody help? And is it right way?
Thanks for any help or reference
0 Kudos
Venkata_RaoTammineni
Occasional Contributor
Hi,

Either you have to specify workspace if that one is available with you...or make it null.

Something like this....

ESRI.ArcGIS.Geodatabase.IQueryFilter qf = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            qf.WhereClause = "Name='moscow'";
            layer.FeatureClass.Select(qf, ESRI.ArcGIS.Geodatabase.esriSelectionType.esriSelectionTypeIDSet,
                ESRI.ArcGIS.Geodatabase.esriSelectionOption.esriSelectionOptionNormal, null);

Thanks and Regards
0 Kudos
AnatoliiTerentiev
Occasional Contributor III
Hi,
and
1. how I can get some fiels from result of type ESRI.ArcGIS.Geodatabase.ISelectionSet
2. can't I use somethink like that
1. У ва�?его IFeatureLayer пол�?�?ае�?е IFeatureClass
2. У IFeatureClass в�?полняе�?е Select п�?едва�?и�?ел�?но создав IQueryFilter и записав �?�?да �?е�?ез ме�?од WhereClause �?�?о-�?о �?ипа [Field_Name] Like "�?�?яжа"
3. �? �?ез�?л�?�?а�?е в�?полнения ме�?ода Select возв�?а�?ае�?ся IFeatureCursor
4. У IFeatureCursor в�?з�?ваем ме�?од NextFeature ко�?о�?�?й возв�?а�?ае�? IFeature
5. У IFeature зап�?а�?иваем геоме�?�?и�? �?е�?ез свойс�?во Shape - возв�?а�?ае�? IGeometry (для зап�?оса зна�?ений а�?�?иб�?�?ов испол�?з�?ем свойс�?во Value, ко�?о�?ое возв�?а�?ае�? VARIANT)
6. �?�?еоб�?аз�?ем IGeometry к �?ип�? IArea и в�?зовем ме�?од QueryCentroid или QueryLabelPoint в зависимос�?и о�? �?ого �?�?о в�? �?о�?и�?е пол�?�?и�?�?.

The goal is to get coordinates of the center of the shapeType field.
Thanks for any advice or reference!
0 Kudos
AnatoliiTerentiev
Occasional Contributor III
I get the field, wich contain the value of shape type
           ESRI.ArcGIS.Geodatabase.IQueryFilter qf = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            qf.WhereClause = "Номе�? = 2";

            ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = layer.FeatureClass.Search(qf, false);
            ESRI.ArcGIS.Geodatabase.IFeature feature = featureCursor.NextFeature();
            ESRI.ArcGIS.Geometry.IGeometry shape = feature.Shape as ESRI.ArcGIS.Geometry.IGeometry;

And now the question is - how get coordinate of the shape value?
I think, that shape must be converted to IArea value and the I will use QueryCentroid or QueryLabelPoint method

Thanks!
0 Kudos