i have 100 x,y coordinate sepaated by comma such as 2553499,6749612
2558073,6749475
2558562,6749717
the firest colomun is x, and the second is y.
I have tried to read this as array and splited in to two. the Pseudocode to impliment land is as follow
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <cmath>
- #include<fstream>
- #include <vector>
- #include <string>
- using namespace std;
- int main ()
- {
- vector< vector<double> > data;
- ifstream myFile("Z://data1.csv");
- if (myFile.is_open())
- {
- while(!myFile.eof())
- {
- string aLine;
- getline(myFile,aLine);
- int comma_pos;
- comma_pos=aLine.find(',',0);
- string xst,yst;
- xst=aLine.substr(0,comma_pos);
- yst=aLine.substr(comma_pos + 1,aLine.length()-comma_pos- 1);
- double xt,yt;
- xt=atof(xst.c_str());
- yt=atof(yst.c_str());
- myFile>> xt >> yt;
- vector <double> vertex;
- vertex.push_back(xt);
- vertex.push_back(yt);
- data.push_back(vertex);
- data.pop_back();
- }
- myFile.close();
- }
- else{
- cout << "unable to open the \n";
- exit(1);
- }
- }
- function lang(PointList[], Tolerance)
- key=0
- endP= PointList.length-1
- do {
- endP= PointList.length-1
- if (key+1 != endP) // If there are intermediate points
- line= new Line( PointList[key], PointList[endP])
- /* Find the point with the furthest perpendicular distance */
- maxIndex= key+1
- maxD= perpendicularDistance(line, PointList[maxIndex])
- for (i=maxIndex+1; i<endP; i++)
- d= perpendicularDistance(line, PointList[i])
- if (d > maxD)
- maxIndex=i
- maxD=d
- if (maxD > Tolerance)
- endP--;
- else
- for (i=key+1; i<endP; i++)
- PointList.remove(i)
- key= endP
- } while ( endP != PointList.length-1 )
- end