Returns the class breaks or unique values for the specified dynamic layer.
[Visual Basic .NET] Public Function GenerateDataClasses ( _ ByVal MapName As String, _ ByVal pTableDescription As IMapTableDescription, _ ByVal pDataClassificationDef As IDataClassificationDef _ ) As IFeatureRenderer
[C#] public IFeatureRenderer GenerateDataClasses ( string MapName, IMapTableDescription pTableDescription, IDataClassificationDef pDataClassificationDef );
[C++]
HRESULT GenerateDataClasses(
BSTR MapName,
IMapTableDescription* pTableDescription,
IDataClassificationDef* pDataClassificationDef,
IFeatureRenderer** ppFeatureRenderer
);
[C++]Parameters
MapName [in] MapName is a parameter of type BSTR pTableDescription [in]pTableDescription is a parameter of type IMapTableDescription
pDataClassificationDef [in]pDataClassificationDef is a parameter of type IDataClassificationDef
ppFeatureRenderer [out, retval]ppFeatureRenderer is a parameter of type IFeatureRenderer
Product Availability
Remarks
GenerateDataClasses is a helper function that allows clients to generate classes based on a classification method or get distinct values from single or multiple fields. This eliminates the need to download entire dataset on the client side to compute class breaks or find out distint values from a field. Since the result is a IFeatureRenderer, the result is primarily used to change the renderer of a layer without needing to access fine grained ArcObjects or restarting a mapservice by simply making coarse grain MapServer function call. Please check IMapServer::Export function help for more information on this.
The type of renderer that is returned by this function depends on DataClassificationDef parameter - for example, if an object of type IClassBreakDef is passed in, the result will be a ClassBreaksRenderer, of if IUniqueValuesDef is passed in you will get back a UniqueValueRenderer object.
Please note that when this function is called with a standalone table as an input parameter, it does not return symbol for each class in the returned IFeatureRenderer unless IDataClassificationDef::BaseSymbol is specified.
You can control the returned symbols in the result by specifying BaseSymbol and/or ColorRamp. If these are not specified, the function returns symbol with default values in case the input is a layer. The default ColorRamp is "Green to Blue". The color of returned symbol is always RgbColor.
This function honors the definition expression set on the queried table or layer.
For performance reason, you should always run this on a base table or layer instead of joined table or table.
Sample code to generate 5 different classes based on LANDVAL field using EqualInterval classification method
IClassBreaksDef pCBDef = new ClassBreaksDef() as IClassBreaksDef;
pCBDef.ClassificationField = "LANDVAL";
pCBDef.ClassificationMethod = esriClassifyMethod.esriClassifyEqualInterval;
pCBDef.BreakCount = 5;
IHsvColor pColorStart = new HsvColor();
pColorStart.Hue = 60;
pColorStart.Saturation = 50;
pColorStart.Value = 100;
IHsvColor pColorMiddle = new HsvColor();
pColorMiddle.Hue = 37;
pColorMiddle.Saturation = 81;
pColorMiddle.Value = 95;
IHsvColor pColorEnd = new HsvColor();
pColorEnd.Hue = 0;
pColorEnd.Saturation = 100;
pColorEnd.Value = 42;
IAlgorithmicColorRamp pAlgorithmicColorRamp1 = new AlgorithmicColorRamp();
pAlgorithmicColorRamp1.FromColor = pColorStart;
pAlgorithmicColorRamp1.ToColor = pColorMiddle;
IAlgorithmicColorRamp pAlgorithmicColorRamp2 = new AlgorithmicColorRamp();
pAlgorithmicColorRamp2.FromColor = pColorMiddle;
pAlgorithmicColorRamp2.ToColor = pColorEnd;
IMultiPartColorRamp pMultiPartColorRamp = new MultiPartColorRamp();
pMultiPartColorRamp.AddRamp(pAlgorithmicColorRamp1);
pMultiPartColorRamp.AddRamp(pAlgorithmicColorRamp2);
pMultiPartColorRamp.Name = "Yellow to Dark Red"; //optional
pCBDef.ColorRamp = pMultiPartColorRamp;
IFeatureRenderer pFeatureRenderer = pMapServer.GenerateDataClasses(strMapName, pLayerDescription, pCBDef);