128
128
/* *************************************************************** */
129
129
int plot1(struct Map_info *Map, int type, int area, struct cat_list *Clist,
130
130
const struct color_rgb *color, const struct color_rgb *fcolor,
131
int chcat, SYMBOL * Symb, int size, int id_flag,
132
int table_colors_flag, int cats_color_flag, char *rgb_column,
133
int default_width, char *width_column, double width_scale,
134
int z_color_flag, char *style)
131
int chcat, char *symbol_name, double size, char *size_column,
132
char *rot_column, int id_flag, int table_colors_flag,
133
int cats_color_flag, char *rgb_column, int default_width,
134
char *width_column, double width_scale, int z_color_flag,
136
137
int i, ltype, nlines = 0, line, cat = -1;
143
144
struct field_info *fi = NULL;
144
145
dbDriver *driver = NULL;
145
dbCatValArray cvarr_rgb, cvarr_width;
146
dbCatVal *cv_rgb = NULL, *cv_width = NULL;
147
int nrec_rgb = 0, nrec_width = 0;
146
dbCatValArray cvarr_rgb, cvarr_width, cvarr_size, cvarr_rot;
147
dbCatVal *cv_rgb = NULL, *cv_width = NULL, *cv_size = NULL, *cv_rot = NULL;
148
int nrec_rgb = 0, nrec_width = 0, nrec_size = 0, nrec_rot = 0;
248
253
if (cvarr_width.ctype != DB_C_TYPE_INT &&
249
254
cvarr_width.ctype != DB_C_TYPE_DOUBLE)
250
G_fatal_error(_("Line width column (%s) not a number."),
255
G_fatal_error(_("Line width column (%s) is not numeric."),
253
258
if (nrec_width < 0)
254
259
G_fatal_error(_("Cannot select data (%s) from table"),
257
G_debug(2, "\n%d records selected from table", nrec_width);
262
G_debug(2, " %d records selected from table", nrec_width);
259
264
for (i = 0; i < cvarr_width.n_values; i++) {
260
G_debug(4, "cat = %d %s = %d", cvarr_width.value[i].cat,
265
G_debug(4, "(width) cat = %d %s = %d", cvarr_width.value[i].cat,
262
267
(cvarr_width.ctype ==
263
268
DB_C_TYPE_INT ? cvarr_width.value[i].val.
274
if (*size_column == '\0')
275
G_fatal_error(_("Symbol size column not specified."));
277
db_CatValArray_init(&cvarr_size);
279
nrec_size = db_select_CatValArray(driver, fi->table, fi->key,
280
size_column, NULL, &cvarr_size);
282
G_debug(3, "nrec_size (%s) = %d", size_column, nrec_size);
284
if (cvarr_size.ctype != DB_C_TYPE_INT &&
285
cvarr_size.ctype != DB_C_TYPE_DOUBLE)
286
G_fatal_error(_("Symbol size column (%s) is not numeric."),
290
G_fatal_error(_("Cannot select data (%s) from table"),
293
G_debug(2, " %d records selected from table", nrec_size);
295
for (i = 0; i < cvarr_size.n_values; i++) {
296
G_debug(4, "(size) cat = %d %s = %d", cvarr_size.value[i].cat,
299
DB_C_TYPE_INT ? cvarr_size.value[i].val.
300
i : (int)cvarr_size.value[i].val.d));
305
if (*rot_column == '\0')
306
G_fatal_error(_("Symbol rotation column not specified."));
308
db_CatValArray_init(&cvarr_rot);
310
nrec_rot = db_select_CatValArray(driver, fi->table, fi->key,
311
rot_column, NULL, &cvarr_rot);
313
G_debug(3, "nrec_rot (%s) = %d", rot_column, nrec_rot);
315
if (cvarr_rot.ctype != DB_C_TYPE_INT &&
316
cvarr_rot.ctype != DB_C_TYPE_DOUBLE)
317
G_fatal_error(_("Symbol rotation column (%s) is not numeric."),
321
G_fatal_error(_("Cannot select data (%s) from table"),
324
G_debug(2, " %d records selected from table", nrec_rot);
326
for (i = 0; i < cvarr_rot.n_values; i++) {
327
G_debug(4, "(rot) cat = %d %s = %d", cvarr_rot.value[i].cat,
330
DB_C_TYPE_INT ? cvarr_rot.value[i].val.
331
i : (int)cvarr_rot.value[i].val.d));
335
if( !(nrec_size || nrec_rot) ) {
336
Symb = S_read(symbol_name);
338
G_warning(_("Unable to read symbol, unable to display points"));
340
S_stroke(Symb, (int)(size + 0.5), 0.0, 0);
269
344
db_close_database_shutdown_driver(driver);
444
519
(Clist->field > 0 ? Clist->field :
446
521
0 ? Cats->field[0] : 1)), &cat);
449
524
G_debug(3, "display element %d, cat %d", line, cat);
451
526
/* Read line width from db for current area # */
453
527
if (db_CatValArray_get_value(&cvarr_width, cat, &cv_width) !=
455
529
width = default_width;
466
540
width = default_width;
471
545
width = default_width;
474
548
D_line_width(width);
475
} /* end if nrec_width */
549
} /* end if nrec_width */
478
552
/* enough of the prep work, lets start plotting stuff */
482
if ((ltype & GV_POINTS) && Symb != NULL) {
556
if ((ltype & GV_POINTS) && (Symb != NULL || (nrec_size || nrec_rot)) ) {
483
557
if (!(color || fcolor || custom_rgb))
492
566
y0 > D_get_d_south() || y0 < D_get_d_north())
569
/* dynamic symbol size */
571
/* only first category */
573
(Clist->field > 0 ? Clist->field :
575
Cats->field[0] : 1)), &cat);
578
G_debug(3, "display element %d, cat %d", line, cat);
580
/* Read symbol size from db for current symbol # */
581
if (db_CatValArray_get_value(&cvarr_size, cat, &cv_size) !=
587
(cvarr_size.ctype == DB_C_TYPE_INT ?
588
(double)cv_size->val.i : cv_size->val.d);
590
if (var_size < 0.0) {
591
G_warning(_("Error in symbol size column (%s), element %d "
592
"with cat %d: symbol size [%f]"),
593
size_column, line, cat, var_size);
601
} /* end if nrec_size */
603
/* dynamic symbol rotation */
605
/* only first category */
607
(Clist->field > 0 ? Clist->field :
609
Cats->field[0] : 1)), &cat);
612
G_debug(3, "display element %d, cat %d", line, cat);
614
/* Read symbol rotation from db for current symbol # */
615
if (db_CatValArray_get_value(&cvarr_rot, cat, &cv_rot) !=
621
(cvarr_rot.ctype == DB_C_TYPE_INT ?
622
(double)cv_rot->val.i : cv_rot->val.d);
628
} /* end if nrec_rot */
630
if(nrec_size || nrec_rot) {
631
G_debug(3, ". dynamic symbol: cat=%d size=%d rotation=%.2f",
632
cat, (int)(var_size + 0.5), rotation);
634
/* symbol stroking is cumulative, so we need to reread it each time */
635
if(Symb) /* unclean free() on first iteration if variables are not init'd to NULL? */
637
Symb = S_read(symbol_name);
639
G_warning(_("Unable to read symbol, unable to display points"));
641
S_stroke(Symb, (int)(var_size + 0.5), rotation, 0);
495
644
/* use random or RGB column color if given, otherwise reset */
496
645
/* centroids always use default color to stand out from underlying area */
497
646
if (custom_rgb && (ltype != GV_CENTROID)) {