Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

region GetLookupTable Method

    /// <summary>
    /// GetLookupTable method loops through the fields of a specific 
    /// featureClass and adds them to an Entities.Layer, which is been 
    /// created. Currently is applyed to get the symbology of a layer
    /// </summary>
    /// <param name="pGeoFeatureLayer">IGeoFeatureLayer layer</param>
    /// <param name="eLayer">Entities.Layer layer</param>
    /// <param name="eColumn">Entities.Column current column</param>
    private static void GetLookupTable(IGeoFeatureLayer pGeoFeatureLayer, Entities.Layer eLayer, Entities.Column eColumn)
    {
        // get the index of the field we are interested in
        List<int> constructOidList = new List<int>();
                  constructOidList.Add(-1);
                  constructOidList.Add(1);
                  constructOidList.Add(2);
                  constructOidList.Add(3);
                  constructOidList.Add(4);
                  constructOidList.Add(5);
                  constructOidList.Add(6);
                  constructOidList.Add(7);
                  constructOidList.Add(8);
                  constructOidList.Add(9);
                  constructOidList.Add(10);
                  constructOidList.Add(20);
                  constructOidList.Add(30);
                  constructOidList.Add(33);
           int[] oidList = constructOidList.ToArray();

        try
        {
            IFeatureClass pFeatureClass = (IFeatureClass)pGeoFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.GetFeatures(oidList, false);
            IFeature pFeature = pFeatureCursor.NextFeature();

            IObject pObject = (IObject)pFeature;
            IRow pRow = (IRow)pObject;
            ITable pTable = (ITable)pRow.Table;
            eLayer.IdColumn = pTable.OIDFieldName; // OID field name

             long valueOut = 0;
             bool canConvert = false;
            // loop through the returned features and get the value and name pair for the field
            while (pFeature != null)
            {
                string pValue = pFeature.get_Value(pFeatureClass.FindField(eColumn.Name)).ToString();
                string pLabel = "";

                if (!string.IsNullOrEmpty(pValue))
                {
                    canConvert = long.TryParse(pValue, out valueOut);
                    if (canConvert == true)
                    {
                        eColumn.LookupTable.Values.Add(valueOut, pLabel); // lookup table values
                    }
                }
                pFeature = pFeatureCursor.NextFeature(); 
            }
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFeatureCursor);
        }
        catch(Exception exc) 
        {
            Console.WriteLine(exc.Message);
        }
    }
    #endregion
share|improve this question
    
vs2010, esri 10 –  Roy Sep 20 '12 at 19:04
    
Is there an error or is it not returning the value you expect? Did you debug this? Can you please add more information? –  Jakub Sep 20 '12 at 19:24
    
Thank you for the reply, the code works, the problem is that i need to get the pLabel in some way. Please see how i get the pValue property. I am new to arcobjects and not sure what other info to provide... –  Roy Sep 20 '12 at 20:25
    
all that is missing from this code is a method to get the pLabel value. –  Roy Sep 21 '12 at 3:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.