Skip to content

Commit

Permalink
core:feature:multipolygon support #824
Browse files Browse the repository at this point in the history
This adds multi polygon support to navit binfile.

It uses the following attempt:

 -  Multipolygon "outer" polygons are converted to polygons inside the binfile map.
 -  Multipolygon "inner" polygons are added as attributes to the outer polygon.
 -  New method is added to graphics to draw polygons with "holes" (currently qt5,
    gtk_drawing_area, and Windows (except CE) but at least sdl can do this as well)

Since the binfile format stays structural intact, new maps can be processed by old Navit versions, except they draw the multipolygons without their "holes",
New version of Navit can still read old maps of course.

Limitations:

 -  In the maps, there are multipolygons having other multipolygons as inner or outer.
    These are unsupported and fail the member check. According to 
    https://wiki.openstreetmap.org/wiki/Relation:multipolygon these are invalid. And the
    current web display cannot display them as well. See
    https://www.openstreetmap.org/relation/5587300 . Don't know if this get a standard
    mapping feature. Hopefully not.
  - Multipolygon polygons tend to become huge. No algorithm to split them into smaller
    chunks is contained. But my personal opinion is to exclude some types of polygons
    from map altogether on constrained devices over not including or artificial cutting the
    multipolygon ones. Btw. there are already huge traditional polygons as well.
  - Processing the map required more disk space as one cannot early drop ways with
    unknown tags any more, as they could be part of multipolygon. Maptools -n flag
    works as expected for the final result though.

Additional changes:
  - Default to 64 bit zip files on maptool
  • Loading branch information
metalstrolch committed Sep 3, 2019
2 parents 94834b7 + b0d66a6 commit b643162
Show file tree
Hide file tree
Showing 14 changed files with 1,420 additions and 360 deletions.
7 changes: 7 additions & 0 deletions navit/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "util.h"
#include "types.h"
#include "xmlconfig.h"
#include "layout.h"

struct attr_name {
enum attr_type attr;
Expand Down Expand Up @@ -471,6 +472,9 @@ char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum
if (type == attr_nav_status) {
return nav_status_to_text(attr->u.num);
}
if (type == attr_poly_hole) {
return g_strdup_printf("count=%d", attr->u.poly_hole->coord_count);
}
return g_strdup_printf("(no text[%s])", attr_to_name(type));
}

