473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I am trying to impliment line simplification using c++. any help will be appreatiated

I am trying to impliment lang line simplification algorism.
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
  1. #include <iostream>
  2. #include <cmath>
  3. #include<fstream>
  4. #include <vector>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int main ()
  9. {
  10.     vector< vector<double> > data;
  11.     ifstream myFile("Z://data1.csv");
  12.     if (myFile.is_open())
  13.     {
  14.         while(!myFile.eof())
  15.         {
  16.  
  17.         string aLine;
  18.         getline(myFile,aLine);
  19.         int comma_pos;
  20.         comma_pos=aLine.find(',',0);
  21.         string xst,yst;
  22.         xst=aLine.substr(0,comma_pos);
  23.         yst=aLine.substr(comma_pos + 1,aLine.length()-comma_pos- 1);
  24.         double xt,yt;
  25.         xt=atof(xst.c_str());
  26.         yt=atof(yst.c_str());
  27.         myFile>> xt >> yt;
  28.         vector <double> vertex;
  29.         vertex.push_back(xt);
  30.         vertex.push_back(yt);
  31.         data.push_back(vertex);
  32.         data.pop_back();
  33.                       }
  34.         myFile.close();
  35.          }
  36.  
  37.     else{
  38.         cout << "unable to open the \n";
  39.         exit(1);
  40.  
  41. }
  42. }
  43. function lang(PointList[], Tolerance)
  44.  key=0
  45.  endP= PointList.length-1
  46.  do {
  47.    endP= PointList.length-1
  48.    if (key+1 != endP) // If there are intermediate points
  49.      line= new Line( PointList[key], PointList[endP])
  50.      /* Find the point with the furthest perpendicular distance */
  51.      maxIndex= key+1
  52.      maxD= perpendicularDistance(line, PointList[maxIndex])
  53.      for (i=maxIndex+1; i<endP; i++)
  54.        d= perpendicularDistance(line, PointList[i])
  55.        if (d > maxD)
  56.          maxIndex=i
  57.          maxD=d
  58.      if (maxD > Tolerance)
  59.        endP--;
  60.      else
  61.        for (i=key+1; i<endP; i++)
  62.          PointList.remove(i)
  63.        key= endP
  64.  } while ( endP != PointList.length-1 )
  65. end
  66.  
how can i impliment this pseudo code? any help will be appreateated.
Apr 16 '14 #1
0 974

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Looks Like Trent | last post by:
Find a character in a string, at a specified position. How do you do this? Any help will be appreciated....
11
by: srinivas | last post by:
Hi all, I have one requirement.Is there any way to create a line graph using javascript.If it is please send me the sample code.But the thing is it should work in all browsers. Thanks,...
5
by: Rated R1 | last post by:
I wrote this before in the NGs, so I am going to paste the responses that I got and see if someone can please help me. Email me and we can set something up as Id even be willing to pay for your...
2
by: Abubakar | last post by:
Hi, NOTE: in the following code Rectangle is a struct inside the System.Drawing namespace. I'v a following code: Rectangle GetFillRectangle(ref Rectangle rect) { Rectangle newrect;...
5
by: Lyle A. Sieren | last post by:
I posted this earlier with another question but did not explain myself well... How do get a line feed character on the end of a line using the streamwriter.writeline fuction? Following are a list...
1
by: jgill | last post by:
Have problems with the recordset…if the value of tempPremium is more than > 10,000 than I get no results after this statement executes: set rsDownPayment =...
3
by: tess1243 | last post by:
How to give a line break using CSS? Is this possible?
3
by: growthndevlpmnt | last post by:
Ok so I'm supposed to be taking a input text file and justifying it. I've have gotten the text to do character justification bar the last line. I'm trying to figure out how to iterate over each space...
1
by: rush2hem | last post by:
I am trying to build a query which will give me unique rows. Details:- Table 1 (F1, F2 are the columns) F1 F2 1 A1 2 A2 3 A3 4 A4 Table 2 (F3,F4 are the columns) F3 F4
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.