X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=osm.c;h=17f2001ec10e6ea69a4cfa2ad2a84ceb167047e2;hb=refs%2Fheads%2Fpruvodce;hp=862f7fbb52012cdcf76221a15879cdc60beace04;hpb=9e0796f5be17bd5e65c31865cac25d38c8b2a0fb;p=leo.git diff --git a/osm.c b/osm.c index 862f7fb..17f2001 100644 --- a/osm.c +++ b/osm.c @@ -4,7 +4,8 @@ * (c) 2014 Martin Mares */ -#include +#include "leo.h" + #include #include #include @@ -12,9 +13,10 @@ #include #include + +#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H #include -#include "leo.h" #include "osm.h" struct osm *osm_this; @@ -144,6 +146,23 @@ void osm_obj_add_tag(struct osm_object *o, const char *key, const char *val) osm_obj_add_tag_raw(o, osm_key_encode(key), osm_val_encode(val)); } +void osm_obj_set_tag_raw(struct osm_object *o, osm_key_t key, osm_val_t val) +{ + CLIST_FOR_EACH(struct osm_tag *, t, o->tags) + if (t->key == key) + { + t->val = val; + return; + } + + osm_obj_add_tag_raw(o, key, val); +} + +void osm_obj_set_tag(struct osm_object *o, const char *key, const char *val) +{ + osm_obj_set_tag_raw(o, osm_key_encode(key), osm_val_encode(val)); +} + osm_val_t osm_obj_find_tag(struct osm_object *o, osm_key_t key) { CLIST_FOR_EACH(struct osm_tag *, t, o->tags) @@ -382,7 +401,7 @@ static void mpg_walk_boundary(struct osm_multipolygon *m, bool inner) clist_init(&b->nodes); struct mpg_vertex *w = v; - while (!w->visited) + while (w && !w->visited) { w->visited = 1; struct osm_ref *f = mp_alloc(osm_this->pool, sizeof(*f)); @@ -412,7 +431,9 @@ static void mpg_walk_boundary(struct osm_multipolygon *m, bool inner) w = dest; } - if (w != v) + if (!w) + osm_obj_warn(&mpg_current->o, "Boundary not closed"); + else if (w != v) osm_obj_warn(&mpg_current->o, "Boundary not closed at node %ju", (uintmax_t) w->o->id); struct osm_ref *f = mp_alloc(osm_this->pool, sizeof(*f)); @@ -445,7 +466,7 @@ static void osm_multipolygon_make(struct osm_relation *r) if (f->role != VALUE_INNER && f->role != VALUE_OUTER) { if (!inner) - osm_obj_warn(o, "Unknown role %s in multipolygon relation", osm_val_decode(f->role)); + osm_obj_warn(o, "Unknown role %s in multipolygon relation", f->role ? osm_val_decode(f->role) : ""); continue; } if ((f->role == VALUE_INNER) != inner)