From acba2058e8e4983e6c21c69e02f7bebcfe891d90 Mon Sep 17 00:00:00 2001
From: Ludovic Hussonnois <ludovic.hussonnois@c-s.fr>
Date: Tue, 31 Jan 2017 11:03:35 +0100
Subject: [PATCH] ENH: Mantis-1350 : Parse input file with geometries points
 with space or tab character.

---
 .../app/otbGenerateRPCSensorModel.cxx         | 26 +++++++------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx
index be181ebb32..f640e072e7 100644
--- a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx
+++ b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx
@@ -60,7 +60,13 @@ private:
     SetDescription("Generate a RPC sensor model from a list of Ground Control Points.");
 
     SetDocName("Generate a RPC sensor model");
-    SetDocLongDescription("This application generates a RPC sensor model from a list of Ground Control Points. At least 20 points are required for estimation wihtout elevation support, and 40 points for estimation with elevation support. Elevation support will be automatically deactivated if an insufficient amount of points is provided. The application can optionnaly output a file containing accuracy statistics for each point, and a vector file containing segments represening points residues. The map projection parameter allows defining a map projection in which the accuracy is evaluated.");
+    SetDocLongDescription( "This application generates a RPC sensor model from a list of Ground Control Points. "
+                                   "At least 20 points are required for estimation without elevation support, "
+                                   "and 40 points for estimation with elevation support. "
+                                   "Elevation support will be automatically deactivated if an insufficient amount of points is provided. "
+                                   "The application can optionally output a file containing accuracy statistics for each point,"
+                                   " and a vector file containing segments representing points residues. "
+                                   "The map projection parameter allows defining a map projection in which the accuracy is evaluated." );
 
     AddDocTag(Tags::Geometry);
 
@@ -72,7 +78,7 @@ private:
     SetParameterDescription("outgeom","Geom file containing the generated RPC sensor model");
 
     AddParameter(ParameterType_InputFilename,"inpoints","Input file containing tie points");
-    SetParameterDescription("inpoints","Input file containing tie points. Points are stored in following format: col row lon lat. Line beginning with # are ignored.");
+    SetParameterDescription("inpoints","Input file containing tie points. Points are stored in following format: col row lon lat. Spaced by a space or tab character. Line beginning with # are ignored.");
 
     AddParameter(ParameterType_OutputFilename,"outstat","Output file containing output precision statistics");
     SetParameterDescription("outstat","Output file containing the following info: ref_lon ref_lat elevation predicted_lon predicted_lat x_error_ref(meters) y_error_ref(meters) global_error_ref(meters) x_error(meters) y_error(meters) overall_error(meters)");
@@ -125,20 +131,8 @@ private:
     // Avoid commented lines or too short ones
     if (!line.empty() && line[0] != '#')
       {
-      // retrieve the x component
-      std::string::size_type pos = 0;
-      std::string::size_type nextpos = line.find_first_of("\t", pos);
-      x = atof(line.substr(pos, nextpos).c_str());
-      pos = nextpos + 1;
-      nextpos = line.find_first_of("\t", pos);
-      y = atof(line.substr(pos, nextpos).c_str());
-      pos = nextpos + 1;
-      nextpos = line.find_first_of("\t", pos);
-      lon = atof(line.substr(pos, nextpos).c_str());
-      pos = nextpos + 1;
-      nextpos = line.find_first_of("\t", pos);
-      lat = atof(line.substr(pos, nextpos).c_str());
-
+      std::istringstream iss(line);
+      iss >> x >> y >> lon >> lat;
       z = otb::DEMHandler::Instance()->GetHeightAboveEllipsoid(lon,lat);
 
       otbAppLogINFO("Adding tie point x="<<x<<", y="<<y<<", z="<<z<<", lon="<<lon<<", lat="<<lat);
-- 
GitLab