Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement:maptool:slice big polygons into smaller parts #906

Merged
merged 14 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions navit/maptool/itembin_slicer.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,8 @@ void itembin_nicer_slicer(struct tile_info *info, struct item_bin *ib, FILE *ref
long long * id;
int is_relation=0;

/* for now only slice polygons. */
if (ib->type < type_area) {
/* for now only slice polygons and things > min. */
if (ib->type < type_area || min <= tile_len(buffer)) {
tile_write_item_to_tile(info, ib, reference, buffer);
return;
}
Expand Down Expand Up @@ -829,8 +829,8 @@ void itembin_nicer_slicer(struct tile_info *info, struct item_bin *ib, FILE *ref
sp.buffer = buffer;
sp.number=0;

/* for all tiles in range...*/
while (strcmp(tilecode,tileend) != 0) {
/* for all tiles in range. Allow this to overflow if tile_len(buffer) == 0*/
do {
struct rect bbox;
/* get tile rectangle */
tile_bbox(tilecode, &bbox, 0);
Expand All @@ -847,7 +847,7 @@ void itembin_nicer_slicer(struct tile_info *info, struct item_bin *ib, FILE *ref
/* next tile */
next_tile(tilecode);
sp.number ++;
}
} while (strcmp(tilecode,tileend) != 0);
itembin_slicerpolygon_free(&sp);
}

19 changes: 13 additions & 6 deletions navit/maptool/tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,22 +334,29 @@ void tile_write_item_to_tile(struct tile_info *info, struct item_bin *ib, FILE *
}

void tile_write_item_minmax(struct tile_info *info, struct item_bin *ib, FILE *reference, int min, int max) {
/*TODO: make slice_trigger and slice_target configurable by commandline parameter.
* bonus: find out why there is a 'min' parameter here
*/
int slice_trigger = 4;
int slice_target = 7;
struct rect r;
char buffer[1024];
bbox((struct coord *)(ib+1), ib->clen/2, &r);
buffer[0]='\0';
tile(&r, info->suffix, buffer, max, overlap, NULL);

/*TODO: make '4' and '7' configurable by commandline parameter.
* bonus: find out why there is a 'min' parameter here
*/
if((ib->type >= type_area) && (ib->type != type_poly_water_tiled) && (tile_len(buffer) < 4)) {
if((ib->type >= type_area) && (ib->type != type_poly_water_tiled) && (tile_len(buffer) < slice_trigger)) {
/* Get a new reference tile before slicing ommitting the overlap. This is required
* as we want to slice without overlap and therefore we do not miss parts of the
* item residing in the overlap area */
buffer[0]='\0';
tile(&r, info->suffix, buffer, max, 0, NULL);
itembin_nicer_slicer(info, ib, reference, buffer, 7);
/* it sometimes ahppens that objects falling into big tile using overlaps falls into way smaller
* one without overlaps. If this happens, there is no need to slice. Just put the item into the
* tile found without overlap. */
if(tile_len(buffer) < slice_trigger)
itembin_nicer_slicer(info, ib, reference, buffer, slice_target);
else
tile_write_item_to_tile(info, ib, reference, buffer);
} else {
tile_write_item_to_tile(info, ib, reference, buffer);
}
Expand Down