}
}
+static bool sym_line_same_p(struct symbol *xx, struct symbol *yy)
+{
+ struct sym_line *x = (struct sym_line *) xx;
+ struct sym_line *y = (struct sym_line *) yy;
+
+ if (!(x->width == y->width &&
+ x->color == y->color &&
+ x->opacity == y->opacity &&
+ x->line_cap == y->line_cap &&
+ x->line_join == y->line_join &&
+ x->miter_limit == y->miter_limit &&
+ x->dash_offset == y->dash_offset))
+ return 0;
+
+ if (x->dash_pattern || y->dash_pattern)
+ {
+ if (!x->dash_pattern || !y->dash_pattern)
+ return 0;
+
+ if (GARY_SIZE(x->dash_pattern) != GARY_SIZE(y->dash_pattern))
+ return 0;
+
+ uint dashes = GARY_SIZE(x->dash_pattern);
+ for (uint i=0; i < dashes; i++)
+ if (x->dash_pattern[i] != y->dash_pattern[i])
+ return 0;
+ }
+
+ return 1;
+}
+
struct symbolizer symbolizer_line = {
.name = "line",
.draw = sym_line_draw,
.gen = sym_line_gen,
+ .same_p = sym_line_same_p,
};
struct sym_line *sym_line_new(struct osm_object *o)
#undef CLAMP // FIXME: Fix in libucw?
#define CLAMP(x,min,max) ({ typeof(x) _t=x; (_t < min) ? min : (_t > max) ? max : _t; }) /** Clip a number @x to interval [@min,@max] **/
+static struct symbolizer symbolizer_disabled = {
+ .name = "disabled",
+};
+
static struct symbolizer *symbolizers[] = {
[SYMBOLIZER_INVALID] = NULL,
[SYMBOLIZER_POINT] = &symbolizer_point,
[SYMBOLIZER_AREA] = &symbolizer_area,
[SYMBOLIZER_TEXT] = &symbolizer_text,
[SYMBOLIZER_LINEIMG] = &symbolizer_lineimg,
+ [SYMBOLIZER_DISABLED] = &symbolizer_disabled,
};
struct mempool *sym_mp;
ASSERT(sym->type && sym->type < SYMBOLIZER_MAX);
if (debug_dump_symbols)
printf("Drawing symbol <%s> at z-index %u for %s\n", symbolizers[sym->type]->name, zindex, STK_OSM_NAME(sym->o));
- symbolizers[sym->type]->draw(sym, svg);
+ if (symbolizers[sym->type]->draw)
+ symbolizers[sym->type]->draw(sym, svg);
}
void sym_draw_all(struct svg *svg)
for (uns i = 0; i < GARY_SIZE(sym_planned); i++)
sym_draw(sym_planned[i].sym, sym_planned[i].zindex, svg);
}
+
+void sym_for_all_planned(void (*callback)(struct symbol *s))
+{
+ for (uns i = 0; i < GARY_SIZE(sym_planned); i++)
+ callback(sym_planned[i].sym);
+}
+
+bool sym_same_attrs_p(struct symbol *x, struct symbol *y)
+{
+ if (x->type != y->type)
+ return 0;
+
+ if (!symbolizers[x->type]->same_p)
+ return 0;
+
+ return (*symbolizers[x->type]->same_p)(x, y);
+}
+
+void sym_disable(struct symbol *sym)
+{
+ sym->type = SYMBOLIZER_DISABLED;
+}
SYMBOLIZER_AREA,
SYMBOLIZER_TEXT,
SYMBOLIZER_LINEIMG,
+ SYMBOLIZER_DISABLED,
SYMBOLIZER_MAX,
};
void (*draw)(struct symbol *sym, struct svg *svg);
void (*gen)(struct osm_object *o, struct style_info *si, struct svg *svg);
void (*init)(void);
+ bool (*same_p)(struct symbol *x, struct symbol *y);
};
extern struct mempool *sym_mp;
void *sym_new(enum symbolizer_type type, struct osm_object *o, size_t size);
void sym_plan(struct symbol *sym, z_index_t zindex);
void sym_draw_all(struct svg *svg);
+void sym_for_all_planned(void (*callback)(struct symbol *s));
void sym_from_style(struct osm_object *o, struct style_results *sr, struct svg *svg);
z_index_t sym_zindex(struct osm_object *o, struct style_info *si, double default_mzi);
+bool sym_same_attrs_p(struct symbol *x, struct symbol *y);
+void sym_disable(struct symbol *s);
/* sym-point.c handles point symbols and icons */