PROGS+=$(o)/leo
CFLAGS+=$(LIBUCW_CFLAGS)
-LEO_MODULES=leo xml osm svg svg-icon css-parse css-lex style css dict sym sym-point sym-line sym-text map shp
+LEO_MODULES=leo xml osm svg svg-icon css-parse css-lex style css dict sym sym-point sym-line sym-text map shp fixed
LEO_OBJECTS=$(addprefix $(o)/, $(addsuffix .o, $(LEO_MODULES)))
$(o)/leo: $(LEO_OBJECTS)
should override each other, but currently they are mixed upon rendering.
Does it matter?
- Fixing of label positions should include some margin
-- Clean up Makefile
+- Clean up shp.c
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * Hic Est Leo -- Fixed Objects
+ *
+ * (c) 2014 Martin Mares <mj@ucw.cz>
+ */
+
+#ifndef _LEO_FIXED_H
+#define _LEO_FIXED_H
+
+void fixed_add(void);
+
+#endif
#include "map.h"
#include "css.h"
#include "sym.h"
+#include "fixed.h"
double map_min_x, map_min_y;
double map_max_x, map_max_y;
static const char * const map_formats[] = {
"invalid",
"osmxml",
+ "fixed",
};
static struct cf_section map_source_cf = {
{
ds->osm = osm_init();
+ bool need_mp = 0;
+ bool need_proj = 0;
+
switch (ds->format)
{
case DATA_SOURCE_OSMXML:
msg(L_INFO, "Parsing %s as OSM XML", ds->file);
+ if (!ds->file)
+ die("OSM XML data sources must have a file name");
osm_xml_parse(ds->file);
- if (debug_dump_source)
- {
- puts("=== Source data ===");
- osm_dump();
- }
- osm_make_multipolygons();
+ need_mp = 1;
+ need_proj = 1;
+ break;
+ case DATA_SOURCE_FIXED:
+ msg(L_INFO, "Adding fixed objects");
+ fixed_add();
break;
default:
die("Invalid data source format");
}
- msg(L_INFO, "Projecting");
- osm_project(map_projection);
- if (debug_dump_after_proj)
+ if (debug_dump_source)
{
- puts("=== Map after projection ===");
+ puts("=== Source data ===");
osm_dump();
}
+ if (need_mp)
+ osm_make_multipolygons();
+
+ if (need_proj)
+ {
+ msg(L_INFO, "Projecting");
+ osm_project(map_projection);
+ if (debug_dump_after_proj)
+ {
+ puts("=== Map after projection ===");
+ osm_dump();
+ }
+ }
}
void map_load_sources(void)
# File format:
# osmxml OpenStreetMap XML
+ # fixed Fixed objects (no File used, see FixedObjects section below)
Format osmxml
# MapCSS stylesheet to apply (multiple style-sheets are allowed)
StyleSheet poskole.css
}
+ Source {
+ Format fixed
+ StyleSheet poskole.css
+ }
+
# Projection of our map
Projection "+proj=utm +zone=33 +ellps=WGS84"
SVGOutput output.svg
}
+FixedObjects {
+ # Fixed objects may be placed at specific positions on the paper
+ # with specific tags. Remember to enable the "fixed" data source.
+ Object {
+ X 100
+ Y 100
+ Tag legend logo
+ }
+}
+
Debug {
# Dump map data exactly as parsed
DumpSource 0
enum data_source_type {
DATA_SOURCE_INVALID,
DATA_SOURCE_OSMXML,
+ DATA_SOURCE_FIXED,
};
struct data_source {