+/*
+ * Hic Est Leo -- Fixed Objects
+ *
+ * (c) 2014 Martin Mares <mj@ucw.cz>
+ */
+
+#include <ucw/lib.h>
+#include <ucw/conf.h>
+
+#include <stdio.h>
+
+#include "leo.h"
+#include "osm.h"
+#include "fixed.h"
+
+struct fixed_tag {
+ cnode n;
+ char *key, *val;
+};
+
+struct fixed_object {
+ cnode n;
+ double x, y;
+ clist tags;
+};
+
+static clist fixed_objects;
+
+static struct cf_section fixed_tag_cf = {
+#define P(_x) PTR_TO(struct fixed_tag, _x)
+ CF_TYPE(struct fixed_object),
+ CF_ITEMS {
+ CF_STRING("Key", P(key)),
+ CF_STRING("Value", P(val)),
+ CF_END
+ }
+#undef P
+};
+
+static struct cf_section fixed_object_cf = {
+#define P(_x) PTR_TO(struct fixed_object, _x)
+ CF_TYPE(struct fixed_object),
+ CF_ITEMS {
+ CF_DOUBLE("X", P(x)),
+ CF_DOUBLE("Y", P(y)),
+ CF_LIST("Tag", P(tags), &fixed_tag_cf),
+ CF_END
+ }
+#undef P
+};
+
+static struct cf_section fixed_cf = {
+ CF_ITEMS {
+ CF_LIST("Object", &fixed_objects, &fixed_object_cf),
+ CF_END
+ }
+};
+
+static void CONSTRUCTOR fixed_preinit(void)
+{
+ cf_declare_section("FixedObjects", &fixed_cf, 0);
+}
+
+void fixed_add(void)
+{
+ u64 id = 1;
+ CLIST_FOR_EACH(struct fixed_object *, fo, fixed_objects)
+ {
+ struct osm_node *n = osm_node_new(id++);
+ n->x = fo->x;
+ n->y = fo->y;
+ CLIST_FOR_EACH(struct fixed_tag *, ft, fo->tags)
+ osm_obj_add_tag(&n->o, ft->key, ft->val);
+ }
+}