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

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