Column::GetCategoricalMap

Description

Get the column which stores the Categorical Map.

Syntax

CategoricalMap GetCategoricalMap()

Example

Run the following code with a worksheet active and print out if a column is categorical or not.

void check_is_categorical()
{
        Worksheet wks=Project.ActiveLayer();
        for(int ii=0;ii<wks.GetNumCols();ii++)
        {
                Column cc = wks.Columns(ii);
                CategoricalMap cmap = cc.GetCategoricalMap();
                printf("%d: column %s ", ii, cc.GetName());
                if(cmap)
                        printf("is categorical\n");
                else
                        printf("is NOT categorical\n");
        }       
}

The following example shows how to use it on worksheet columns

void MyCategoricalMap()
{ 
    Worksheet wks=Project.ActiveLayer();
    if (wks)
    { 
                vector<string> vstrKey={"aa", "cc", "bb", "dd"};  //design your own categories map
                for(int ii=0;ii<5;ii+=2){
                wks.Columns(ii).SetAsCategorical(CMT_NOMINAL); //set column into categorical with normal mode
                wks.Columns(ii).GetCategoricalMap().ReplaceMap(vstrKey);  //update the categorical map
                }       
    }
}

Remark

See Also

Column::SetAsCategorical

header to Included

origin.h