Skip to content

Commit

Permalink
enhancement:maptool:slice big polygons into smaller parts (#906)
Browse files Browse the repository at this point in the history
This commit allows to slice all polygons (except poly_water_sliced) into
squares so that they fit into smaller map tiles. Holes if present are
correctly sliced as well.

This has the advantage that they do not need to be processed albeit not
being displayed, and navit-planet-extractor can filter them out.

This has the disadvantage that the big polygons are displayed checkered
if the corresponding itemgra in config features an outline.

TODO: Slice already on polygon creation. Currently the slicing has to be
performed twice, because of tile preprocessing and saving is done in
seperate steps from the tempfiles.

TODO: Make the trigger for slicing configurable. Right now it slices
everything smaller than tile level 4.
  • Loading branch information
metalstrolch authored Oct 28, 2019
1 parent a0ea905 commit b99187e
Show file tree
Hide file tree
Showing 21 changed files with 950 additions and 28 deletions.
4 changes: 2 additions & 2 deletions navit/maptool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ if(BUILD_MAPTOOL)

add_executable (maptool maptool.c)
add_library (maptool_core boundaries.c buffer.c ch.c coastline.c itembin.c
itembin_buffer.c misc.c osm.c osm_o5m.c osm_psql.c osm_relations.c
sourcesink.c tempfile.c tile.c zip.c osm_xml.c)
itembin_buffer.c itembin_slicer.c misc.c osm.c osm_o5m.c osm_psql.c
osm_relations.c sourcesink.c tempfile.c tile.c zip.c osm_xml.c)

if(NOT MSVC)
PROTOBUF_C_GENERATE_C (PROTO_SRCS PROTO_HDRS osmformat.proto)
Expand Down
2 changes: 1 addition & 1 deletion navit/maptool/boundaries.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2011 Navit Team
*
Expand Down
2 changes: 1 addition & 1 deletion navit/maptool/buffer.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2018 Navit Team
*
Expand Down
2 changes: 1 addition & 1 deletion navit/maptool/ch.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2011 Navit Team
*
Expand Down
2 changes: 1 addition & 1 deletion navit/maptool/coastline.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2011 Navit Team
*
Expand Down
33 changes: 32 additions & 1 deletion navit/maptool/itembin.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2011 Navit Team
*
Expand Down Expand Up @@ -226,6 +226,37 @@ void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min
item_bin_add_attr(ib, &attr);
}

/**
* @brief add a "hole" to an item
*
* This function adds a "hole" (attr_poly_hole) to a map item. It adds the
* coordinates and the coordinate count to the existing item.
* WARNING: It does NOT allocate any memory, so the memory after the item
* must be already allocated for that purpose.
* @param[inout] ib item - to add hole to
* @param[in] coord - hole coordinate array
* @param[in] ccount - number of coordinates in coord
*/
void item_bin_add_hole(struct item_bin * ib, struct coord * coord, int ccount) {
/* get space for next attr in buffer */
int * buffer = ((int *) ib) + ib->len +1;
/* get the attr heder in binary file */
struct attr_bin * attr = (struct attr_bin *)buffer;
/* fill header */
attr->len = (ccount *2) + 2;
attr->type = attr_poly_hole;
/* get the first attr byte in buffer */
buffer = (int *)(attr +1);
/* for poly_hole, the first 4 bytes are the coordinate count */
*buffer = ccount;
/* coordinates are behind that */
buffer ++;
/* copy in the coordinates */
memcpy(buffer,coord, ccount * sizeof(struct coord));
/* add the hole to the total size */
ib->len += attr->len +1;
}

void item_bin_write(struct item_bin *ib, FILE *out) {
dbg_assert(fwrite(ib, (ib->len+1)*4, 1, out)==1);
}
Expand Down
2 changes: 1 addition & 1 deletion navit/maptool/itembin_buffer.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2011 Navit Team
*
Expand Down
Loading

0 comments on commit b99187e

Please sign in to comment.