43 static struct line_pnts *Points =
NULL;
44 struct line_cats *Cats =
NULL;
45 geopoint *top, *gpt, *prev;
47 struct Cell_head wind;
60 Vect_set_open_level(1);
61 if (Vect_open_old(&map,
name,
"") == -1) {
66 Points = Vect_new_line_struct();
67 Cats = Vect_new_cats_struct();
69 top = gpt = (geopoint *)G_malloc(
sizeof(geopoint));
70 G_zero(gpt,
sizeof(geopoint));
76 Vect_set_constraint_region(&map, wind.north, wind.south, wind.east,
77 wind.west, PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX);
82 if (Vect_is_3d(&map)) {
88 ltype = Vect_read_next_line(&map, Points, Cats);
91 G_warning(_(
"Unable to read vector map <%s>"),
101 if ((ltype & GV_POINTS)) {
103 gpt->p3[
X] = Points->x[0];
104 gpt->p3[
Y] = Points->y[0];
108 gpt->p3[Z] = Points->z[0];
115 if (Cats->n_cats > 0) {
117 Cats = Vect_new_cats_struct();
120 Vect_reset_cats(Cats);
123 gpt->highlighted = 0;
125 G_debug(5,
"loading vector point %d x=%f y=%f ncats=%d", np,
126 Points->x[0], Points->y[0], Cats->n_cats);
129 (geopoint *)G_malloc(
sizeof(geopoint));
130 G_zero(gpt->next,
sizeof(geopoint));
148 _(
"No points from vector map <%s> fall within current region"),
153 G_message(_(
"Vector map <%s> loaded (%d points)"),
176 struct field_info *Fi;
178 int nvals, cat, npts, nskipped;
186 if (!gp || !gp->tstyle || !gp->filename)
194 Vect_set_open_level(1);
195 if (Vect_open_old(&Map, gp->filename,
"") == -1) {
200 Fi = Vect_get_field(&Map, gp->tstyle->layer);
202 G_warning(_(
"Database connection not defined for layer %d"),
206 driver = db_start_driver_open_database(Fi->driver, Fi->database);
208 G_fatal_error(_(
"Unable to open database <%s> by driver <%s>"),
209 Fi->database, Fi->driver);
211 G_message(_(
"Loading thematic points layer <%s>..."),
214 for (gpt = gp->points; gpt; gpt = gpt->next) {
215 gpt->style = (gvstyle *)G_malloc(
sizeof(gvstyle));
216 G_zero(gpt->style,
sizeof(gvstyle));
219 gpt->style->color = gp->style->color;
220 gpt->style->symbol = gp->style->symbol;
221 gpt->style->size = gp->style->size;
222 gpt->style->width = gp->style->width;
226 Vect_cat_get(gpt->cats, gp->tstyle->layer, &cat);
234 if (!Rast_get_c_color((
const CELL *)&cat, &red, &grn, &blu,
236 G_warning(_(
"No color rule defined for category %d"), cat);
237 gpt->style->color = gp->style->color;
239 gpt->style->color = (red &
RED_MASK) +
243 if (gp->tstyle->color_column) {
244 nvals = db_select_value(
driver, Fi->table, Fi->key, cat,
245 gp->tstyle->color_column, &value);
248 str = db_get_value_string(&value);
252 G_warning(_(
"Invalid color definition (%s)"), str);
253 gpt->style->color = gp->style->color;
256 gpt->style->color = (red &
RED_MASK) +
263 if (gp->tstyle->size_column) {
264 nvals = db_select_value(
driver, Fi->table, Fi->key, cat,
265 gp->tstyle->size_column, &value);
268 gpt->style->size = db_get_value_int(&value);
272 if (gp->tstyle->width_column) {
273 nvals = db_select_value(
driver, Fi->table, Fi->key, cat,
274 gp->tstyle->width_column, &value);
277 gpt->style->width = db_get_value_int(&value);
281 if (gp->tstyle->symbol_column) {
282 nvals = db_select_value(
driver, Fi->table, Fi->key, cat,
283 gp->tstyle->symbol_column, &value);
286 str = db_get_value_string(&value);
295 _(
"%d points without category. "
296 "Unable to determine color rules for features without category."),
int G_str_to_color(const char *str, int *red, int *grn, int *blu)
Parse color string and set red,green,blue.