From 191978f0e0af5bd74ecaf883405a8f0635f2f527 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gregor=20J=C3=A4ger?= <g.jaeger@fz-juelich.de>
Date: Mon, 4 Feb 2019 11:30:19 +0100
Subject: [PATCH] issue98, tests

---
 methods/Method_D.cpp |  2 +-
 methods/PedData.cpp  | 24 +++++++++++++++++-------
 methods/PedData.h    |  1 +
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/methods/Method_D.cpp b/methods/Method_D.cpp
index 560dafa7..4bba99fd 100644
--- a/methods/Method_D.cpp
+++ b/methods/Method_D.cpp
@@ -137,7 +137,7 @@ bool Method_D::Process (const PedData& peddata,const std::string& scriptsLocatio
           }
           vector<int> ids=_peds_t[frameNr];
           vector<int> IdInFrame = peddata.GetIdInFrame(frameNr, ids, zPos_measureArea);
-          vector<double> XInFrame = peddata.GetXInFrame(frameNr, ids, zPos_measureArea);
+          //    vector<int> RealIdInFrame = peddata.GetRealIdInFrame(frameNr, ids, zPos_measureArea);
           vector<double> YInFrame = peddata.GetYInFrame(frameNr, ids, zPos_measureArea);
           vector<double> VInFrame = peddata.GetVInFrame(frameNr, ids, zPos_measureArea);
           //vector int to_remove
diff --git a/methods/PedData.cpp b/methods/PedData.cpp
index 5cae0000..c08333b3 100644
--- a/methods/PedData.cpp
+++ b/methods/PedData.cpp
@@ -29,7 +29,7 @@
 #include "PedData.h"
 #include <cmath>
 #include <string>
-
+#include <set>
 using std::string;
 using std::map;
 using std::vector;
@@ -47,6 +47,7 @@ PedData::~PedData()
 bool PedData::ReadData(const string& projectRootDir, const string& path, const string& filename, const FileFormat& trajformat, int deltaF, std::string vComponent, const bool IgnoreBackwardMovement)
 {
      _minID = INT_MAX;
+     _maxID = INT_MAX;
      _minFrame = INT_MAX;
      _deltaF = deltaF;
      _vComponent = vComponent;
@@ -217,10 +218,13 @@ bool PedData::InitializeVariables(const string& filename)
           Log->Write("INFO:\t Finished reading the data");
 
      }
+
      fdata.close();
      Log->Write("INFO: Got %d lines", _IdsTXT.size());
      _minID = *min_element(_IdsTXT.begin(),_IdsTXT.end());
+     _maxID = *max_element(_IdsTXT.begin(),_IdsTXT.end());
      Log->Write("INFO: minID: %d", _minID);
+     Log->Write("INFO: maxID: %d", _maxID);
      _minFrame = *min_element(_FramesTXT.begin(),_FramesTXT.end());
      Log->Write("INFO: minFrame: %d", _minFrame);
      //Total number of frames
@@ -229,15 +233,19 @@ bool PedData::InitializeVariables(const string& filename)
 
      //Total number of agents
      std::vector<int> unique_ids = _IdsTXT;
-     // no need to
+
+    // no need to
      //sort. Assume that ids are ascendant
-     sort(unique_ids.begin(), unique_ids.end());
-     std::vector<int>::iterator it;
-     it = unique(unique_ids.begin(), unique_ids.end());
-     unique_ids.resize(distance(unique_ids.begin(),it));
+
+    std::set<int> s;
+    for( auto a: _IdsTXT )
+    {
+        s.insert( a );
+    }
+    unique_ids.assign( s.begin(), s.end() );
      _numPeds = unique_ids.size();
      Log->Write("INFO: Total number of Agents: %d", _numPeds);
-     CreateGlobalVariables(_numPeds, _numFrames);
+    CreateGlobalVariables(_numPeds, _numFrames);
      Log->Write("INFO: Create Global Variables done");
 
 
@@ -302,6 +310,8 @@ bool PedData::InitializeVariables(const string& filename)
           _xCor(ID,frm) = x;
           _yCor(ID,frm) = y;
           _zCor(ID,frm) = z;
+         //_IdsTXT[i]
+         //unique_ids
           if(_vComponent == "F")
           {
                _vComp(ID,frm) = vcmp[i];
diff --git a/methods/PedData.h b/methods/PedData.h
index 4b174a49..b15bd371 100644
--- a/methods/PedData.h
+++ b/methods/PedData.h
@@ -90,6 +90,7 @@ private:
      std::string _projectRootDir="";
      int _minFrame=0;
      int _minID=1;
+     int _maxID=0;
      int _numFrames=0;  // total number of frames
      int _numPeds=0; // total number of pedestrians
      float _fps=16;
-- 
GitLab