Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void draw_curve(unsigned i, ezgl::renderer &g, float x1, float x2, float y1, float y2) {
- int numCurvePoints = getInfoStreetSegment(i).curvePointCount;
- //if the street segment has curve points you must draw line from curve point to vruve point
- if (numCurvePoints > 0) {
- //gets the first curve point
- LatLon curve = getStreetSegmentCurvePoint(0, i);
- //X and Y coordinates for the curve point
- float pointX = x_from_lon(curve.lon());
- float pointY = y_from_lat(curve.lat());
- //draws the line from the from point to first curve point
- g.draw_line({x1, y1},
- {
- pointX, pointY
- });
- //iterates through all the curve points and draws the lines from all the inbetween curve points
- for (int j = 0; j < numCurvePoints - 1; j++) {
- //first curve point
- LatLon fromPoint = getStreetSegmentCurvePoint(j, i);
- //second curve point
- LatLon toPoint = getStreetSegmentCurvePoint(j + 1, i);
- //X and Y coordinates of the curve points
- float fromPointX = x_from_lon(fromPoint.lon());
- float fromPointY = y_from_lat(fromPoint.lat());
- float toPointX = x_from_lon(toPoint.lon());
- float toPointY = y_from_lat(toPoint.lat());
- //draw from point to the next point
- g.draw_line({fromPointX, fromPointY},
- {
- toPointX, toPointY
- });
- }
- //after drawing all the curve points in between this draws from the last curve point to the "to" point
- curve = getStreetSegmentCurvePoint(numCurvePoints - 1, i);
- //X and Y coordinates for the last curve point
- pointX = x_from_lon(curve.lon());
- pointY = y_from_lat(curve.lat());
- g.draw_line({pointX, pointY},
- {
- x2, y2
- });
- } //if there are no curve points just draw a straight line
- else if (numCurvePoints == 0) {
- g.draw_line({x1, y1},
- {
- x2, y2
- });
- }
- //THIS WAS THE PREVIOUS METHOD
- // for (std::multimap<unsigned, curves_info>::iterator it_curve = curvesMap.begin(); it_curve != curvesMap.end(); it_curve++) {
- // g.set_color(ezgl::WHITE);
- // g.set_line_width(1);
- // g.draw_line({it_curve->second.before_x, it_curve->second.before_y},
- // {
- // it_curve->second.curve_x, it_curve->second.curve_y
- // });
- //
- // if (it_curve->second.curved_point_index == segments[it_curve->first].info.curvePointCount - 1) {
- // g.draw_line({it_curve->second.curve_x, it_curve->second.curve_y},
- // {
- // it_curve->second.after_x, it_curve->second.after_y
- // });
- //
- // }
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement