Commit 603e3fc1 authored by Guillaume Pasero's avatar Guillaume Pasero

BUG: #1989: keep initial interface for ReadInputListSample

parent d1a9186e
Pipeline #3308 passed with stages
in 76 minutes and 32 seconds
......@@ -98,8 +98,8 @@ private:
/** Method returning whether the confidence map should be computed, depending on the regression mode and input parameters */
bool shouldComputeConfidenceMap() const;
/** Method returning the input list sample from the input DataSource */
typename ListSampleType::Pointer ReadInputListSample(ogr::DataSource::Pointer source);
/** Method returning the input list sample from the input layer */
typename ListSampleType::Pointer ReadInputListSample(otb::ogr::Layer const& layer);
/** Normalize a list sample using the statistic file given */
typename ListSampleType::Pointer NormalizeListSample(ListSampleType::Pointer input);
......
......@@ -72,24 +72,30 @@ void VectorPrediction<RegressionMode>::DoUpdateParameters()
}
}
template <bool RegressionMode>
typename VectorPrediction<RegressionMode>::ListSampleType::Pointer VectorPrediction<RegressionMode>::ReadInputListSample(ogr::DataSource::Pointer source)
template <bool RegressionMode>
typename VectorPrediction<RegressionMode>::ListSampleType::Pointer
VectorPrediction<RegressionMode>
::ReadInputListSample(otb::ogr::Layer const& layer)
{
auto layer = source->GetLayer(0);
typename ListSampleType::Pointer input = ListSampleType::New();
const auto nbFeatures = GetSelectedItems("feat").size();
input->SetMeasurementVectorSize(nbFeatures);
ogr::Feature feature = layer.ogr().GetNextFeature();
std::vector<int> featureFieldIndex(nbFeatures, -1);
ogr::Layer::const_iterator it_feat = layer.cbegin();
for (unsigned int i = 0; i < nbFeatures; i++)
{
featureFieldIndex[i] = feature.ogr().GetFieldIndex(GetChoiceNames("feat")[GetSelectedItems("feat")[i]].c_str());
if (featureFieldIndex[i] < 0)
otbAppLogFATAL("The field name for feature " << GetChoiceNames("feat")[GetSelectedItems("feat")[i]].c_str() << " has not been found" << std::endl);
try
{
featureFieldIndex[i] = (*it_feat).GetFieldIndex(GetChoiceNames("feat")[GetSelectedItems("feat")[i]]);
}
catch(...)
{
otbAppLogFATAL("The field name for feature " << GetChoiceNames("feat")[GetSelectedItems("feat")[i]] << " has not been found" << std::endl);
}
}
layer.ogr().ResetReading();
for (auto const& feature : layer)
{
MeasurementType mv(nbFeatures);
......@@ -289,7 +295,7 @@ void VectorPrediction<RegressionMode>::DoExecute()
ogr::DataSource::Pointer source = ogr::DataSource::New(shapefileName, ogr::DataSource::Modes::Read);
auto layer = source->GetLayer(0);
auto input = ReadInputListSample(source);
auto input = ReadInputListSample(layer);
ListSampleType::Pointer listSample = NormalizeListSample(input);
typename LabelListSampleType::Pointer target;
......
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