16static struct _region {
17 double center_easting;
18 double center_northing;
34static struct robject *draw_line_vertices(
void);
38static struct robject *robj_alloc(
int,
int);
40static double dist_in_px(
double);
41static void en_to_xy(
double,
double,
int *,
int *);
42static void draw_arrow(
int,
int,
int,
int,
double,
int,
int,
59 double center_easting,
60 double center_northing,
int map_width,
61 int map_height,
double map_res)
69 region.center_easting = center_easting;
70 region.center_northing = center_northing;
71 region.map_width = map_width;
72 region.map_height = map_height;
73 region.map_res = map_res;
74 region.map_west = center_easting - (map_width / 2.) * map_res;
75 region.map_north = center_northing + (map_height / 2.) * map_res;
79 state.nitems_alloc = 1000;
89 for (i = 0; i <
nfeat; i++) {
98 G_debug(1,
"Vedit_render_map(): region: w=%f, e=%f, s=%f, n=%f nlines=%d",
102 for (i = 0; i <
list->n_values; i++) {
112 robj = draw_line_vertices();
166 if (left == 0 && right == 0) {
170 else if (left > 0 && right > 0) {
192 else if (
cret == 0) {
202 G_debug(3,
" draw_line(): type=%d rtype=%d npoints=%d draw=%d",
state.type,
210 obj->npoints =
state.Points->n_points;
221void en_to_xy(
double east,
double north,
int *
x,
int *
y)
225 w = region.center_easting - (region.map_width / 2) * region.map_res;
226 n = region.center_northing + (region.map_height / 2) * region.map_res;
229 *
x = (east - w) / region.map_res;
231 *
y = (n - north) / region.map_res;
253 for (i = 0; i <
sizeof(
nodes) /
sizeof(
int); i++) {
272 en_to_xy(east, north, &x, &y);
286 if (
list->nitems >=
state.nitems_alloc) {
287 state.nitems_alloc += 1000;
312struct robject *draw_line_vertices(
void)
321 for (i = 1; i <
state.Points->n_points - 1; i++) {
322 en_to_xy(
state.Points->x[i],
state.Points->y[i], &x, &y);
323 robj->point[i - 1].x =
x;
324 robj->point[i - 1].y = y;
338 double dist,
angle, pos;
347 G_debug(5,
" draw_line_dir() line=%d", line);
349 if (dist_in_px(dist) >= limit) {
351 pos = (
narrows + 1) * 8 * limit * region.map_res;
358 en_to_xy(e, n, &x0, &
y0);
361 pos - 3 * size * region.map_res, &e, &n,
366 en_to_xy(e, n, &x1, &y1);
368 draw_arrow(x0,
y0, x1, y1,
angle, size, line,
list);
382 en_to_xy(e, n, &x0, &
y0);
385 dist - 3 * size * region.map_res, &e, &n,
388 en_to_xy(e, n, &x1, &y1);
390 draw_arrow(x0,
y0, x1, y1,
angle, size, line,
list);
402double dist_in_px(
double dist)
406 en_to_xy(region.map_west + dist, region.map_north, &x, &y);
414void draw_arrow(
int x0,
int y0,
int x1,
int y1,
double angle,
int size,
427 robj->point[1].x = x0;
442 int i, centroid,
isle;
492 for (i = 0; i < points->
n_points; i++) {
493 en_to_xy(points->
x[i], points->
y[i], &x, &y);
494 robj->point[i].x =
x;
495 robj->point[i].y = y;
void G_free(void *)
Free allocated memory.
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_get_line_nodes(struct Map_info *, int, int *, int *)
Get line nodes.
int Vect_get_node_coor(struct Map_info *, int, double *, double *, double *)
Get node coordinates.
double Vect_line_length(const struct line_pnts *)
Calculate line length, 3D-length in case of 3D vector line.
int Vect_area_alive(struct Map_info *, int)
Check if area 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.
int Vect_get_line_type(struct Map_info *, int)
Get line type.
struct boxlist * Vect_new_boxlist(int)
Creates and initializes a struct boxlist.
void Vect_destroy_boxlist(struct boxlist *)
Frees all memory associated with a struct boxlist, including the struct itself.
int Vect_get_isle_points(struct Map_info *, int, struct line_pnts *)
Returns polygon array of points for given isle.
int Vect_get_area_points(struct Map_info *, int, struct line_pnts *)
Returns polygon array of points (outer ring) of given area.
int Vect_get_centroid_area(struct Map_info *, int)
Get area id the centroid is within.
int Vect_isle_alive(struct Map_info *, int)
Check if isle is alive or dead (topological level required)
int Vect_get_area_isle(struct Map_info *, int, int)
Returns isle id for area.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_get_area_num_isles(struct Map_info *, int)
Returns number of isles for given area.
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_select_areas_by_box(struct Map_info *, const struct bound_box *, struct boxlist *)
Select areas with bounding boxes by box.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
int Vect_get_node_n_lines(struct Map_info *, int)
Get number of lines for node.
int Vect_get_area_centroid(struct Map_info *, int)
Returns centroid id for given area.
int Vect_get_line_areas(struct Map_info *, int, int *, int *)
Get area id on the left and right side of the boundary.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
#define GV_POINT
Feature types used in memory on run time (may change)
List of bounding boxes with id.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
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.