20 double center_easting;
21 double center_northing;
38 static struct robject *draw_line_vertices();
39 static void draw_line_nodes(
struct Map_info *,
int,
int,
43 static struct robject *robj_alloc(
int,
int);
45 static double dist_in_px(
double);
46 static void en_to_xy(
double,
double,
int *,
int *);
47 static void draw_arrow(
int,
int,
int,
int,
double,
int,
int,
63 double center_easting,
64 double center_northing,
int map_width,
65 int map_height,
double map_res)
73 region.center_easting = center_easting;
74 region.center_northing = center_northing;
75 region.map_width = map_width;
76 region.map_height = map_height;
77 region.map_res = map_res;
78 region.map_west = center_easting - (map_width / 2.) * map_res;
79 region.map_north = center_northing + (map_height / 2.) * map_res;
83 state.nitems_alloc = 1000;
94 for (i = 0; i < nfeat; i++) {
96 draw_area(Map, fid, list_obj);
103 G_debug(1,
"Vedit_render_map(): region: w=%f, e=%f, s=%f, n=%f nlines=%d",
104 box->
W, box->
E, box->
S, box->
N, nfeat);
107 for (i = 0; i < list->
n_values; i++) {
109 robj = draw_line(Map, fid, draw_flag);
112 list_append(list_obj, robj);
117 robj = draw_line_vertices();
120 list_append(list_obj, robj);
124 draw_line_nodes(Map, fid, draw_flag, list_obj);
128 draw_line_dir(list_obj, fid);
138 G_debug(1,
"Vedit_render_map(): -> nitems = %d",
149 struct robject *draw_line(
struct Map_info *Map,
int line,
int draw_flag)
174 if (left == 0 && right == 0) {
178 else if (left > 0 && right > 0) {
200 else if (cret == 0) {
210 G_debug(3,
" draw_line(): type=%d rtype=%d npoints=%d draw=%d",
219 robj_points(obj,
state.Points);
227 void en_to_xy(
double east,
double north,
int *
x,
int *
y)
231 w = region.center_easting - (region.map_width / 2) * region.map_res;
232 n = region.center_northing + (region.map_height / 2) * region.map_res;
235 *
x = (east - w) / region.map_res;
237 *y = (n - north) / region.map_res;
245 void draw_line_nodes(
struct Map_info *Map,
int line,
int draw_flag,
259 for (i = 0; i <
sizeof(nodes) /
sizeof(
int); i++) {
277 robj = robj_alloc(type, 1);
278 en_to_xy(east, north, &x, &y);
283 list_append(list, robj);
293 state.nitems_alloc += 1000;
320 struct robject *draw_line_vertices()
328 for (i = 1; i <
state.Points->n_points - 1; i++) {
329 en_to_xy(
state.Points->x[i],
state.Points->y[i], &x, &y);
345 double dist, angle, pos;
354 G_debug(5,
" draw_line_dir() line=%d", line);
356 if (dist_in_px(dist) >= limit) {
358 pos = (narrows + 1) * 8 * limit * region.map_res;
365 en_to_xy(e, n, &x0, &y0);
368 (
state.Points, pos - 3 * size * region.map_res, &e, &n,
NULL,
373 en_to_xy(e, n, &x1, &y1);
375 draw_arrow(x0, y0, x1, y1, angle, size, line, list);
389 en_to_xy(e, n, &x0, &y0);
392 (
state.Points, dist - 3 * size * region.map_res, &e, &n,
395 en_to_xy(e, n, &x1, &y1);
397 draw_arrow(x0, y0, x1, y1, angle, size, line, list);
409 double dist_in_px(
double dist)
413 en_to_xy(region.map_west + dist, region.map_north, &x, &y);
421 void draw_arrow(
int x0,
int y0,
int x1,
int y1,
double angle,
int size,
int line,
430 angle_symb = angle -
M_PI / 2.;
431 robj->
point[0].
x = (int)x1 + size * cos(angle_symb);
432 robj->
point[0].
y = (int)y1 - size * sin(angle_symb);
437 angle_symb =
M_PI / 2. + angle;
438 robj->
point[2].
x = (int)x1 + size * cos(angle_symb);
439 robj->
point[2].
y = (int)y1 - size * sin(angle_symb);
441 list_append(list, robj);
449 int i, centroid, isle;
471 robj_points(robj,
state.Points);
472 list_append(list, robj);
476 for (i = 0; i < num_isles; i++) {
484 robj_points(robj, ipoints);
485 list_append(list, robj);
499 for (i = 0; i < points->
n_points; i++) {
500 en_to_xy(points->
x[i], points->
y[i], &x, &y);
void Vect_destroy_boxlist(struct boxlist *)
Frees all memory associated with a struct boxlist, including the struct itself.
int Vect_get_area_isle(const struct Map_info *, int, int)
Returns isle id for area.
int Vect_select_areas_by_box(struct Map_info *, const struct bound_box *, struct boxlist *)
Select areas with bounding boxes by box.
int Vect_get_area_centroid(const struct Map_info *, int)
Returns centroid id for given area.
int n_points
Number of points.
int Vect_get_area_num_isles(const struct Map_info *, int)
Returns number of isles for given area.
int Vect_isle_alive(const struct Map_info *, int)
Check if isle is alive or dead (topological level required)
double Vect_line_length(const struct line_pnts *)
Calculate line length, 3D-length in case of 3D vector line.
int n_values
Number of items in the list.
#define GV_POINT
Feature types used in memory on run time (may change)
int Vect_get_node_n_lines(const struct Map_info *, int)
Get number of lines for node.
int Vect_get_node_coor(const struct Map_info *, int, double *, double *, double *)
Get node coordinates.
double * x
Array of X coordinates.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
Feature geometry info - coordinates.
int Vect_get_centroid_area(const struct Map_info *, int)
Get area id the centroid is within.
struct robject_list * Vedit_render_map(struct Map_info *Map, struct bound_box *box, int draw_flag, double center_easting, double center_northing, int map_width, int map_height, double map_res)
Render vector features into list.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_get_isle_points(const struct Map_info *, int, struct line_pnts *)
Returns polygon array of points for given isle.
int Vect_area_alive(const struct Map_info *, int)
Check if area is alive or dead (topological level required)
int Vect_get_line_nodes(const struct Map_info *, int, int *, int *)
Get line nodes.
double * y
Array of Y coordinates.
List of bounding boxes with id.
int Vect_line_alive(const struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_point_on_line(const struct line_pnts *, double, double *, double *, double *, double *, double *)
Find point on line in the specified distance.
struct boxlist * Vect_new_boxlist(int)
Creates and initializes a struct boxlist.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_get_area_points(const struct Map_info *, int, struct line_pnts *)
Returns polygon array of points (outer ring) of given area.
int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int G_debug(int, const char *,...) __attribute__((format(printf
int Vect_get_line_areas(const struct Map_info *, int, int *, int *)
Get area id on the left and right side of the boundary.
int Vect_get_line_type(const struct Map_info *, int)
Get line type.