summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wildemann <metalstrolch@users.noreply.github.com>2020-06-18 22:45:37 +0200
committerViktor Verebelyi <vviktor2@gmail.com>2020-09-22 02:16:16 +0100
commite4e9a9a9e67f1981a4dced04ec54389569f0b9e6 (patch)
tree618b14787741b9199d417bedf677cd55c46e4f91
parent7a1729128e715cd058fdc8e0dd3bcda18fcfe479 (diff)
downloadnavit-e4e9a9a9e67f1981a4dced04ec54389569f0b9e6.tar.gz
Fix:maptool:Duplicte multipolygons if required (#1019)
In order to support (multi)polygons that are tagged with more than one set of tags resulting it to require two navit items to be represented on map, affected elements are duplicated and added with every item type decoded. This is already done for ways and points. This fix makes maptool do this for multipolygons as well. + fixes some valgrind findings
-rw-r--r--navit/maptool/maptool.c1
-rw-r--r--navit/maptool/osm.c55
2 files changed, 39 insertions, 17 deletions
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index f18175990..a1b23cf82 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -879,6 +879,7 @@ static void maptool_assemble_map(struct maptool_params *p, char *suffix, char **
zip_write_index(zip_info);
zip_write_directory(zip_info);
zip_close(zip_info);
+ zip_destroy(zip_info);
if (!p->keep_tmpfiles) {
remove_countryfiles();
tempfile_unlink("index","");
diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c
index de3b51064..cbe13cc6f 100644
--- a/navit/maptool/osm.c
+++ b/navit/maptool/osm.c
@@ -1639,40 +1639,63 @@ country_from_iso2(char *iso) {
return country_from_countryid(country_id_from_iso2(iso));
}
-static inline void osm_end_relation_multipolygon (struct maptool_osm * osm, enum item_type* type) {
+static inline void osm_end_relation_multipolygon (struct maptool_osm * osm) {
if((!g_strcmp0(relation_type, "multipolygon")) && (!boundary)) {
- if(attr_longest_match(attr_mapping_way, attr_mapping_way_count, type, 1)) {
- tmp_item_bin->type = *type;
+ int count;
+ enum item_type types[10];
+ /* This is a multipolygon relation which is no boundary. Lets check what it is */
+ count = attr_longest_match(attr_mapping_way, attr_mapping_way_count, types, sizeof(types) / (sizeof(enum item_type)));
+ if(count > 0) {
+ int a;
+ /* got some type(s). Duplicate the multipolygon if more than one type. That's the only
+ * way right now to deal with things tagged multiple things without loosing something.
+ */
+ if (count >= 10) {
+ fprintf(stderr,"relation id "OSMID_FMT"\n",osmid_attr_value);
+ dbg_assert(count < 10);
+ count = 10;
+ }
+ //fprintf(stderr, "relation id "OSMID_FMT": got %d types\n", osmid_attr_value, count);
+ item_bin_add_attr_string(tmp_item_bin, attr_label, attr_strings[attr_string_label]);
+ for(a=0; a < count ; a++) {
+ /* no need to clone the item in memory. We just write it out multiple times */
+ if(a==1) {
+ /*add duplicate tag if 2nd type. The tag stays for all subsequent writes */
+ item_bin_add_attr_int(tmp_item_bin, attr_duplicate, 1);
+ }
+ tmp_item_bin->type = types[a];
+ item_bin_write(tmp_item_bin, osm->multipolygons);
+ }
} else {
- *type=type_none;
+ /* Don't know what this is. Keep it, as it could have been preprocessed by e.g. turn restriction
+ * code before
+ */
/* do not touch tmp_item_bin->type in this case, as it may be already set! For example
* indicating the turn restrictions */
- //tmp_item_bin->type=*type;
+ //tmp_item_bin->type=type_none;
+ item_bin_add_attr_string(tmp_item_bin, attr_label, attr_strings[attr_string_label]);
+ item_bin_write(tmp_item_bin, osm->multipolygons);
}
- item_bin_add_attr_string(tmp_item_bin, attr_label, attr_strings[attr_string_label]);
- item_bin_write(tmp_item_bin, osm->multipolygons);
} else {
- if(attr_longest_match(attr_mapping_rel2poly_place, attr_mapping_rel2poly_place_count, type, 1)) {
- tmp_item_bin->type=*type;
+ enum item_type type;
+ if(attr_longest_match(attr_mapping_rel2poly_place, attr_mapping_rel2poly_place_count, &type, 1)) {
+ tmp_item_bin->type=type;
} else {
- *type=type_none;
/* do not touch tmp_item_bin->type in this case, as it may be already set! For example
* indicating the turn restrictions */
- //tmp_item_bin->type=*type;
+ //tmp_item_bin->type=type_none;
}
if ((!g_strcmp0(relation_type, "multipolygon") || !g_strcmp0(relation_type, "boundary"))
- && (boundary || *type!=type_none)) {
+ && (boundary || type!=type_none)) {
item_bin_write(tmp_item_bin, osm->boundaries);
}
}
}
void osm_end_relation(struct maptool_osm *osm) {
- enum item_type type;
-
in_relation=0;
/* sets tmp_item_bin type and other fields */
- osm_end_relation_multipolygon (osm, &type);
+ osm_end_relation_multipolygon (osm);
if (!g_strcmp0(relation_type, "restriction") && (tmp_item_bin->type == type_street_turn_restriction_no
|| tmp_item_bin->type == type_street_turn_restriction_only))
@@ -3209,7 +3232,6 @@ static GList ** process_multipolygons_setup(FILE *in, int thread_count, struct r
GList **multipolygons=NULL;
/* allocate and reference async queue */
GAsyncQueue * ib_queue=g_async_queue_new ();
- g_async_queue_ref(ib_queue);
/* allocate per thread storage */
sthread=g_malloc0(sizeof(struct process_multipolygon_setup_thread) * thread_count);
@@ -3565,7 +3587,6 @@ static GList ** process_turn_restrictions_setup(FILE *in, int thread_count, stru
GList **turn_restrictions=NULL;
/* allocate and reference async queue */
GAsyncQueue * ib_queue=g_async_queue_new ();
- g_async_queue_ref(ib_queue);
/* allocate per thread storage */
sthread=g_malloc0(sizeof(struct process_turn_restrictions_setup_thread) * thread_count);