From 168d3b386dca8e67e079f149936c5ea3553d1079 Mon Sep 17 00:00:00 2001 From: steffen Date: Tue, 23 Apr 2013 19:58:10 +0000 Subject: [PATCH] osm_webload fixed.. refresh from openstreetmap. --- base/config.c | 38 +++++++++++++++++++++++++++----------- mapsys/map.c | 3 ++- mapsys/map.h | 2 +- mapsys/map_osmload.c | 25 ++++++++++++++++++++++--- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/base/config.c b/base/config.c index 2372a8c..d8bfebf 100644 --- a/base/config.c +++ b/base/config.c @@ -78,23 +78,22 @@ void config_init () { */ #else /* windows ce version */ -#if defined(__MINGW32CE__) || defined(_WIN32_WCE) + #if defined(__MINGW32CE__) || defined(_WIN32_WCE) strcpy (cfg.mappath, "\\Storage Card\\map\\"); strcpy (cfg.configpath, "\\My Documents\\wOSMroute\\"); strcpy (cfg.logpath, "\\My Documents\\wOSMroute\\Logdir\\"); -#endif + #endif /* windows version */ -#if defined(__MINGW32__) && !defined(__MINGW32CE__) && !defined(_WIN32_WCE) + #if defined(__MINGW32__) && !defined(__MINGW32CE__) && !defined(_WIN32_WCE) TCHAR szPath[MAX_PATH]; if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, 0, szPath))) { snprintf (cfg.configpath, LEN_FILENAME, "%s\\wOSMroute\\", szPath); snprintf (cfg.logpath, LEN_FILENAME, "%s\\wOSMroute\\Logdir\\", szPath); } -#endif - + #endif /* linux version */ -#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) + #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) char *hd; if ((hd = getenv ("HOME")) == NULL) { @@ -106,7 +105,7 @@ void config_init () { snprintf (cfg.configpath, LEN_FILENAME, "%s/.OSMroute/", hd); snprintf (cfg.logpath, LEN_FILENAME, "%s/.OSMroute/Logdir/", hd); } -#endif + #endif d_print_init(); if (stat(cfg.configpath, &sb) == -1) { @@ -114,12 +113,15 @@ void config_init () { strncpy (fn, cfg.configpath, LEN_FILENAME); fn[strlen(fn)-1] = 0; d_printf ("create config dir:%s", fn); -#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) + #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) mkdir (fn, 0755); -#else + #else mkdir (fn); -#endif + #endif } +#endif + + config_load (); if (stat(cfg.logpath, &sb) == -1) { char fn[LEN_FILENAME]; @@ -132,8 +134,19 @@ void config_init () { mkdir (fn); #endif } + + if (stat(cfg.mappath, &sb) == -1) { + char fn[LEN_FILENAME]; + strncpy (fn, cfg.mappath, LEN_FILENAME); + fn[strlen(fn)-1] = 0; + d_printf ("create map dir:%s", fn); +#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) + mkdir (fn, 0755); +#else + mkdir (fn); #endif - config_load (); + } + config_save (); if (cfg.gps_flags) SETFLAG(gpsflags, GPSF_LOG); @@ -184,6 +197,8 @@ void config_load () { strncpy (cfg.mappath, value, LEN_FILENAME); if (!strcmp (keyword, "temppath")) strncpy (cfg.temppath, value, LEN_FILENAME); + if (!strcmp (keyword, "cachepath")) + strncpy (cfg.cachepath, value, LEN_FILENAME); if (!strcmp (keyword, "logpath")) strncpy (cfg.logpath, value, LEN_FILENAME); #if defined(SPOSMROUTE) @@ -231,6 +246,7 @@ void config_save () { fprintf (f, "# config file for osmroute\n\n"); fprintf (f, "mappath=%s\n", cfg.mappath); fprintf (f, "logpath=%s\n", cfg.logpath); + fprintf (f, "cachepath=%s\n", cfg.cachepath); fprintf (f, "temppath=%s\n", cfg.temppath); #if defined(SPOSMROUTE) fprintf (f, "last_lon=%f\n", cfg.last_lon); diff --git a/mapsys/map.c b/mapsys/map.c index 8350031..77c3b02 100644 --- a/mapsys/map.c +++ b/mapsys/map.c @@ -52,8 +52,9 @@ void map_init () { d_printf (" Directory: %s", cfg.mappath); strncpy (fn, cfg.mappath, LEN_FILENAME); - if (fn[(i=strlen(fn))] == DIR_SEP) fn[i] = '\0'; + if (fn[(i=strlen(fn))-1] == DIR_SEP) fn[i] = '\0'; else { + d_printf (" append '%c' to mappath.", DIR_SEP); cfg.mappath[strlen(cfg.mappath)+1] = '\0'; cfg.mappath[strlen(cfg.mappath)] = DIR_SEP; } diff --git a/mapsys/map.h b/mapsys/map.h index bec78b6..6f1007c 100644 --- a/mapsys/map.h +++ b/mapsys/map.h @@ -34,7 +34,7 @@ #define MAP_W_NAMELEN 64 #define MAP_HASH_DEGFACTOR 80.0f -#define MAP_OSMWEB_DELTA 0.025f +#define MAP_OSMWEB_DELTA 0.0125f #define MAP_LSHASHFACTOR 80 #define MAP_LSFREECNT 4096 diff --git a/mapsys/map_osmload.c b/mapsys/map_osmload.c index a203458..1c28f56 100644 --- a/mapsys/map_osmload.c +++ b/mapsys/map_osmload.c @@ -659,7 +659,8 @@ int osm_node_load (struct osm_node *node, unsigned long long int id) { * save the waynode data inside the hash file to read all needed data later on * and check the waynodes inside the map files. */ -void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned long long int id, unsigned short int subid, unsigned short int pnr) { +void osm_waynode_add (struct osm_node *node, long long int nodepos, unsigned long long int id, + unsigned short int subid, unsigned short int pnr) { struct s_osm_hashnodes *hnodes = NULL; struct osm_nodehash hash; struct osm_waynode wn; @@ -1023,7 +1024,8 @@ void osm_marea_new (struct s_osmmarea *a, int max) { * hash data block. I case the way goes over more hash segments the * way will be slit into peaces * - * splitting into peaces does not work yet + * splitting into peaces does not work yet, also taking care of the + * polygons, no angles over 180°. * * CALL with NULL will free all unneeded memory */ @@ -1785,6 +1787,21 @@ void map_load_web (struct map_pos hs, struct map_pos he) { char fcache[LEN_FILENAME]; } wl[MLWEBMAX]; + d_printf ("map_load_web: (%f , %f) --> (%f , %f)", hs.lon, hs.lat, he.lon, he.lat); + + /* check for cache directory */ + if (stat(cfg.cachepath, &sb) == -1) { + char fn[LEN_FILENAME]; + strncpy (fn, cfg.cachepath, LEN_FILENAME); + fn[strlen(fn)-1] = 0; + d_printf ("create cache dir:%s", fn); + #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__) + mkdir (fn, 0755); + #else + mkdir (fn); + #endif + } + app.status = APPSTATUS_loadfromweb; #if defined (_LINUX_) osm_load_from_web_end = he; @@ -1798,6 +1815,8 @@ void map_load_web (struct map_pos hs, struct map_pos he) { for (h.lat = hs.lat; h.lat < he.lat || cmpf(h.lat, he.lat); h.lat = h.lat + MAP_OSMWEB_DELTA) { do { main_wnd_loop (-1,-1); + /* check for any finished forked processes + * if so, call osm_loadfile */ for (i = 0; i < MLWEBMAX; i++) { if (wl[i].p.used) { ret = execwait (&wl[i].p); @@ -1811,7 +1830,7 @@ void map_load_web (struct map_pos hs, struct map_pos he) { for (i = 0; i < MLWEBMAX && wl[i].p.used == 1; i++); } - while (i >= MLWEBMAX); + while (i >= MLWEBMAX); /* exit if we can fork another process */ y1 = CALC_START (h.lon, MAP_OSMWEB_DELTA); x1 = CALC_START (h.lat, MAP_OSMWEB_DELTA);