sukhjitk50

Remove duplicate symbols from UniqueValueRenderer

Discussion created by sukhjitk50 on Aug 19, 2020
Latest reply on Aug 28, 2020 by Hornbydd

I have a feature layer with 500 unique values in the UniqueValueRenderer. It's supposed to only have 2 because 499 of them are identical. How do I programmatically remove duplicate symbols from the renderer?

 

More details:

I have a Graphics Layer that I want converted to Feature Layer. The new feature layer needs a UniqueValueRenderer.

My graphics layer for example has 499 identical symbols and one other symbol. I need a UVR that will have only 2 values +  DefaultSymbol

Right now, I have successfully created the desired feature layer out of the graphics layer, but I see 500 Symbols in the TOC control, which I had no choice but to add add to the UVR. 

As I am adding new values to the UVR while going through the graphics container of the graphics layer, I tried checking that specific symbol already exists in the UVR, but it kept coming back saying I don't even though I know for a fact it does. I can see in the debugger that coming in symbol's characterists are identical to the one that already exists in UVR but the .Equals always came back False. So, yes, I ended up makeing 500 unique values when I only wanted (should've needed) 2.

 

Sample Code:

IElement element = graphicsLayerGC.Next();

ILineSymbol passedInSymbol =  (element as ILineElement).Symbol;  

 

string rendVal = UVRend.Value[0];
ILineSymbol rendSymbol = UVRend.Symbol[rendVal] as ILineSymbol;

 

//find out if duplicate

if(passedInSymbol.Equals(rendSymbol))

{

      //This statement should be true, but never is.

}

 

I am only able to see if passedInSymbol's and rendSymbol's characteristics are identical while using "Watch" during debugging.

If I hover on these two while debugging all I can see is this for both. I wanted to see things like Color, Width, etc.

Any help will be appreciated.

 

Thanks!

Outcomes