Skip to content
Snippets Groups Projects
Commit b40ca582 authored by Julien Malik's avatar Julien Malik
Browse files

ENH: increment NodeID during DataNode creations

parent c04edc45
No related branches found
No related tags found
No related merge requests found
......@@ -122,6 +122,13 @@ private:
LabeledSampleLocalizationGenerator(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
std::string GetNextID()
{
std::ostringstream oss;
oss << m_CurrentID++;
return oss.str();
}
RandomGeneratorType::Pointer m_RandomGenerator;
std::string m_ClassKey;
......@@ -130,6 +137,7 @@ private:
double m_InhibitionRadius;
unsigned long int m_NbMaxIteration;
unsigned int m_NumberOfPositiveSamplesPerPoint;
unsigned int m_CurrentID;
};
} // end namespace otb
......
......@@ -32,7 +32,8 @@ LabeledSampleLocalizationGenerator<TVectorData>
m_RandomLocalizationDensity(.005),
m_InhibitionRadius(5.0),
m_NbMaxIteration(10000),
m_NumberOfPositiveSamplesPerPoint(50)
m_NumberOfPositiveSamplesPerPoint(50),
m_CurrentID(0)
{
this->SetNumberOfRequiredInputs(1);
this->SetNumberOfRequiredOutputs(1);
......@@ -210,7 +211,19 @@ LabeledSampleLocalizationGenerator<TVectorData>
{
if (itVector.Get()->IsPointFeature())
{
this->GetOutput(0)->GetDataTree()->Add(itVector.Get(), document);
// Duplicate input feature
typename DataNodeType::Pointer currentGeometry = DataNodeType::New();
currentGeometry->SetNodeId(this->GetNextID());
currentGeometry->SetNodeType(otb::FEATURE_POINT);
currentGeometry->SetPoint(itVector.Get()->GetPoint());
std::vector<std::string> fields = itVector.Get()->GetFieldList();
for (std::vector<std::string>::const_iterator it = fields.begin(); it != fields.end(); ++it)
{
currentGeometry->SetFieldAsString( *it, itVector.Get()->GetFieldAsString(*it) );
}
this->GetOutput(0)->GetDataTree()->Add(currentGeometry, document);
}
++itVector;
}
......@@ -234,21 +247,21 @@ LabeledSampleLocalizationGenerator<TVectorData>
for (typename PointVectorType::const_iterator it = vPoint.begin(); it != vPoint.end(); ++it)
{
typename DataNodeType::Pointer CurrentGeometry = DataNodeType::New();
CurrentGeometry->SetNodeId("FEATURE_POINT");
CurrentGeometry->SetNodeType(otb::FEATURE_POINT);
CurrentGeometry->SetPoint(*it);
CurrentGeometry->SetFieldAsInt(this->GetClassKey(), this->GetNoClassIdentifier());
this->GetOutput(0)->GetDataTree()->Add(CurrentGeometry, document);
typename DataNodeType::Pointer currentGeometry = DataNodeType::New();
currentGeometry->SetNodeId(this->GetNextID());
currentGeometry->SetNodeType(otb::FEATURE_POINT);
currentGeometry->SetPoint(*it);
currentGeometry->SetFieldAsInt(this->GetClassKey(), this->GetNoClassIdentifier());
this->GetOutput(0)->GetDataTree()->Add(currentGeometry, document);
}
for (typename PointVectorType::const_iterator it = pPoint.begin(); it != pPoint.end(); ++it)
{
typename DataNodeType::Pointer CurrentGeometry = DataNodeType::New();
CurrentGeometry->SetNodeId("FEATURE_POINT");
CurrentGeometry->SetNodeType(otb::FEATURE_POINT);
CurrentGeometry->SetPoint(*it);
CurrentGeometry->SetFieldAsInt(this->GetClassKey(), 1);
this->GetOutput(0)->GetDataTree()->Add(CurrentGeometry, document);
typename DataNodeType::Pointer currentGeometry = DataNodeType::New();
currentGeometry->SetNodeId(this->GetNextID());
currentGeometry->SetNodeType(otb::FEATURE_POINT);
currentGeometry->SetPoint(*it);
currentGeometry->SetFieldAsInt(this->GetClassKey(), 1);
this->GetOutput(0)->GetDataTree()->Add(currentGeometry, document);
}
}
++itVector;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment