Commit d8abe8f8 authored by Cédric Traizet's avatar Cédric Traizet

BUG: do not set FID field as it hasn't been created

parent 38e4e896
Pipeline #1715 passed with stages
in 43 minutes and 4 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