summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2015-10-15 10:31:29 +0200
committermvglasow <michael -at- vonglasow.com>2015-10-15 10:31:29 +0200
commit2449f7473d02417d3b145d1c928ceae3fe419f6a (patch)
tree1d4eed6462e4521ff2ed272bb894e8058e8bfd59
parenta61ffd436b6a75157f2d6d6eb1112def8b958a1b (diff)
parent944bfe56e6ab8382fd572d722eeb78fa6acb9f63 (diff)
downloadnavit-2449f7473d02417d3b145d1c928ceae3fe419f6a.tar.gz
Merge branch 'trunk' into trac1324
-rwxr-xr-xCMakeLists.txt3
-rw-r--r--navit/font/freetype/font_freetype.c246
-rw-r--r--navit/font/freetype/font_freetype.h66
-rw-r--r--navit/graphics.c7
-rw-r--r--navit/graphics/gd/graphics_gd.c4
-rw-r--r--navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c4
-rw-r--r--navit/graphics/opengl/graphics_opengl.c5
-rw-r--r--navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp4
-rw-r--r--navit/graphics/sdl/graphics_sdl.c6
-rw-r--r--navit/maptool/buffer.c4
-rw-r--r--navit/maptool/itembin.c4
-rw-r--r--navit/maptool/maptool.c1
-rw-r--r--navit/maptool/misc.c27
-rw-r--r--navit/maptool/osm.c40
-rw-r--r--navit/maptool/tile.c4
-rw-r--r--navit/maptool/zip.c9
-rw-r--r--navit/navigation.c197
17 files changed, 192 insertions, 439 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 519e930cb..3528e4cfb 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,8 +11,7 @@ if (NOT DISABLE_CXX)
enable_language(CXX OPTIONAL)
endif(NOT DISABLE_CXX)
-cmake_minimum_required(VERSION 2.6)
-cmake_policy(VERSION 2.6)
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
set(NAVIT_VERSION_MAJOR "0")
set(NAVIT_VERSION_MINOR "5")
set(NAVIT_VERSION_PATCH "0")
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c
index f4359fb90..f41eff314 100644
--- a/navit/font/freetype/font_freetype.c
+++ b/navit/font/freetype/font_freetype.c
@@ -374,17 +374,7 @@ static FT_Error face_requester( FTC_FaceID face_id, FT_Library library, FT_Point
}
#endif
-/**
- * Load a new font using the fontconfig library.
- * First search for each of the font families and require and exact match on family
- * If no font found, let fontconfig pick the best match
- * @param graphics_priv FIXME
- * @param graphics_font_methods FIXME
- * @param fontfamily the preferred font family
- * @param size requested size of fonts
- * @param flags extra flags for the font (bold,etc)
- * @returns <>
-*/
+/** Implementation of font_freetype_methods.font_new */
static struct font_freetype_font *
font_freetype_font_new(struct graphics_priv *gr,
struct graphics_font_methods *meth,
@@ -542,36 +532,22 @@ font_freetype_font_new(struct graphics_priv *gr,
return font;
}
+/** Implementation of font_freetype_methods.get_shadow. */
static int
font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
- unsigned char *data, int depth, int stride, struct color *foreground, struct color *background)
+ unsigned char *data, int stride, struct color *foreground, struct color *background)
{
- int mask0, mask1, mask2, x, y, w = g->w, h = g->h;
+ int x, y, w = g->w, h = g->h;
unsigned int bg, fg;
unsigned char *pm, *psp,*ps,*psn;
- switch (depth) {
- case 1:
- fg=0xff;
- bg=0x00;
- break;
- case 8:
- fg=foreground->a>>COL_SHIFT;
- bg=background->a>>COL_SHIFT;
- break;
- case 24:
- case 32:
- fg=((foreground->a>>COL_SHIFT)<<24)|
- ((foreground->r>>COL_SHIFT)<<16)|
- ((foreground->g>>COL_SHIFT)<<8)|
- ((foreground->b>>COL_SHIFT)<<0);
- bg=((background->a>>COL_SHIFT)<<24)|
- ((background->r>>COL_SHIFT)<<16)|
- ((background->g>>COL_SHIFT)<<8)|
- ((background->b>>COL_SHIFT)<<0);
- break;
- default:
- return 0;
- }
+ fg=((foreground->a>>COL_SHIFT)<<24)|
+ ((foreground->r>>COL_SHIFT)<<16)|
+ ((foreground->g>>COL_SHIFT)<<8)|
+ ((foreground->b>>COL_SHIFT)<<0);
+ bg=((background->a>>COL_SHIFT)<<24)|
+ ((background->r>>COL_SHIFT)<<16)|
+ ((background->g>>COL_SHIFT)<<8)|
+ ((background->b>>COL_SHIFT)<<0);
for (y = 0; y < h+2; y++) {
if (stride) {
ps = data + stride * y;
@@ -579,25 +555,8 @@ font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
unsigned char **dataptr=(unsigned char **)data;
ps = dataptr[y];
}
- switch (depth) {
- case 1:
- memset(ps, bg, (w+9)/2);
- break;
- case 8:
- memset(ps, bg, w+2);
- break;
- case 24:
- for (x = 0 ; x < w+2 ; x++) {
- ps[x*3]=bg>>16;
- ps[x*3+1]=bg>>8;
- ps[x*3+2]=bg;
- }
- break;
- case 32:
- for (x = 0 ; x < w+2 ; x++)
- ((unsigned int *)ps)[x]=bg;
- break;
- }
+ for (x = 0 ; x < w+2 ; x++)
+ ((unsigned int *)ps)[x]=bg;
}
for (y = 0; y < h; y++) {
pm = g->pixmap + y * w;
@@ -611,120 +570,35 @@ font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
ps = dataptr[y+1];
psn = dataptr[y+2];
}
- switch (depth) {
- case 1:
- mask0 = 0x4000;
- mask1 = 0xe000;
- mask2 = 0x4000;
- for (x = 0; x < w; x++) {
- if (*pm) {
- psp[0] |= (mask0 >> 8);
- if (mask0 & 0xff)
- psp[1] |= mask0;
- ps[0] |= (mask1 >> 8);
- if (mask1 & 0xff)
- ps[1] |= mask1;
- psn[0] |= (mask2 >> 8);
- if (mask2 & 0xff)
- psn[1] |= mask2;
- }
- mask0 >>= 1;
- mask1 >>= 1;
- mask2 >>= 1;
- if (!
- ((mask0 >> 8) | (mask1 >> 8) |
- (mask2 >> 8))) {
- mask0 <<= 8;
- mask1 <<= 8;
- mask2 <<= 8;
- psp++;
- ps++;
- psn++;
- }
- pm++;
- }
- break;
- case 8:
- for (x = 0; x < w; x++) {
- if (*pm) {
- psp[1] = fg;
- ps[0] = fg;
- ps[1] = fg;
- ps[2] = fg;
- psn[1] = fg;
- }
- psp++;
- ps++;
- psn++;
- pm++;
+ for (x = 0; x < w; x++) {
+ if (*pm) {
+ ((unsigned int *)psp)[1]=fg;
+ ((unsigned int *)ps)[0]=fg;
+ ((unsigned int *)ps)[1]=fg;
+ ((unsigned int *)ps)[2]=fg;
+ ((unsigned int *)psn)[1]=fg;
}
- break;
- case 24:
- for (x = 0; x < w; x++) {
- if (*pm) {
- psp[3]=fg>>16;
- psp[4]=fg>>8;
- psp[5]=fg;
- ps[0]=fg>>16;
- ps[1]=fg>>8;
- ps[2]=fg;
- ps[3]=fg>>16;
- ps[4]=fg>>8;
- ps[5]=fg;
- ps[6]=fg>>16;
- ps[7]=fg>>8;
- ps[8]=fg;
- psn[3]=fg>>16;
- psn[4]=fg>>8;
- psn[5]=fg;
- }
- psp+=3;
- ps+=3;
- psn+=3;
- pm++;
- }
- break;
- case 32:
- for (x = 0; x < w; x++) {
- if (*pm) {
- ((unsigned int *)psp)[1]=fg;
- ((unsigned int *)ps)[0]=fg;
- ((unsigned int *)ps)[1]=fg;
- ((unsigned int *)ps)[2]=fg;
- ((unsigned int *)psn)[1]=fg;
- }
- psp+=4;
- ps+=4;
- psn+=4;
- pm++;
- }
- break;
+ psp+=4;
+ ps+=4;
+ psn+=4;
+ pm++;
}
}
return 1;
}
+/** Implementation of font_freetype_methods.get_glyph. */
static int
font_freetype_glyph_get_glyph(struct font_freetype_glyph *g,
- unsigned char *data, int depth, int stride, struct color *fg, struct color *bg, struct color *transparent)
+ unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent)
{
int x, y, w = g->w, h = g->h;
unsigned int tr;
unsigned char v,vi,*pm, *ps;
- switch (depth) {
- case 8:
- tr=transparent->a>>COL_SHIFT;
- break;
- case 24:
- case 32:
- tr=((transparent->a>>COL_SHIFT)<<24)|
- ((transparent->r>>COL_SHIFT)<<16)|
- ((transparent->g>>COL_SHIFT)<<8)|
- ((transparent->b>>COL_SHIFT)<<0);
- break;
- default:
- return 0;
- }
+ tr=((transparent->a>>COL_SHIFT)<<24)|
+ ((transparent->r>>COL_SHIFT)<<16)|
+ ((transparent->g>>COL_SHIFT)<<8)|
+ ((transparent->b>>COL_SHIFT)<<0);
for (y = 0; y < h; y++) {
pm = g->pixmap + y * w;
if (stride) {
@@ -733,51 +607,19 @@ font_freetype_glyph_get_glyph(struct font_freetype_glyph *g,
unsigned char **dataptr=(unsigned char **)data;
ps = dataptr[y];
}
- switch (depth) {
- case 8:
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v)
- *ps=fg->a;
- else
- *ps=tr;
- ps++;
- pm++;
- }
- break;
- case 24:
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v) {
- vi=255-v;
- ps[0]=(((fg->r*v+bg->r*vi)/255)>>COL_SHIFT);
- ps[1]=(((fg->g*v+bg->g*vi)/255)>>COL_SHIFT);
- ps[2]=(((fg->b*v+bg->b*vi)/255)>>COL_SHIFT);
- } else {
- ps[0]=tr >> 16;
- ps[1]=tr >> 8;
- ps[2]=tr;
- }
- ps+=3;
- pm++;
- }
- break;
- case 32:
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v) {
- vi=255-v;
- ((unsigned int *)ps)[0]=
- ((((fg->a*v+bg->a*vi)/255)>>COL_SHIFT)<<24)|
- ((((fg->r*v+bg->r*vi)/255)>>COL_SHIFT)<<16)|
- ((((fg->g*v+bg->g*vi)/255)>>COL_SHIFT)<<8)|
- ((((fg->b*v+bg->b*vi)/255)>>COL_SHIFT)<<0);
- } else
- ((unsigned int *)ps)[0]=tr;
- ps+=4;
- pm++;
- }
- break;
+ for (x = 0; x < w; x++) {
+ v=*pm;
+ if (v) {
+ vi=255-v;
+ ((unsigned int *)ps)[0]=
+ ((((fg->a*v+bg->a*vi)/255)>>COL_SHIFT)<<24)|
+ ((((fg->r*v+bg->r*vi)/255)>>COL_SHIFT)<<16)|
+ ((((fg->g*v+bg->g*vi)/255)>>COL_SHIFT)<<8)|
+ ((((fg->b*v+bg->b*vi)/255)>>COL_SHIFT)<<0);
+ } else
+ ((unsigned int *)ps)[0]=tr;
+ ps+=4;
+ pm++;
}
}
return 1;
diff --git a/navit/font/freetype/font_freetype.h b/navit/font/freetype/font_freetype.h
index 26cfc558d..e4ef58bb9 100644
--- a/navit/font/freetype/font_freetype.h
+++ b/navit/font/freetype/font_freetype.h
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2011 Navit Team
*
@@ -16,11 +16,37 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
+
+/** @file
+ * @brief Interface to the FreeType 2 library, to render text as bitmaps.
+ *
+ * This plugin supplies functions to render text (encoded as UTF-8) to bitmaps with the help of
+ * FreeType 2. Typical usage:
+ * @li create a struct font_freetype_font by calling font_freetype_methods.font_new()
+ * @li for the text to render, create a struct font_freetype_text by calling font_freetype_methods.text_new()
+ * @li obtain glyph bitmaps by calling font_freetype_methods.get_glyph() on the glyphs inside
+ * struct font_freetype_text
+ * @li optionally, obtain a "shadow" of the glyph from font_freetype_methods.get_shadow(), to make
+ * the text easier to read against a colored background (like the map)
+ */
struct font_freetype_font;
struct font_freetype_glyph;
+/** Methods provided by this plugin. */
struct font_freetype_methods {
void (*destroy)(void);
+ /**
+ * @brief Load a font, preferring one with the given font family.
+ *
+ * Try to load a font, trying to match either the given font family, or one from a list
+ * of hardcoded families, or let fontconfig pick the best match.
+ * @param graphics_priv unused
+ * @param graphics_font_methods used to return font methods
+ * @param fontfamily the preferred font family
+ * @param size requested size of font
+ * @param flags extra flags for the font (bold,etc)
+ * @returns loaded font, or NULL
+ */
struct font_freetype_font *(*font_new) (struct graphics_priv * gr,
struct
graphics_font_methods *
@@ -34,10 +60,40 @@ struct font_freetype_methods {
struct font_freetype_font *
font, int dx, int dy);
void (*text_destroy) (struct font_freetype_text * text);
+ /**
+ * @brief Get glyph "shadow", a glyph bitmap to be used as background.
+ *
+ * This method returns a glyph shadow, a bitmap with the glyph, where the glyph has been
+ * "fattened" by expanding it by one pixel on each side.
+ * In Navit, the shadow is used as the background behind the glyph bitmaps (returned by
+ * font_freetype_methods.get_glyph() ), to make the text easier to read.
+ *
+ * @param g glyph to render, usually created via font_freetype_methods.text_new()
+ * @param data buffer for result image bitmap. Size must be at least (4 * stride * (g->h+2)).
+ * @param stride see font_freetype_methods.get_glyph(). Minimum: g->w+2.
+ * @param foreground color for rendering the "shadow"
+ * @param background color for rest of the bitmap (typically set to transparent)
+ * @returns 0 if depth is invalid, 1 otherwise
+ */
int (*get_shadow) (struct font_freetype_glyph * glyph,
- unsigned char *data, int depth, int stride, struct color *fg, struct color *tr);
+ unsigned char *data, int stride, struct color *fg, struct color *tr);
+ /**
+ * @brief Get a glyph bitmap.
+ *
+ * This method returns a bitmap for rendering the supplied glyph.
+ *
+ * @param g glyph to render, usually obtained from a struct font_freetype_text created via font_freetype_methods.text_new()
+ * @param data buffer for result image bitmap. Size must be at least (4 * stride * g->h).
+ * @param stride stride (bytes per data row) for result bitmap; must be at least g->w, but may include padding.
+ * Special case:
+ * If set to 0, 'data' is interpreted as an array of pointers to image data rows (i.e. unsigned char**).
+ * @param fg color for rendering the glyph
+ * @param bg color to alpha blend with fg for semi-transparent glyph pixels
+ * @param transparent color for background pixels
+ * @returns 0 if depth is invalid, 1 otherwise
+ */
int (*get_glyph) (struct font_freetype_glyph * glyph,
- unsigned char *data, int depth, int stride,
+ unsigned char *data, int stride,
struct color * fg, struct color * bg, struct color *tr);
};
@@ -47,10 +103,6 @@ struct font_freetype_glyph {
};
struct font_freetype_text {
- int x1, y1;
- int x2, y2;
- int x3, y3;
- int x4, y4;
int glyph_count;
struct font_freetype_glyph *glyph[0];
};
diff --git a/navit/graphics.c b/navit/graphics.c
index 44993b3e3..e27794382 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -868,7 +868,12 @@ void graphics_image_free(struct graphics *gra, struct graphics_image *img)
}
/**
- * Report the beginning or the end of a set of drawing operations.
+ * @brief Start or finish a set of drawing operations.
+ *
+ * graphics_draw_mode(draw_mode_begin) must be invoked before performing any drawing
+ * operations; this allows the graphics driver to perform any necessary setup.
+ * graphics_draw_mode(draw_mode_end) must be invoked to finish a set of drawing operations;
+ * this will typically clean up drawing resources and display the drawing result.
* @param this_ graphics object that is being drawn to
* @param mode specify beginning or end of drawing
* @author Martin Schaller (04/2008)
diff --git a/navit/graphics/gd/graphics_gd.c b/navit/graphics/gd/graphics_gd.c
index b4991f30a..47868d622 100644
--- a/navit/graphics/gd/graphics_gd.c
+++ b/navit/graphics/gd/graphics_gd.c
@@ -430,7 +430,7 @@ draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics
h=g->h;
if (w && h) {
im=gdImageCreateTrueColor(w+2, h+2);
- gr->freetype_methods.get_shadow(g,(unsigned char *)(im->tpixels),32,0,&bgc,&transparent);
+ gr->freetype_methods.get_shadow(g,(unsigned char *)(im->tpixels),0,&bgc,&transparent);
gdImageCopy(gr->im, im, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, 0, 0, w+2, h+2);
gdImageDestroy(im);
}
@@ -450,7 +450,7 @@ draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics
h=g->h;
if (w && h) {
im=gdImageCreateTrueColor(w, h);
- gr->freetype_methods.get_glyph(g,(unsigned char *)(im->tpixels),32,0,&fgc,&bgc,&transparent);
+ gr->freetype_methods.get_glyph(g,(unsigned char *)(im->tpixels),0,&fgc,&bgc,&transparent);
gdImageCopy(gr->im, im, (x+g->x)>>6, (y+g->y)>>6, 0, 0, w, h);
gdImageDestroy(im);
}
diff --git a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
index 332673529..665d306e3 100644
--- a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
+++ b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
@@ -366,7 +366,7 @@ display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, str
unsigned char *shadow;
stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w+2);
shadow=g_malloc(stride*(g->h+2));
- gr->freetype_methods.get_shadow(g, shadow, 32, stride, &bg->c, &transparent);
+ gr->freetype_methods.get_shadow(g, shadow, stride, &bg->c, &transparent);
draw_rgb_image_buffer(gr->cairo, g->w+2, g->h+2, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, stride, shadow);
g_free(shadow);
}
@@ -384,7 +384,7 @@ display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, str
unsigned char *glyph;
stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w);
glyph=g_malloc(stride*g->h);
- gr->freetype_methods.get_glyph(g, glyph, 32, stride, &fg->c, bg?&bg->c:&transparent, &transparent);
+ gr->freetype_methods.get_glyph(g, glyph, stride, &fg->c, bg?&bg->c:&transparent, &transparent);
draw_rgb_image_buffer(gr->cairo, g->w, g->h, (x+g->x)>>6, (y+g->y)>>6, stride, glyph);
g_free(glyph);
}
diff --git a/navit/graphics/opengl/graphics_opengl.c b/navit/graphics/opengl/graphics_opengl.c
index 742dcae51..b6e0fb41a 100644
--- a/navit/graphics/opengl/graphics_opengl.c
+++ b/navit/graphics/opengl/graphics_opengl.c
@@ -921,7 +921,7 @@ display_text_draw(struct font_freetype_text *text,
if (color) {
shadow = g_malloc(stride * (g->h + 2));
gr->freetype_methods.get_shadow(g, shadow,
- 32, stride,
+ stride,
&white,
&transparent);
#ifdef USE_OPENGLES
@@ -961,7 +961,6 @@ display_text_draw(struct font_freetype_text *text,
g_malloc(stride * g->h * 4);
gr->freetype_methods.get_glyph(g,
glyph,
- 32,
stride
* 4,
&black,
@@ -989,7 +988,7 @@ display_text_draw(struct font_freetype_text *text,
stride *= 4;
glyph = g_malloc(stride * g->h);
gr->freetype_methods.get_glyph(g, glyph,
- 32, stride,
+ stride,
&black,
&white,
&transparent);
diff --git a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
index 20ac0c296..714f0753e 100644
--- a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
+++ b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
@@ -420,7 +420,7 @@ static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, str
unsigned char *data;
QImage img(g->w+2, g->h+2, QImage::Format_ARGB32_Premultiplied);
data=img.bits();
- gr->freetype_methods.get_shadow(g,(unsigned char *)data,32,img.bytesPerLine(),bgc,&transparent);
+ gr->freetype_methods.get_shadow(g,(unsigned char *)data,img.bytesPerLine(),bgc,&transparent);
painter->drawImage(((x+g->x)>>6)-1, ((y+g->y)>>6)-1, img);
}
@@ -439,7 +439,7 @@ static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, str
unsigned char *data;
QImage img(g->w, g->h, QImage::Format_ARGB32_Premultiplied);
data=img.bits();
- gr->freetype_methods.get_glyph(g,(unsigned char *)data,32,img.bytesPerLine(),fgc,bgc,&transparent);
+ gr->freetype_methods.get_glyph(g,(unsigned char *)data,img.bytesPerLine(),fgc,bgc,&transparent);
painter->drawImage((x+g->x)>>6, (y+g->y)>>6, img);
}
x+=g->dx;
diff --git a/navit/graphics/sdl/graphics_sdl.c b/navit/graphics/sdl/graphics_sdl.c
index b01af5c3f..e5d9f7872 100644
--- a/navit/graphics/sdl/graphics_sdl.c
+++ b/navit/graphics/sdl/graphics_sdl.c
@@ -650,7 +650,7 @@ display_text_draw(struct font_freetype_text *text,
stride = (g->w + 2) * 4;
if (color) {
resize_ft_buffer(stride * (g->h + 2));
- gr->freetype_methods.get_shadow(g, ft_buffer, 32, stride, &white, &transparent);
+ gr->freetype_methods.get_shadow(g, ft_buffer, stride, &white, &transparent);
SDL_Surface *glyph_surface =
SDL_CreateRGBSurfaceFrom(ft_buffer, g->w + 2, g->h + 2,
@@ -684,7 +684,7 @@ display_text_draw(struct font_freetype_text *text,
stride = g->w;
if (bg) {
resize_ft_buffer(stride * g->h * 4);
- gr->freetype_methods.get_glyph(g, ft_buffer, 32,
+ gr->freetype_methods.get_glyph(g, ft_buffer,
stride * 4, &black,
&white, &transparent);
SDL_Surface *glyph_surface =
@@ -704,7 +704,7 @@ display_text_draw(struct font_freetype_text *text,
}
stride *= 4;
resize_ft_buffer(stride * g->h);
- gr->freetype_methods.get_glyph(g, ft_buffer, 32, stride,
+ gr->freetype_methods.get_glyph(g, ft_buffer, stride,
&black, &white,
&transparent);
int ii, jj;
diff --git a/navit/maptool/buffer.c b/navit/maptool/buffer.c
index 9cc2f995e..2907b0670 100644
--- a/navit/maptool/buffer.c
+++ b/navit/maptool/buffer.c
@@ -30,8 +30,8 @@ save_buffer(char *filename, struct buffer *b, long long offset)
f=fopen(filename,"wb+");
dbg_assert(f != NULL);
- fseeko(f, offset, SEEK_SET);
- fwrite(b->base, b->size, 1, f);
+ dbg_assert(fseeko(f, offset, SEEK_SET)==0);
+ dbg_assert(fwrite(b->base, b->size, 1, f)==1);
fclose(f);
}
diff --git a/navit/maptool/itembin.c b/navit/maptool/itembin.c
index 4b5a09d7b..98b0c52a6 100644
--- a/navit/maptool/itembin.c
+++ b/navit/maptool/itembin.c
@@ -269,7 +269,7 @@ item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, sho
void
item_bin_write(struct item_bin *ib, FILE *out)
{
- fwrite(ib, (ib->len+1)*4, 1, out);
+ dbg_assert(fwrite(ib, (ib->len+1)*4, 1, out)==1);
}
struct item_bin *
@@ -587,7 +587,7 @@ item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size)
for (j = 0 ; j < count ; j++) {
ib=(struct item_bin *)(idx[j]);
c=(struct coord *)(ib+1);
- fwrite(ib, (ib->len+1)*4, 1, f);
+ dbg_assert(fwrite(ib, (ib->len+1)*4, 1, f)==1);
if (r) {
for (k = 0 ; k < ib->clen/2 ; k++) {
if (rc)
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index 765d6abf7..815eb9fff 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -1014,7 +1014,6 @@ int main(int argc, char **argv)
fclose(ways_split);
}
}
-
if (start_phase(&p,"generating coastlines")) {
osm_process_coastlines(&p, suffix);
}
diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c
index a0816e120..d4ce6f169 100644
--- a/navit/maptool/misc.c
+++ b/navit/maptool/misc.c
@@ -347,20 +347,19 @@ process_slice(FILE **in, FILE **reference, int in_count, int with_range, long lo
info.tilesdir_out=NULL;
phase34(&info, zip_info, in, reference, in_count, with_range);
- th=tile_head_root;
- while (th) {
- if (th->process) {
- if (th->name[0]) {
- if (th->total_size != th->total_size_used) {
- fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
- exit(1);
- }
- write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
- zipfiles++;
- } else
- fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info));
+ for (th=tile_head_root;th;th=th->next) {
+ if (!th->process)
+ continue;
+ if (th->name[0]) {
+ if (th->total_size != th->total_size_used) {
+ fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
+ exit(1);
+ }
+ write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
+ zipfiles++;
+ } else {
+ dbg_assert(fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info))==1);
}
- th=th->next;
}
free(slice_data);
@@ -420,7 +419,7 @@ process_binfile(FILE *in, FILE *out)
{
struct item_bin *ib;
while ((ib=read_item(in))) {
- fwrite(ib, (ib->len+1)*4, 1, out);
+ item_bin_write(ib, out);
}
}
diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c
index 9f251b136..37c0e7626 100644
--- a/navit/maptool/osm.c
+++ b/navit/maptool/osm.c
@@ -2977,6 +2977,23 @@ osm_add_nd(osmid ref)
}
static void
+write_item_way_subsection_index(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, long long *last_id)
+{
+ osmid idx[2];
+ idx[0]=item_bin_get_wayid(orig);
+ idx[1]=ftello(out);
+ if (way_hash) {
+ if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long)idx[0], NULL, NULL)))
+ g_hash_table_insert(way_hash, (gpointer)(long)idx[0], (gpointer)(long)idx[1]);
+ } else {
+ if (!last_id || *last_id != idx[0])
+ dbg_assert(fwrite(idx, sizeof(idx), 1, out_index)==1);
+ if (last_id)
+ *last_id=idx[0];
+ }
+}
+
+static void
write_item_way_subsection(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, int first, int last, long long *last_id)
{
struct item_bin new;
@@ -2987,27 +3004,14 @@ write_item_way_subsection(FILE *out, FILE *out_index, FILE *out_graph, struct it
new.type=orig->type;
new.clen=(last-first+1)*2;
new.len=new.clen+attr_len+2;
- if (out_index) {
- osmid idx[2];
- idx[0]=item_bin_get_wayid(orig);
- idx[1]=ftello(out);
- if (way_hash) {
- if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long)idx[0], NULL, NULL)))
- g_hash_table_insert(way_hash, (gpointer)(long)idx[0], (gpointer)(long)idx[1]);
- } else {
- if (!last_id || *last_id != idx[0])
- fwrite(idx, sizeof(idx), 1, out_index);
- if (last_id)
- *last_id=idx[0];
- }
-
- }
+ if (out_index)
+ write_item_way_subsection_index(out, out_index, out_graph, orig, last_id);
#if 0
fprintf(stderr,"first %d last %d type 0x%x len %d clen %d attr_len %d\n", first, last, new.type, new.len, new.clen, attr_len);
#endif
- fwrite(&new, sizeof(new), 1, out);
- fwrite(c+first, new.clen*4, 1, out);
- fwrite(attr, attr_len*4, 1, out);
+ dbg_assert(fwrite(&new, sizeof(new), 1, out)==1);
+ dbg_assert(fwrite(c+first, new.clen*4, 1, out)==1);
+ dbg_assert(fwrite(attr, attr_len*4, 1, out)==1);
#if 0
fwrite(&new, sizeof(new), 1, out_graph);
fwrite(c+first, new.clen*4, 1, out_graph);
diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c
index 68b837bc0..9d9f94145 100644
--- a/navit/maptool/tile.c
+++ b/navit/maptool/tile.c
@@ -336,8 +336,8 @@ write_item(char *tile, struct item_bin *ib, FILE *reference)
}
if (reference) {
int offset=th->total_size_used/4;
- fwrite(&th->zipnum, sizeof(th->zipnum), 1, reference);
- fwrite(&offset, sizeof(th->total_size_used), 1, reference);
+ dbg_assert(fwrite(&th->zipnum, sizeof(th->zipnum), 1, reference)==1);
+ dbg_assert(fwrite(&offset, sizeof(th->total_size_used), 1, reference)==1);
}
if (th->zip_data)
memcpy(th->zip_data+th->total_size_used, ib, size);
diff --git a/navit/maptool/zip.c b/navit/maptool/zip.c
index b75f1e3e7..f352e6353 100644
--- a/navit/maptool/zip.c
+++ b/navit/maptool/zip.c
@@ -20,6 +20,7 @@
#include <zlib.h>
#include <string.h>
#include <stdlib.h>
+#include "debug.h"
#include "maptool.h"
#include "config.h"
#include "zipfile.h"
@@ -261,16 +262,16 @@ write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data,
zip_info->offset+=sizeof(mac);
}
#endif
- fwrite(&cd, sizeof(cd), 1, zip_info->dir);
- fwrite(filename, filelen, 1, zip_info->dir);
+ dbg_assert(fwrite(&cd, sizeof(cd), 1, zip_info->dir)==1);
+ dbg_assert(fwrite(filename, filelen, 1, zip_info->dir)==1);
zip_info->dir_size+=sizeof(cd)+filelen;
if (zip_info->zip64) {
- fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir);
+ dbg_assert(fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir)==1);
zip_info->dir_size+=sizeof(cd_ext);
}
#ifdef HAVE_LIBCRYPTO
if (zip_info->passwd) {
- fwrite(&enc, sizeof(enc), 1, zip_info->dir);
+ dbg_assert(fwrite(&enc, sizeof(enc), 1, zip_info->dir)==1);
zip_info->dir_size+=sizeof(enc);
}
#endif
diff --git a/navit/navigation.c b/navit/navigation.c
index baab11376..7cfe886e9 100644
--- a/navit/navigation.c
+++ b/navit/navigation.c
@@ -109,6 +109,7 @@ struct suffix {
char *abbrev;
int gender;
} suffixes[]= {
+ /* DE */
{"weg", NULL, masculine},
/* {"platz", "pl.", masculine}, collides with Lithuanian "plentas" (which is more frequent) */
{"platz", NULL, masculine},
@@ -118,18 +119,16 @@ struct suffix {
{"gasse", NULL, feminine},
{"straße", "str.", feminine},
- /* some for the dutch lang. */
- {"straat", NULL, neuter},
-/* {"weg", NULL, neuter}, doubles-up with German */
- {"baan", NULL, neuter},
- {"laan", NULL, neuter},
- {"wegel", NULL, neuter},
-
- /* some for the english lang. */
+ /* EN */
{"street", NULL, masculine},
{"drive", NULL, masculine},
- /* some for Lithuanian, as per http://wiki.openstreetmap.org/wiki/WikiProject_Lithuania */
+ /* FR */
+ {"boulevard", NULL, masculine},
+ {"chemin", NULL, neuter},
+ {"rue", NULL, feminine},
+
+ /* LT, as per http://wiki.openstreetmap.org/wiki/WikiProject_Lithuania */
{"gatvė", "g.", feminine},
{"plentas", "pl.", masculine},
{"prospektas", "pr.", masculine},
@@ -137,6 +136,13 @@ struct suffix {
{"skersgatvis", "skg.", masculine},
{"aikštė", "a.", feminine},
+ /* NL */
+ {"straat", NULL, neuter},
+/* {"weg", NULL, neuter}, doubles-up with German */
+ {"baan", NULL, neuter},
+ {"laan", NULL, neuter},
+ {"wegel", NULL, neuter},
+
};
@@ -993,7 +999,7 @@ get_distance_str(struct navigation *nav, int dist_meters, enum attr_type type, i
dist_feet = round_distance_reduced(dist_feet);
}
- // check for statement in feet
+ /* check for statement in feet */
if (dist_feet <= 500)
{
if (is_length)
@@ -1144,158 +1150,6 @@ navigation_way_init(struct navigation_way *w)
}
-#if 0
-// /home/michael/src/navit/navit/navit/navigation.c:1039:1: warning: ‘navigation_way_get_exit_angle’ defined but not used [-Wunused-function]
-/**
- * @brief Returns the bearing at the end of a way
- *
- * @param w The way to examine
- *
- * @return The bearing, {@code 0 <= bearing < 360}.
- */
-static int
-navigation_way_get_exit_angle(struct navigation_way *w) {
- int ret = invalid_angle;
- struct coord cbuf[2];
- struct item *realitem;
- struct coord c;
- struct map_rect *mr;
-
- mr = map_rect_new(w->item.map, NULL);
- if (!mr)
- return ret;
-
- realitem = map_rect_get_item_byid(mr, w->item.id_hi, w->item.id_lo);
- if (!realitem) {
- dbg(lvl_warning,"Item from segment not found on map!\n");
- map_rect_destroy(mr);
- return ret;
- }
-
- if (realitem->type < type_line || realitem->type >= type_area) {
- map_rect_destroy(mr);
- return ret;
- }
-
- if (w->dir < 0) {
- if (item_coord_get(realitem, cbuf, 2) != 2) {
- dbg(lvl_warning,"Using calculate_angle() with a less-than-two-coords-item?\n");
- map_rect_destroy(mr);
- return ret;
- }
- c = cbuf[0];
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- }
- else {
- if (item_coord_get(realitem, cbuf, 2) != 2) {
- dbg(lvl_warning,"Using calculate_angle() with a less-than-two-coords-item?\n");
- map_rect_destroy(mr);
- return ret;
- }
-
- while (item_coord_get(realitem, &c, 1)) {
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- }
- }
-
- map_rect_destroy(mr);
-
- ret = road_angle(&cbuf[1],&cbuf[0],0);
-
- return ret;
-}
-#endif
-
-
-#if 0
-// /home/michael/src/navit/navit/navit/navigation.c:1110:1: warning: ‘navigation_way_get_angle_at’ defined but not used [-Wunused-function]
-/**
- * @brief Returns the bearing of a way at a given distance from its start
- *
- * {@code invalid_angle} will be returned if one of the following errors occurs:
- * <ul>
- * <li>The item is not found on the map</li>
- * <li>The item is not of the correct type</li>
- * <li>The item is shorter than {@code distance}</li>
- * </ul>
- *
- * @param pro The projection used by the map
- * @param w The way to examine
- * @param dist The distance from the start of the way at which to determine bearing
- *
- * @return The bearing, {@code 0 <= bearing < 360}, or {@code invalid_angle} if an error occurred.
- */
-static int
-navigation_way_get_angle_at(struct navigation_way *w, enum projection pro, double dist) {
- double dist_left = dist; /* distance from last examined point */
- int ret = invalid_angle;
- struct coord cbuf[2];
- struct item *realitem;
- struct coord c;
- struct map_rect *mr;
-
- mr = map_rect_new(w->item.map, NULL);
- if (!mr)
- return ret;
-
- realitem = map_rect_get_item_byid(mr, w->item.id_hi, w->item.id_lo);
- if (!realitem) {
- dbg(lvl_warning,"Item from segment not found on map!\n");
- map_rect_destroy(mr);
- return ret;
- }
-
- if (realitem->type < type_line || realitem->type >= type_area) {
- map_rect_destroy(mr);
- return ret;
- }
-
- if (item_coord_get(realitem, &cbuf[1], 1) != 1) {
- dbg(lvl_warning,"item has no coords\n");
- map_rect_destroy(mr);
- return ret;
- }
-
- if (w->dir < 0) {
- /* we're going against the direction of the item:
- * measure its total length and set distance_left to difference of total length and distance */
- dist_left = 0;
- while (item_coord_get(realitem, &c, 1)) {
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- dist_left += transform_distance(pro, &cbuf[0], &cbuf[1]);
- }
-
- // FIXME: dist_left is now the complete length - subtract dist
-
- item_coord_rewind(realitem);
-
- if (item_coord_get(realitem, &cbuf[1], 1) != 1) {
- dbg(lvl_warning,"item has no more coords after rewind\n");
- map_rect_destroy(mr);
- return ret;
- }
- }
-
- while (item_coord_get(realitem, &c, 1)) {
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- dist_left -= transform_distance(pro, &cbuf[0], &cbuf[1]);
- if (dist_left <= 0) {
- ret = road_angle(&cbuf[0], &cbuf[1], w->dir);
- map_rect_destroy(mr);
- return ret;
- }
- }
-
- map_rect_destroy(mr);
- return ret;
-}
-#endif
-
-
/**
* @brief Returns the maximum delta between a reference bearing and any segment of a given way, up to a given distance from its start
*
@@ -2190,7 +2044,6 @@ maneuver_required2 (struct navigation *nav, struct navigation_itm *old, struct n
* side effects.
*/
if (m.is_same_street && is_same_street2(old->way.name, old->way.name_systematic, w->name, w->name_systematic) && (!is_motorway_like(&(old->way), 0) || (!is_motorway_like(w, 0) && w->item.type != type_ramp)) && is_way_allowed(nav,w,2))
- //if (m.is_same_street && is_same_street2(old->way.name, old->way.name_systematic, w->name, w->name_systematic) && (!is_motorway_like(&(old->way), 0) || !is_motorway_like(w, 1)) && is_way_allowed(nav,w,2))
m.is_same_street=0;
/* If the route category changes to a lower one but another road has the same route category as old,
* it is not clear which of the two the driver would perceive as the "same street", hence reset is_same_street */
@@ -2242,7 +2095,7 @@ maneuver_required2 (struct navigation *nav, struct navigation_itm *old, struct n
int hist_dist = old->length; /* distance between previous and current maneuver */
ni = old;
while (ni && (hist_through_segments == 0) && (hist_dist <= junction_limit)) {
- // TODO: shouldn't the condition be (hist_through_segments < 2) to catch through segments that are slightly offset??
+ /* TODO: shouldn't the condition be (hist_through_segments < 2) to catch through segments that are slightly offset?? */
struct navigation_way *w = ni->way.next;
while (w) {
if (is_same_street2(new->way.name, new->way.name_systematic, w->name, w->name_systematic)
@@ -2839,10 +2692,10 @@ command_new(struct navigation *this_, struct navigation_itm *itm, struct navigat
}
- // Investigate the strengthening of announcement.
+ /* Investigate the strengthening of announcement. */
switch (more_ways_for_strength) {
case 0:
- // Only one possibility to turn to this direction
+ /* Only one possibility to turn to this direction */
if (ret->delta < -sharp_turn_limit) {
ret->maneuver->type = type_nav_left_3; /* strongly left */
} else if (ret->delta <= 0) {
@@ -2856,7 +2709,7 @@ command_new(struct navigation *this_, struct navigation_itm *itm, struct navigat
case 1:
/* One additional possibility to turn to the same direction */
if (turn_no_of_route_way == 0) {
- // the route is less strong to turn
+ /* the route is less strong to turn */
if (ret->delta < -turn_2_limit) {
ret->maneuver->type = type_nav_left_2; /* normally left */
} else if (ret->delta <= 0) {
@@ -2903,7 +2756,7 @@ command_new(struct navigation *this_, struct navigation_itm *itm, struct navigat
}
}
else if (turn_no_of_route_way > 1) {
- // if the route is the strongest of all possible turns here
+ /* if the route is the strongest of all possible turns here */
if (ret->delta < -u_turn_limit) {
ret->maneuver->type = type_nav_turnaround_left; /* turn around left */
} else if (ret->delta < -sharp_turn_limit) {
@@ -3659,7 +3512,7 @@ show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigat
static char *
show_next_maneuvers(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum attr_type type)
{
- int distance = itm->dest_length-cmd->itm->dest_length; // distance from e.g. current GPS position to next announced turn position
+ int distance = itm->dest_length-cmd->itm->dest_length; /* distance from e.g. current GPS position to next announced turn position */
enum announcement_level level;
char *ret,*buf,*next;
@@ -3697,17 +3550,17 @@ show_next_maneuvers(struct navigation *nav, struct navigation_itm *itm, struct n
}
if (cmd->next && cmd->itm) {
- // determine the level of the command that comes immediately after that.
+ /* determine the level of the command that comes immediately after that. */
enum announcement_level nextlevel = navigation_get_announce_level(nav, cmd->itm->way.item.type, cmd->itm->dest_length - cmd->next->itm->dest_length);
- // If this level starts with 1 or 0 concatenate the following announcement to the current:
+ /* If this level starts with 1 or 0 concatenate the following announcement to the current: */
if (nextlevel <= level_soon) {
next = show_maneuver(nav, cmd->itm, cmd->next, type, level_connect);
if (*next != '\0') /* is the second announcement not an empty string? */
{
cmd->itm->told = 1;
buf = ret;
- ret = g_strdup_printf("%s, %s", buf, next); // concatenate both announcements
+ ret = g_strdup_printf("%s, %s", buf, next); /* concatenate both announcements */
g_free(buf);
}
g_free(next);