Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.to.rast: Add points without segfault with densification flag (-d) #3440

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions vector/v.to.rast/dense_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,15 @@ void dense_line(double x1, double y1, double x2, double y2,
}
point(ix2, iy2);
}

/* point plotting, alternative to G_plot_point()
* x, y are col, row numbers */
void plot_point(double east, double north)
Comment on lines +278 to +280
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is an alternative, does that mean that if changes to the G_plot_point() are made, they may need to be kept in sync/compatible with the function here? If so, should we add a note in the comments of G_plot_point() to refer back here (to not forget in the future)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea.

{
int x, y;

x = ifloor(X(G_adjust_easting(east, &st->window)) + 0.5);
y = ifloor(Y(north) + 0.5);
Comment on lines +284 to +285
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why not to use G_plot_where_xy here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

st in G_plot_where_xy() is static and internal to libgis. dense_line.c has its own st.


st->dot(x, y);
}
14 changes: 9 additions & 5 deletions vector/v.to.rast/do_lines.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* function prototypes */
static int plot_line(double *, double *, int, int, int);
static int plot_points(double *, double *, int);
static int plot_points(double *, double *, int, int);
static double v2angle(double[2], double[2], double, double);
static double deg_angle(double, double, double, double);

Expand Down Expand Up @@ -131,7 +131,7 @@ int do_lines(struct Map_info *Map, struct line_pnts *Points,
count++;
}
else if (type & GV_POINTS) {
plot_points(Points->x, Points->y, Points->n_points);
plot_points(Points->x, Points->y, Points->n_points, dense);
count++;
}
}
Expand Down Expand Up @@ -199,11 +199,15 @@ static double deg_angle(double x0, double y0, double x1, double y1)
return (v_ang * 360.0 / M_2PI);
}

static int plot_points(double *x, double *y, int n)
static int plot_points(double *x, double *y, int n, int dense)
{
/* only plot the first point */
if (n > 0)
G_plot_point(*x, *y);
if (n > 0) {
if (dense)
plot_point(*x, *y);
else
G_plot_point(*x, *y);
}

return 0;
}
1 change: 1 addition & 0 deletions vector/v.to.rast/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int do_lines(struct Map_info *, struct line_pnts *, dbCatValArray *, int, int,
struct cat_list *, int, double, int, int, int *, int);

void plot_line_dense(double, double, double, double);
void plot_point(double, double);
void setup_plot(double, double, double, double, int (*dot)(int, int));

/* raster.c */
Expand Down
Loading