Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. void draw_curve(unsigned i, ezgl::renderer &g, float x1, float x2, float y1, float y2) {
  2.  
  3. int numCurvePoints = getInfoStreetSegment(i).curvePointCount;
  4.  
  5. //if the street segment has curve points you must draw line from curve point to vruve point
  6. if (numCurvePoints > 0) {
  7.  
  8. //gets the first curve point
  9. LatLon curve = getStreetSegmentCurvePoint(0, i);
  10.  
  11. //X and Y coordinates for the curve point
  12. float pointX = x_from_lon(curve.lon());
  13. float pointY = y_from_lat(curve.lat());
  14.  
  15. //draws the line from the from point to first curve point
  16. g.draw_line({x1, y1},
  17. {
  18. pointX, pointY
  19. });
  20.  
  21. //iterates through all the curve points and draws the lines from all the inbetween curve points
  22. for (int j = 0; j < numCurvePoints - 1; j++) {
  23.  
  24. //first curve point
  25. LatLon fromPoint = getStreetSegmentCurvePoint(j, i);
  26.  
  27. //second curve point
  28. LatLon toPoint = getStreetSegmentCurvePoint(j + 1, i);
  29.  
  30. //X and Y coordinates of the curve points
  31. float fromPointX = x_from_lon(fromPoint.lon());
  32. float fromPointY = y_from_lat(fromPoint.lat());
  33. float toPointX = x_from_lon(toPoint.lon());
  34. float toPointY = y_from_lat(toPoint.lat());
  35. //draw from point to the next point
  36. g.draw_line({fromPointX, fromPointY},
  37. {
  38. toPointX, toPointY
  39. });
  40. }
  41.  
  42. //after drawing all the curve points in between this draws from the last curve point to the "to" point
  43. curve = getStreetSegmentCurvePoint(numCurvePoints - 1, i);
  44.  
  45. //X and Y coordinates for the last curve point
  46. pointX = x_from_lon(curve.lon());
  47. pointY = y_from_lat(curve.lat());
  48. g.draw_line({pointX, pointY},
  49. {
  50. x2, y2
  51. });
  52. } //if there are no curve points just draw a straight line
  53. else if (numCurvePoints == 0) {
  54. g.draw_line({x1, y1},
  55. {
  56. x2, y2
  57. });
  58.  
  59. }
  60. //THIS WAS THE PREVIOUS METHOD
  61. // for (std::multimap<unsigned, curves_info>::iterator it_curve = curvesMap.begin(); it_curve != curvesMap.end(); it_curve++) {
  62. // g.set_color(ezgl::WHITE);
  63. // g.set_line_width(1);
  64. // g.draw_line({it_curve->second.before_x, it_curve->second.before_y},
  65. // {
  66. // it_curve->second.curve_x, it_curve->second.curve_y
  67. // });
  68. //
  69. // if (it_curve->second.curved_point_index == segments[it_curve->first].info.curvePointCount - 1) {
  70. // g.draw_line({it_curve->second.curve_x, it_curve->second.curve_y},
  71. // {
  72. // it_curve->second.after_x, it_curve->second.after_y
  73. // });
  74. //
  75. // }
  76. // }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement