X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=map.c;h=bbcd7463b1f33de9864a3becb632b2b8c2c3f50e;hb=4175c5e7a411e1e29905ff8b4fa964dc60ad5fec;hp=2aab9e2c66cdbe2687187277e37bc99ccea5de97;hpb=b5ad4205a047a4be68e74c82f5637b13bd3f6896;p=leo.git diff --git a/map.c b/map.c index 2aab9e2..bbcd746 100644 --- a/map.c +++ b/map.c @@ -15,9 +15,11 @@ #include "leo.h" #include "osm.h" +#include "shp.h" #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; @@ -42,6 +44,8 @@ static struct cf_section map_style_cf = { static const char * const map_formats[] = { "invalid", "osmxml", + "fixed", + "shape", }; static struct cf_section map_source_cf = { @@ -217,29 +221,55 @@ static void map_load_source(struct data_source *ds) { 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"); + if (!ds->file) + ds->file = "fixed"; + fixed_add(); + break; + case DATA_SOURCE_SHAPE: + msg(L_INFO, "Parsing %s as shape file", ds->file); + if (!ds->file) + die("Shape data sources must have a file name"); + shp_parse(ds->file); + need_proj = 1; break; default: die("Invalid data source format"); } - msg(L_INFO, "Projecting"); - osm_project(map_projection); - if (debug_dump_after_proj) + osm_stats(); + 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)