You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(92) |
Dec
(141) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(126) |
Feb
(72) |
Mar
(31) |
Apr
(200) |
May
(81) |
Jun
(130) |
Jul
(112) |
Aug
(134) |
Sep
(76) |
Oct
(89) |
Nov
(153) |
Dec
(9) |
2007 |
Jan
(59) |
Feb
(82) |
Mar
(50) |
Apr
(20) |
May
(9) |
Jun
(81) |
Jul
(41) |
Aug
(109) |
Sep
(91) |
Oct
(87) |
Nov
(33) |
Dec
(60) |
2008 |
Jan
(21) |
Feb
(15) |
Mar
(38) |
Apr
(75) |
May
(59) |
Jun
(46) |
Jul
(30) |
Aug
(20) |
Sep
(35) |
Oct
(32) |
Nov
(34) |
Dec
(19) |
2009 |
Jan
(29) |
Feb
(71) |
Mar
(54) |
Apr
(17) |
May
(4) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(58) |
Sep
(7) |
Oct
(7) |
Nov
(12) |
Dec
(18) |
2011 |
Jan
(17) |
Feb
(29) |
Mar
(11) |
Apr
(5) |
May
(1) |
Jun
|
Jul
|
Aug
(11) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(87) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(44) |
Jun
(79) |
Jul
(16) |
Aug
(31) |
Sep
|
Oct
(51) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <pg...@us...> - 2014-06-07 20:23:14
|
Revision: 2729 http://sourceforge.net/p/roadmap/code/2729 Author: pgf Date: 2014-06-07 20:23:11 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: can now create quadtiles using the native XML parser previously we relied on the OSM Binary Protocol to produce quadtiles. the trouble was that that protocol never took off, and there are no public servers for that protocol. so we used a (slow) PHP script to translate XML from the regular servers into the binary protocol. this commit eliminates the need for that script. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c trunk/roadmap/src/roadmap_locator.c trunk/roadmap/src/roadmap_osm.c trunk/roadmap/src/roadmap_osm.h Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:23:06 UTC (rev 2728) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:23:11 UTC (rev 2729) @@ -32,6 +32,7 @@ #include <sys/types.h> #include <ctype.h> #include <errno.h> +#include <signal.h> #include "roadmap.h" #include "roadmap_types.h" @@ -54,9 +55,6 @@ int BuildMapNoLongLines; -#define BUILDMAP_FORMAT_OSMBIN 1 - -static char *BuildMapFormat; static int BuildMapReplaceAll = 0; static char *BuildMapFileName = 0; @@ -64,7 +62,7 @@ struct opt_defs options[] = { - {"format", "f", opt_string, "osmbinary", + {"format", "f", opt_string, "osmtext", "Input format (OSM protocol)"}, {"class", "c", opt_string, "default/All", "The class file to create the map for"}, @@ -74,15 +72,15 @@ "Re-request maps that are already present"}, {"maps", "m", opt_string, "", "Location for the generated map files"}, - {"source", "s", opt_string, "osmgetbmap", - "commandname or URL for accessing map data"}, + {"fetcher", "F", opt_string, "osm_fetch_tile", + "commandname for accessing map data to stdout"}, {"tileid", "t", opt_int, "", "Fetch the given numeric tileid (use 0x for hex)"}, {"decode", "d", opt_string, "", "Analyze given tileid (or quadtile filename) (hex only)"}, {"encode", "e", opt_string, "", "Report tileid for given lat,lon"}, - {"listonly", "l", opt_int, "0", + {"listonly", "l", opt_flag, "0", "Dump the list of filenames and bounding boxes for the request"}, {"quiet", "q", opt_flag, "0", "Show less progress information"}, @@ -107,6 +105,7 @@ char *parent; int ret = 0; + /* create all parents of our file */ parent = roadmap_path_parent(BuildMapResult, filename); roadmap_path_create (parent); roadmap_path_free(parent); @@ -127,6 +126,9 @@ if (ret != 0) { ret = buildmap_db_remove (BuildMapResult, filename); } + + buildmap_osm_text_save_wayids(BuildMapResult, filename); + return 0; } @@ -139,7 +141,7 @@ char db_name[128]; - roadmap_osm_filename(db_name, 1, tileid); + roadmap_osm_filename(db_name, 1, tileid, ".rdm"); buildmap_osm_save_custom(db_name, writeit); } @@ -181,7 +183,7 @@ for (dir = TILE_SOUTHEAST; dir < TILE_NORTHWEST+1; dir++) { bit = (1 << dir); n = roadmap_osm_tileid_to_neighbor(tileid, dir); - roadmap_osm_filename(filename, 1, n); + roadmap_osm_filename(filename, 1, n, ".rdm"); if (roadmap_file_exists (BuildMapResult, filename)) have |= bit; } @@ -195,19 +197,21 @@ /** * @brief query the web server using the OSM binary protocol, and process it * @param tileid - * @param source - * @param cmdfmt is a printf style format string used to format the web query + * @param fetcher * @return */ static int -buildmap_osm_process_one_tile - (int tileid, const char *source, const char *cmdfmt) +buildmap_osm_process_one_tile (int tileid, const char *fetcher, const char *format) { - char urlcmd[256]; + char cmd[512]; + char bbox[100], *bbp; FILE *fdata; int have = 0; int ret, bits, trutile; + RoadMapArea edges[1]; + char *xmlfile; + char *parent; bits = tileid2bits(tileid); buildmap_verbose("called for tileid 0x%x, bits %d", tileid, bits); @@ -217,61 +221,131 @@ buildmap_verbose ("tileid %d, have 0x%02x", tileid, have); trutile = tileid2trutile(tileid); - snprintf(urlcmd, sizeof(urlcmd), cmdfmt, source, trutile, bits, have); - buildmap_info("command is \"%s\"", urlcmd); + + roadmap_osm_tileid_to_bbox(tileid, edges); + /* w, s, e, n */ + bbp = bbox; + bbp += sprintf(bbp, "%s,", + roadmap_math_to_floatstring(0, edges->west, MILLIONTHS)); + bbp += sprintf(bbp, "%s,", + roadmap_math_to_floatstring(0, edges->south, MILLIONTHS)); + bbp += sprintf(bbp, "%s,", + roadmap_math_to_floatstring(0, edges->east, MILLIONTHS)); + bbp += sprintf(bbp, "%s", + roadmap_math_to_floatstring(0, edges->north, MILLIONTHS)); + + /* create all parents of our file */ + parent = roadmap_path_parent(BuildMapResult, + roadmap_osm_filename(0, 1, tileid, ".osm")); + roadmap_path_create(parent); + roadmap_path_free(parent); - fdata = popen(urlcmd, "r"); - if (fdata == NULL) { - buildmap_fatal(0, "couldn't open \"%s\"", urlcmd); - } + xmlfile = roadmap_path_join(BuildMapResult, + roadmap_osm_filename(0, 1, tileid, ".osm")); - buildmap_osm_common_find_layers(); + snprintf(cmd, sizeof(cmd), "%s --trutile %d " + "--bits %d --have %d --bbox %s --xmlfile %s", + fetcher, trutile, bits, have, bbox, xmlfile); - ret = buildmap_osm_binary_read(fdata); +// sprintf(cmd, "cat /tmp/out.xml > %s", xmlfile); - if (pclose(fdata) != 0) { - buildmap_error(0, "problem fetching data (pclose: %s), continuing", strerror(errno)); - // ret = -1; - } + if (strcasecmp(format, "osmbinary") == 0) { + buildmap_info("command is \"%s\"", cmd); - /* - * When the OSM server is congested, it returns - * HTTP/1.1 509 Bandwidth Limit Exceeded - * - * Don't fail on this, but retry after a while. - */ - int cnt = 0; - while (ret == -509 && cnt++ < 100) { - sleep(30); - fdata = popen(urlcmd, "r"); - if (fdata == NULL) { - buildmap_fatal(0, "couldn't open \"%s\"", urlcmd); - } + fdata = popen(cmd, "r"); + if (fdata == NULL) { + buildmap_fatal(0, "couldn't open \"%s\"", cmd); + } - buildmap_osm_common_find_layers(); + buildmap_osm_common_find_layers(); - ret = buildmap_osm_binary_read(fdata); + ret = buildmap_osm_binary_read(fdata); - if (pclose(fdata) != 0) { - buildmap_error(0, "problem fetching data (pclose: %s), continuing", strerror(errno)); - // ret = -1; - } + if (pclose(fdata) != 0) { + buildmap_error(0, "problem fetching data (pclose: %s)", strerror(errno)); + ret = -1; + } + + /* + * When the OSM server is congested, it returns + * HTTP/1.1 509 Bandwidth Limit Exceeded + * + * Don't fail on this, but retry after a while. + */ + int cnt = 0; + while (ret == -509 && cnt++ < 100) { + sleep(30); + fdata = popen(cmd, "r"); + if (fdata == NULL) { + buildmap_fatal(0, "couldn't open \"%s\"", cmd); + } + + buildmap_osm_common_find_layers(); + + ret = buildmap_osm_binary_read(fdata); + + if (pclose(fdata) != 0) { + buildmap_error(0, "problem fetching data (pclose: %s), continuing", strerror(errno)); + ret = -1; + } + } + + } else { + struct stat statbuf; + if (!BuildMapReplaceAll && + stat(xmlfile, &statbuf) == 0 && + statbuf.st_size != 0) + ret = 0; + else + ret = system(cmd); + + if ((WEXITSTATUS(ret) != 0) || + (WIFSIGNALED(ret) && + (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))) { + ret = -1; + } else { + fdata = fopen(xmlfile, "r"); + if (!fdata) { + buildmap_fatal(0, "couldn't open \"%s\"", xmlfile); + } + ret = buildmap_osm_text_read(fdata, 0, 0); + fclose(fdata); + } } + return ret; } +int buildmap_osm_filename_to_tileid(char *fn, int *ptileid, char *suffix) +{ + int n; + char pattern[32], tileid[32], *p; + + /* Find last path separator, if any */ + p = strrchr(fn, '/'); + + sprintf(pattern, "qt%%[0-9a-fA-F]%s", suffix); + n = sscanf(p ? p+1 : fn, pattern, tileid); + if (n == 1 && strlen(tileid) == 8) { + *ptileid = strtol(tileid, 0, 16); + return 1; + } + return 0; +} + /** * @brief process a .osm text file * @param fn the file name * @return success indicator */ -int buildmap_osm_text_process_file(char *fn) +int buildmap_osm_text_process_file(char *fn, char *ofn) { int n, ret = 0, ret2; FILE *f; char country[6], division[6]; int fips, country_num = 0, division_num = 0; + int tileid; f = fopen(fn, "r"); if (f == NULL) { @@ -300,9 +374,12 @@ country_num = fips / 1000; division_num = fips % 1000; + } else if (buildmap_osm_filename_to_tileid(fn, &tileid, ".osm")) { + country_num = division_num = 0; } else { - buildmap_fatal(0, - "Invalid file name \"%s\" should be ISO or USC shape", fn); + buildmap_info( + "Proper file name \"%s\" should be quadtile, ISO or USC shape.", fn); + country_num = division_num = 0; } buildmap_metadata_add_attribute ("Class", "Name", "All"); @@ -317,7 +394,7 @@ } buildmap_db_sort(); - ret2 = buildmap_osm_save_custom(BuildMapFileName, (ret == 0) ? 1 : 0); + ret2 = buildmap_osm_save_custom(ofn, (ret == 0) ? 1 : 0); if (ret2 != 0) return ret2; @@ -325,6 +402,34 @@ } +int qsort_compare_tiles(const void *t1, const void *t2) +{ + int tile1 = *(int *)t1; + int tile2 = *(int *)t2; + RoadMapArea edges1, edges2; + + roadmap_osm_tileid_to_bbox(tile1, &edges1); + roadmap_osm_tileid_to_bbox(tile2, &edges2); + + if (edges1.north > edges2.north) // tile 1 is further north + return -1; + if (edges1.north < edges2.north) // tile 1 is further south + return 1; + if (edges1.west < edges2.west) // tile 1 is further west + return -1; + if (edges1.west > edges2.west) // tile 1 is further east + return 1; + return 1; +} + +void +buildmap_osm_sort_tiles(int **tilesp, int count) +{ + int *tiles = *tilesp; + + qsort(tiles, count, sizeof(int), qsort_compare_tiles); +} + /** * @brief populates a list of tileids necessary to give coverage * for the given position @@ -358,9 +463,14 @@ width = 1; ofound = -1; while (found != ofound) { - /* we keep checking until a trip around the block says - * that we haven't found any visibility overlaps - * in a full circuit. + /* start with one square in the middle, at our requested + * point. go northwest, then start walking east across 3 + * blocks testing visibility as we go, then south, west, and + * north. repeat by going northwest again, increasing width + * to 5, etc. we keep checking until a trip around the block + * says that we haven't found any visibility overlaps in a + * full circuit. (note that the northwest block isn't + * actually checked and recorded until the _end_ of the loop.) */ ofound = found; tileid = roadmap_osm_tileid_to_neighbor(tileid, TILE_NORTHWEST); @@ -499,7 +609,7 @@ int childid, bits, j; if (roadmap_file_exists (BuildMapResult, - roadmap_osm_filename(NULL, 1, tileid))) { + roadmap_osm_filename(NULL, 1, tileid, ".rdm"))) { return 1; } @@ -521,78 +631,78 @@ * @param tiles * @param bits * @param count - * @param source - * @param cmdfmt + * @param fetcher * @return */ static int buildmap_osm_process_tiles (int *tiles, int bits, int count, - const char *source, const char *cmdfmt) + const char *fetcher, const char *format) { int i, ret = 0; int nbits; - char name[64]; + char name[128]; + char osmfile[128]; for (i = 0; i < count; i++) { int tileid = tiles[i]; - roadmap_osm_filename(name, 1, tileid); + roadmap_osm_filename(name, 1, tileid, ".rdm"); if (!BuildMapReplaceAll && roadmap_osm_tile_has_coverage(tileid)) { buildmap_info("have coverage for tile %s already, skipping", name); continue; } - if (strcasecmp(BuildMapFormat, "osmbinary") == 0) { + buildmap_info(""); + buildmap_info + ("processing tile %d of %d, file '%s'", i+1, count, name); - buildmap_info(""); - buildmap_info - ("processing tile %d of %d, file '%s'", i, count, name); + roadmap_osm_filename(osmfile, 1, tileid, ".osm"); + ret = buildmap_osm_process_one_tile (tileid, fetcher, format); - ret = buildmap_osm_process_one_tile (tileid, source, cmdfmt); + if (ret == -2) { + /* we got a "tile too big" error. try for four + * subtiles instead. + */ + int n; - if (ret == -2) { - /* we got a "tile too big" error. try for four - * subtiles instead. - */ - int n; + nbits = tileid2bits(tileid); + if (nbits >= TILE_MAXBITS-1) { + buildmap_info("can't split tile 0x%x further", tileid); + continue; + } + buildmap_info + ("splitting tile 0x%x, new bits %d", tileid, nbits+2); - nbits = tileid2bits(tileid); - if (nbits >= TILE_MAXBITS-1) { - buildmap_info("can't split tile 0x%x further", tileid); - continue; - } - buildmap_info - ("splitting tile 0x%x, new bits %d", tileid, nbits+2); + count += 3; + tiles = realloc(tiles, sizeof(*tiles) * count); + buildmap_check_allocated(tiles); - count += 3; - tiles = realloc(tiles, sizeof(*tiles) * count); - buildmap_check_allocated(tiles); + /* insert new tiles in-place, so that we try the new size right away. + * this doesn't matter, except for the user who is trying + * to figure out what tile size is needed. + */ + for (n = count - 1; n >= i + 3; n--) { + tiles[n] = tiles[n-4]; + } + roadmap_osm_tilesplit(tileid, &tiles[i], 2); + i--; + continue; + } - /* insert new tiles in-place, so that we try the new size right away. - * this doesn't matter, except for the user who is trying - * to figure out what tile size is needed. - */ - for (n = count - 1; n >= i + 3; n--) { - tiles[n] = tiles[n-4]; - } - roadmap_osm_tilesplit(tileid, &tiles[i], 2); - i--; - continue; - } - - if (ret < 0) break; - } + if (ret < 0) break; - if (ret > 0) buildmap_db_sort(); + if (ret >= 0) { + buildmap_db_sort(); - if (buildmap_is_verbose()) { - roadmap_hash_summary(); - buildmap_db_summary(); + if (buildmap_is_verbose()) { + roadmap_hash_summary(); + buildmap_db_summary(); + } + + buildmap_osm_save(tileid, 1); } - buildmap_osm_save(tileid, ret); - buildmap_db_reset(); roadmap_hash_reset(); } @@ -772,6 +882,25 @@ exit(1); } +void buildmap_osm_list_tiles(int *tileslist, int count) +{ + int i, n; + char filename[128]; + RoadMapArea edges[1]; + + for (i = 0; i < count; i++) { + n = tileslist[i]; + roadmap_osm_filename(filename, 1, n, ".rdm"); + printf("%s ", filename); + roadmap_osm_tileid_to_bbox(n, edges); + /* w, s, e, n */ + printf("%s,", roadmap_math_to_floatstring(0, edges->west, MILLIONTHS)); + printf("%s,", roadmap_math_to_floatstring(0, edges->south, MILLIONTHS)); + printf("%s,", roadmap_math_to_floatstring(0, edges->east, MILLIONTHS)); + printf("%s\n", roadmap_math_to_floatstring(0, edges->north, MILLIONTHS)); + } +} + /** * @brief main program * @param argc @@ -790,7 +919,8 @@ char *decode, *encode; int listonly; int tileid; - char *class, *latlonarg, *source, *cmdfmt, *inputfile; + char *class, *latlonarg, *fetcher, *inputfile; + char *format; BuildMapResult = strdup(roadmap_path_preferred("maps")); /* default. */ @@ -802,12 +932,12 @@ error = opt_val("verbose", &verbose) || opt_val("debug", &debug) || opt_val("quiet", &quiet) || - opt_val("format", &BuildMapFormat) || + opt_val("format", &format) || opt_val("class", &class) || opt_val("bits", &osm_bits) || opt_val("replace", &BuildMapReplaceAll) || opt_val("maps", &BuildMapResult) || - opt_val("source", &source) || + opt_val("fetcher", &fetcher) || opt_val("tileid", &tileid) || opt_val("decode", &decode) || opt_val("encode", &encode) || @@ -831,22 +961,17 @@ exit ( buildmap_osm_encode(encode, osm_bits) ); } - if (strcasecmp(BuildMapFormat, "osmtext") != 0) { - } else if (strcasecmp(BuildMapFormat, "osmbinary") != 0) { + if (strcasecmp(format, "osmtext") != 0 && + strcasecmp(format, "osmbinary") != 0) { fprintf (stderr, - "unsupported protocol input format %s", BuildMapFormat); + "unsupported protocol input format %s", format); exit(1); } - if (!*source) { - usage (argv[0], "missing source (commandname or URL) option"); + if (!*fetcher) { + usage (argv[0], "missing fetcher command option"); } - if (strncmp(source, "http:", 5) == 0) { - cmdfmt = "wget -q -O - '%s?tile=%d&ts=%d&have=%d'"; - } else { - cmdfmt = "%s -t %d -b %d -h %d"; - } if (debug) buildmap_message_adjust_level (BUILDMAP_MESSAGE_DEBUG); @@ -867,7 +992,8 @@ count = 1; } else if (*inputfile && *BuildMapFileName) { - exit(buildmap_osm_text_process_file(inputfile)); + int r = buildmap_osm_text_process_file(inputfile, BuildMapFileName); + exit(r); } else if (*inputfile) { usage(argv[0], "cannot specify -i without -o"); } else if (*BuildMapFileName) { @@ -885,33 +1011,22 @@ buildmap_info("processing with bits '%d'", osm_bits); count = buildmap_osm_which_tiles(latlonarg, &tileslist, osm_bits); - if (listonly) { - int i, n; - char filename[128]; - RoadMapArea edges[1]; - for (i = 0; i < count; i++) { - n = tileslist[i]; - roadmap_osm_filename(filename, 1, n); - printf("%s ", filename); - roadmap_osm_tileid_to_bbox(n, edges); - /* w, s, e, n */ - printf("%s,", - roadmap_math_to_floatstring(0, edges->west, MILLIONTHS)); - printf("%s,", - roadmap_math_to_floatstring(0, edges->south, MILLIONTHS)); - printf("%s,", - roadmap_math_to_floatstring(0, edges->east, MILLIONTHS)); - printf("%s\n", - roadmap_math_to_floatstring(0, edges->north, MILLIONTHS)); - } + /* we did a center-out spiral search to find the tiles we + * need. but we want to process them from their northwest + * corner to the southwest, because that matches our tile merge + * heuristic. sort the tiles to that order now. + */ + buildmap_osm_sort_tiles(&tileslist, count); + if (listonly) { + buildmap_osm_list_tiles(tileslist, count); exit(0); } } error = buildmap_osm_process_tiles - (tileslist, osm_bits, count, source, cmdfmt); + (tileslist, osm_bits, count, fetcher, format); free (tileslist); Modified: trunk/roadmap/src/roadmap_locator.c =================================================================== --- trunk/roadmap/src/roadmap_locator.c 2014-06-07 20:23:06 UTC (rev 2728) +++ trunk/roadmap/src/roadmap_locator.c 2014-06-07 20:23:11 UTC (rev 2729) @@ -177,7 +177,7 @@ if (fips > 1000000) { roadmap_iso_mapfile_from_fips(buf, fips); } else if (fips < 0) { - roadmap_osm_filename(buf, 1, fips); + roadmap_osm_filename(buf, 1, fips, ".rdm"); } else { roadmap_county_filename(buf, fips); } Modified: trunk/roadmap/src/roadmap_osm.c =================================================================== --- trunk/roadmap/src/roadmap_osm.c 2014-06-07 20:23:06 UTC (rev 2728) +++ trunk/roadmap/src/roadmap_osm.c 2014-06-07 20:23:11 UTC (rev 2729) @@ -208,7 +208,7 @@ } -char *roadmap_osm_filename(char *buf, int dirpath, int tileid) { +char *roadmap_osm_filename(char *buf, int dirpath, int tileid, char *suffix) { int a, b; char *n; @@ -230,7 +230,7 @@ n += sprintf(n, "qt%d/%02x/%02x/", tileid2bits(tileid), a, b); } - n += sprintf(n, "qt%08x.rdm", tileid); + n += sprintf(n, "qt%08x%s", tileid, suffix); return buf; } @@ -282,7 +282,7 @@ if (roadmap_osm_bits_paths[bits] && roadmap_file_exists (roadmap_osm_bits_paths[bits], - roadmap_osm_filename(NULL, 1, tileid))) { + roadmap_osm_filename(NULL, 1, tileid, ".rdm"))) { roadmap_osm_add_tile_to_list(tileid); } else { if (bits < roadmap_osm_maps_smallest) { @@ -314,7 +314,7 @@ int bits; roadmap_osm_maps_available = 0; - for (bits = RoadMapOSMBits; bits < TILE_MAXBITS; bits++) { + for (bits = RoadMapOSMBits; bits <= TILE_MAXBITS; bits++) { sprintf(bitsdir, "qt%d", bits); path = roadmap_scan ("maps", bitsdir); if (path) { Modified: trunk/roadmap/src/roadmap_osm.h =================================================================== --- trunk/roadmap/src/roadmap_osm.h 2014-06-07 20:23:06 UTC (rev 2728) +++ trunk/roadmap/src/roadmap_osm.h 2014-06-07 20:23:11 UTC (rev 2729) @@ -52,7 +52,7 @@ int roadmap_osm_latlon2tileid(int lat, int lon, int bits); void roadmap_osm_tileid_to_bbox(int tileid, RoadMapArea *edges); -char *roadmap_osm_filename(char *buf, int dirpath, int tileid); +char *roadmap_osm_filename(char *buf, int dirpath, int tileid, char *suffix); void roadmap_osm_tilesplit(int tileid, int *ntiles, int howmanybits); int roadmap_osm_by_position This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:23:09
|
Revision: 2728 http://sourceforge.net/p/roadmap/code/2728 Author: pgf Date: 2014-06-07 20:23:06 +0000 (Sat, 07 Jun 2014) Log Message: ----------- osm_fetch_tile: new quadtile fetch helper Added Paths: ----------- trunk/roadmap/src/osm_fetch_tile Added: trunk/roadmap/src/osm_fetch_tile =================================================================== --- trunk/roadmap/src/osm_fetch_tile (rev 0) +++ trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:23:06 UTC (rev 2728) @@ -0,0 +1,52 @@ +#!/bin/sh + +usage() +{ + echo $program: invocation error >&2 + exit 1 +} + +me="&contact=pg...@fo..." + +# doit=echo + +program=${0##*/} + +: args: $* + +#server="www.overpass-api.de/api/xapi?*" +server="overpass.osm.rambler.ru/cgi/xapi?*" + + +if ! opts="$(getopt -o t:b:h:B:x: \ + -l trutile:,bits:,have:,bbox:,xmlfile: -n $program -- $@)" +then + usage +fi + +eval set -- "$opts" + +xmlfile="-" + +while true +do + : \$1 is $1 + case $1 in + -t|--trutile) trutile=$2; shift 2 ;; + -h|--have) have=$2; shift 2 ;; + -b|--bits) bits=$2; shift 2 ;; + -B|--bbox) bbox=$2; shift 2 ;; + -x|--xmlfile) xmlfile=$2; shift 2 ;; + --) shift; break ;; + *) usage ;; + esac +done + +bbox="[bbox=$bbox]" + +if wget -O $xmlfile.tmp "http://$server$bbox$query$me" +then + mv $xmlfile.tmp $xmlfile +else + rm $xmlfile.tmp +fi Property changes on: trunk/roadmap/src/osm_fetch_tile ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:23:04
|
Revision: 2727 http://sourceforge.net/p/roadmap/code/2727 Author: pgf Date: 2014-06-07 20:23:01 +0000 (Sat, 07 Jun 2014) Log Message: ----------- osmgetbmap: adjust servers, and implement long option names Modified Paths: -------------- trunk/roadmap/src/php/osmgetbmap Modified: trunk/roadmap/src/php/osmgetbmap =================================================================== --- trunk/roadmap/src/php/osmgetbmap 2014-06-07 20:22:56 UTC (rev 2726) +++ trunk/roadmap/src/php/osmgetbmap 2014-06-07 20:23:01 UTC (rev 2727) @@ -15,10 +15,23 @@ // configure the server -- should perhaps be cmdline arg $server = "www.openstreetmap.org"; +$path = "/api/0.6/map"; + +$server = "api.openstreetmap.fr"; +$path = "/api/0.6/map"; + //$server = "osmxapi.informationfreeway.org"; //$server = "openstreetmap.gryph.de"; -$path = "/api/0.6/map"; +// $server = "jxapi.openstreetmap.org"; +$server = "www.overpass-api.de"; +$path = "/api/xapi?map"; + +#$server = "overpass.osm.rambler.ru"; +#$path = "/cgi/xapi?map"; + +// api/xapi?*[key=value][bbox=-180,-90,180,90] + function doLog($text) { fwrite(STDERR, $text . "\n"); } @@ -62,13 +75,17 @@ $nocache = false; $CacheDir = getenv('HOME')."/".".osm_bmap_cache"; -$options = getopt("b:t:h:c:"); +$options = getopt("b:t:h:c:", array('bits:', 'trutile:', 'have:', 'cache:')); foreach (array_keys($options) as $opt) { switch ($opt) { - case 'b': $bits = $options['b']; break; - case 't': $tileid = $options['t']; break; - case 'h': $have = $options['h']; break; - case 'c': $CacheDir = $options['c']; break; + case 'b': $bits = $options['b']; break; + case 'bits': $bits = $options['bits']; break; + case 't': $tileid = $options['t']; break; + case 'trutile': $tileid = $options['trutile']; break; + case 'h': $have = $options['h']; break; + case 'have': $have = $options['have']; break; + case 'c': $CacheDir = $options['c']; break; + case 'cache': $CacheDir = $options['cache']; break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:59
|
Revision: 2726 http://sourceforge.net/p/roadmap/code/2726 Author: pgf Date: 2014-06-07 20:22:56 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm_text: move globals into structs both for clarity, and to ensure everything that should be reset gets cleared together. also, reset the point hash and lists on every call. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_text.c trunk/roadmap/src/buildmap_osm_text.h Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:22:52 UTC (rev 2725) +++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:22:56 UTC (rev 2726) @@ -70,51 +70,43 @@ /** * @brief a couple of variables to keep track of the way we're dealing with */ -static int in_way = 0; /**< are we in a way (its id) */ -static int nWayNodes = 0; /**< number of nodes known for - this way */ -static int nWayNodeAlloc = 0; /**< size of the allocation of - the array */ -static int *WayNodes = 0; /**< the array to keep track of - this way's nodes */ -static int WayLayer = 0; /**< the layer for this way */ -static char *WayStreetName = 0; /**< the street name */ -static char *WayStreetRef = 0; /**< street code, - to be used when no name (e.g. motorway) */ -static int WayFlags = 0; /**< properties of this way, from - the table flags */ -static int WayInvalid = 0; /**< this way contains invalid nodes */ -static int WayIsOneWay = ROADMAP_LINE_DIRECTION_BOTH; - /**< is this way one direction only */ -static int WayAdminLevel = 0; /**< boundaries */ -static int WayCoast = 0; /**< coastline */ +static struct WayInfo { + int inWay; /**< are we in a way (its id) */ + int nWayNodes; /**< number of nodes known for + this way */ + int WayLayer; /**< the layer for this way */ + char *WayStreetName; /**< the street name */ + char *WayStreetRef; /**< street code, + to be used when no name (e.g. motorway) */ + int WayFlags; /**< properties of this way, from + the table flags */ + int WayInvalid; /**< this way contains invalid nodes */ + int WayIsOneWay; /**< is this way one direction only */ + int WayAdminLevel; /**< boundaries */ + int WayCoast; /**< coastline */ + int WayNotInteresting; /**< this way is not interesting for RoadMap */ +} wi; /** * @brief variables referring to the current node */ -static int NodeId = 0; /**< which node */ -static char *NodePlace = 0; /**< what kind of place is this */ -static char *NodeTownName = 0; /**< which town */ -static char *NodePostalCode = 0; /**< postal code */ -static int NodeLon, /**< coordinates */ - NodeLat; /**< coordinates */ +static struct NodeInfo { + int NodeId; /**< which node */ + char *NodePlace; /**< what kind of place is this */ + char *NodeTownName; /**< which town */ + char *NodePostalCode; /**< postal code */ + int NodeLon, /**< coordinates */ + NodeLat; /**< coordinates */ + int NodeFakeFips; /**< fake postal code */ +} ni; -static int NodeFakeFips; /**< fake postal code */ -static int WayNotInteresting = 0; /**< this way is not interesting for RoadMap */ - /** * @brief some global variables */ static int LineNo; /**< line number in the input file */ static int nPolygons = 0; /**< current polygon id (number of polygons until now) */ - static int LineId = 0; /**< for buildmap_line_add */ -static int nsplits = 0; /**< number of times we've split - a way */ -static int WaysSplit = 0, /**< Number of ways that were split */ - WaysNotSplit = 0, /**< Number of ways not split */ - WaysMissingNode = 0; /**< Number of ways discarded due to missing nodes */ /** * @brief table for translating the names in XML strings into readable format @@ -172,16 +164,9 @@ static void buildmap_osm_text_reset_way(void) { - in_way = 0; - nWayNodes = 0; - free(WayStreetName); WayStreetName = 0; - free(WayStreetRef); WayStreetRef = 0; - WayLayer = 0; - WayFlags = 0; - WayInvalid = 0; - WayIsOneWay = ROADMAP_LINE_DIRECTION_BOTH; - WayAdminLevel = 0; - WayCoast = 0; + if (wi.WayStreetName) free(wi.WayStreetName); + if (wi.WayStreetRef) free(wi.WayStreetRef); + memset(&wi, 0, sizeof(wi)); } /** @@ -190,12 +175,12 @@ static void buildmap_osm_text_reset_node(void) { -// buildmap_info("reset node %d", NodeId); +// buildmap_info("reset node %d", ni.NodeId); - NodeId = 0; - free(NodePlace); NodePlace = 0; - free(NodeTownName); NodeTownName = 0; - free(NodePostalCode); NodePostalCode = 0; + if (ni.NodePlace) free(ni.NodePlace); + if (ni.NodeTownName) free(ni.NodeTownName); + if (ni.NodePostalCode) free(ni.NodePostalCode); + memset(&ni, 0, sizeof(ni)); } /** @@ -206,7 +191,7 @@ */ static RoadMapString str2dict (BuildMapDictionary d, const char *string) { - if (string == 0 || !strlen(string)) { + if (string == 0 || *string == 0) { return buildmap_dictionary_add (d, "", 0); } @@ -228,6 +213,16 @@ RoadMapHash *PointsHash = NULL; static void +buildmap_osm_text_point_hash_reset(void) +{ + nPoints = 0; + PointsHash = 0; + if (points) free(points); + points = 0; + nPointsAlloc = 0; +} + +static void buildmap_osm_text_point_add(int id, int npoint) { if (nPoints == nPointsAlloc) { @@ -283,21 +278,17 @@ buildmap_osm_text_node(char *data) { int nchars, r; +#if 0 double flat, flon; +#endif char *p; - static char *tag = 0, *value = 0; int NodeLatRead, NodeLonRead; + char tag[512], value[512]; - sscanf(data, "node id=%*[\"']%d%*[\"']%n", &NodeId, &nchars); + sscanf(data, "node id=%*[\"']%d%*[\"']%n", &ni.NodeId, &nchars); p = data + nchars; - /* Initialize/allocate these only once, never free them. */ - if (! tag) - tag = malloc(512); - if (! value) - value = malloc(512); - - NodeLat = NodeLon = 0; + ni.NodeLat = ni.NodeLon = 0; NodeLatRead = NodeLonRead = 0; while (NodeLatRead == 0 || NodeLonRead == 0) { @@ -308,15 +299,25 @@ if (r != 2) buildmap_error(0, "bad tag read at '%s'\n", p); +#if 0 if (strcmp(tag, "lat") == 0) { sscanf(value, "%lf", &flat); - NodeLat = flat * 1000000; + ni.NodeLat = flat * 1000000; NodeLatRead++; } else if (strcmp(tag, "lon") == 0) { sscanf(value, "%lf", &flon); - NodeLon = flon * 1000000; + ni.NodeLon = flon * 1000000; NodeLonRead++; } +#else + if (strcmp(tag, "lat") == 0) { + ni.NodeLat = roadmap_math_from_floatstring(value, MILLIONTHS); + NodeLatRead++; + } else if (strcmp(tag, "lon") == 0) { + ni.NodeLon = roadmap_math_from_floatstring(value, MILLIONTHS); + NodeLonRead++; + } +#endif p += nchars; } @@ -334,31 +335,33 @@ { int npoints; - if (NodePlace && (strcmp(NodePlace, "town") == 0 - || strcmp(NodePlace, "village") == 0 - || strcmp(NodePlace, "city") == 0)) { + if (ni.NodeFakeFips) { + if (ni.NodePlace && (strcmp(ni.NodePlace, "town") == 0 + || strcmp(ni.NodePlace, "village") == 0 + || strcmp(ni.NodePlace, "city") == 0)) { /* We have a town, process it */ - if (NodeTownName) { - NodeFakeFips++; + if (ni.NodeTownName) { + ni.NodeFakeFips++; int year = 2008; RoadMapString s; s = buildmap_dictionary_add (DictionaryCity, - (char *) NodeTownName, strlen(NodeTownName)); - buildmap_city_add(NodeFakeFips, year, s); + (char *) ni.NodeTownName, strlen(ni.NodeTownName)); + buildmap_city_add(ni.NodeFakeFips, year, s); } - if (NodePostalCode) { + if (ni.NodePostalCode) { int zip = 0; - sscanf(NodePostalCode, "%d", &zip); + sscanf(ni.NodePostalCode, "%d", &zip); if (zip) - buildmap_zip_add(zip, NodeLon, NodeLat); + buildmap_zip_add(zip, ni.NodeLon, ni.NodeLat); } + } } /* Add the node */ - npoints = buildmap_point_add(NodeLon, NodeLat); - buildmap_osm_text_point_add(NodeId, npoints); + npoints = buildmap_point_add(ni.NodeLon, ni.NodeLat); + buildmap_osm_text_point_add(ni.NodeId, npoints); buildmap_osm_text_reset_node(); return 0; @@ -406,21 +409,17 @@ /* Severely cut in pieces. * This only remembers which way we're in... */ - sscanf(data, "way id=%*[\"']%d%*[\"']", &in_way); - WayNotInteresting = 0; + sscanf(data, "way id=%*[\"']%d%*[\"']", &wi.inWay); + wi.WayNotInteresting = 0; - if (in_way == 0) + if (wi.inWay == 0) buildmap_fatal(0, "buildmap_osm_text_way(%s) error", data); return 0; } static int maxWayTable = 0; -static int nWayTable = 0; -static int interestingWays = 0; -typedef struct WayTableStruct { - int wayid; -} WayTableStruct; -static WayTableStruct *WayTable = NULL; +int nWayTable = 0; +int *WayTable = NULL; static void WayIsInteresting(int wayid, int ni) @@ -433,13 +432,12 @@ maxWayTable *= 2; else maxWayTable = 1000; - WayTable = (struct WayTableStruct *) realloc(WayTable, - sizeof(struct WayTableStruct) * maxWayTable); + WayTable = (int *) realloc(WayTable, + sizeof(int) * maxWayTable); } - WayTable[nWayTable].wayid = wayid; + WayTable[nWayTable] = wayid; nWayTable++; - interestingWays++; } /** @@ -454,15 +452,15 @@ { static int ptr = 0; - if (wayid == WayTable[ptr].wayid) + if ((ptr < nWayTable) && wayid == WayTable[ptr]) return 1; - if (wayid == WayTable[ptr+1].wayid) { + if ((ptr < nWayTable - 1) && wayid == WayTable[ptr+1]) { ptr++; return 1; } for (ptr=0; ptr<nWayTable; ptr++) - if (wayid == WayTable[ptr].wayid) + if (wayid == WayTable[ptr]) return 1; return 0; @@ -475,6 +473,30 @@ } NodeTableStruct; static NodeTableStruct *NodeTable = NULL; + +int +qsort_compare_wayid(const void *id1, const void *id2) +{ + return *(int *)id1 - *(int *)id2; +} + +void +buildmap_osm_text_save_wayids(const char *path, const char *outfile) +{ + char nfn[1024]; + char *p; + + strcpy(nfn, outfile); + p = strrchr(nfn, '.'); + if (p) *p = '\0'; + strcat(nfn, ".ways"); + + qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_wayid); + + roadmap_file_save(path, nfn, WayTable, nWayTable * sizeof(int)); +} + + static void NodeIsInteresting(int node) { @@ -522,8 +544,6 @@ static int buildmap_osm_text_node_interesting(char *data) { - int r = 0; - /* * Avoid figuring out whether we're in a * <node ... /> @@ -533,16 +553,16 @@ * </node> * case, by resetting first if needed. */ - if (NodeId) + if (ni.NodeId) buildmap_osm_text_node_end_and_process(""); - if (sscanf(data, "node id=%*[\"']%d%*[\"']", &NodeId) != 1) { + if (sscanf(data, "node id=%*[\"']%d%*[\"']", &ni.NodeId) != 1) { return -1; } - r += buildmap_osm_text_node(data); + buildmap_osm_text_node(data); - return r; + return 0; } /** @@ -551,7 +571,7 @@ static int buildmap_osm_text_node_interesting_end(char *data) { - if (IsNodeInteresting(NodeId)) + if (IsNodeInteresting(ni.NodeId)) buildmap_osm_text_node_end_and_process(data); return 0; } @@ -565,12 +585,16 @@ * Example line : * <nd ref="997470"/> */ + +int nWayNodeAlloc; /**< size of the allocation of the array */ +int *WayNodes; /**< the array to keep track of this way's nodes */ + static int buildmap_osm_text_nd(char *data) { int node, ix; - if (! in_way) + if (! wi.inWay) buildmap_fatal(0, "Wasn't in a way (%s)", data); if (sscanf(data, "nd ref=%*[\"']%d%*[\"']", &node) != 1) @@ -581,7 +605,7 @@ return 0; } - if (nWayNodes == nWayNodeAlloc) { + if (wi.nWayNodes == nWayNodeAlloc) { if (WayNodes) nWayNodeAlloc *= 2; else @@ -592,7 +616,7 @@ buildmap_fatal (0, "allocation failed for %d ints", nWayNodeAlloc); } - WayNodes[nWayNodes++] = node; + WayNodes[wi.nWayNodes++] = node; return 0; } @@ -618,22 +642,22 @@ if (strcmp(tagk, "postal_code") == 0) { /* <tag k="postal_code" v="3020"/> */ - if (NodePostalCode) - free(NodePostalCode); - NodePostalCode = strdup(tagv); - NodeIsInteresting(NodeId); + if (ni.NodePostalCode) + free(ni.NodePostalCode); + ni.NodePostalCode = strdup(tagv); + NodeIsInteresting(ni.NodeId); } else if (strcmp(tagk, "place") == 0) { /* <tag k="place" v="town"/> */ - if (NodePlace) - free(NodePlace); - NodePlace = strdup(tagv); - NodeIsInteresting(NodeId); + if (ni.NodePlace) + free(ni.NodePlace); + ni.NodePlace = strdup(tagv); + NodeIsInteresting(ni.NodeId); } else if (strcmp(tagk, "name") == 0) { /* <tag k="name" v="Herent"/> */ - if (NodeTownName) - free(NodeTownName); - NodeTownName = FromXmlAndDup(tagv); - NodeIsInteresting(NodeId); + if (ni.NodeTownName) + free(ni.NodeTownName); + ni.NodeTownName = FromXmlAndDup(tagv); + NodeIsInteresting(ni.NodeId); } return 0; @@ -666,27 +690,27 @@ /* street names */ if (strcasecmp(tag, "name") == 0) { - if (WayStreetName) - free(WayStreetName); - WayStreetName = FromXmlAndDup(value); + if (wi.WayStreetName) + free(wi.WayStreetName); + wi.WayStreetName = FromXmlAndDup(value); return 0; /* FIX ME ?? */ } else if (strcasecmp(tag, "landuse") == 0) { - WayNotInteresting = 1; + wi.WayNotInteresting = 1; } else if (strcasecmp(tag, "oneway") == 0 && strcasecmp(value, "yes") == 0) { - WayIsOneWay = ROADMAP_LINE_DIRECTION_ONEWAY; + wi.WayIsOneWay = ROADMAP_LINE_DIRECTION_ONEWAY; } else if (strcasecmp(tag, "building") == 0) { if (strcasecmp(value, "yes") == 0) { - WayNotInteresting = 1; + wi.WayNotInteresting = 1; } } else if (strcasecmp(tag, "ref") == 0) { - if (WayStreetRef) - free(WayStreetRef); - WayStreetRef = FromXmlAndDup(value); + if (wi.WayStreetRef) + free(wi.WayStreetRef); + wi.WayStreetRef = FromXmlAndDup(value); return 0; /* FIX ME ?? */ } else if (strcasecmp(tag, "admin_level") == 0) { - WayAdminLevel = atoi(value); + wi.WayAdminLevel = atoi(value); } else if (strcasecmp(tag, "natural") == 0 && strcasecmp(value, "coastline") == 0) { - WayCoast = 1; + wi.WayCoast = 1; } /* Scan list_info @@ -706,7 +730,7 @@ if (list) { for (i=1; list[i].name; i++) { if (strcmp(value, list[i].name) == 0) { - WayFlags = list[i].flags; + wi.WayFlags = list[i].flags; if (list[i].layerp) ret = *(list[i].layerp); } @@ -718,7 +742,7 @@ /* FIX ME When are we supposed to do this */ if (ret) - WayLayer = ret; + wi.WayLayer = ret; return 0; } @@ -743,39 +767,39 @@ if (l_boundary == 0) l_boundary = buildmap_layer_get("boundaries");; - if (WayInvalid) { + if (wi.WayInvalid) { // REMOVEME buildmap_osm_text_reset_way(); return 0; } - if (in_way == 0) + if (wi.inWay == 0) buildmap_fatal(0, "Wasn't in a way (%s)", data); /* if a way is both a coast and a boundary, treat it only as coast */ - if (WayCoast) { - WayNotInteresting = 0; - WayLayer = l_shoreline; - } else if (WayAdminLevel) { + if (wi.WayCoast) { + wi.WayNotInteresting = 0; + wi.WayLayer = l_shoreline; + } else if (wi.WayAdminLevel) { /* national == 2, state == 4, ignore lesser boundaries */ - if (WayAdminLevel > 4) { - WayNotInteresting = 1; + if (wi.WayAdminLevel > 4) { + wi.WayNotInteresting = 1; } - WayLayer = l_boundary; + wi.WayLayer = l_boundary; } - if (WayNotInteresting || WayLayer == 0) { - buildmap_verbose("discarding way %d, not interesting (%s)", in_way, data); + if (wi.WayNotInteresting || wi.WayLayer == 0) { + buildmap_verbose("discarding way %d, not interesting (%s)", wi.inWay, data); - WayNotInteresting = 0; + wi.WayNotInteresting = 0; buildmap_osm_text_reset_way(); return 0; } - if (nWayNodes < 1) { - WayNotInteresting = 1; + if (wi.nWayNodes < 1) { buildmap_osm_text_reset_way(); + wi.WayNotInteresting = 1; return 0; } @@ -785,14 +809,14 @@ RoadMapString rms_name = 0; from_point = buildmap_osm_text_point_get(WayNodes[0]); - to_point = buildmap_osm_text_point_get(WayNodes[nWayNodes-1]); + to_point = buildmap_osm_text_point_get(WayNodes[wi.nWayNodes-1]); fromlon = buildmap_point_get_longitude(from_point); fromlat = buildmap_point_get_latitude(from_point); tolon = buildmap_point_get_longitude(to_point); tolat = buildmap_point_get_latitude(to_point); - if ((WayFlags & AREA) && (fromlon == tolon) && (fromlat == tolat)) { + if ((wi.WayFlags & AREA) && (fromlon == tolon) && (fromlat == tolat)) { static int polyid = 0; static int cenid = 0; @@ -803,11 +827,11 @@ cenid++; polyid++; - rms_name = str2dict(DictionaryStreet, WayStreetName); - buildmap_polygon_add_landmark (nPolygons, WayLayer, rms_name); + rms_name = str2dict(DictionaryStreet, wi.WayStreetName); + buildmap_polygon_add_landmark (nPolygons, wi.WayLayer, rms_name); buildmap_polygon_add(nPolygons, cenid, polyid); - for (j=1; j<nWayNodes; j++) { + for (j=1; j<wi.nWayNodes; j++) { int prevpoint = buildmap_osm_text_point_get(WayNodes[j-1]); int point = @@ -815,7 +839,7 @@ LineId++; buildmap_line_add - (LineId, WayLayer, prevpoint, point, + (LineId, wi.WayLayer, prevpoint, point, ROADMAP_LINE_DIRECTION_BOTH); buildmap_polygon_add_line (cenid, polyid, LineId, POLYGON_SIDE_RIGHT); } @@ -836,22 +860,22 @@ /* Map begin and end points to internal point id */ from_point = buildmap_osm_text_point_get(WayNodes[0]); - to_point = buildmap_osm_text_point_get(WayNodes[nWayNodes-1]); + to_point = buildmap_osm_text_point_get(WayNodes[wi.nWayNodes-1]); /* Street name */ - if (WayStreetName) - rms_name = str2dict(DictionaryStreet, WayStreetName); - else if (WayStreetRef) - rms_name = str2dict(DictionaryStreet, WayStreetRef); - buildmap_verbose ("Way %d [%s] ref [%s]", in_way, - WayStreetName ? WayStreetName : "", - WayStreetRef ? WayStreetRef : ""); + if (wi.WayStreetName) + rms_name = str2dict(DictionaryStreet, wi.WayStreetName); + else if (wi.WayStreetRef) + rms_name = str2dict(DictionaryStreet, wi.WayStreetRef); + buildmap_verbose ("Way %d [%s] ref [%s]", wi.inWay, + wi.WayStreetName ? wi.WayStreetName : "", + wi.WayStreetRef ? wi.WayStreetRef : ""); LineId++; line = buildmap_line_add(LineId, - WayLayer, from_point, to_point, WayIsOneWay); + wi.WayLayer, from_point, to_point, wi.WayIsOneWay); - street = buildmap_street_add(WayLayer, + street = buildmap_street_add(wi.WayLayer, rms_dirp, rms_name, rms_type, rms_dirs, line); buildmap_range_add_no_address(line, street); @@ -869,10 +893,10 @@ * free this for us. */ - lonsbuf = calloc(nWayNodes, sizeof(int)); - latsbuf = calloc(nWayNodes, sizeof(int)); + lonsbuf = calloc(wi.nWayNodes, sizeof(int)); + latsbuf = calloc(wi.nWayNodes, sizeof(int)); - for (j=0; j<nWayNodes; j++) { + for (j=0; j<wi.nWayNodes; j++) { int point = buildmap_osm_text_point_get(WayNodes[j]); int lon = buildmap_point_get_longitude(point); @@ -897,11 +921,12 @@ buildmap_check_allocated(shapes); } - buildmap_verbose("lineid %d not split, nWayNodes %d\n", LineId, nWayNodes); + buildmap_verbose("lineid %d wi.nWayNodes %d\n", + LineId, wi.nWayNodes); /* Keep info for the shapes */ shapes[numshapes].lons = lonsbuf; shapes[numshapes].lats = latsbuf; - shapes[numshapes].count = nWayNodes; + shapes[numshapes].count = wi.nWayNodes; shapes[numshapes].lineid = LineId; numshapes++; @@ -990,8 +1015,10 @@ fstat(fileno(fdata), &st); - NodeFakeFips = 1000000 + country_num * 1000 + division_num; + ni.NodeFakeFips = 1000000 + country_num * 1000 + division_num; + buildmap_osm_text_point_hash_reset(); + (void) time(&t[0]); passid = 1; @@ -1048,19 +1075,19 @@ for (; *p && isspace(*p); p++) ; if (strncasecmp(p, "way", 3) == 0) { - WayNotInteresting = 0; - if (sscanf(p, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { - in_way = 0; + wi.WayNotInteresting = 0; + if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) != 1) { + wi.inWay = 0; } NumWays++; continue; } else if (strncasecmp(p, "/way", 4) == 0) { - if (in_way) - WayIsInteresting(in_way, WayNotInteresting); + if (wi.inWay) + WayIsInteresting(wi.inWay, wi.WayNotInteresting); buildmap_osm_text_reset_way(); continue; } else if (strncasecmp(p, "tag", 3) == 0) { - if (! in_way) + if (! wi.inWay) ret += buildmap_osm_text_node_tag(p); else ret += buildmap_osm_text_way_tag(p); @@ -1121,11 +1148,11 @@ for (; *p && isspace(*p); p++) ; if (strncasecmp(p, "way", 3) == 0) { - if (sscanf(p, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { - in_way = 0; + if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) != 1) { + wi.inWay = 0; interesting_way = 0; } else { - interesting_way = IsWayInteresting(in_way); + interesting_way = IsWayInteresting(wi.inWay); } continue; } else if (strncasecmp(p, "/way", 4) == 0) { @@ -1133,7 +1160,7 @@ interesting_way = 0; continue; } else if (strncasecmp(p, "nd", 2) == 0) { - if (in_way && interesting_way) + if (wi.inWay && interesting_way) buildmap_osm_text_nd_interesting(p); continue; } @@ -1202,7 +1229,7 @@ ret += buildmap_osm_text_node_interesting_end(p); continue; } else if (strncasecmp(p, "tag", 3) == 0) { - if (! in_way) + if (! wi.inWay) ret += buildmap_osm_text_node_tag(p); else ret += buildmap_osm_text_way_tag(p); @@ -1229,21 +1256,15 @@ passid, LineNo, t[passid] - t[passid - 1]); passid++; - /* - * End pass 4 - */ + buildmap_osm_text_ways_shapeinfo(); (void) time(&t[passid]); - buildmap_info("Ways %d, interesting %d, discarded (missing node) %d", - NumWays, interestingWays, WaysMissingNode); + buildmap_info("Ways %d, interesting %d", + NumWays, nWayTable); buildmap_info("Number of nodes : %d, interesting %d", NumNodes, nNodeTable); - buildmap_info("Pass %d : %d lines read (%d seconds)", - passid, LineNo, t[passid] - t[passid - 1]); - passid++; + buildmap_info("Final: (%d seconds)", + passid, t[passid] - t[passid - 1]); - buildmap_info("Splits %d, ways split %d, not split %d", - nsplits, WaysSplit, WaysNotSplit); - return ret; } Modified: trunk/roadmap/src/buildmap_osm_text.h =================================================================== --- trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:22:52 UTC (rev 2725) +++ trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:22:56 UTC (rev 2726) @@ -30,3 +30,4 @@ void buildmap_osm_text_find_layers (void); int buildmap_osm_text_read(FILE * fdata, int country_num, int division_num); +void buildmap_osm_text_save_wayids(const char *path, const char *outfile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:54
|
Revision: 2725 http://sourceforge.net/p/roadmap/code/2725 Author: pgf Date: 2014-06-07 20:22:52 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: turn off AREA for some boundaries and places we don't really want these things filled with color. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_common.c Modified: trunk/roadmap/src/buildmap_osm_common.c =================================================================== --- trunk/roadmap/src/buildmap_osm_common.c 2014-06-07 20:22:48 UTC (rev 2724) +++ trunk/roadmap/src/buildmap_osm_common.c 2014-06-07 20:22:52 UTC (rev 2725) @@ -333,11 +333,11 @@ layer_info_t boundary_to_layer[] = { { 0, NULL, 0 }, - { "administrative", NULL, AREA }, /* 1 */ + { "administrative", NULL, 0 }, /* 1 */ { "civil", NULL, AREA }, /* 2 */ - { "political", NULL, AREA }, /* 3 */ + { "political", NULL, 0 }, /* 3 */ { "national_park", NULL, AREA }, /* 4 */ - { "world_country", NULL, AREA }, /* 5 */ + { "world_country", NULL, 0 }, /* 5 */ { 0, NULL, 0 }, }; @@ -424,16 +424,16 @@ layer_info_t place_to_layer[] = { { 0, NULL, 0 }, - { "continent", NULL, AREA }, /* 1 */ - { "country", NULL, AREA }, /* 2 */ - { "state", NULL, AREA }, /* 3 */ - { "region", NULL, AREA }, /* 4 */ - { "county", NULL, AREA }, /* 5 */ - { "city", NULL, AREA }, /* 6 */ - { "town", NULL, AREA }, /* 7 */ - { "village", NULL, AREA }, /* 8 */ - { "hamlet", NULL, AREA }, /* 9 */ - { "suburb", SUBURBS, AREA }, /* 10 */ + { "continent", NULL, 0 }, /* 1 */ + { "country", NULL, 0 }, /* 2 */ + { "state", NULL, 0 }, /* 3 */ + { "region", NULL, 0 }, /* 4 */ + { "county", NULL, 0 }, /* 5 */ + { "city", NULL, 0 }, /* 6 */ + { "town", NULL, 0 }, /* 7 */ + { "village", NULL, 0 }, /* 8 */ + { "hamlet", NULL, 0 }, /* 9 */ + { "suburb", SUBURBS, 0 }, /* 10 */ { 0, NULL, 0 }, }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:50
|
Revision: 2724 http://sourceforge.net/p/roadmap/code/2724 Author: pgf Date: 2014-06-07 20:22:48 +0000 (Sat, 07 Jun 2014) Log Message: ----------- let buildmap_progress() express linear as well as percent progress also, don't emit buildmap_progress indicator if output is redirected Modified Paths: -------------- trunk/roadmap/src/buildmap_messages.c Modified: trunk/roadmap/src/buildmap_messages.c =================================================================== --- trunk/roadmap/src/buildmap_messages.c 2014-06-07 20:22:44 UTC (rev 2723) +++ trunk/roadmap/src/buildmap_messages.c 2014-06-07 20:22:48 UTC (rev 2724) @@ -34,6 +34,7 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> +#include <unistd.h> #include "buildmap.h" @@ -214,15 +215,23 @@ void buildmap_progress (unsigned long done, unsigned long estimated) { unsigned long this; + int percent; + if (!isatty(1)) return; if (BuildMapMessageLevel >= BUILDMAP_MESSAGE_PROGRESS) { - this = (100 * done) / estimated; + if (estimated) { + this = (100 * done) / estimated; + percent = '%'; + } else { + this = done; + percent = ' '; + } if (this != LastProgress) { LastProgress = this; - fprintf (stdout, "-- %s: %3ld%% done\r", SourceFile, this); + fprintf (stdout, "-- %s: %3ld%c done\r", SourceFile, this, percent); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:46
|
Revision: 2723 http://sourceforge.net/p/roadmap/code/2723 Author: pgf Date: 2014-06-07 20:22:44 +0000 (Sat, 07 Jun 2014) Log Message: ----------- osmgetbmapcore.php: remove unused code and add a couple of comments Modified Paths: -------------- trunk/roadmap/src/php/osmgetbmapcore.php Modified: trunk/roadmap/src/php/osmgetbmapcore.php =================================================================== --- trunk/roadmap/src/php/osmgetbmapcore.php 2014-06-07 20:22:39 UTC (rev 2722) +++ trunk/roadmap/src/php/osmgetbmapcore.php 2014-06-07 20:22:44 UTC (rev 2723) @@ -1090,172 +1090,7 @@ } -function old_downloadToXml($serverhost,$serverpath,$query) { - $testfile = $_REQUEST["testfile"]; - - $path = $serverpath . "?" . $query; - if ($testfile) { - $fp = fopen("test.5.osm",'r'); - } else { - $fp = fsockopen( $serverhost, 80, &$errno, &$errstr, 120); - } - - if( !$fp ) { - global $EDownloadErrorConnect; - reportError($EDownloadErrorConnect, - "Couldn't connect to API server ".$serverhost); - } - - doLog($serverhost.$path); - if (!$testfile) { - fwrite($fp, "GET $path HTTP/1.1\r\n"); - fwrite($fp, "Host: $serverhost\r\n"); - if ($_SERVER['PHP_AUTH_PW']) { - fwrite($fp, "Authorization: Basic " . - base64_encode($_SERVER['PHP_AUTH_USER'] . - ":" . $_SERVER['PHP_AUTH_PW']) . "\r\n"); - } - fwrite($fp, "User-Agent: OSMtoCSV/1.0\r\n"); - fwrite($fp, "Accept-encoding: gzip\r\n"); - fwrite($fp, "Connection: Close\r\n"); - fwrite($fp, "\r\n"); - } - - $gzip = False; - $chunked = False; - $header200 = False; - $gotdata = False; - if (!$testfile) { - stream_set_timeout($fp,60*20); - ini_set('default_socket_timeout', 60*20); - } - - // get first (status) line - if ($statusline = fgets($fp)) { - $statusline = trim($statusline); - if (strpos($statusline," 200 ")!==FALSE) { - $header200 = True; - } else if (strpos($statusline," 401 ")!==FALSE) { - needAuth(); - } else if (strpos($statusline," 400 ")!==FALSE) { - global $EDownloadErrorTooBig; - reportError($EDownloadErrorTooBig); - } else if (strpos($statusline," 404 ")!==FALSE) { - global $EDownloadErrorConnect; - reportError($EDownloadErrorConnect); - } - } - - if ($gzip && $chunked) { - global $EDownloadErrorNoData; - reportError($EDownloadErrorNoData, - "Can't handle chunked gzipped response"); - } - - // get header - while (!feof($fp)) { - - $headerline = trim(fgets($fp)); - - // headers end with a blank line - if (!$headerline) - break; - - if (strncasecmp($headerline,'Location:', 9) == 0) { - $headerline = trim(substr($headerline, 9)); - doLog("Redirecting to: " . $headerline ); - $parsed = parse_url($headerline); - fclose($fp); - downloadToXml( - $parsed['host'],$parsed['path'], - $parsed['query']); - return; - } - - if (strncasecmp($headerline,"Content-encoding: gzip", - strlen("Content-encoding: gzip")) == 0) { - $gzip = True; - } - - if (strncasecmp($headerline, "Transfer-Encoding: chunked", - strlen("Transfer-Encoding: chunked")) == 0) { - $chunked = True; - } - - } - - if (!$header200) { - doLog("No 200 header: '" . $statusline . "'"); - reportError($EDownloadErrorNoData, - "Got: " . $statusline); - } - - - if ($gzip) { - $toss = fread($fp, 10); // discard gzip file header - if (!stream_filter_append($fp, 'zlib.inflate', - STREAM_FILTER_READ)) { - doLog("error appending zlib.inflate"); - exit(); - } - } - - $xml_parser = xml_parser_create(); - xml_set_element_handler($xml_parser, "startElement", "endElement"); - - /* get and parse the body */ - if ($chunked) { - while (!feof($fp)) { - - // read a length line: "hex[;[comment]]CRNL" - $chunkline = preg_replace("/;.*/","",fgets($fp)); - $chunk = hexdec($chunkline); - - if ($chunk == 0) - break; - - $got = 0; - while ($got < $chunk && - ($piece = fread($fp, $chunk - $got))) { - $got += strlen($piece); - if (!xml_parse($xml_parser, $piece, False)) { - report_xml_error($xml_parser); - } - $gotdata = True; - } - fgets($fp); // data is followed by CR/NL - } - if (!xml_parse($xml_parser, "", True)) { - report_xml_error($xml_parser); - } - // consume footers, if any, and trailing blank line - while (!feof($fp)) { - $footer = fgets($fp); - } - - } else { - // not chunked -- much simpler - while (!feof($fp)) { - $data = fread($fp, 8192); - // doLog("data is '" . $data . "'"); - if (!xml_parse($xml_parser, $data, feof($fp))) { - report_xml_error($xml_parser); - } - $gotdata = True; - } - } - xml_parser_free($xml_parser); - - fclose($fp); - - if (!$gotdata) { - global $EDownloadErrorNoData; - reportError($EDownloadErrorNoData); - } - -} - function getStaticPageNameBMap($tileid) { global $KMaxBits, $CacheDir; $htmldir = $CacheDir."/".$KMaxBits."/"; @@ -1454,11 +1289,13 @@ findKnownWays($tileid,$have); + /* if cached copy is found, will output it and exit */ staticPageStartBMap($tileid); downloadToXml($server, $path, "bbox=".$bbox); doLog("Nodes: ".$nodecount.", Ways: ".$waycount); + /* will output based on fresh download */ staticPageEndBMap(); global $skipwaycount; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:42
|
Revision: 2722 http://sourceforge.net/p/roadmap/code/2722 Author: pgf Date: 2014-06-07 20:22:39 +0000 (Sat, 07 Jun 2014) Log Message: ----------- roadmap_osm.c: comment typos Modified Paths: -------------- trunk/roadmap/src/roadmap_osm.c Modified: trunk/roadmap/src/roadmap_osm.c =================================================================== --- trunk/roadmap/src/roadmap_osm.c 2014-06-07 20:22:34 UTC (rev 2721) +++ trunk/roadmap/src/roadmap_osm.c 2014-06-07 20:22:39 UTC (rev 2722) @@ -36,7 +36,7 @@ * We use a slightly modified format for describing the tiles, since * the full address of the smallest quadtile as described on that page * would take 32 bits, and we need to set some aside. - * First, since we want to avoid the sign bit, so we lose one there. + * First, we want to avoid the sign bit, so we lose one there. * Second, we want to encode the number of bits used in the encoding, * in the tileid itself. There's a tradeoff here -- the more bits we * set aside for describing the encoding bits, the fewer we have for @@ -64,7 +64,7 @@ * Except for the semantics of the sign bit, these encodings are * entirely contained within a few macros in roadmap_osm.h. The use * of negation to distinguish fips values from tileids is mainly here - * (this code deals with postitive tileids) and in roadmap_locator.c + * (this code deals with positive tileids) and in roadmap_locator.c * (which knows that tileids are negative). * * A few of the routines in this file which transform lat/lon pairs This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:37
|
Revision: 2721 http://sourceforge.net/p/roadmap/code/2721 Author: pgf Date: 2014-06-07 20:22:34 +0000 (Sat, 07 Jun 2014) Log Message: ----------- distinguish some identical error messages Modified Paths: -------------- trunk/roadmap/src/buildmap_line.c trunk/roadmap/src/buildmap_place.c trunk/roadmap/src/buildmap_polygon.c Modified: trunk/roadmap/src/buildmap_line.c =================================================================== --- trunk/roadmap/src/buildmap_line.c 2014-06-07 20:22:30 UTC (rev 2720) +++ trunk/roadmap/src/buildmap_line.c 2014-06-07 20:22:34 UTC (rev 2721) @@ -699,7 +699,7 @@ if (square != square_current) { if (square < square_current) { - buildmap_error (0, "abnormal square order: %d following %d", + buildmap_error (0, "abnormal square order (1): %d following %d", square, square_current); return 1; } @@ -755,7 +755,7 @@ if (square != square_current) { if (square < square_current) { - buildmap_error (0, "abnormal square order: d following %d", + buildmap_error (0, "abnormal square order (2): %d following %d", square, square_current); return 1; } Modified: trunk/roadmap/src/buildmap_place.c =================================================================== --- trunk/roadmap/src/buildmap_place.c 2014-06-07 20:22:30 UTC (rev 2720) +++ trunk/roadmap/src/buildmap_place.c 2014-06-07 20:22:34 UTC (rev 2721) @@ -413,7 +413,7 @@ if (square != square_current) { if (square < square_current) { - buildmap_error (0, "abnormal square order: %d following %d", + buildmap_error (0, "abnormal square order (3): %d following %d", square, square_current); return 1; } Modified: trunk/roadmap/src/buildmap_polygon.c =================================================================== --- trunk/roadmap/src/buildmap_polygon.c 2014-06-07 20:22:30 UTC (rev 2720) +++ trunk/roadmap/src/buildmap_polygon.c 2014-06-07 20:22:34 UTC (rev 2721) @@ -985,7 +985,7 @@ if (square != square_current) { if (square < square_current) { - buildmap_error (0, "abnormal square order: %d following %d", + buildmap_error (0, "abnormal square order (4): %d following %d", square, square_current); return 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:33
|
Revision: 2720 http://sourceforge.net/p/roadmap/code/2720 Author: pgf Date: 2014-06-07 20:22:30 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: add --listonly use --listonly to show filenames and bounding boxes for requested tiles Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:22:26 UTC (rev 2719) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:22:30 UTC (rev 2720) @@ -82,6 +82,8 @@ "Analyze given tileid (or quadtile filename) (hex only)"}, {"encode", "e", opt_string, "", "Report tileid for given lat,lon"}, + {"listonly", "l", opt_int, "0", + "Dump the list of filenames and bounding boxes for the request"}, {"quiet", "q", opt_flag, "0", "Show less progress information"}, {"verbose", "v", opt_flag, "0", @@ -786,6 +788,7 @@ int count; int *tileslist; char *decode, *encode; + int listonly; int tileid; char *class, *latlonarg, *source, *cmdfmt, *inputfile; @@ -808,6 +811,7 @@ opt_val("tileid", &tileid) || opt_val("decode", &decode) || opt_val("encode", &encode) || + opt_val("listonly", &listonly) || opt_val("outputfile", &BuildMapFileName) || opt_val("inputfile", &inputfile); if (error) @@ -881,6 +885,29 @@ buildmap_info("processing with bits '%d'", osm_bits); count = buildmap_osm_which_tiles(latlonarg, &tileslist, osm_bits); + if (listonly) { + int i, n; + char filename[128]; + RoadMapArea edges[1]; + + for (i = 0; i < count; i++) { + n = tileslist[i]; + roadmap_osm_filename(filename, 1, n); + printf("%s ", filename); + roadmap_osm_tileid_to_bbox(n, edges); + /* w, s, e, n */ + printf("%s,", + roadmap_math_to_floatstring(0, edges->west, MILLIONTHS)); + printf("%s,", + roadmap_math_to_floatstring(0, edges->south, MILLIONTHS)); + printf("%s,", + roadmap_math_to_floatstring(0, edges->east, MILLIONTHS)); + printf("%s\n", + roadmap_math_to_floatstring(0, edges->north, MILLIONTHS)); + } + + exit(0); + } } error = buildmap_osm_process_tiles This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:28
|
Revision: 2719 http://sourceforge.net/p/roadmap/code/2719 Author: pgf Date: 2014-06-07 20:22:26 +0000 (Sat, 07 Jun 2014) Log Message: ----------- permanently enable labels for quadtile --map-boxes Modified Paths: -------------- trunk/roadmap/src/roadmap_screen.c Modified: trunk/roadmap/src/roadmap_screen.c =================================================================== --- trunk/roadmap/src/roadmap_screen.c 2014-06-07 20:22:22 UTC (rev 2718) +++ trunk/roadmap/src/roadmap_screen.c 2014-06-07 20:22:26 UTC (rev 2719) @@ -930,6 +930,31 @@ roadmap_log_pop (); } +static void roadmap_screen_draw_osm_label(int tileid) +{ + void roadmap_osm_tileid_to_bbox(int tileid, RoadMapArea *edges); + /* mark each OSM tile location with its tileid -- the + * edges will be its true bounding box -- the label will + * be at its purported center. + */ + RoadMapArea edges; + RoadMapPosition position; + RoadMapGuiRect bbox, tbbox; + RoadMapGuiPoint screen_point; + char label[16]; + + sprintf(label, "0x%x", tileid); + roadmap_osm_tileid_to_bbox(tileid, &edges); + position.latitude = (edges.north + edges.south) / 2; + position.longitude = (edges.east + edges.west) / 2; + if (roadmap_math_point_is_visible(&position)) { + roadmap_math_coordinate (&position, &screen_point); + roadmap_math_rotate_coordinates (1, &screen_point); + roadmap_sprite_draw_with_text + ("TextBox", &screen_point, 0, &bbox, &tbbox, label); + } +} + /* arrange to not do labels further than 3/4 up the screen */ static int roadmap_screen_label_cutoff(RoadMapGuiPoint *loweredge) { @@ -1504,13 +1529,14 @@ drawnlist = (int *)calloc(count, sizeof(int)); roadmap_check_allocated(drawnlist); - for (i = count-1; i >= 0; --i) { - - /* draw global square outline (with "--square" or "--map-boxes") */ - if (roadmap_is_visible (ROADMAP_SHOW_GLOBAL_SQUARE)) { + if (roadmap_is_visible (ROADMAP_SHOW_GLOBAL_SQUARE)) { + /* draw global square outline (with "--square" or "--map-boxes") */ + for (i = count-1; i >= 0; --i) { if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) continue; roadmap_screen_draw_square_edges (ROADMAP_SQUARE_GLOBAL); + if (fipslist[i] < 0) + roadmap_screen_draw_osm_label(-fipslist[i]); } } @@ -1523,43 +1549,6 @@ if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) continue; -#if 0 - /* mark each OSM tile location with its tileid -- the - * edges will be its true bounding box -- the label will - * be at its purported center. - */ - if (fipslist[i] < 0 && - roadmap_is_visible (ROADMAP_SHOW_GLOBAL_SQUARE)) { - void roadmap_osm_tileid_to_bbox(int tileid, RoadMapArea *edges); - RoadMapArea edges; - RoadMapPosition position; - RoadMapGuiRect bbox, tbbox; - RoadMapGuiPoint screen_point; - char label[16]; - - sprintf(label, "0x%x", -fipslist[i]); - roadmap_osm_tileid_to_bbox(-fipslist[i], &edges); - position.latitude = (edges.north + edges.south) / 2; - position.longitude = (edges.east + edges.west) / 2; - if (roadmap_math_point_is_visible(&position)) { - roadmap_math_coordinate (&position, &screen_point); - roadmap_math_rotate_coordinates (1, &screen_point); - roadmap_sprite_draw_with_text - ("TextBox", &screen_point, 0, &bbox, &tbbox, label); - } - } -#endif - } - - for (i = count-1; i >= 0; --i) { - /* -- nothing to draw at this zoom? -- */ - if (roadmap_locator_get_decluttered(fipslist[i])) - continue; - - /* -- Access the county's database. */ - if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) - continue; - drawnlist[i] += roadmap_screen_draw_polygons (); if (roadmap_screen_repaint_leave(count, count - i)) { @@ -2403,7 +2392,7 @@ (roadmap_config_get (&RoadMapConfigMapBackground)); RoadMapPenEdges = roadmap_canvas_create_pen ("Map.Edges"); - roadmap_canvas_set_thickness (4); + roadmap_canvas_set_thickness (2); roadmap_canvas_set_foreground ("grey"); roadmap_layer_adjust (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:24
|
Revision: 2718 http://sourceforge.net/p/roadmap/code/2718 Author: pgf Date: 2014-06-07 20:22:22 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: show which tile we're doing, and how many left Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:22:17 UTC (rev 2717) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:22:22 UTC (rev 2718) @@ -545,7 +545,7 @@ buildmap_info(""); buildmap_info - ("processing tileid '0x%x', for file '%s'", tileid, name); + ("processing tile %d of %d, file '%s'", i, count, name); ret = buildmap_osm_process_one_tile (tileid, source, cmdfmt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:19
|
Revision: 2717 http://sourceforge.net/p/roadmap/code/2717 Author: pgf Date: 2014-06-07 20:22:17 +0000 (Sat, 07 Jun 2014) Log Message: ----------- fix handling of va_start()/va_end() and use "usual" parameter names for va_start/va_end Modified Paths: -------------- trunk/roadmap/src/buildmap_messages.c trunk/roadmap/src/roadmap_display.c trunk/roadmap/src/roadmap_log.c Modified: trunk/roadmap/src/buildmap_messages.c =================================================================== --- trunk/roadmap/src/buildmap_messages.c 2014-06-07 20:22:13 UTC (rev 2716) +++ trunk/roadmap/src/buildmap_messages.c 2014-06-07 20:22:17 UTC (rev 2717) @@ -148,7 +148,9 @@ va_start(ap, format); if (BuildMapMessageLevel >= BUILDMAP_MESSAGE_ERROR) vfprintf(stderr, format, ap); + va_end(ap); + va_start(ap, format); if (log != NULL) { vfprintf(log, format, ap); } @@ -187,6 +189,8 @@ va_start(ap, format); if (BuildMapMessageLevel >= BUILDMAP_MESSAGE_FATAL) vfprintf(stderr, format, ap); + va_end(ap); + va_start(ap, format); if (log != NULL) { vfprintf(log, format, ap); } Modified: trunk/roadmap/src/roadmap_display.c =================================================================== --- trunk/roadmap/src/roadmap_display.c 2014-06-07 20:22:13 UTC (rev 2716) +++ trunk/roadmap/src/roadmap_display.c 2014-06-07 20:22:17 UTC (rev 2717) @@ -684,11 +684,11 @@ RoadMapSign *sign = roadmap_display_search_sign (title); char text[1024]; - va_list parameters; + va_list ap; - va_start(parameters, format); - vsnprintf (text, sizeof(text), format, parameters); - va_end(parameters); + va_start(ap, format); + vsnprintf (text, sizeof(text), format, ap); + va_end(ap); if (sign->content != NULL) { free (sign->content); Modified: trunk/roadmap/src/roadmap_log.c =================================================================== --- trunk/roadmap/src/roadmap_log.c 2014-06-07 20:22:13 UTC (rev 2716) +++ trunk/roadmap/src/roadmap_log.c 2014-06-07 20:22:17 UTC (rev 2717) @@ -237,6 +237,9 @@ roadmap_log_one (category, stderr, saved, source, line, format, ap); + va_end(ap); + va_start(ap, format); + roadmap_redirect_one (category, format, ap); /* for now, assume that if someone has put in a redirect for This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:15
|
Revision: 2716 http://sourceforge.net/p/roadmap/code/2716 Author: pgf Date: 2014-06-07 20:22:13 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: tileids should normally be in hex Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:22:09 UTC (rev 2715) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:22:13 UTC (rev 2716) @@ -77,7 +77,7 @@ {"source", "s", opt_string, "osmgetbmap", "commandname or URL for accessing map data"}, {"tileid", "t", opt_int, "", - "Fetch the given numeric tileid"}, + "Fetch the given numeric tileid (use 0x for hex)"}, {"decode", "d", opt_string, "", "Analyze given tileid (or quadtile filename) (hex only)"}, {"encode", "e", opt_string, "", @@ -545,7 +545,7 @@ buildmap_info(""); buildmap_info - ("processing tileid '%d', for file '%s'", tileid, name); + ("processing tileid '0x%x', for file '%s'", tileid, name); ret = buildmap_osm_process_one_tile (tileid, source, cmdfmt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:11
|
Revision: 2715 http://sourceforge.net/p/roadmap/code/2715 Author: pgf Date: 2014-06-07 20:22:09 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm_text: ifdef and debug cleanup previous commit still had all my ifdefs and debugging. this one removes all that. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_text.c Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:22:05 UTC (rev 2714) +++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:22:09 UTC (rev 2715) @@ -344,7 +344,6 @@ int year = 2008; RoadMapString s; -// buildmap_info("buildmap_dictionary_add(%s)", NodeTownName); s = buildmap_dictionary_add (DictionaryCity, (char *) NodeTownName, strlen(NodeTownName)); buildmap_city_add(NodeFakeFips, year, s); @@ -420,22 +419,14 @@ static int interestingWays = 0; typedef struct WayTableStruct { int wayid; -#if 0 - int notinteresting; -#endif } WayTableStruct; static WayTableStruct *WayTable = NULL; static void WayIsInteresting(int wayid, int ni) { -#if 0 - int i; -#endif -#if 1 if (ni) return; -#endif if (nWayTable == maxWayTable) { if (WayTable) @@ -446,19 +437,9 @@ sizeof(struct WayTableStruct) * maxWayTable); } -#if 0 - for (i=0; i<nWayTable; i++) - if (WayTable[i].wayid == wayid) - return; -#endif - WayTable[nWayTable].wayid = wayid; -#if 0 - WayTable[nWayTable].notinteresting = ni; -#endif nWayTable++; - if (ni == 0) - interestingWays++; + interestingWays++; } /** @@ -473,23 +454,7 @@ { static int ptr = 0; -#if 0 if (wayid == WayTable[ptr].wayid) - return ! WayTable[ptr].notinteresting; - if (wayid == WayTable[ptr+1].wayid) { - ptr++; - return ! WayTable[ptr].notinteresting; - } - - for (ptr=0; ptr<nWayTable; ptr++) - if (wayid == WayTable[ptr].wayid) - return ! WayTable[ptr].notinteresting; - - /* Should not happen */ - buildmap_fatal(0, "IsWayInteresting(%d): unknown way", wayid); - return 0; /* to avoid compiler warning */ -#else - if (wayid == WayTable[ptr].wayid) return 1; if (wayid == WayTable[ptr+1].wayid) { ptr++; @@ -500,59 +465,9 @@ if (wayid == WayTable[ptr].wayid) return 1; - // /* Should not happen */ - // buildmap_fatal(0, "IsWayInteresting(%d): unknown way", wayid); - return 0; // /* to avoid compiler warning */ -#endif -} - -/** - * @brief to figure out early (in pass 1) whether this is an interesting way - * @param data - * @return - */ -static int -buildmap_osm_text_way_pass1(char *data) -{ - WayNotInteresting = 0; - if (sscanf(data, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { - in_way = 0; - return 0; - } return 0; } -static int -buildmap_osm_text_way_pass2(char *data) -{ - if (sscanf(data, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { - in_way = 0; - return 0; - } - return IsWayInteresting(in_way); -} - -/** - * @brief to figure out early (in pass 1) whether this is an interesting way - * @param data - * @return - */ -static int -buildmap_osm_text_way_end_pass1(char *data) -{ - WayIsInteresting(in_way, WayNotInteresting); - - buildmap_osm_text_reset_way(); - return 0; -} - -static int -buildmap_osm_text_way_end_pass2(char *data) -{ - buildmap_osm_text_reset_way(); - return 0; -} - static int maxNodeTable = 0; static int nNodeTable = 0; typedef struct NodeTableStruct { @@ -563,9 +478,6 @@ static void NodeIsInteresting(int node) { -#if 0 - int i; -#endif if (nNodeTable == maxNodeTable) { if (NodeTable) @@ -575,15 +487,6 @@ NodeTable = (struct NodeTableStruct *) realloc(NodeTable, sizeof(struct NodeTableStruct) * maxNodeTable); } -#if 0 -// it's not clear to me why it matters if a node is in here -// twice. searching makes this O(n^^2). - for (i=0; i<nNodeTable; i++) { - if (NodeTable[i].nodeid == node) { - return; - } - } -#endif NodeTable[nNodeTable].nodeid = node; nNodeTable++; @@ -593,16 +496,7 @@ static int IsNodeInteresting(int node) { -#if 0 - int i; - for (i=0; i<nNodeTable; i++) { - if (NodeTable[i].nodeid == node) - return 1; - } - return 0; -#else return 1; -#endif } /** @@ -630,7 +524,6 @@ { int r = 0; -// buildmap_verbose("buildmap_osm_text_node_interesting(%d)", NodeId); /* * Avoid figuring out whether we're in a * <node ... /> @@ -658,7 +551,6 @@ static int buildmap_osm_text_node_interesting_end(char *data) { -// buildmap_verbose("buildmap_osm_text_node_interesting_end(%d)", NodeId); if (IsNodeInteresting(NodeId)) buildmap_osm_text_node_end_and_process(data); return 0; @@ -677,7 +569,6 @@ buildmap_osm_text_nd(char *data) { int node, ix; - // float lon, lat; if (! in_way) buildmap_fatal(0, "Wasn't in a way (%s)", data); @@ -687,33 +578,8 @@ ix = buildmap_osm_text_point_get(node); if (ix < 0) { -#if 0 - /* - * This started out as a consistency check, but output of - * splitter has a massive amount of these : - * a way (an area like a lake) that is cut in two because of - * the boundaries splitter introduces will turn up in several - * maps. The strangeness from splitter is that the ways are - * all fully defined, but the nodes aren't all present. - * - * So here we take care not to discard those ways (areas). - * - * It might be a good idea to enable this just when the output - * is created by splitter, e.g. by putting an if statement - * around the lines of code #if-fed out below. - */ - - /* Inconsistent OSM file, this node is not defined */ - /* Only count if we didn't already know this */ - if (WayInvalid == 0) - WaysMissingNode++; - WayInvalid = 1; - buildmap_verbose("Invalid way %d due to missing node %d", in_way, node); -#endif return 0; } - // lon = buildmap_point_get_longitude(ix); - // lat = buildmap_point_get_latitude(ix); if (nWayNodes == nWayNodeAlloc) { if (WayNodes) @@ -806,7 +672,6 @@ return 0; /* FIX ME ?? */ } else if (strcasecmp(tag, "landuse") == 0) { WayNotInteresting = 1; -// buildmap_info("discarding way %d, landuse %s", in_way, data); } else if (strcasecmp(tag, "oneway") == 0 && strcasecmp(value, "yes") == 0) { WayIsOneWay = ROADMAP_LINE_DIRECTION_ONEWAY; } else if (strcasecmp(tag, "building") == 0) { @@ -870,7 +735,6 @@ int from_point, to_point, line, street; int fromlon, tolon, fromlat, tolat; int j; -// int was_split = 0; static int l_shoreline = 0, l_boundary = 0; @@ -890,31 +754,13 @@ /* if a way is both a coast and a boundary, treat it only as coast */ if (WayCoast) { WayNotInteresting = 0; -#if 0 - buildmap_info("Way %d (%s) admin level %d", - in_way, WayStreetName ? WayStreetName : "", WayAdminLevel); -#endif WayLayer = l_shoreline; } else if (WayAdminLevel) { -#if 0 - if (WayStreetName) { - buildmap_info("Way %s admin level %d", WayStreetName, WayAdminLevel); - } else { - buildmap_info("Way %d <unnamed> admin level %d", in_way, WayAdminLevel); - } -#endif -#if 0 - if (WayAdminLevel == 2) { - /* National border, always considered interesting */ - WayNotInteresting = 0; - } -#else /* national == 2, state == 4, ignore lesser boundaries */ if (WayAdminLevel > 4) { WayNotInteresting = 1; } -#endif WayLayer = l_boundary; } @@ -950,7 +796,6 @@ static int polyid = 0; static int cenid = 0; - // buildmap_info ("Way %d is an area, %d polygon lines", in_way, nWayNodes); /* * Detect an AREA -> create a polygon */ @@ -974,304 +819,96 @@ ROADMAP_LINE_DIRECTION_BOTH); buildmap_polygon_add_line (cenid, polyid, LineId, POLYGON_SIDE_RIGHT); } - } else { - /* - * Register the way - * - * Need to do this several different ways : - * - begin and end points form a "line" - * - register street name - * - adjust the square - * - keep memory of the point coordinates so we can - * postprocess the so called shapes (otherwise we only have - * straight lines) - */ + } else { + /* + * Register the way + * + * Need to do this several different ways : + * - begin and end points form a "line" + * - register street name + * - adjust the square + * - keep memory of the point coordinates so we can + * postprocess the so called shapes (otherwise we only have + * straight lines) + */ - int *lonsbuf, *latsbuf; -#if 0 - int from_ix; -#endif + int *lonsbuf, *latsbuf; - /* Map begin and end points to internal point id */ - from_point = buildmap_osm_text_point_get(WayNodes[0]); - to_point = buildmap_osm_text_point_get(WayNodes[nWayNodes-1]); + /* Map begin and end points to internal point id */ + from_point = buildmap_osm_text_point_get(WayNodes[0]); + to_point = buildmap_osm_text_point_get(WayNodes[nWayNodes-1]); - /* Street name */ - if (WayStreetName) - rms_name = str2dict(DictionaryStreet, WayStreetName); + /* Street name */ + if (WayStreetName) + rms_name = str2dict(DictionaryStreet, WayStreetName); else if (WayStreetRef) - rms_name = str2dict(DictionaryStreet, WayStreetRef); -#if 0 - else { - /* - * debugging purpose : flag unnamed ways, whatever they - * are, with the OSM way id. - * You can use this to look them up in the OSM XML file. - */ - char s[64]; - sprintf(s, "OSM unnamed way %d", in_way); - rms_name = str2dict(DictionaryStreet, s); - } -#endif + rms_name = str2dict(DictionaryStreet, WayStreetRef); buildmap_verbose ("Way %d [%s] ref [%s]", in_way, WayStreetName ? WayStreetName : "", WayStreetRef ? WayStreetRef : ""); -#if 0 - /* - * Loop over the points of the way. - * - * If we find a (non-endpoint) node that is also referenced - * in another way, then this way needs to be split. In - * case of a split, and in case of the end node : create - * all the right stuff for the map. - */ - from_ix = 0; - for (j=1; j<nWayNodes-1; j++) { -#if 0 - int point = WayNodes[j]; - if (NodeReportUse(point) <= 1) - continue; -#endif - int k, num; + LineId++; + line = buildmap_line_add(LineId, + WayLayer, from_point, to_point, WayIsOneWay); - /* Keep track of what we did */ - nsplits++; - was_split = 1; + street = buildmap_street_add(WayLayer, + rms_dirp, rms_name, rms_type, + rms_dirs, line); + buildmap_range_add_no_address(line, street); - /* Create a way */ - int from_point = - buildmap_osm_text_point_get( - WayNodes[from_ix]); - int to_point = - buildmap_osm_text_point_get(WayNodes[j]); + /* + * We're passing too much here - the endpoints of + * the line don't need to be passed to the shape + * module. We're keeping them here just to be on + * the safe side, they'll be ignored in + * buildmap_osm_text_ways_shapeinfo(). + * + * The lonsbuf/latsbuf are never freed, need to be + * preserved for shape registration which happens + * at the end of the program run, so exit() will + * free this for us. + */ - LineId++; - line = buildmap_line_add( - LineId, WayLayer, from_point, to_point, - WayIsOneWay); + lonsbuf = calloc(nWayNodes, sizeof(int)); + latsbuf = calloc(nWayNodes, sizeof(int)); - street = buildmap_street_add(WayLayer, - rms_dirp, rms_name, rms_type, - rms_dirs, line); - buildmap_range_add_no_address(line, street); + for (j=0; j<nWayNodes; j++) { + int point = + buildmap_osm_text_point_get(WayNodes[j]); + int lon = buildmap_point_get_longitude(point); + int lat = buildmap_point_get_latitude(point); - /* - * Pass stuff to the shape module. - * - * We're passing too much here - the - * endpoints of the line don't need to be - * passed to the shape module. We're - * keeping them here just to be on the safe - * side, they'll be ignored in - * buildmap_osm_text_ways_shapeinfo(). - * - * The lonsbuf/latsbuf are never freed, - * need to be preserved for shape - * registration which happens at the end of - * the program run, so exit() will free - * this for us. - */ - num = j - from_ix + 1; + /* Keep info for the shapes */ + lonsbuf[j] = lon; + latsbuf[j] = lat; - lonsbuf = calloc(num, sizeof(int)); - latsbuf = calloc(num, sizeof(int)); + buildmap_square_adjust_limits(lon, lat); + } - for (k=0; k<num; k++) { - int point = buildmap_osm_text_point_get( - WayNodes[from_ix+k]); - int lon = buildmap_point_get_longitude(point); - int lat = buildmap_point_get_latitude(point); + if (numshapes == nallocshapes) { + /* Allocate additional space (in big + * chunks) when needed */ + if (shapes) + nallocshapes *= 2; + else + nallocshapes = 1000; + shapes = realloc(shapes, + nallocshapes * sizeof(struct shapeinfo)); + buildmap_check_allocated(shapes); + } - /* Keep info for the shapes */ - lonsbuf[k] = lon; - latsbuf[k] = lat; + buildmap_verbose("lineid %d not split, nWayNodes %d\n", LineId, nWayNodes); + /* Keep info for the shapes */ + shapes[numshapes].lons = lonsbuf; + shapes[numshapes].lats = latsbuf; + shapes[numshapes].count = nWayNodes; + shapes[numshapes].lineid = LineId; - buildmap_square_adjust_limits(lon, lat); - } + numshapes++; + } - if (numshapes == nallocshapes) { - /* Allocate additional space (in big - * chunks) when needed */ - if (shapes) - nallocshapes *= 2; - else - nallocshapes = 1000; - shapes = realloc(shapes, - nallocshapes * sizeof(struct shapeinfo)); - buildmap_check_allocated(shapes); - } - - buildmap_verbose("lineid %d splitting, num %d\n", LineId, num); - /* Keep info for the shapes */ - shapes[numshapes].lons = lonsbuf; - shapes[numshapes].lats = latsbuf; - shapes[numshapes].count = num; - shapes[numshapes].lineid = LineId; - - numshapes++; - - /* Prepare for next iteration */ - from_ix = j; - } - - if (was_split) { - int k, num; - /* - * Need to create an additional way for the last piece - * This is from from_ix to nWayNodes-1 - */ - j = nWayNodes-1; - - /* Create a way */ - int from_point = - buildmap_osm_text_point_get(WayNodes[from_ix]); - int to_point = - buildmap_osm_text_point_get(WayNodes[j]); - - LineId++; - line = buildmap_line_add(LineId, - WayLayer, from_point, to_point, WayIsOneWay); - - street = buildmap_street_add(WayLayer, - rms_dirp, rms_name, rms_type, - rms_dirs, line); - buildmap_range_add_no_address(line, street); - - /* - * Pass stuff to the shape module. - * - * We're passing too much here - the endpoints of - * the line don't need to be passed to the shape - * module. We're keeping them here just to be on - * the safe side, they'll be ignored in - * buildmap_osm_text_ways_shapeinfo(). - * - * The lonsbuf/latsbuf are never freed, need to be - * preserved for shape registration which happens - * at the end of the program run, so exit() will - * free this for us. - */ - num = j - from_ix + 1; - - lonsbuf = calloc(num, sizeof(int)); - latsbuf = calloc(num, sizeof(int)); - - for (k=0; k<num; k++) { - int point = buildmap_osm_text_point_get( - WayNodes[from_ix+k]); - int lon = buildmap_point_get_longitude(point); - int lat = buildmap_point_get_latitude(point); - - /* Keep info for the shapes */ - lonsbuf[k] = lon; - latsbuf[k] = lat; - - buildmap_square_adjust_limits(lon, lat); - } - - if (numshapes == nallocshapes) { - /* Allocate additional space (in big - * chunks) when needed */ - if (shapes) - nallocshapes *= 2; - else - nallocshapes = 1000; - shapes = realloc(shapes, - nallocshapes * sizeof(struct shapeinfo)); - buildmap_check_allocated(shapes); - } - - buildmap_verbose("lineid %d was split, num %d\n", LineId, num); - /* Keep info for the shapes */ - shapes[numshapes].lons = lonsbuf; - shapes[numshapes].lats = latsbuf; - shapes[numshapes].count = num; - shapes[numshapes].lineid = LineId; - - numshapes++; - } - - /* If we didn't split, process the whole way in one piece */ - if (! was_split) { - int from_point = - buildmap_osm_text_point_get(WayNodes[0]); - int to_point = - buildmap_osm_text_point_get(WayNodes[nWayNodes-1]); -#endif - - LineId++; - line = buildmap_line_add(LineId, - WayLayer, from_point, to_point, WayIsOneWay); - - street = buildmap_street_add(WayLayer, - rms_dirp, rms_name, rms_type, - rms_dirs, line); - buildmap_range_add_no_address(line, street); - - /* - * We're passing too much here - the endpoints of - * the line don't need to be passed to the shape - * module. We're keeping them here just to be on - * the safe side, they'll be ignored in - * buildmap_osm_text_ways_shapeinfo(). - * - * The lonsbuf/latsbuf are never freed, need to be - * preserved for shape registration which happens - * at the end of the program run, so exit() will - * free this for us. - */ - - lonsbuf = calloc(nWayNodes, sizeof(int)); - latsbuf = calloc(nWayNodes, sizeof(int)); - - for (j=0; j<nWayNodes; j++) { - int point = - buildmap_osm_text_point_get(WayNodes[j]); - int lon = buildmap_point_get_longitude(point); - int lat = buildmap_point_get_latitude(point); - - /* Keep info for the shapes */ - lonsbuf[j] = lon; - latsbuf[j] = lat; - - buildmap_square_adjust_limits(lon, lat); - } - - if (numshapes == nallocshapes) { - /* Allocate additional space (in big - * chunks) when needed */ - if (shapes) - nallocshapes *= 2; - else - nallocshapes = 1000; - shapes = realloc(shapes, - nallocshapes * sizeof(struct shapeinfo)); - buildmap_check_allocated(shapes); - } - - buildmap_verbose("lineid %d not split, nWayNodes %d\n", LineId, nWayNodes); - /* Keep info for the shapes */ - shapes[numshapes].lons = lonsbuf; - shapes[numshapes].lats = latsbuf; - shapes[numshapes].count = nWayNodes; - shapes[numshapes].lineid = LineId; - - numshapes++; -#if 0 - } -#endif - } - buildmap_osm_text_reset_way(); -#if 0 - if (was_split) - WaysSplit++; - else - WaysNotSplit++; -#endif - return 0; } @@ -1309,32 +946,12 @@ lons = shapes[i].lons; lats = shapes[i].lats; -#if 0 - used = calloc(count, sizeof(int)); - - roadmap_math_reduce_points(lats, lons, count, used, 100); - need = 0; - for (j = 0; j < count; j++) - if (used[j]) need++; - buildmap_verbose("reduced %d from %d to %d points", lineid, count, need); - /* Add the shape points here, don't include beginning and end * point */ for (j = 1; j < count - 1; j++) { - if (used[j]) { - buildmap_shape_add - (line_index, i, lineid, j - 1, lons[j], lats[j]); - } - } - free(used); -#else - /* Add the shape points here, don't include beginning and end - * point */ - for (j = 1; j < count - 1; j++) { buildmap_shape_add (line_index, i, lineid, j - 1, lons[j], lats[j]); } -#endif } } @@ -1430,14 +1047,17 @@ p++; /* point to character after '<' now */ for (; *p && isspace(*p); p++) ; -// ways are put on a list here, and marked interesting or not, -// based on what's learned in text_way_tag() if (strncasecmp(p, "way", 3) == 0) { - buildmap_osm_text_way_pass1(p); + WayNotInteresting = 0; + if (sscanf(p, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { + in_way = 0; + } NumWays++; continue; } else if (strncasecmp(p, "/way", 4) == 0) { - ret += buildmap_osm_text_way_end_pass1(p); + if (in_way) + WayIsInteresting(in_way, WayNotInteresting); + buildmap_osm_text_reset_way(); continue; } else if (strncasecmp(p, "tag", 3) == 0) { if (! in_way) @@ -1446,16 +1066,6 @@ ret += buildmap_osm_text_way_tag(p); continue; } -#if 0 -// i don't think these results are saved - else if (strncasecmp(p, "node", 4) == 0) { - ret += buildmap_osm_text_node(p); - continue; - } else if (strncasecmp(p, "/node", 5) == 0) { - buildmap_osm_text_reset_node(); - continue; - } -#endif } buildmap_progress(ftell(fdata), st.st_size); putchar('\n'); @@ -1510,18 +1120,20 @@ p++; /* point to character after '<' now */ for (; *p && isspace(*p); p++) ; -// looks to me like we did all this in pass 1. except that -// the nd case, below, depends on inway. surely we can do -// less work this time, rather than adding it to the list again. if (strncasecmp(p, "way", 3) == 0) { - interesting_way = buildmap_osm_text_way_pass2(p); + if (sscanf(p, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { + in_way = 0; + interesting_way = 0; + } else { + interesting_way = IsWayInteresting(in_way); + } continue; } else if (strncasecmp(p, "/way", 4) == 0) { buildmap_osm_text_reset_way(); interesting_way = 0; continue; } else if (strncasecmp(p, "nd", 2) == 0) { - if (interesting_way) + if (in_way && interesting_way) buildmap_osm_text_nd_interesting(p); continue; } @@ -1580,12 +1192,12 @@ p++; /* point to character after '<' now */ for (; *p && isspace(*p); p++) ; -// nodes get added to the buildmap tables here... + // nodes get added to the buildmap tables here... if (strncasecmp(p, "node", 4) == 0) { ret += buildmap_osm_text_node_interesting(p); NumNodes++; continue; -// ...and here + // ...and here } else if (strncasecmp(p, "/node", 5) == 0) { ret += buildmap_osm_text_node_interesting_end(p); continue; @@ -1595,15 +1207,15 @@ else ret += buildmap_osm_text_way_tag(p); continue; -// ways get added to the buildmap tables (if interesting) here... + // ways get added to the buildmap tables (if interesting) here... } else if (strncasecmp(p, "way", 3) == 0) { ret += buildmap_osm_text_way(p); continue; -// ...and here + // ...and here } else if (strncasecmp(p, "/way", 4) == 0) { ret += buildmap_osm_text_way_end(p); continue; -// the nd node references gets put on WayNodes list + // the nd node references gets put on WayNodes list } else if (strncasecmp(p, "nd", 2) == 0) { ret += buildmap_osm_text_nd(p); continue; @@ -1617,78 +1229,7 @@ passid, LineNo, t[passid] - t[passid - 1]); passid++; -#if 0 /* - * Pass 4 - define ways flagged as interesting - */ - LineNo = 0; - buildmap_set_source("pass 4"); - fseek(fdata, 0L, SEEK_SET); - buildmap_osm_text_reset_way(); - buildmap_osm_text_reset_node(); - - while (! feof(fdata)) { - buildmap_progress(ftell(fdata), st.st_size); - buildmap_set_line(++LineNo); - got = fgets(buf, LINELEN, fdata); - if (got == NULL) { - if (feof(fdata)) - break; - buildmap_fatal(0, "short read (length)"); - } - - /* Figure out the XML */ - for (p=buf; *p && isspace(*p); p++) ; - if (*p == '\n' || *p == '\r') - continue; - if (*p != '<') { - /* - * Assume we're in a continuation line such as - * - * <tag k='opening_hours' v='Mo 09:30-19:00; - * Tu 09:30-17:00; - * We 09:30-17:00; - * Th 09:30-19:00; - * Fr 09:30-17:00; - * Sa 09:30-16:00; - * Su 10:00-14:00'/> - * - * and just continue with the next line and hope we'll pick up - * a new tag soon. - */ - continue; - } - - p++; /* point to character after '<' now */ - for (; *p && isspace(*p); p++) ; - - if (strncasecmp(p, "way", 3) == 0) { - ret += buildmap_osm_text_way(p); - continue; - } else if (strncasecmp(p, "/way", 4) == 0) { - ret += buildmap_osm_text_way_end(p); - continue; - } else if (strncasecmp(p, "nd", 2) == 0) { - ret += buildmap_osm_text_nd(p); - continue; - } else if (strncasecmp(p, "tag", 3) == 0) { - if (! in_way) - ret += buildmap_osm_text_node_tag(p); - else - ret += buildmap_osm_text_way_tag(p); - continue; - } - } - buildmap_progress(ftell(fdata), st.st_size); - putchar('\n'); - - (void) time(&t[passid]); - buildmap_info("Pass %d : %d lines read (%d seconds)", - passid, LineNo, t[passid] - t[passid - 1]); - - passid++; -#endif - /* * End pass 4 */ buildmap_osm_text_ways_shapeinfo(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:07
|
Revision: 2714 http://sourceforge.net/p/roadmap/code/2714 Author: pgf Date: 2014-06-07 20:22:05 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm_text speedup i'm not sure what the broader ramifications of this change are, but i'm now able to convert the massachusetts-latest.osm file from geofabrik in less than 10 hours -- it ran for a day and a half originally before i killed it. mainly i eliminated extra searches, and the .rdm file may end up with more nodes or ways than it would have originally, but i'm not even convinced of that. there's a good chance that this has broken code that was meant to deal with the "splitter" output. i have no way of testing that at present. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_text.c Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:22:00 UTC (rev 2713) +++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:22:05 UTC (rev 2714) @@ -305,6 +305,9 @@ r = sscanf(p, "%[a-zA-Z0-9_]=%*[\"']%[^\"']%*[\"']%n", tag, value, &nchars); + if (r != 2) + buildmap_error(0, "bad tag read at '%s'\n", p); + if (strcmp(tag, "lat") == 0) { sscanf(value, "%lf", &flat); NodeLat = flat * 1000000; @@ -327,18 +330,6 @@ * @return error indication */ int -buildmap_osm_text_node_end(char *data) -{ - buildmap_osm_text_reset_node(); - return 0; -} - -/** - * @brief At the end of a node, process its data - * @param data point to the line buffer - * @return error indication - */ -int buildmap_osm_text_node_end_and_process(char *data) { int npoints; @@ -429,27 +420,42 @@ static int interestingWays = 0; typedef struct WayTableStruct { int wayid; +#if 0 int notinteresting; +#endif } WayTableStruct; static WayTableStruct *WayTable = NULL; static void WayIsInteresting(int wayid, int ni) { +#if 0 int i; +#endif +#if 1 + if (ni) return; +#endif + if (nWayTable == maxWayTable) { - maxWayTable += 1000; + if (WayTable) + maxWayTable *= 2; + else + maxWayTable = 1000; WayTable = (struct WayTableStruct *) realloc(WayTable, sizeof(struct WayTableStruct) * maxWayTable); } +#if 0 for (i=0; i<nWayTable; i++) if (WayTable[i].wayid == wayid) return; +#endif WayTable[nWayTable].wayid = wayid; +#if 0 WayTable[nWayTable].notinteresting = ni; +#endif nWayTable++; if (ni == 0) interestingWays++; @@ -458,7 +464,7 @@ /** * @brief find out if this way is interesting * @param wayid - * @return inverted !! + * @return whether we thought way was interesting when we found it * * Note : relies on the order of ways encountered in the file, for performance */ @@ -467,20 +473,37 @@ { static int ptr = 0; +#if 0 if (wayid == WayTable[ptr].wayid) - return WayTable[ptr].notinteresting; + return ! WayTable[ptr].notinteresting; if (wayid == WayTable[ptr+1].wayid) { ptr++; - return WayTable[ptr].notinteresting; + return ! WayTable[ptr].notinteresting; } for (ptr=0; ptr<nWayTable; ptr++) if (wayid == WayTable[ptr].wayid) - return WayTable[ptr].notinteresting; + return ! WayTable[ptr].notinteresting; /* Should not happen */ buildmap_fatal(0, "IsWayInteresting(%d): unknown way", wayid); return 0; /* to avoid compiler warning */ +#else + if (wayid == WayTable[ptr].wayid) + return 1; + if (wayid == WayTable[ptr+1].wayid) { + ptr++; + return 1; + } + + for (ptr=0; ptr<nWayTable; ptr++) + if (wayid == WayTable[ptr].wayid) + return 1; + + // /* Should not happen */ + // buildmap_fatal(0, "IsWayInteresting(%d): unknown way", wayid); + return 0; // /* to avoid compiler warning */ +#endif } /** @@ -491,18 +514,22 @@ static int buildmap_osm_text_way_pass1(char *data) { - sscanf(data, "way id=%*[\"']%d%*[\"']", &in_way); WayNotInteresting = 0; + if (sscanf(data, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { + in_way = 0; + return 0; + } return 0; } -static int EarlyPolygonCount = 0; /**< @brief count polygon lines early */ -static int EarlyPolygonNodeCounter = 0; - -static void -buildmap_osm_nd_counter(void) +static int +buildmap_osm_text_way_pass2(char *data) { - EarlyPolygonNodeCounter++; + if (sscanf(data, "way id=%*[\"']%d%*[\"']", &in_way) != 1) { + in_way = 0; + return 0; + } + return IsWayInteresting(in_way); } /** @@ -515,14 +542,13 @@ { WayIsInteresting(in_way, WayNotInteresting); - /* To count polygon lines early ?? */ - if (WayFlags & AREA) { - // buildmap_info ("Early - Way %d is an area", in_way); - EarlyPolygonCount += EarlyPolygonNodeCounter; - } - EarlyPolygonNodeCounter = 0; - /* End count polygon lines */ + buildmap_osm_text_reset_way(); + return 0; +} +static int +buildmap_osm_text_way_end_pass2(char *data) +{ buildmap_osm_text_reset_way(); return 0; } @@ -537,18 +563,27 @@ static void NodeIsInteresting(int node) { +#if 0 int i; +#endif if (nNodeTable == maxNodeTable) { - maxNodeTable += 1000; + if (NodeTable) + maxNodeTable *= 2; + else + maxNodeTable = 1000; NodeTable = (struct NodeTableStruct *) realloc(NodeTable, sizeof(struct NodeTableStruct) * maxNodeTable); } +#if 0 +// it's not clear to me why it matters if a node is in here +// twice. searching makes this O(n^^2). for (i=0; i<nNodeTable; i++) { if (NodeTable[i].nodeid == node) { return; } } +#endif NodeTable[nNodeTable].nodeid = node; nNodeTable++; @@ -558,12 +593,16 @@ static int IsNodeInteresting(int node) { +#if 0 int i; for (i=0; i<nNodeTable; i++) { if (NodeTable[i].nodeid == node) return 1; } return 0; +#else + return 1; +#endif } /** @@ -602,7 +641,7 @@ * case, by resetting first if needed. */ if (NodeId) - r += buildmap_osm_text_node_end_and_process(""); + buildmap_osm_text_node_end_and_process(""); if (sscanf(data, "node id=%*[\"']%d%*[\"']", &NodeId) != 1) { return -1; @@ -621,9 +660,8 @@ { // buildmap_verbose("buildmap_osm_text_node_interesting_end(%d)", NodeId); if (IsNodeInteresting(NodeId)) - return buildmap_osm_text_node_end_and_process(data); - else - return 0; + buildmap_osm_text_node_end_and_process(data); + return 0; } @@ -639,7 +677,7 @@ buildmap_osm_text_nd(char *data) { int node, ix; - float lon, lat; + // float lon, lat; if (! in_way) buildmap_fatal(0, "Wasn't in a way (%s)", data); @@ -674,11 +712,14 @@ #endif return 0; } - lon = buildmap_point_get_longitude(ix); - lat = buildmap_point_get_latitude(ix); + // lon = buildmap_point_get_longitude(ix); + // lat = buildmap_point_get_latitude(ix); if (nWayNodes == nWayNodeAlloc) { - nWayNodeAlloc += 100; + if (WayNodes) + nWayNodeAlloc *= 2; + else + nWayNodeAlloc = 1000; WayNodes = (int *)realloc(WayNodes, sizeof(int) * nWayNodeAlloc); if (WayNodes == 0) @@ -745,18 +786,13 @@ * <tag k="int_ref" v="E 40"> */ static int -buildmap_osm_text_tag(char *data) +buildmap_osm_text_way_tag(char *data) { static char *tag = 0, *value = 0; int i, found; layer_info_t *list; int ret = 0; - if (! in_way) { - /* Deal with tags outside ways */ - return buildmap_osm_text_node_tag(data); - } - if (! tag) tag = malloc(512); if (! value) value = malloc(512); @@ -776,7 +812,6 @@ } else if (strcasecmp(tag, "building") == 0) { if (strcasecmp(value, "yes") == 0) { WayNotInteresting = 1; - buildmap_verbose("buildmap_osm_text_tag(%d) building, not interesting", in_way); } } else if (strcasecmp(tag, "ref") == 0) { if (WayStreetRef) @@ -835,7 +870,7 @@ int from_point, to_point, line, street; int fromlon, tolon, fromlat, tolat; int j; - int was_split = 0; +// int was_split = 0; static int l_shoreline = 0, l_boundary = 0; @@ -852,6 +887,7 @@ if (in_way == 0) buildmap_fatal(0, "Wasn't in a way (%s)", data); + /* if a way is both a coast and a boundary, treat it only as coast */ if (WayCoast) { WayNotInteresting = 0; #if 0 @@ -859,9 +895,7 @@ in_way, WayStreetName ? WayStreetName : "", WayAdminLevel); #endif WayLayer = l_shoreline; - } - - if (WayAdminLevel) { + } else if (WayAdminLevel) { #if 0 if (WayStreetName) { buildmap_info("Way %s admin level %d", WayStreetName, WayAdminLevel); @@ -870,10 +904,17 @@ } #endif +#if 0 if (WayAdminLevel == 2) { /* National border, always considered interesting */ WayNotInteresting = 0; } +#else + /* national == 2, state == 4, ignore lesser boundaries */ + if (WayAdminLevel > 4) { + WayNotInteresting = 1; + } +#endif WayLayer = l_boundary; } @@ -908,7 +949,6 @@ if ((WayFlags & AREA) && (fromlon == tolon) && (fromlat == tolat)) { static int polyid = 0; static int cenid = 0; - int line; // buildmap_info ("Way %d is an area, %d polygon lines", in_way, nWayNodes); /* @@ -929,7 +969,7 @@ buildmap_osm_text_point_get(WayNodes[j]); LineId++; - line = buildmap_line_add + buildmap_line_add (LineId, WayLayer, prevpoint, point, ROADMAP_LINE_DIRECTION_BOTH); buildmap_polygon_add_line (cenid, polyid, LineId, POLYGON_SIDE_RIGHT); @@ -948,7 +988,9 @@ */ int *lonsbuf, *latsbuf; +#if 0 int from_ix; +#endif /* Map begin and end points to internal point id */ from_point = buildmap_osm_text_point_get(WayNodes[0]); @@ -974,6 +1016,7 @@ buildmap_verbose ("Way %d [%s] ref [%s]", in_way, WayStreetName ? WayStreetName : "", WayStreetRef ? WayStreetRef : ""); +#if 0 /* * Loop over the points of the way. * @@ -1050,12 +1093,16 @@ if (numshapes == nallocshapes) { /* Allocate additional space (in big * chunks) when needed */ - nallocshapes += 1000; + if (shapes) + nallocshapes *= 2; + else + nallocshapes = 1000; shapes = realloc(shapes, nallocshapes * sizeof(struct shapeinfo)); buildmap_check_allocated(shapes); } + buildmap_verbose("lineid %d splitting, num %d\n", LineId, num); /* Keep info for the shapes */ shapes[numshapes].lons = lonsbuf; shapes[numshapes].lats = latsbuf; @@ -1126,12 +1173,16 @@ if (numshapes == nallocshapes) { /* Allocate additional space (in big * chunks) when needed */ - nallocshapes += 1000; + if (shapes) + nallocshapes *= 2; + else + nallocshapes = 1000; shapes = realloc(shapes, nallocshapes * sizeof(struct shapeinfo)); buildmap_check_allocated(shapes); } + buildmap_verbose("lineid %d was split, num %d\n", LineId, num); /* Keep info for the shapes */ shapes[numshapes].lons = lonsbuf; shapes[numshapes].lats = latsbuf; @@ -1147,6 +1198,7 @@ buildmap_osm_text_point_get(WayNodes[0]); int to_point = buildmap_osm_text_point_get(WayNodes[nWayNodes-1]); +#endif LineId++; line = buildmap_line_add(LineId, @@ -1189,12 +1241,16 @@ if (numshapes == nallocshapes) { /* Allocate additional space (in big * chunks) when needed */ - nallocshapes += 1000; + if (shapes) + nallocshapes *= 2; + else + nallocshapes = 1000; shapes = realloc(shapes, nallocshapes * sizeof(struct shapeinfo)); buildmap_check_allocated(shapes); } + buildmap_verbose("lineid %d not split, nWayNodes %d\n", LineId, nWayNodes); /* Keep info for the shapes */ shapes[numshapes].lons = lonsbuf; shapes[numshapes].lats = latsbuf; @@ -1202,15 +1258,19 @@ shapes[numshapes].lineid = LineId; numshapes++; +#if 0 } +#endif } buildmap_osm_text_reset_way(); +#if 0 if (was_split) WaysSplit++; else WaysNotSplit++; +#endif return 0; } @@ -1226,8 +1286,8 @@ static int buildmap_osm_text_ways_shapeinfo(void) { - int i, j, count, lineid; - int *lons, *lats; + int i, j, count, lineid; /* , need; */ + int *lons, *lats; /* , *used; */ int line_index; buildmap_info("loading shape info (from %d ways) ...", numshapes); @@ -1241,6 +1301,7 @@ if (count <= 2) continue; + buildmap_verbose("trying line %d, %d points", lineid, count); lineid = shapes[i].lineid; line_index = buildmap_line_find_sorted(lineid); @@ -1248,12 +1309,32 @@ lons = shapes[i].lons; lats = shapes[i].lats; +#if 0 + used = calloc(count, sizeof(int)); + + roadmap_math_reduce_points(lats, lons, count, used, 100); + need = 0; + for (j = 0; j < count; j++) + if (used[j]) need++; + buildmap_verbose("reduced %d from %d to %d points", lineid, count, need); + /* Add the shape points here, don't include beginning and end * point */ for (j = 1; j < count - 1; j++) { - buildmap_shape_add - (line_index, i, lineid, j - 1, lons[j], lats[j]); + if (used[j]) { + buildmap_shape_add + (line_index, i, lineid, j - 1, lons[j], lats[j]); + } } + free(used); +#else + /* Add the shape points here, don't include beginning and end + * point */ + for (j = 1; j < count - 1; j++) { + buildmap_shape_add + (line_index, i, lineid, j - 1, lons[j], lats[j]); + } +#endif } } @@ -1287,11 +1368,15 @@ char *p; time_t t[10]; int passid, NumNodes, NumWays; + struct stat st; + int interesting_way; + fstat(fileno(fdata), &st); + NodeFakeFips = 1000000 + country_num * 1000 + division_num; + (void) time(&t[0]); passid = 1; - (void) time(&t[passid - 1]); DictionaryPrefix = buildmap_dictionary_open("prefix"); DictionaryStreet = buildmap_dictionary_open("street"); @@ -1305,10 +1390,13 @@ * Pass 1 - just figure out which ways are interesting * Currently this is *all ways* but this may change. */ + buildmap_info("Starting pass %d", passid); + buildmap_set_source("pass 1"); LineNo = 0; NumWays = 0; while (! feof(fdata)) { + buildmap_progress(ftell(fdata), st.st_size); buildmap_set_line(++LineNo); got = fgets(buf, LINELEN, fdata); if (got == NULL) { @@ -1342,34 +1430,39 @@ p++; /* point to character after '<' now */ for (; *p && isspace(*p); p++) ; +// ways are put on a list here, and marked interesting or not, +// based on what's learned in text_way_tag() if (strncasecmp(p, "way", 3) == 0) { - ret += buildmap_osm_text_way_pass1(p); + buildmap_osm_text_way_pass1(p); NumWays++; continue; -#if 1 - } else if (strncasecmp(p, "nd", 2) == 0) { - buildmap_osm_nd_counter(); - continue; -#endif } else if (strncasecmp(p, "/way", 4) == 0) { ret += buildmap_osm_text_way_end_pass1(p); continue; } else if (strncasecmp(p, "tag", 3) == 0) { - ret += buildmap_osm_text_tag(p); + if (! in_way) + ret += buildmap_osm_text_node_tag(p); + else + ret += buildmap_osm_text_way_tag(p); continue; - } else if (strncasecmp(p, "node", 4) == 0) { + } +#if 0 +// i don't think these results are saved + else if (strncasecmp(p, "node", 4) == 0) { ret += buildmap_osm_text_node(p); continue; } else if (strncasecmp(p, "/node", 5) == 0) { - ret += buildmap_osm_text_node_end(p); + buildmap_osm_text_reset_node(); continue; } +#endif } + buildmap_progress(ftell(fdata), st.st_size); + putchar('\n'); (void) time(&t[passid]); buildmap_info("Pass %d : %d lines read (%d seconds)", passid, LineNo, t[passid] - t[passid - 1]); - buildmap_info("Early polygon count %d", EarlyPolygonCount); passid++; /* @@ -1377,11 +1470,13 @@ * but e.g. nodes that represent town definitions as well. */ LineNo = 0; + buildmap_set_source("pass 2"); fseek(fdata, 0L, SEEK_SET); buildmap_osm_text_reset_way(); buildmap_osm_text_reset_node(); while (! feof(fdata)) { + buildmap_progress(ftell(fdata), st.st_size); buildmap_set_line(++LineNo); got = fgets(buf, LINELEN, fdata); if (got == NULL) { @@ -1415,18 +1510,24 @@ p++; /* point to character after '<' now */ for (; *p && isspace(*p); p++) ; +// looks to me like we did all this in pass 1. except that +// the nd case, below, depends on inway. surely we can do +// less work this time, rather than adding it to the list again. if (strncasecmp(p, "way", 3) == 0) { - ret += buildmap_osm_text_way_pass1(p); + interesting_way = buildmap_osm_text_way_pass2(p); continue; } else if (strncasecmp(p, "/way", 4) == 0) { - ret += buildmap_osm_text_way_end_pass1(p); + buildmap_osm_text_reset_way(); + interesting_way = 0; continue; } else if (strncasecmp(p, "nd", 2) == 0) { - if (in_way && ! IsWayInteresting(in_way)) - ret += buildmap_osm_text_nd_interesting(p); + if (interesting_way) + buildmap_osm_text_nd_interesting(p); continue; } } + buildmap_progress(ftell(fdata), st.st_size); + putchar('\n'); (void) time(&t[passid]); buildmap_info("Pass %d : %d lines read (%d seconds)", @@ -1439,11 +1540,13 @@ */ LineNo = 0; NumNodes = 0; + buildmap_set_source("pass 3"); fseek(fdata, 0L, SEEK_SET); buildmap_osm_text_reset_way(); buildmap_osm_text_reset_node(); while (! feof(fdata)) { + buildmap_progress(ftell(fdata), st.st_size); buildmap_set_line(++LineNo); got = fgets(buf, LINELEN, fdata); if (got == NULL) { @@ -1477,27 +1580,37 @@ p++; /* point to character after '<' now */ for (; *p && isspace(*p); p++) ; +// nodes get added to the buildmap tables here... if (strncasecmp(p, "node", 4) == 0) { ret += buildmap_osm_text_node_interesting(p); NumNodes++; continue; +// ...and here } else if (strncasecmp(p, "/node", 5) == 0) { ret += buildmap_osm_text_node_interesting_end(p); continue; } else if (strncasecmp(p, "tag", 3) == 0) { - ret += buildmap_osm_text_tag(p); + if (! in_way) + ret += buildmap_osm_text_node_tag(p); + else + ret += buildmap_osm_text_way_tag(p); continue; +// ways get added to the buildmap tables (if interesting) here... } else if (strncasecmp(p, "way", 3) == 0) { ret += buildmap_osm_text_way(p); continue; +// ...and here } else if (strncasecmp(p, "/way", 4) == 0) { ret += buildmap_osm_text_way_end(p); continue; +// the nd node references gets put on WayNodes list } else if (strncasecmp(p, "nd", 2) == 0) { ret += buildmap_osm_text_nd(p); continue; } } + buildmap_progress(ftell(fdata), st.st_size); + putchar('\n'); (void) time(&t[passid]); buildmap_info("Pass %d : %d lines read (%d seconds)", @@ -1509,11 +1622,13 @@ * Pass 4 - define ways flagged as interesting */ LineNo = 0; + buildmap_set_source("pass 4"); fseek(fdata, 0L, SEEK_SET); buildmap_osm_text_reset_way(); buildmap_osm_text_reset_node(); while (! feof(fdata)) { + buildmap_progress(ftell(fdata), st.st_size); buildmap_set_line(++LineNo); got = fgets(buf, LINELEN, fdata); if (got == NULL) { @@ -1557,10 +1672,15 @@ ret += buildmap_osm_text_nd(p); continue; } else if (strncasecmp(p, "tag", 3) == 0) { - ret += buildmap_osm_text_tag(p); + if (! in_way) + ret += buildmap_osm_text_node_tag(p); + else + ret += buildmap_osm_text_way_tag(p); continue; } } + buildmap_progress(ftell(fdata), st.st_size); + putchar('\n'); (void) time(&t[passid]); buildmap_info("Pass %d : %d lines read (%d seconds)", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:22:03
|
Revision: 2713 http://sourceforge.net/p/roadmap/code/2713 Author: pgf Date: 2014-06-07 20:22:00 +0000 (Sat, 07 Jun 2014) Log Message: ----------- roadmap_math.c: minor reformat for easier grepping roadmap_math_trip_set_distance() calls roadmap_message_set(), and the only way to find the values of the ascii indices to roadmap_message_get/set() is to grep for them. so move the indices to the same line as the function call Modified Paths: -------------- trunk/roadmap/src/roadmap_math.c Modified: trunk/roadmap/src/roadmap_math.c =================================================================== --- trunk/roadmap/src/roadmap_math.c 2014-06-07 20:21:56 UTC (rev 2712) +++ trunk/roadmap/src/roadmap_math.c 2014-06-07 20:22:00 UTC (rev 2713) @@ -352,11 +352,11 @@ RoadMapContext->upright_screen.south = position.latitude; RoadMapContext->upright_screen.east = position.longitude; - roadmap_math_trip_set_distance - ('x', RoadMapContext->width * RoadMapContext->zoom_x * + roadmap_math_trip_set_distance ('x', + RoadMapContext->width * RoadMapContext->zoom_x * RoadMapContext->units->unit_per_longitude); - roadmap_math_trip_set_distance - ('y', RoadMapContext->height * RoadMapContext->zoom_y * + roadmap_math_trip_set_distance ('y', + RoadMapContext->height * RoadMapContext->zoom_y * RoadMapContext->units->unit_per_latitude); roadmap_math_set_orientation (orientation); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:59
|
Revision: 2712 http://sourceforge.net/p/roadmap/code/2712 Author: pgf Date: 2014-06-07 20:21:56 +0000 (Sat, 07 Jun 2014) Log Message: ----------- mapinfo: improve message box, and send position/size to log sending the current map position/dimensions to stderr makes them available for copy/paste when fetching maps with buildmap_osm. both the center/dimensions and the screen's bounding box are logged. Modified Paths: -------------- trunk/roadmap/src/roadmap_start.c Modified: trunk/roadmap/src/roadmap_start.c =================================================================== --- trunk/roadmap/src/roadmap_start.c 2014-06-07 20:21:51 UTC (rev 2711) +++ trunk/roadmap/src/roadmap_start.c 2014-06-07 20:21:56 UTC (rev 2712) @@ -301,17 +301,33 @@ char map_info[512]; RoadMapPosition pos; - char lon[32], lat[32]; + char clat[32], clon[32]; + char w[32], s[32], e[32], n[32]; + RoadMapArea screen; roadmap_math_get_context (&pos, NULL, NULL); + roadmap_math_to_floatstring(clat, pos.latitude, MILLIONTHS); + roadmap_math_to_floatstring(clon, pos.longitude, MILLIONTHS); + roadmap_log (ROADMAP_WARNING, "%s,%s %s x %s", clat, clon, + roadmap_message_get('x'), roadmap_message_get('y')); + + roadmap_math_screen_edges (&screen); + roadmap_math_to_floatstring(s, screen.south, MILLIONTHS); + roadmap_math_to_floatstring(w, screen.west, MILLIONTHS); + roadmap_math_to_floatstring(n, screen.north, MILLIONTHS); + roadmap_math_to_floatstring(e, screen.east, MILLIONTHS); + + /* s, w, n, e */ + roadmap_log (ROADMAP_WARNING, "%s,%s:%s,%s", s, w, n, e); + + snprintf(map_info, sizeof(map_info), - "Map view area: %s by %s\n" - "Map center: %s, %s", + "Map view area: %s wide by %s high\n" + "Map center (lat,lon): %s, %s", roadmap_message_get('x'), roadmap_message_get('y'), - roadmap_math_to_floatstring(lon, pos.longitude, MILLIONTHS), - roadmap_math_to_floatstring(lat, pos.latitude, MILLIONTHS)); + clat, clon); roadmap_messagebox_wait ("Map Parameters", map_info); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:54
|
Revision: 2711 http://sourceforge.net/p/roadmap/code/2711 Author: pgf Date: 2014-06-07 20:21:51 +0000 (Sat, 07 Jun 2014) Log Message: ----------- osmgetbmapcore: log the server name before connecting instead of after Modified Paths: -------------- trunk/roadmap/src/php/osmgetbmapcore.php Modified: trunk/roadmap/src/php/osmgetbmapcore.php =================================================================== --- trunk/roadmap/src/php/osmgetbmapcore.php 2014-06-07 20:21:47 UTC (rev 2710) +++ trunk/roadmap/src/php/osmgetbmapcore.php 2014-06-07 20:21:51 UTC (rev 2711) @@ -902,6 +902,7 @@ if ($testfile) { $fp = fopen("test.5.osm",'r'); } else { + doLog("Trying: " . $serverhost . $path . "\n"); $fp = fsockopen( $serverhost, 80, &$errno, &$errstr, 120); } @@ -911,7 +912,6 @@ "Couldn't connect to API server ".$serverhost); } - doLog($serverhost.$path); if (!$testfile) { fwrite($fp, "GET $path HTTP/1.1\r\n"); fwrite($fp, "Host: $serverhost\r\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:50
|
Revision: 2710 http://sourceforge.net/p/roadmap/code/2710 Author: pgf Date: 2014-06-07 20:21:47 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: fixups for --decode Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:21:43 UTC (rev 2709) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:21:47 UTC (rev 2710) @@ -610,7 +610,16 @@ RoadMapArea e[1]; char lat[16], lon[16]; RoadMapPosition pos1, pos2; + int i; + /* if it was a pathname, find the last path element */ + p = strrchr(decode, '/'); + if (p && *(p+1)) { + p++; + decode = p; + } + + /* strip leading "0x", or non-hex characters */ if (strncasecmp("0x", decode, 2) == 0) { decode += 2; @@ -637,6 +646,10 @@ if (*end) return 1; + roadmap_math_working_context(); + roadmap_math_use_imperial(); + roadmap_math_compute_scale(); + roadmap_osm_tileid_to_bbox(tileid, e); printf("tileid:\t0x%08x\t%d\n", tileid, tileid); @@ -646,7 +659,7 @@ pos1.latitude = (e->north + e->south)/2; pos1.longitude = (e->west + e->east)/2; - printf("center:\t%s\t%s\n", + printf("center:\t%s,%s\n", roadmap_math_to_floatstring(lat, pos1.latitude, MILLIONTHS), roadmap_math_to_floatstring(lon, pos1.longitude, MILLIONTHS)); printf("north:\t%s\n", @@ -658,26 +671,28 @@ printf("west:\t%s\n", roadmap_math_to_floatstring(NULL, e->west, MILLIONTHS)); - roadmap_math_use_metric (); roadmap_math_set_center (&pos1); + /* upper left */ pos1.latitude = e->north; pos1.longitude = e->west; - /* upper right */ - pos2.latitude = e->north; - pos2.longitude = e->east; + for (i = 0; i < 2; i++, roadmap_math_use_metric()) { + /* upper right */ + pos2.latitude = e->north; + pos2.longitude = e->east; - printf("width km:\t%s\n", - roadmap_math_to_floatstring - (NULL, roadmap_math_to_trip_distance_tenths - (roadmap_math_distance(&pos1, &pos2)) , TENTHS)); - /* lower left */ - pos2.latitude = e->south; - pos2.longitude = e->west; - printf("height km:\t%s\n", - roadmap_math_to_floatstring - (NULL, roadmap_math_to_trip_distance_tenths - (roadmap_math_distance(&pos1, &pos2)) , TENTHS)); + printf("%s%s wide by ", + roadmap_math_to_floatstring + (NULL, roadmap_math_to_trip_distance_tenths + (roadmap_math_distance(&pos1, &pos2)) , TENTHS), roadmap_math_trip_unit()); + /* lower left */ + pos2.latitude = e->south; + pos2.longitude = e->west; + printf("%s%s high\n", + roadmap_math_to_floatstring + (NULL, roadmap_math_to_trip_distance_tenths + (roadmap_math_distance(&pos1, &pos2)) , TENTHS), roadmap_math_trip_unit()); + } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:45
|
Revision: 2709 http://sourceforge.net/p/roadmap/code/2709 Author: pgf Date: 2014-06-07 20:21:43 +0000 (Sat, 07 Jun 2014) Log Message: ----------- doc: rendering has been reordered; remove the OSM "messiness" caveat Modified Paths: -------------- trunk/roadmap/doc/OpenStreetMap Modified: trunk/roadmap/doc/OpenStreetMap =================================================================== --- trunk/roadmap/doc/OpenStreetMap 2014-06-07 20:21:38 UTC (rev 2708) +++ trunk/roadmap/doc/OpenStreetMap 2014-06-07 20:21:43 UTC (rev 2709) @@ -136,7 +136,7 @@ country xx). The codes xx and yyy are defined in the ISO-3166-1 (country) and ISO-3166-2 (country subdivision). Note that the latter is incomplete. - - Limitations + - Overall OpenStreetMap Limitations - Because the OSM maps are loaded based on geographic location, they currently have no notion of political locality. This means that @@ -146,7 +146,7 @@ needs to be done to integrate a buildmap_osm "method" into RoadMap's map download scheme. - - When a tile is fetched, it will include all roads (and other lines -- + - When a quadtile is fetched, it will include all roads (and other lines -- "ways" in OSM parlance) which start or end in that tile. This leads to two interesting issues: @@ -168,14 +168,6 @@ requested. The order in which RoadMap fetches tiles might need to be changed to help with this problem, as well. - - Because tiles can provide overlapping data, map rendering near the edges - of tiles can be somewhat messy -- the lines on one tile may be - rendered before the polygons of the next, for instance, and labels - placed when rendering one may collide with labels placed when - rendering the next. For this reason, tiles should be kept fairly - large -- RoadMap already has the means to make rendering relatively - large areas efficiently. The only reason to choose small tiles is to - reduce "latency" when requesting data on-demand. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:41
|
Revision: 2708 http://sourceforge.net/p/roadmap/code/2708 Author: pgf Date: 2014-06-07 20:21:38 +0000 (Sat, 07 Jun 2014) Log Message: ----------- roadmap_screen_repaint: draw by layers rather than by county previously we drew each county (or quadtile) in its entirety. this led to rendering glitches, where polygons would obscure lines, lines would obscure labels, etc. so i split the county loop up, and do all polygons first, then all streets, etc. this is almost certainly slower, but probably worth it. we can perhaps add a switch to select either mode later on, if that make sense. Modified Paths: -------------- trunk/roadmap/src/roadmap_screen.c Modified: trunk/roadmap/src/roadmap_screen.c =================================================================== --- trunk/roadmap/src/roadmap_screen.c 2014-06-07 20:21:34 UTC (rev 2707) +++ trunk/roadmap/src/roadmap_screen.c 2014-06-07 20:21:38 UTC (rev 2708) @@ -1443,7 +1443,7 @@ int j; int k; int count, sqcount; - int drawn; + int *drawnlist; int max_pen = roadmap_layer_max_pen(); static int nomap; @@ -1497,7 +1497,12 @@ roadmap_label_start(); - /* - For each candidate county: */ + /* if a county has nothing to draw at this zoom level, we + * want to remember that, so we don't bother trying again + * next time. + */ + drawnlist = (int *)calloc(count, sizeof(int)); + roadmap_check_allocated(drawnlist); for (i = count-1; i >= 0; --i) { @@ -1507,15 +1512,17 @@ continue; roadmap_screen_draw_square_edges (ROADMAP_SQUARE_GLOBAL); } + } + for (i = count-1; i >= 0; --i) { /* -- nothing to draw at this zoom? -- */ if (roadmap_locator_get_decluttered(fipslist[i])) continue; /* -- Access the county's database. */ + if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) + continue; - if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) continue; - #if 0 /* mark each OSM tile location with its tileid -- the * edges will be its true bounding box -- the label will @@ -1542,17 +1549,36 @@ } } #endif + } - drawn = 0; - drawn += roadmap_screen_draw_polygons (); + for (i = count-1; i >= 0; --i) { + /* -- nothing to draw at this zoom? -- */ + if (roadmap_locator_get_decluttered(fipslist[i])) + continue; + /* -- Access the county's database. */ + if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) + continue; + + drawnlist[i] += roadmap_screen_draw_polygons (); + if (roadmap_screen_repaint_leave(count, count - i)) { roadmap_label_new_invalidate(); goto out; } + } + + for (i = count-1; i >= 0; --i) { + /* -- nothing to draw at this zoom? -- */ + if (roadmap_locator_get_decluttered(fipslist[i])) + continue; + + /* -- Access the county's database. */ + if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) + continue; + /* -- Look for the squares that are currently visible. */ - sqcount = roadmap_square_view (&in_view); for (k = 0; k < max_pen; ++k) { @@ -1576,13 +1602,13 @@ if (!layer_count) continue; for (j = sqcount - 1; j >= 0; --j) { - drawn += roadmap_screen_repaint_square (in_view[j], pen_type, + drawnlist[i] += roadmap_screen_repaint_square (in_view[j], pen_type, layer_count, layers); } } - drawn += roadmap_screen_draw_long_lines (k); + drawnlist[i] += roadmap_screen_draw_long_lines (k); } @@ -1596,11 +1622,25 @@ goto out; } - if (drawn && !RoadMapScreenDragging) { + } + + for (i = count-1; i >= 0; --i) { + /* -- nothing to draw at this zoom? -- */ + if (roadmap_locator_get_decluttered(fipslist[i])) + continue; + + /* -- Access the county's database. */ + + if (roadmap_locator_activate (fipslist[i]) != ROADMAP_US_OK) continue; + + if (drawnlist[i] && !RoadMapScreenDragging) { roadmap_label_draw_cache (RoadMapScreen3dHorizon == 0); } - if (!drawn) + } + + for (i = count-1; i >= 0; --i) { + if (!drawnlist[i]) roadmap_locator_set_decluttered(fipslist[i]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:37
|
Revision: 2707 http://sourceforge.net/p/roadmap/code/2707 Author: pgf Date: 2014-06-07 20:21:34 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: fix check for splitting a tile too far Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:21:30 UTC (rev 2706) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:21:34 UTC (rev 2707) @@ -225,7 +225,6 @@ } buildmap_osm_common_find_layers(); - buildmap_debug("reading file %s", fn); ret = buildmap_osm_binary_read(fdata); @@ -556,11 +555,11 @@ */ int n; - if (bits >= TILE_MAXBITS-1) { + nbits = tileid2bits(tileid); + if (nbits >= TILE_MAXBITS-1) { buildmap_info("can't split tile 0x%x further", tileid); continue; } - nbits = tileid2bits(tileid); buildmap_info ("splitting tile 0x%x, new bits %d", tileid, nbits+2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:32
|
Revision: 2706 http://sourceforge.net/p/roadmap/code/2706 Author: pgf Date: 2014-06-07 20:21:30 +0000 (Sat, 07 Jun 2014) Log Message: ----------- buildmap_osm: attempt to process freshly split tiles right away adding the new tileids to the end of the processing list was annoying, since you wouldn't know if they were going to be split again until much later. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:21:26 UTC (rev 2705) +++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:21:30 UTC (rev 2706) @@ -308,6 +308,7 @@ buildmap_metadata_add_attribute ("Data", "Source", "OSM"); buildmap_osm_common_find_layers(); + buildmap_debug("reading file %s", fn); ret = buildmap_osm_text_read(f, country_num, division_num); if (fclose(f) != 0) { buildmap_error(0, "problem fetching data (fclose: %s)", strerror(errno)); @@ -348,7 +349,7 @@ found = 0; tileid = roadmap_osm_latlon2tileid (position->latitude, position->longitude, bits); - fipslist = realloc(fipslist, (found + 1) * sizeof(int)); + fipslist = realloc(fipslist, (found + 100) * sizeof(int)); buildmap_check_allocated(fipslist); fipslist[found++] = tileid; @@ -368,7 +369,7 @@ tileid = roadmap_osm_tileid_to_neighbor(tileid, eswn[d]); roadmap_osm_tileid_to_bbox(tileid, &tileedges); if (roadmap_math_areas_intersect (&tileedges, focus)) { - fipslist = realloc(fipslist, (found + 1) * sizeof(int)); + fipslist = realloc(fipslist, (found + 100) * sizeof(int)); buildmap_check_allocated(fipslist); fipslist[found++] = tileid; } @@ -550,20 +551,32 @@ ret = buildmap_osm_process_one_tile (tileid, source, cmdfmt); if (ret == -2) { + /* we got a "tile too big" error. try for four + * subtiles instead. + */ + int n; + if (bits >= TILE_MAXBITS-1) { buildmap_info("can't split tile 0x%x further", tileid); continue; } - /* we got a "tile too big" error. try for four - * subtiles instead -- put them at the end of the list. - */ nbits = tileid2bits(tileid); buildmap_info ("splitting tile 0x%x, new bits %d", tileid, nbits+2); - count += 4; + + count += 3; tiles = realloc(tiles, sizeof(*tiles) * count); buildmap_check_allocated(tiles); - roadmap_osm_tilesplit(tileid, &tiles[count - 4], 2); + + /* insert new tiles in-place, so that we try the new size right away. + * this doesn't matter, except for the user who is trying + * to figure out what tile size is needed. + */ + for (n = count - 1; n >= i + 3; n--) { + tiles[n] = tiles[n-4]; + } + roadmap_osm_tilesplit(tileid, &tiles[i], 2); + i--; continue; } @@ -828,8 +841,6 @@ buildmap_metadata_add_attribute ("MapFormat", "Version", "1.3 alpha"); - buildmap_verbose("processing with bits '%d'", osm_bits); - if (tileid) { tileslist = malloc(sizeof(int)); @@ -853,6 +864,8 @@ latlonarg = argv[1]; + buildmap_info("processing with bits '%d'", osm_bits); + count = buildmap_osm_which_tiles(latlonarg, &tileslist, osm_bits); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2014-06-07 20:21:29
|
Revision: 2705 http://sourceforge.net/p/roadmap/code/2705 Author: pgf Date: 2014-06-07 20:21:26 +0000 (Sat, 07 Jun 2014) Log Message: ----------- add ifdefed (and untested) douglas-peucker line reduction code Modified Paths: -------------- trunk/roadmap/src/roadmap_math.c trunk/roadmap/src/roadmap_math.h trunk/roadmap/src/roadmap_trip.c Modified: trunk/roadmap/src/roadmap_math.c =================================================================== --- trunk/roadmap/src/roadmap_math.c 2014-06-07 20:21:21 UTC (rev 2704) +++ trunk/roadmap/src/roadmap_math.c 2014-06-07 20:21:26 UTC (rev 2705) @@ -2190,3 +2190,128 @@ return length_result; } #endif + + + + +#if 0 + +/* this code came from http://mappinghacks.com/code/PolyLineReduction/ . + * i converted it from float to int, and it is basically untested. + */ +typedef struct STACK_RECORD { + int nAnchorIndex, nFloaterIndex; + struct STACK_RECORD *precPrev; +} STACK_RECORD; + +STACK_RECORD *m_pStack = 0; + +static void +StackPush(int nAnchorIndex, int nFloaterIndex) +{ + STACK_RECORD *precPrev = m_pStack; + m_pStack = (STACK_RECORD *) malloc(sizeof(STACK_RECORD)); + m_pStack->nAnchorIndex = nAnchorIndex; + m_pStack->nFloaterIndex = nFloaterIndex; + m_pStack->precPrev = precPrev; +} + +static int +StackPop(int *pnAnchorIndex, int *pnFloaterIndex) +{ + STACK_RECORD *precStack = m_pStack; + if (precStack == 0) + return 0; + *pnAnchorIndex = precStack->nAnchorIndex; + *pnFloaterIndex = precStack->nFloaterIndex; + m_pStack = precStack->precPrev; + free(precStack); + return 1; +} + + +void +roadmap_math_reduce_points(int *pPointsX, int *pPointsY, int nPointsCount, + int *pnUseFlag, int dTolerance) +{ + int nVertexIndex, nAnchorIndex, nFloaterIndex; + int dSegmentVecLength; + int dAnchorVecX, dAnchorVecY; + int dAnchorUnitVecX, dAnchorUnitVecY; + int dVertexVecLength; + int dVertexVecX, dVertexVecY; + int dProjScalar; + int dVertexDistanceToSegment; + int dMaxDistThisSegment; + int nVertexIndexMaxDistance; + + nAnchorIndex = 0; + nFloaterIndex = nPointsCount - 1; + StackPush(nAnchorIndex, nFloaterIndex); + while (StackPop(&nAnchorIndex, &nFloaterIndex)) { + + // initialize line segment + dAnchorVecX = pPointsX[nFloaterIndex] - pPointsX[nAnchorIndex]; + dAnchorVecY = pPointsY[nFloaterIndex] - pPointsY[nAnchorIndex]; + dSegmentVecLength = sqrt(dAnchorVecX * dAnchorVecX + + dAnchorVecY * dAnchorVecY); + if (dSegmentVecLength == 0) { + pnUseFlag[nAnchorIndex] = 1; + pnUseFlag[nFloaterIndex] = 1; + continue; + } + dAnchorUnitVecX = dAnchorVecX / dSegmentVecLength; + dAnchorUnitVecY = dAnchorVecY / dSegmentVecLength; + + // inner loop: + dMaxDistThisSegment = 0.0; + nVertexIndexMaxDistance = nAnchorIndex + 1; + for (nVertexIndex = nAnchorIndex + 1; nVertexIndex < nFloaterIndex; + nVertexIndex++) { + + // compare to anchor + dVertexVecX = pPointsX[nVertexIndex] - pPointsX[nAnchorIndex]; + dVertexVecY = pPointsY[nVertexIndex] - pPointsY[nAnchorIndex]; + dVertexVecLength = sqrt(dVertexVecX * dVertexVecX + + dVertexVecY * dVertexVecY); + // dot product: + dProjScalar = + dVertexVecX * dAnchorUnitVecX + dVertexVecY * dAnchorUnitVecY; + if (dProjScalar < 0.0) { + dVertexDistanceToSegment = dVertexVecLength; + } else { + // compare to floater + dVertexVecX = pPointsX[nVertexIndex] - pPointsX[nFloaterIndex]; + dVertexVecY = pPointsY[nVertexIndex] - pPointsY[nFloaterIndex]; + dVertexVecLength = sqrt(dVertexVecX * dVertexVecX + + dVertexVecY * dVertexVecY); + // dot product: + dProjScalar = + dVertexVecX * (-dAnchorUnitVecX) + + dVertexVecY * (-dAnchorUnitVecY); + if (dProjScalar < 0.0) { + dVertexDistanceToSegment = dVertexVecLength; + } else { + // perpendicular distance to line + dVertexDistanceToSegment = + sqrt( + abs(dVertexVecLength * dVertexVecLength - + dProjScalar * dProjScalar) + ); + } + } + if (dMaxDistThisSegment < dVertexDistanceToSegment) { + dMaxDistThisSegment = dVertexDistanceToSegment; + nVertexIndexMaxDistance = nVertexIndex; + } + } + if (dMaxDistThisSegment <= dTolerance) { //use line segment + pnUseFlag[nAnchorIndex] = 1; + pnUseFlag[nFloaterIndex] = 1; + } else { + StackPush(nAnchorIndex, nVertexIndexMaxDistance); + StackPush(nVertexIndexMaxDistance, nFloaterIndex); + } + } +} +#endif Modified: trunk/roadmap/src/roadmap_math.h =================================================================== --- trunk/roadmap/src/roadmap_math.h 2014-06-07 20:21:21 UTC (rev 2704) +++ trunk/roadmap/src/roadmap_math.h 2014-06-07 20:21:26 UTC (rev 2705) @@ -160,6 +160,11 @@ int roadmap_math_delta_direction (int direction1, int direction2); +#if 0 +void roadmap_math_reduce_points(int *pPointsX, int *pPointsY, int nPointsCount, + int *pnUseFlag, int dTolerance); +#endif + #if NEEDED void roadmap_math_set_context (RoadMapPosition *position, unsigned int zoom); #endif Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2014-06-07 20:21:21 UTC (rev 2704) +++ trunk/roadmap/src/roadmap_trip.c 2014-06-07 20:21:26 UTC (rev 2705) @@ -2984,8 +2984,10 @@ * C, then point B will be dropped. Doing a cross-track-error * simplification would give better results, but that's * much more expensive. (gpsbabel's smplroute.c contains code - * for this, and there are implementationso fo Douglas-Peucker on - * the web: e.g. http://geometryalgorithms.com/Archive/algorithm_0205/) + * for this, and there are implementations of Douglas-Peucker on + * the web: e.g. http://geomalgorithms.com/a16-_decimate-1.html) + * Actually, there's now an implementation in in roadmap, in + * roadmap_map_reduce_points(). */ int roadmap_trip_simplify_route (const route_head *orig_route, route_head *new_route) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |