20 #include <grass/gis.h>
21 #include <grass/colors.h>
22 #include <grass/raster.h>
23 #include <grass/vector.h>
24 #include <grass/dbmi.h>
25 #include <grass/glocale.h>
26 #include <grass/ogsf.h>
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);
92 G_warning(_(
"Unable to read vector map <%s>"),
102 if ((ltype & GV_POINTS)) {
104 gpt->p3[
X] = Points->x[0];
105 gpt->p3[
Y] = Points->y[0];
109 gpt->p3[Z] = Points->z[0];
116 if (Cats->n_cats > 0) {
118 Cats = Vect_new_cats_struct();
121 Vect_reset_cats(Cats);
124 gpt->highlighted = 0;
126 G_debug(5,
"loading vector point %d x=%f y=%f ncats=%d",
127 np, Points->x[0], Points->y[0], Cats->n_cats);
129 gpt->next = (geopoint *) G_malloc(
sizeof(geopoint));
130 G_zero(gpt->next,
sizeof(geopoint));
148 G_warning(_(
"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, colors)) {
235 G_warning(_(
"No color rule defined for category %d"), cat);
236 gpt->style->color = gp->style->color;
241 if (gp->tstyle->color_column) {
242 nvals = db_select_value(
driver, Fi->table, Fi->key, cat, gp->tstyle->color_column, &value);
245 str = db_get_value_string(&value);
249 G_warning(_(
"Invalid color definition (%s)"),
251 gpt->style->color = gp->style->color;
260 if (gp->tstyle->size_column) {
261 nvals = db_select_value(
driver, Fi->table, Fi->key, cat, gp->tstyle->size_column, &value);
264 gpt->style->size = db_get_value_int(&value);
268 if (gp->tstyle->width_column) {
269 nvals = db_select_value(
driver, Fi->table, Fi->key, cat, gp->tstyle->width_column, &value);
272 gpt->style->width = db_get_value_int(&value);
276 if (gp->tstyle->symbol_column) {
277 nvals = db_select_value(
driver, Fi->table, Fi->key, cat, gp->tstyle->symbol_column, &value);
280 str = db_get_value_string(&value);
288 G_warning(_(
"%d points without category. "
289 "Unable to determine color rules for features without category."),