]> mj.ucw.cz Git - leo.git/blobdiff - sym-line.c
Symbols: Comparison, disabling, and iterating
[leo.git] / sym-line.c
index 09dcee4d73c7f8e7fc6c811d1b46a0ad913dfac3..74d6d56df8678ec4faac11dab9c2e5d7df7ea551 100644 (file)
@@ -184,10 +184,42 @@ static void sym_line_gen(struct osm_object *o, struct style_info *si, struct svg
     }
 }
 
+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)