*new = *e;
e->next = new;
- switch (e->label->type)
- {
- case SYMBOLIZER_TEXT:
- new->label = xmalloc(sizeof(struct sym_text));
- *((struct sym_text *) new->label) = *((struct sym_text *) e->label);
- break;
- default:
- ;
- }
+ new->label = sym_copy(e->label);
struct osm_node *n1 = e->n1->o;
struct osm_node *n2 = e->n2->o;
svg_set_attr(svg, "font-style", osm_val_decode(font->style));
}
+static struct symbol * sym_text_copy(struct symbol *sym)
+{
+ struct sym_text *t = (struct sym_text *) sym;
+
+ struct sym_text *new = xmalloc(sizeof(struct sym_text));
+ *new = *t; // FIXME: Is this OK? with respect to pointer fields...
+
+ return (struct symbol *) new;
+}
+
static void sym_text_draw(struct symbol *sym, struct svg *svg)
{
struct sym_text *t = (struct sym_text *) sym;
.draw = sym_text_draw,
.gen = sym_text_gen,
.init = sym_text_init,
+ .copy = sym_text_copy,
};
struct sym_text *sym_text_new(struct osm_object *o)
for (uns i = 0; i < GARY_SIZE(sym_planned); i++)
sym_draw(sym_planned[i].sym, sym_planned[i].zindex, svg);
}
+
+struct symbol * sym_copy(struct symbol *sym)
+{
+ ASSERT(sym->type && sym->type < SYMBOLIZER_MAX);
+ if (symbolizers[sym->type]->copy)
+ return symbolizers[sym->type]->copy(sym);
+ else
+ return NULL;
+}
void (*draw)(struct symbol *sym, struct svg *svg);
void (*gen)(struct osm_object *o, struct style_info *si, struct svg *svg);
void (*init)(void);
+ struct symbol* (*copy)(struct symbol *sym);
};
extern struct mempool *sym_mp;
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);
+struct symbol * sym_copy(struct symbol *sym);
+
/* sym-point.c handles point symbols and icons */
struct sym_point {