Expand Down Expand Up @@ -770,6 +774,9 @@ int attr_data_size(struct attr *attr) {
while (attr->u.attr_types[i++] != attr_none);
return i*sizeof(enum attr_type);
}
if (attr->type == attr_poly_hole) {
return (sizeof(attr->u.poly_hole->coord_count) + (attr->u.poly_hole->coord_count * sizeof(*attr->u.poly_hole->coord)));
}
dbg(lvl_error,"size for %s unknown", attr_to_name(attr->type));
return 0;
}
Expand Down
136 changes: 69 additions & 67 deletions navit/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ enum attr_type {
#define ATTR2(x,y) attr_##y=x,
#define ATTR(x) attr_##x,

/* Special macro for unused attribute types. Creates a placeholder entry
* in the enum so the following values do not change. */
/* Special macro for unused attribute types. Creates a placeholder entry
* in the enum so the following values do not change. */
#define ATTR_UNUSED ATTR_UNUSED_L(__LINE__)
#define ATTR_UNUSED_L(x) ATTR_UNUSED_WITH_LINE_NUMBER(x)
#define ATTR_UNUSED_WITH_LINE_NUMBER(x) ATTR_UNUSED_##x,
Expand All @@ -52,8 +52,8 @@ enum attr_type {
};

enum attr_format {
attr_format_default=0,
attr_format_with_units=1,
attr_format_default=0,
attr_format_with_units=1,
};

#define AF_ONEWAY (1<<0)
Expand Down Expand Up @@ -120,19 +120,19 @@ enum attr_format {

/** Indicates whether a position is valid **/
enum attr_position_valid {
attr_position_valid_invalid, /**< The position is invalid and should be discarded. **/
attr_position_valid_static, /**< The position is valid but the vehicle is not moving, or moving very slowly.
attr_position_valid_invalid, /**< The position is invalid and should be discarded. **/
attr_position_valid_static, /**< The position is valid but the vehicle is not moving, or moving very slowly.
Calculations that involve the difference between two consecutive positions,
such as bearing, may therefore be inaccurate. **/
attr_position_valid_extrapolated_time, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
attr_position_valid_extrapolated_time, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
The position is the vehicle's last known position, and the consumer of the
information should be aware that the vehicle may have moved since. **/
attr_position_valid_extrapolated_spatial, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
attr_position_valid_extrapolated_spatial, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
The position is a prediction of the vehicle's current position, based on
its last known position, the time elapsed since it was obtained and possibly
other factors. This would be used for positions obtained through inertial
navigation. **/
attr_position_valid_valid, /**< The position is valid and can be used for all purposes. **/
attr_position_valid_valid, /**< The position is valid and can be used for all purposes. **/
};

#define ATTR_IS_INT(x) ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
Expand All @@ -151,66 +151,67 @@ enum attr_position_valid {
#define ATTR_OBJECT(x,y) ((struct attr){attr_##x,{.navit=y}})

struct range {
short min, max;
short min, max;
};

struct attr {
enum attr_type type;
union {
char *str;
void *data;
long num;
struct item *item;
enum item_type item_type;
enum projection projection;
double * numd;
struct color *color;
struct coord_geo *coord_geo;
struct navit *navit;
struct callback *callback;
struct callback_list *callback_list;
struct vehicle *vehicle;
struct layout *layout;
struct layer *layer;
struct map *map;
struct mapset *mapset;
struct log *log;
struct route *route;
struct navigation *navigation;
struct coord *coord;
struct pcoord *pcoord;
struct gui *gui;
struct graphics *graphics;
struct tracking *tracking;
struct itemgra *itemgra;
struct plugin *plugin;
struct plugins *plugins;
struct polygon *polygon;
struct polyline *polyline;
struct circle *circle;
struct text *text;
struct icon *icon;
struct image *image;
struct arrows *arrows;
struct element *element;
struct speech *speech;
struct cursor *cursor;
struct displaylist *displaylist;
struct transformation *transformation;
struct vehicleprofile *vehicleprofile;
struct roadprofile *roadprofile;
struct bookmarks *bookmarks;
struct config *config;
struct osd *osd;
struct range range;
struct navit_object *navit_object;
struct traffic *traffic;
int *dash;
enum item_type *item_types;
enum attr_type *attr_types;
long long *num64;
struct attr *attrs;
} u;
enum attr_type type;
union {
char *str;
void *data;
long num;
struct item *item;
enum item_type item_type;
enum projection projection;
double * numd;
struct color *color;
struct coord_geo *coord_geo;
struct navit *navit;
struct callback *callback;
struct callback_list *callback_list;
struct vehicle *vehicle;
struct layout *layout;
struct layer *layer;
struct map *map;
struct mapset *mapset;
struct log *log;
struct route *route;
struct navigation *navigation;
struct coord *coord;
struct pcoord *pcoord;
struct gui *gui;
struct graphics *graphics;
struct tracking *tracking;
struct itemgra *itemgra;
struct plugin *plugin;
struct plugins *plugins;
struct polygon *polygon;
struct polyline *polyline;
struct circle *circle;
struct text *text;
struct icon *icon;
struct image *image;
struct arrows *arrows;
struct element *element;
struct speech *speech;
struct cursor *cursor;
struct displaylist *displaylist;
struct transformation *transformation;
struct vehicleprofile *vehicleprofile;
struct roadprofile *roadprofile;
struct bookmarks *bookmarks;
struct config *config;
struct osd *osd;
struct range range;
struct navit_object *navit_object;
struct traffic *traffic;
int *dash;
enum item_type *item_types;
enum attr_type *attr_types;
long long *num64;
struct attr *attrs;
struct poly_hole *poly_hole;
} u;
};

struct attr_iter;
Expand All @@ -223,7 +224,8 @@ struct attr *attr_new_from_text(const char *name, const char *value);
char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map);
char *attr_to_text(struct attr *attr, struct map *map, int pretty);
struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter);
int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr,
struct attr_iter *iter);
struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
struct attr **attr_generic_add_attr(struct attr **attrs, struct attr *attr);
struct attr **attr_generic_add_attr_list(struct attr **attrs, struct attr **add);
Expand Down
1 change: 1 addition & 0 deletions navit/attr_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ ATTR(ch_edge)
ATTR(zipfile_ref_block)
ATTR(item_id)
ATTR(pdl_gps_update)
ATTR(poly_hole)
ATTR2(0x0004ffff,type_special_end)
ATTR2(0x00050000,type_double_begin)
ATTR(position_height)
Expand Down

0 comments on commit b643162

Please sign in to comment.