Commit 68978a6d authored by Marina Bertolino's avatar Marina Bertolino

BUG: mantis-1339 transform key to alphanumeric in OGRLayerClassifier

parent 5a8ea781
......@@ -113,12 +113,22 @@ private:
otb::ogr::Feature feature = layer.ogr().GetNextFeature();
ClearChoices("feat");
std::vector<std::string> choiceKeys;
for(int iField=0; iField<feature.ogr().GetFieldCount(); iField++)
{
std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
key = item;
key.erase(std::remove(key.begin(), key.end(), ' '), key.end());
// Transform chain : lowercase and alphanumerical
key.erase(std::remove_if(key.begin(), key.end(), std::not1(std::ptr_fun(::isalnum))), key.end());
std::transform(key.begin(), key.end(), key.begin(), tolower);
// Key must be unique
choiceKeys = GetChoiceKeys("feat");
while(choiceKeys.end() != std::find(choiceKeys.begin(), choiceKeys.end(), key) )
key.append("0");
key="feat."+key;
AddChoice(key,item);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment