Commit 43f06085 authored by Cédric Traizet's avatar Cédric Traizet

Merge branch 'fix_invalid_index' into 'develop'

Fix error : Invalid index -1

See merge request !512
parents f19f72ae d8abe8f8
Pipeline #1728 passed with stages
in 6 minutes and 12 seconds
......@@ -828,9 +828,13 @@ unsigned int OGRIOHelper
// Get the key of the Nth OGRFieldRefn
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
int fIndex = ogrFeature->GetFieldIndex(key);
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
int fIndex = ogrFeature->GetFieldIndex(key);
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
}
}
// ogrFeature->SetField("Name", dataNode->GetNodeId());
......@@ -916,10 +920,13 @@ unsigned int OGRIOHelper
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
int fIndex = ogrFeature->GetFieldIndex(key);
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
}
}
ogrFeature->SetGeometry(ogrPolygon);
if (ogrCurrentLayer->CreateFeature(ogrFeature) != OGRERR_NONE)
......@@ -1049,7 +1056,6 @@ std::vector<OGRLayer*> OGRIOHelper
GDT_Unknown,
0);
}
std::vector<OGRLayer*> ogrLayerVector;
//unsigned int kept = 0;
bool fieldsAddedToOGRLayer = false;
......@@ -1188,7 +1194,12 @@ std::vector<OGRLayer*> OGRIOHelper
// Get the key of the Nth OGRFieldRefn
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
}
}
ogrFeature->SetGeometry(&ogrLine);
......@@ -1259,8 +1270,11 @@ std::vector<OGRLayer*> OGRIOHelper
{
// Get the key of the Nth OGRFieldRefn
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
}
}
ogrFeature->SetGeometry(ogrPolygon);
......
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