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:25:12
|
Revision: 2754
http://sourceforge.net/p/roadmap/code/2754
Author: pgf
Date: 2014-06-07 20:25:09 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
roadmap_osm.h: bump default bits to 19 (bigger tiles)
Modified Paths:
--------------
trunk/roadmap/src/roadmap_osm.h
Modified: trunk/roadmap/src/roadmap_osm.h
===================================================================
--- trunk/roadmap/src/roadmap_osm.h 2014-06-07 20:25:05 UTC (rev 2753)
+++ trunk/roadmap/src/roadmap_osm.h 2014-06-07 20:25:09 UTC (rev 2754)
@@ -27,7 +27,7 @@
* These functions are used both by roadmap and by buildmap.
*/
-#define ROADMAP_OSM_DEFAULT_BITS "21" // yes, it's a string
+#define ROADMAP_OSM_DEFAULT_BITS "19" // yes, it's a string
#define MaxLon 180000000
#define MaxLat 90000000
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:25:07
|
Revision: 2753
http://sourceforge.net/p/roadmap/code/2753
Author: pgf
Date: 2014-06-07 20:25:05 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
roadmap_county: ifdef unused code
Modified Paths:
--------------
trunk/roadmap/src/roadmap_county.c
Modified: trunk/roadmap/src/roadmap_county.c
===================================================================
--- trunk/roadmap/src/roadmap_county.c 2014-06-07 20:25:00 UTC (rev 2752)
+++ trunk/roadmap/src/roadmap_county.c 2014-06-07 20:25:05 UTC (rev 2753)
@@ -384,6 +384,7 @@
return found;
}
+#ifdef NEEDED
/**
* @brief
* @param state
@@ -415,6 +416,7 @@
return "";
}
+#endif
/**
* @brief
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:25:03
|
Revision: 2752
http://sourceforge.net/p/roadmap/code/2752
Author: pgf
Date: 2014-06-07 20:25:00 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_square: output more information when we wrap the meridian
Modified Paths:
--------------
trunk/roadmap/src/buildmap_square.c
Modified: trunk/roadmap/src/buildmap_square.c
===================================================================
--- trunk/roadmap/src/buildmap_square.c 2014-06-07 20:24:56 UTC (rev 2751)
+++ trunk/roadmap/src/buildmap_square.c 2014-06-07 20:25:00 UTC (rev 2752)
@@ -103,7 +103,10 @@
/* okay */ ;
} else {
static int warned;
- if (!warned++) fprintf(stderr, "\nWarning -- 180'th meridian wrap\n\n");
+ if (!warned++) {
+ fprintf(stderr, "\nWarning -- 180'th meridian wrap\n");
+ fprintf(stderr, "longitude %d, first longitude %d\n\n", longitude, firstlongitude);
+ }
}
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:24:59
|
Revision: 2751
http://sourceforge.net/p/roadmap/code/2751
Author: pgf
Date: 2014-06-07 20:24:56 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: work harder to pick up the last node in a way
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:24:52 UTC (rev 2750)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:56 UTC (rev 2751)
@@ -263,73 +263,7 @@
return -1;
}
-/**
- * @brief collect node data in pass 1
- * @param data
- * @return an error indicator
- *
- * The input line is discarded if a bounding box is specified and
- * the node is outside.
- *
- * Example input line :
- * <node id="123295" timestamp="2005-07-05T03:26:11Z" user="LA2"
- * lat="50.4443626" lon="3.6855288"/>
- */
-void
-buildmap_osm_text_node_read_lat_lon(char *data)
-{
- int nchars;
-#if 1
- double flat, flon;
-#endif
- char *p;
- int NodeLatRead, NodeLonRead;
- char tag[512], value[512];
- int s;
- s = sscanf(data, "node id=%*[\"']%u%*[\"']%n", &ni.NodeId, &nchars);
- if (s != 1)
- buildmap_fatal(0, "buildmap_osm_text(%s) node error", data);
-
- p = data + nchars;
-
- ni.NodeLat = ni.NodeLon = 0;
- NodeLatRead = NodeLonRead = 0;
-
- while (NodeLatRead == 0 || NodeLonRead == 0) {
-
- for (; *p && isspace(*p); p++) ;
-
- s = sscanf(p, "%[a-zA-Z0-9_]=%*[\"']%[^\"']%*[\"']%n",
- tag, value, &nchars);
- if (s != 2)
- buildmap_fatal(0, "bad tag read at '%s'\n", p);
-
-#if 1
- if (strcmp(tag, "lat") == 0) {
- sscanf(value, "%lf", &flat);
- ni.NodeLat = flat * 1000000;
- NodeLatRead++;
- } else if (strcmp(tag, "lon") == 0) {
- sscanf(value, "%lf", &flon);
- 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;
- }
-
-}
-
/**
* @brief At the end of a node, process its data
* @param data point to the line buffer
@@ -568,6 +502,71 @@
}
/**
+ * @brief collect node data in pass 1
+ * @param data
+ * @return an error indicator
+ *
+ * The input line is discarded if a bounding box is specified and
+ * the node is outside.
+ *
+ * Example input line :
+ * <node id="123295" timestamp="2005-07-05T03:26:11Z" user="LA2"
+ * lat="50.4443626" lon="3.6855288"/>
+ */
+void
+buildmap_osm_text_node_read_lat_lon(char *data)
+{
+ int nchars;
+#if 1
+ double flat, flon;
+#endif
+ char *p;
+ int NodeLatRead, NodeLonRead;
+ char tag[512], value[512];
+ int s;
+
+ s = sscanf(data, "node id=%*[\"']%u%*[\"']%n", &ni.NodeId, &nchars);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) node error", data);
+
+ p = data + nchars;
+
+ ni.NodeLat = ni.NodeLon = 0;
+ NodeLatRead = NodeLonRead = 0;
+
+ while (NodeLatRead == 0 || NodeLonRead == 0) {
+
+ for (; *p && isspace(*p); p++) ;
+
+ s = sscanf(p, "%[a-zA-Z0-9_]=%*[\"']%[^\"']%*[\"']%n",
+ tag, value, &nchars);
+ if (s != 2)
+ buildmap_fatal(0, "bad tag read at '%s'\n", p);
+
+ if (strcmp(tag, "lat") == 0) {
+ sscanf(value, "%lf", &flat);
+ ni.NodeLat = flat * 1000000;
+ NodeLatRead++;
+ } else if (strcmp(tag, "lon") == 0) {
+ sscanf(value, "%lf", &flon);
+ ni.NodeLon = flon * 1000000;
+ NodeLonRead++;
+ }
+
+ p += nchars;
+ }
+
+ /* if the node is finished ("\>"), then finish it off */
+ for (; *p && isspace(*p); p++) ;
+ if (*p == '/' && *(p+1) == '>') {
+ if (isNodeInteresting(ni.NodeId)) {
+ buildmap_osm_text_node_finish();
+ }
+ }
+
+}
+
+/**
* @brief deal with tag lines outside of ways
* @param data points into the line of text being processed
* @return error indication
@@ -1401,6 +1400,7 @@
continue;
} else if (strncasecmp(p, "node", 4) == 0) {
+#if 0
/*
* Avoid figuring out whether we're in a
* <node ... />
@@ -1412,19 +1412,26 @@
*/
if (ni.NodeId && isNodeInteresting(ni.NodeId))
buildmap_osm_text_node_finish();
+#endif
s = sscanf(p, "node id=%*[\"']%u%*[\"']", &ni.NodeId);
if (s != 1)
buildmap_fatal(0, "buildmap_osm_text(%s) node error", p);
+ /* will read lat/lon k/v tags, and also call _finish()
+ * if necessary. */
buildmap_osm_text_node_read_lat_lon(p);
NumNodes++;
continue;
} else if (strncasecmp(p, "/node", 5) == 0) {
- if (isNodeInteresting(ni.NodeId))
+ /* if what we had was <node .... />, then we won't get
+ * here. buildmap_osm_text_node_finish() was called
+ * already, from buildmap_osm_text_node_read_lat_lon() */
+ if (isNodeInteresting(ni.NodeId)) {
buildmap_osm_text_node_finish();
+ }
continue;
} else if (strncasecmp(p, "tag", 3) == 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:24:55
|
Revision: 2750
http://sourceforge.net/p/roadmap/code/2750
Author: pgf
Date: 2014-06-07 20:24:52 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: switch back to float scanf for lat/lon
we clearly shouldn't rely on a fixed number of places after the
decimal.
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:24:48 UTC (rev 2749)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:52 UTC (rev 2750)
@@ -279,6 +279,9 @@
buildmap_osm_text_node_read_lat_lon(char *data)
{
int nchars;
+#if 1
+ double flat, flon;
+#endif
char *p;
int NodeLatRead, NodeLonRead;
char tag[512], value[512];
@@ -302,13 +305,25 @@
if (s != 2)
buildmap_fatal(0, "bad tag read at '%s'\n", p);
+#if 1
if (strcmp(tag, "lat") == 0) {
+ sscanf(value, "%lf", &flat);
+ ni.NodeLat = flat * 1000000;
+ NodeLatRead++;
+ } else if (strcmp(tag, "lon") == 0) {
+ sscanf(value, "%lf", &flon);
+ 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;
}
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:24:50
|
Revision: 2749
http://sourceforge.net/p/roadmap/code/2749
Author: pgf
Date: 2014-06-07 20:24:48 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm: don't save a ways file for non-quadtile conversions
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:24:44 UTC (rev 2748)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:48 UTC (rev 2749)
@@ -100,7 +100,7 @@
* @param filename
* @param writeit
*/
-static int buildmap_osm_save_custom (const char *filename, int writeit) {
+static int buildmap_osm_save_custom (const char *filename, int tileid, int writeit) {
char *parent;
int ret = 0;
@@ -127,7 +127,8 @@
ret = buildmap_db_remove (BuildMapResult, filename);
}
- buildmap_osm_text_save_wayids(BuildMapResult, filename);
+ if (tileid)
+ buildmap_osm_text_save_wayids(BuildMapResult, filename);
return 0;
}
@@ -143,7 +144,7 @@
roadmap_osm_filename(db_name, 1, tileid, ".rdm");
- buildmap_osm_save_custom(db_name, writeit);
+ buildmap_osm_save_custom(db_name, tileid, writeit);
}
/**
@@ -373,7 +374,7 @@
buildmap_osm_text_read(fn, 0, country_num, division_num);
buildmap_db_sort();
- ret2 = buildmap_osm_save_custom(ofn, (ret == 0) ? 1 : 0);
+ ret2 = buildmap_osm_save_custom(ofn, 0, (ret == 0) ? 1 : 0);
if (ret2 != 0)
return ret2;
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:24:46
|
Revision: 2748
http://sourceforge.net/p/roadmap/code/2748
Author: pgf
Date: 2014-06-07 20:24:44 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: don't create empty .ways files -- unlink instead
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:24:39 UTC (rev 2747)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:44 UTC (rev 2748)
@@ -461,6 +461,11 @@
if (p) *p = '\0';
strcat(nfn, ".ways");
+ if (!nWayTable) {
+ unlink(nfn);
+ return;
+ }
+
fp = roadmap_file_fopen (path, nfn, "w");
/* write out the list. it's already sorted, and unwanted entries
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:24:42
|
Revision: 2747
http://sourceforge.net/p/roadmap/code/2747
Author: pgf
Date: 2014-06-07 20:24:39 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: reinitialize some globals for every new file
some tables (ways, nodes, shapes) were never shrinking, causing too
much data to be saved for each successive tile.
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:24:35 UTC (rev 2746)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:39 UTC (rev 2747)
@@ -1100,6 +1100,8 @@
buildmap_osm_text_neighbor_way_maps(tileid);
buildmap_osm_text_point_hash_reset();
+ buildmap_osm_text_reset_way();
+ buildmap_osm_text_reset_node();
(void) time(&t[0]);
passid = 1;
@@ -1119,6 +1121,11 @@
buildmap_set_source("pass 1");
LineNo = 0;
NumWays = 0;
+ numshapes = 0;
+ nPolygons = 0;
+ LineId = 0;
+ nWayTable = 0;
+ nNodeTable = 0;
while (! feof(fdata) && need_osm_trailer) {
buildmap_set_line(++LineNo);
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:24:37
|
Revision: 2746
http://sourceforge.net/p/roadmap/code/2746
Author: pgf
Date: 2014-06-07 20:24:35 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
rename osm_fetch_tile to rdm_osm_fetch_tile, and add to Makefile
and make it the default fetcher in buildmap_osm_main
Modified Paths:
--------------
trunk/roadmap/src/Makefile
trunk/roadmap/src/buildmap_osm_main.c
Added Paths:
-----------
trunk/roadmap/src/rdm_osm_fetch_tile
Removed Paths:
-------------
trunk/roadmap/src/osm_fetch_tile
Modified: trunk/roadmap/src/Makefile
===================================================================
--- trunk/roadmap/src/Makefile 2014-06-07 20:24:30 UTC (rev 2745)
+++ trunk/roadmap/src/Makefile 2014-06-07 20:24:35 UTC (rev 2746)
@@ -331,7 +331,8 @@
roadmap.toolbar.ex roadmap.actionlabels.ex \
app_a02.txt usstates.txt roadmap.doxy
SCRIPTS = rdmdownload rdmcompare \
- rdmgenmaps rdmgenshpmaps rdmgenstatemaps rdmgendcwmaps
+ rdmgenmaps rdmgenshpmaps rdmgenstatemaps rdmgendcwmaps \
+ rdm_osm_fetch_tile
MKFILES = Makefile config.mk options.mk
# this font is GPL, and comes from RedHat's "liberation-fonts-ttf-3.tar.gz"
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:30 UTC (rev 2745)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:35 UTC (rev 2746)
@@ -72,7 +72,7 @@
"Rebuild .rdm files, reuse existing .osm if possible"},
{"maps", "m", opt_string, "",
"Location for the generated map files"},
- {"fetcher", "F", opt_string, "osm_fetch_tile",
+ {"fetcher", "F", opt_string, "rdm_osm_fetch_tile",
"commandname for accessing map data to stdout"},
{"tileid", "t", opt_int, "",
"Fetch the given numeric tileid (use 0x for hex)"},
Deleted: trunk/roadmap/src/osm_fetch_tile
===================================================================
--- trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:24:30 UTC (rev 2745)
+++ trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:24:35 UTC (rev 2746)
@@ -1,83 +0,0 @@
-#!/bin/bash
-
-usage()
-{
- echo $program: invocation error >&2
- exit 1
-}
-
-me="&con...@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]"
-
-trap "rm -f $xmlfile.tmp" 0
-
-if [ -e $xmlfile ]
-then
- echo Already have $xmlfile
- exit
-fi
-
-case $xmlfile in
-*.gz) want_compressed=1 ;;
-esac
-
-url="http://$server$bbox$query$me"
-
-if [ "$want_compressed" ]
-then
- wget_opt="--header=Accept-Encoding: gzip"
- if wget "$wget_opt" -O - "$url" >$xmlfile.tmp
- then
- case $(file $xmlfile.tmp) in
- *gzip*)
- mv $xmlfile.tmp $xmlfile
- ;;
- *)
- echo "Note: download didn't use gzip encoding."
- echo "Compressing now..."
- gzip -c -d $xmlfile.tmp > $xmlfile
- ;;
- esac
- fi
-else
- if wget $wget_opt -O - "$url" >$xmlfile.tmp
- then
- mv $xmlfile.tmp $xmlfile
- fi
-fi
-
Copied: trunk/roadmap/src/rdm_osm_fetch_tile (from rev 2745, trunk/roadmap/src/osm_fetch_tile)
===================================================================
--- trunk/roadmap/src/rdm_osm_fetch_tile (rev 0)
+++ trunk/roadmap/src/rdm_osm_fetch_tile 2014-06-07 20:24:35 UTC (rev 2746)
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+usage()
+{
+ echo $program: invocation error >&2
+ exit 1
+}
+
+me="&con...@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]"
+
+trap "rm -f $xmlfile.tmp" 0
+
+if [ -e $xmlfile ]
+then
+ echo Already have $xmlfile
+ exit
+fi
+
+case $xmlfile in
+*.gz) want_compressed=1 ;;
+esac
+
+url="http://$server$bbox$query$me"
+
+if [ "$want_compressed" ]
+then
+ wget_opt="--header=Accept-Encoding: gzip"
+ if wget "$wget_opt" -O - "$url" >$xmlfile.tmp
+ then
+ case $(file $xmlfile.tmp) in
+ *gzip*)
+ mv $xmlfile.tmp $xmlfile
+ ;;
+ *)
+ echo "Note: download didn't use gzip encoding."
+ echo "Compressing now..."
+ gzip -c -d $xmlfile.tmp > $xmlfile
+ ;;
+ esac
+ fi
+else
+ if wget $wget_opt -O - "$url" >$xmlfile.tmp
+ then
+ mv $xmlfile.tmp $xmlfile
+ fi
+fi
+
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:24:32
|
Revision: 2745
http://sourceforge.net/p/roadmap/code/2745
Author: pgf
Date: 2014-06-07 20:24:30 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
osm_fetch_tile: request gzip from server, and recover if we don't get it
Modified Paths:
--------------
trunk/roadmap/src/osm_fetch_tile
Modified: trunk/roadmap/src/osm_fetch_tile
===================================================================
--- trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:24:25 UTC (rev 2744)
+++ trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:24:30 UTC (rev 2745)
@@ -14,8 +14,8 @@
: args: $*
-#server="www.overpass-api.de/api/xapi?*"
-server="overpass.osm.rambler.ru/cgi/xapi?*"
+server="www.overpass-api.de/api/xapi?*"
+#server="overpass.osm.rambler.ru/cgi/xapi?*"
if ! opts="$(getopt -o t:b:h:B:x: \
@@ -44,21 +44,40 @@
bbox="[bbox=$bbox]"
-case $xmlfile in
-*.gz) pipe="gzip -c" ;;
-*) pipe="cat" ;;
-esac
-
-set -o pipefail
-
trap "rm -f $xmlfile.tmp" 0
if [ -e $xmlfile ]
then
echo Already have $xmlfile
-elif wget -O - "http://$server$bbox$query$me" | $pipe >$xmlfile.tmp
+ exit
+fi
+
+case $xmlfile in
+*.gz) want_compressed=1 ;;
+esac
+
+url="http://$server$bbox$query$me"
+
+if [ "$want_compressed" ]
then
- mv $xmlfile.tmp $xmlfile
+ wget_opt="--header=Accept-Encoding: gzip"
+ if wget "$wget_opt" -O - "$url" >$xmlfile.tmp
+ then
+ case $(file $xmlfile.tmp) in
+ *gzip*)
+ mv $xmlfile.tmp $xmlfile
+ ;;
+ *)
+ echo "Note: download didn't use gzip encoding."
+ echo "Compressing now..."
+ gzip -c -d $xmlfile.tmp > $xmlfile
+ ;;
+ esac
+ fi
else
- rm $xmlfile.tmp
+ if wget $wget_opt -O - "$url" >$xmlfile.tmp
+ then
+ mv $xmlfile.tmp $xmlfile
+ fi
fi
+
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:24:28
|
Revision: 2744
http://sourceforge.net/p/roadmap/code/2744
Author: pgf
Date: 2014-06-07 20:24:25 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm: skip ways that neighboring tiles already provide
this commit also fixes a problem with reuse of the file handle
after its been closed/opened.
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_main.c
trunk/roadmap/src/buildmap_osm_text.c
trunk/roadmap/src/buildmap_osm_text.h
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:21 UTC (rev 2743)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:25 UTC (rev 2744)
@@ -299,7 +299,7 @@
(WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))) {
ret = -1;
} else {
- buildmap_osm_text_read(xmlfile, 0, 0);
+ buildmap_osm_text_read(xmlfile, tileid, 0, 0);
ret = 0;
}
}
@@ -370,7 +370,7 @@
buildmap_osm_common_find_layers();
buildmap_debug("reading file %s", fn);
- buildmap_osm_text_read(fn, country_num, division_num);
+ buildmap_osm_text_read(fn, 0, country_num, division_num);
buildmap_db_sort();
ret2 = buildmap_osm_save_custom(ofn, (ret == 0) ? 1 : 0);
Modified: trunk/roadmap/src/buildmap_osm_text.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:21 UTC (rev 2743)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:25 UTC (rev 2744)
@@ -66,6 +66,7 @@
#include "buildmap_osm_common.h"
#include "buildmap_osm_text.h"
+extern char *BuildMapResult;
/* OSM has over 2G nodes already -- enough to overflow a 32 bit signed int */
typedef unsigned int nodeid_t;
@@ -235,8 +236,7 @@
roadmap_hash_resize(PointsHash, nPointsAlloc);
points = realloc(points, sizeof(struct points) * nPointsAlloc);
- if (!points)
- buildmap_fatal(0, "allocate %d points", nPointsAlloc);
+ buildmap_check_allocated(points);
}
roadmap_hash_add(PointsHash, id, nPoints);
@@ -376,11 +376,29 @@
*/
static struct shapeinfo *shapes;
+struct neighbor_ways {
+ int tileid; // these are the ways for this tileid
+ RoadMapFileContext fc; // file context for the mmap
+ int count; // how many ways
+ const wayid_t *ways; // the way ids for that tileid.
+ // (also serves as the "populated" flag.)
+} Neighbor_Ways[8];
+
static int maxWayTable = 0;
int nWayTable = 0;
wayid_t *WayTable = NULL;
+wayid_t *WayTableCopy = NULL;
+
static void
+copyWayTable(void)
+{
+ WayTableCopy = (wayid_t *) malloc(sizeof(wayid_t) * nWayTable);
+ buildmap_check_allocated(WayTableCopy);
+ memcpy(WayTableCopy, WayTable, nWayTable * sizeof(wayid_t));
+}
+
+static void
saveInterestingWay(wayid_t wayid)
{
@@ -391,6 +409,7 @@
maxWayTable = 1000;
WayTable = (wayid_t *) realloc(WayTable,
sizeof(wayid_t) * maxWayTable);
+ buildmap_check_allocated(WayTable);
}
WayTable[nWayTable] = wayid;
@@ -415,15 +434,13 @@
*
* Note : relies on the order of ways encountered in the file, for performance
*/
-static wayid_t
+static wayid_t *
isWayInteresting(wayid_t wayid)
{
- int *r;
- r = bsearch(&wayid, WayTable, nWayTable,
+ wayid_t *r;
+ r = (wayid_t *)bsearch(&wayid, WayTable, nWayTable,
sizeof(*WayTable), qsort_compare_unsigneds);
- if (!r) return 0;
-
- return *r;
+ return r;
}
static int maxNodeTable = 0;
@@ -436,14 +453,25 @@
{
char nfn[1024];
char *p;
+ FILE *fp;
+ wayid_t *wp;
strcpy(nfn, outfile);
p = strrchr(nfn, '.');
if (p) *p = '\0';
strcat(nfn, ".ways");
+ fp = roadmap_file_fopen (path, nfn, "w");
- roadmap_file_save(path, nfn, WayTable, nWayTable * sizeof(*WayTable));
+ /* write out the list. it's already sorted, and unwanted entries
+ * have been zeroed. */
+ for (wp = WayTableCopy; wp < &WayTableCopy[nWayTable]; wp++) {
+ if (*wp) {
+ fwrite(wp, sizeof(wayid_t), 1, fp);
+ }
+ }
+
+ fclose(fp);
}
@@ -458,6 +486,7 @@
maxNodeTable = 1000;
NodeTable = (nodeid_t *) realloc(NodeTable,
sizeof(*NodeTable) * maxNodeTable);
+ buildmap_check_allocated(NodeTable);
}
NodeTable[nNodeTable] = node;
@@ -513,9 +542,7 @@
nWayNodeAlloc = 1000;
WayNodes =
(int *)realloc(WayNodes, sizeof(*WayNodes) * nWayNodeAlloc);
- if (WayNodes == 0)
- buildmap_fatal
- (0, "allocation failed for %d ints", nWayNodeAlloc);
+ buildmap_check_allocated(WayNodes);
}
WayNodes[wi.nWayNodes++] = node;
}
@@ -670,10 +697,8 @@
/* if a way is both a coast and a boundary, treat it only as coast */
if (wi.WayCoast) {
- wi.WayIsInteresting = 1;
wi.WayLayer = l_shoreline;
} else if (wi.WayAdminLevel) {
-
/* national == 2, state == 4, ignore lesser boundaries */
if (wi.WayAdminLevel > 4) {
wi.WayIsInteresting = 0;
@@ -683,7 +708,12 @@
}
if ( !wi.WayIsInteresting || wi.WayLayer == 0) {
+ wayid_t *wp;
buildmap_verbose("discarding way %d, not interesting (%s)", wi.WayId, data);
+ wp = isWayInteresting(wi.WayId);
+ if (wp) {
+ WayTableCopy[wp-WayTable] = 0;
+ }
buildmap_osm_text_reset_way();
return;
@@ -848,6 +878,103 @@
}
+/*
+ * @brief memory maps the way list for the give tileid, if it exists
+ */
+void
+buildmap_osm_text_load_neighbor_ways(int neighbor,
+ struct neighbor_ways *neighbor_ways)
+{
+ const char *waysmap;
+ RoadMapFileContext fc;
+
+ waysmap = roadmap_file_map(BuildMapResult,
+ roadmap_osm_filename(0, 1, neighbor, ".ways"), "r", &fc);
+ if (waysmap) {
+ neighbor_ways->tileid = neighbor;
+ neighbor_ways->fc = fc;
+ neighbor_ways->count = roadmap_file_size(fc) / sizeof(wayid_t);
+ }
+ neighbor_ways->ways = (wayid_t *)waysmap;
+}
+
+void
+buildmap_osm_text_unload_neighbor_ways(int i)
+{
+ roadmap_file_unmap (&Neighbor_Ways[i].fc);
+ Neighbor_Ways[i].ways = 0;
+}
+
+/*
+ * @brief populates the correct way maps for all of our neighbors.
+ * we don't really care which neighbor map is which.
+ */
+void
+buildmap_osm_text_neighbor_way_maps(int tileid)
+{
+ struct neighbor_ways new_neighbor_ways[8];
+ int neighbor_tile;
+ int i, j;
+
+ /* stage a new set of neighbor way lists. we reuse those
+ * that we can, and load new lists when we can't.
+ */
+ for (i = 0; i < 8; i++) {
+ neighbor_tile = roadmap_osm_tileid_to_neighbor(tileid, i);
+ // fprintf(stderr, "loading ways list for neighbor 0x%x\n", neighbor_tile);
+
+ /* if we already have that neighbor's ways, reuse */
+ for (j = 0; j < 8; j++) {
+ if (Neighbor_Ways[j].tileid == neighbor_tile) {
+ // fprintf(stderr, "reusing neighbor 0x%x\n", neighbor_tile);
+ new_neighbor_ways[i] = Neighbor_Ways[j];
+ Neighbor_Ways[j].ways = 0;
+ break;
+ }
+ }
+
+ /* didn't find it -- fetch the neighbor's ways */
+ if (j == 8) {
+ // fprintf(stderr, "fetching neighbor 0x%x\n", neighbor_tile);
+ buildmap_osm_text_load_neighbor_ways(neighbor_tile,
+ &new_neighbor_ways[i]);
+ }
+ }
+
+ /* release any old way lists we're not reusing */
+ for (i = 0; i < 8; i++)
+ if (Neighbor_Ways[i].ways)
+ buildmap_osm_text_unload_neighbor_ways(i);
+
+ /* our new set of reused or freshly loaded way lists into place */
+ for (i = 0; i < 8; i++)
+ Neighbor_Ways[i] = new_neighbor_ways[i];
+
+}
+
+/*
+ * @brief check to see if the given way exists in any of
+ * our neighbors.
+ */
+int
+buildmap_osm_text_check_neighbors(wayid_t wayid)
+{
+ int i;
+ wayid_t *r;
+
+ for (i = 0; i < 8; i++) {
+ if (Neighbor_Ways[i].ways) {
+ r = bsearch(&wayid, Neighbor_Ways[i].ways,
+ Neighbor_Ways[i].count,
+ sizeof(*(Neighbor_Ways[i].ways)),
+ qsort_compare_unsigneds);
+ if (r)
+ return 1;
+ }
+ }
+ return 0;
+}
+
/**
* @brief a postprocessing step to load shape info
*
@@ -947,7 +1074,7 @@
* All underlying processing is passed to other functions.
*/
void
-buildmap_osm_text_read(char *fn, int country_num, int division_num)
+buildmap_osm_text_read(char *fn, int tileid, int country_num, int division_num)
{
FILE *fdata;
int lines;
@@ -969,6 +1096,9 @@
ni.NodeFakeFips = 1000000 + country_num * 1000 + division_num;
+ if (tileid)
+ buildmap_osm_text_neighbor_way_maps(tileid);
+
buildmap_osm_text_point_hash_reset();
(void) time(&t[0]);
@@ -1061,6 +1191,15 @@
} else if (strncasecmp(p, "/way", 4) == 0) {
+ /* if we're processing a quadtile, don't include any
+ * ways that our neighbors already include */
+ if (tileid && wi.WayId && wi.WayIsInteresting &&
+ buildmap_osm_text_check_neighbors(wi.WayId)) {
+ buildmap_verbose("dropping way %d because a neighbor "
+ "already has it", wi.WayId);
+ wi.WayIsInteresting = 0;
+ }
+
/* if the way is still flagged interesting, save it */
if (wi.WayId && wi.WayIsInteresting)
saveInterestingWay(wi.WayId);
@@ -1101,7 +1240,7 @@
LineNo = 0;
buildmap_set_source("pass 2");
buildmap_osm_text_fclose(fdata);
- buildmap_osm_text_fopen(fn);
+ fdata = buildmap_osm_text_fopen(fn);
buildmap_osm_text_reset_way();
buildmap_osm_text_reset_node();
@@ -1146,7 +1285,7 @@
if (s != 1)
buildmap_fatal(0, "buildmap_osm_text(%s) way error", p);
- interesting_way = isWayInteresting(wi.WayId);
+ interesting_way = !!isWayInteresting(wi.WayId);
continue;
} else if (strncasecmp(p, "/way", 4) == 0) {
@@ -1193,10 +1332,15 @@
NumNodes = 0;
buildmap_set_source("pass 3");
buildmap_osm_text_fclose(fdata);
- buildmap_osm_text_fopen(fn);
+ fdata = buildmap_osm_text_fopen(fn);
buildmap_osm_text_reset_way();
buildmap_osm_text_reset_node();
+ /* we've finished saving ways. we need a fresh place to mark
+ * the ones we're discarding, while still keeping the original list
+ * quickly searchable. */
+ copyWayTable();
+
while (! feof(fdata)) {
buildmap_progress(LineNo, lines);
buildmap_set_line(++LineNo);
@@ -1270,18 +1414,20 @@
if (s != 1)
buildmap_fatal(0, "buildmap_osm_text(%s) way error", p);
- wi.WayIsInteresting = 1;
+ wi.WayIsInteresting = !!isWayInteresting(wi.WayId);
continue;
} else if (strncasecmp(p, "/way", 4) == 0) {
- buildmap_osm_text_way_finish(p);
+ if (wi.WayIsInteresting)
+ buildmap_osm_text_way_finish(p);
continue;
} else if (strncasecmp(p, "nd", 2) == 0) {
// the nd node references gets put on WayNodes list
- buildmap_osm_text_save_way_nodes(p);
+ if (wi.WayIsInteresting)
+ buildmap_osm_text_save_way_nodes(p);
continue;
}
}
Modified: trunk/roadmap/src/buildmap_osm_text.h
===================================================================
--- trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:24:21 UTC (rev 2743)
+++ trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:24:25 UTC (rev 2744)
@@ -29,5 +29,5 @@
#define LINELEN 2048
void buildmap_osm_text_find_layers (void);
-void buildmap_osm_text_read(char *filename, int country_num, int division_num);
+void buildmap_osm_text_read(char *filename, int tileid, 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:24:23
|
Revision: 2743
http://sourceforge.net/p/roadmap/code/2743
Author: pgf
Date: 2014-06-07 20:24:21 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
default/All: declutter some things much earlier (esp. areas)
Modified Paths:
--------------
trunk/roadmap/src/default/All
Modified: trunk/roadmap/src/default/All
===================================================================
--- trunk/roadmap/src/default/All 2014-06-07 20:24:16 UTC (rev 2742)
+++ trunk/roadmap/src/default/All 2014-06-07 20:24:21 UTC (rev 2743)
@@ -50,19 +50,19 @@
Shore.Thickness: 2
Shore.Speed: 30
Hospitals.Color: red
-Hospitals.Declutter: 4096
+Hospitals.Declutter: 300
Hospitals.Thickness: 1
Hospitals.Speed: 1
Malls.Color: yellow
-Malls.Declutter: 4096
+Malls.Declutter: 300
Malls.Thickness: 1
Malls.Speed: 1
Airports.Color: grey
-Airports.Declutter: 4096
+Airports.Declutter: 300
Airports.Thickness: 1
Airports.Speed: 1
Stations.Color: grey
-Stations.Declutter: 4096
+Stations.Declutter: 300
Stations.Thickness: 1
Stations.Speed: 1
Lakes.Color: LightBlue
@@ -70,7 +70,7 @@
Lakes.Thickness: 1
Lakes.Speed: 1
Parks.Color: green
-Parks.Declutter: 4096
+Parks.Declutter: 600
Parks.Thickness: 1
Parks.Speed: 30
Sea.Color: SlateBlue
@@ -82,14 +82,14 @@
Boundaries.Declutter: 2147483647
Boundaries.Speed: 1
Nature.Color: green
-Nature.Declutter: 1300
+Nature.Declutter: 600
Nature.Thickness: 1
Nature.Speed: 1
Amenity.Color: orange
-Amenity.Declutter: 1300
+Amenity.Declutter: 160
Amenity.Thickness: 1
Amenity.Speed: 1
Suburbs.Color: grey
-Suburbs.Declutter: 1300
+Suburbs.Declutter: 300
Suburbs.Thickness: 1
Suburbs.Speed: 50
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:24:19
|
Revision: 2742
http://sourceforge.net/p/roadmap/code/2742
Author: pgf
Date: 2014-06-07 20:24:16 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
osm_fetch_tile: try to catch wget errors, and remove tmp file on exit
Modified Paths:
--------------
trunk/roadmap/src/osm_fetch_tile
Modified: trunk/roadmap/src/osm_fetch_tile
===================================================================
--- trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:24:11 UTC (rev 2741)
+++ trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:24:16 UTC (rev 2742)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
usage()
{
@@ -49,6 +49,10 @@
*) pipe="cat" ;;
esac
+set -o pipefail
+
+trap "rm -f $xmlfile.tmp" 0
+
if [ -e $xmlfile ]
then
echo Already have $xmlfile
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:24:13
|
Revision: 2741
http://sourceforge.net/p/roadmap/code/2741
Author: pgf
Date: 2014-06-07 20:24:11 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: create typedefs for node and way ids
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:24:06 UTC (rev 2740)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:11 UTC (rev 2741)
@@ -67,11 +67,15 @@
#include "buildmap_osm_text.h"
+/* OSM has over 2G nodes already -- enough to overflow a 32 bit signed int */
+typedef unsigned int nodeid_t;
+typedef unsigned int wayid_t;
+
/**
* @brief a couple of variables to keep track of the way we're dealing with
*/
static struct WayInfo {
- unsigned int WayId; /**< are we in a way (its id) */
+ wayid_t WayId; /**< are we in a way (its id) */
int nWayNodes; /**< number of nodes known for
this way */
int WayLayer; /**< the layer for this way */
@@ -90,7 +94,7 @@
* @brief variables referring to the current node
*/
static struct NodeInfo {
- unsigned int NodeId; /**< which node */
+ nodeid_t NodeId; /**< which node */
char *NodePlace; /**< what kind of place is this */
char *NodeTownName; /**< which town */
char *NodePostalCode; /**< postal code */
@@ -374,10 +378,10 @@
static int maxWayTable = 0;
int nWayTable = 0;
-unsigned int *WayTable = NULL;
+wayid_t *WayTable = NULL;
static void
-saveInterestingWay(unsigned int wayid)
+saveInterestingWay(wayid_t wayid)
{
if (nWayTable == maxWayTable) {
@@ -385,8 +389,8 @@
maxWayTable *= 2;
else
maxWayTable = 1000;
- WayTable = (unsigned int *) realloc(WayTable,
- sizeof(unsigned int) * maxWayTable);
+ WayTable = (wayid_t *) realloc(WayTable,
+ sizeof(wayid_t) * maxWayTable);
}
WayTable[nWayTable] = wayid;
@@ -411,8 +415,8 @@
*
* Note : relies on the order of ways encountered in the file, for performance
*/
-static unsigned int
-isWayInteresting(unsigned int wayid)
+static wayid_t
+isWayInteresting(wayid_t wayid)
{
int *r;
r = bsearch(&wayid, WayTable, nWayTable,
@@ -424,7 +428,7 @@
static int maxNodeTable = 0;
static int nNodeTable = 0;
-static unsigned int *NodeTable = NULL;
+static nodeid_t *NodeTable = NULL;
void
@@ -444,7 +448,7 @@
static void
-saveInterestingNode(unsigned int node)
+saveInterestingNode(nodeid_t node)
{
if (nNodeTable == maxNodeTable) {
@@ -452,7 +456,7 @@
maxNodeTable *= 2;
else
maxNodeTable = 1000;
- NodeTable = (unsigned int *) realloc(NodeTable,
+ NodeTable = (nodeid_t *) realloc(NodeTable,
sizeof(*NodeTable) * maxNodeTable);
}
@@ -461,7 +465,7 @@
}
static int
-isNodeInteresting(unsigned int nodeid)
+isNodeInteresting(nodeid_t nodeid)
{
int *r;
@@ -488,7 +492,7 @@
void
buildmap_osm_text_save_way_nodes(char *data)
{
- unsigned int node;
+ nodeid_t node;
int s;
if (!wi.WayId)
@@ -953,7 +957,7 @@
time_t t[10];
int passid, NumNodes, NumWays;
struct stat st;
- unsigned int interesting_way;
+ wayid_t interesting_way;
int in_relation;
int need_xml_header = 1;
int need_osm_header = 1;
@@ -1058,9 +1062,9 @@
} else if (strncasecmp(p, "/way", 4) == 0) {
/* if the way is still flagged interesting, save it */
- if (wi.WayId && wi.WayIsInteresting) {
- saveInterestingWay(wi.WayId);
- }
+ if (wi.WayId && wi.WayIsInteresting)
+ saveInterestingWay(wi.WayId);
+
buildmap_osm_text_reset_way();
continue;
@@ -1153,7 +1157,7 @@
} else if (strncasecmp(p, "nd", 2) == 0) {
- unsigned int node;
+ nodeid_t node;
/* nodes referenced by interesting ways are interesting */
if (wi.WayId && interesting_way) {
s = sscanf(p, "nd ref=%*[\"']%u%*[\"']", &node);
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:24:08
|
Revision: 2740
http://sourceforge.net/p/roadmap/code/2740
Author: pgf
Date: 2014-06-07 20:24:06 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: reduce clutter, clean up error returns
it was time for a thorough grooming: more consistent naming,
more consistent error return checking, more consistent failure
conditions.
there should be little, if any, functionality change in this commit.
(but there might be some.)
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_main.c
trunk/roadmap/src/buildmap_osm_text.c
trunk/roadmap/src/buildmap_osm_text.h
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:01 UTC (rev 2739)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:24:06 UTC (rev 2740)
@@ -299,7 +299,8 @@
(WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))) {
ret = -1;
} else {
- ret = buildmap_osm_text_read(xmlfile, 0, 0);
+ buildmap_osm_text_read(xmlfile, 0, 0);
+ ret = 0;
}
}
@@ -369,11 +370,8 @@
buildmap_osm_common_find_layers();
buildmap_debug("reading file %s", fn);
- ret = buildmap_osm_text_read(fn, country_num, division_num);
- if (ret < 0)
- return ret;
+ buildmap_osm_text_read(fn, country_num, division_num);
-
buildmap_db_sort();
ret2 = buildmap_osm_save_custom(ofn, (ret == 0) ? 1 : 0);
if (ret2 != 0)
Modified: trunk/roadmap/src/buildmap_osm_text.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:01 UTC (rev 2739)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:06 UTC (rev 2740)
@@ -80,11 +80,10 @@
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 */
+ int WayIsInteresting; /**< this way is interesting for RoadMap */
} wi;
/**
@@ -125,14 +124,14 @@
/**
* @brief remove XMLisms such as ' and strdup
- * limitation : names must be shorter than 256 bytes
+ * limitation : names must be shorter than 512 bytes
* @param s input string
* @return duplicate, to be freed elsewhere
*/
static char *FromXmlAndDup(const char *s)
{
int i, j, k, l, found;
- static char res[256];
+ static char res[512];
for (i=j=0; s[i]; i++)
if (s[i] == '&') {
@@ -175,8 +174,6 @@
static void
buildmap_osm_text_reset_node(void)
{
-// buildmap_info("reset node %d", ni.NodeId);
-
if (ni.NodePlace) free(ni.NodePlace);
if (ni.NodeTownName) free(ni.NodeTownName);
if (ni.NodePostalCode) free(ni.NodePostalCode);
@@ -274,55 +271,44 @@
* <node id="123295" timestamp="2005-07-05T03:26:11Z" user="LA2"
* lat="50.4443626" lon="3.6855288"/>
*/
-int
-buildmap_osm_text_node(char *data)
+void
+buildmap_osm_text_node_read_lat_lon(char *data)
{
- int nchars, r;
-#if 0
- double flat, flon;
-#endif
+ int nchars;
char *p;
int NodeLatRead, NodeLonRead;
char tag[512], value[512];
+ int s;
- sscanf(data, "node id=%*[\"']%u%*[\"']%n", &ni.NodeId, &nchars);
+ s = sscanf(data, "node id=%*[\"']%u%*[\"']%n", &ni.NodeId, &nchars);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) node error", data);
+
p = data + nchars;
ni.NodeLat = ni.NodeLon = 0;
NodeLatRead = NodeLonRead = 0;
while (NodeLatRead == 0 || NodeLonRead == 0) {
+
for (; *p && isspace(*p); p++) ;
- r = sscanf(p, "%[a-zA-Z0-9_]=%*[\"']%[^\"']%*[\"']%n",
- tag, value, &nchars);
- if (r != 2)
- buildmap_error(0, "bad tag read at '%s'\n", p);
+ s = sscanf(p, "%[a-zA-Z0-9_]=%*[\"']%[^\"']%*[\"']%n",
+ tag, value, &nchars);
+ if (s != 2)
+ buildmap_fatal(0, "bad tag read at '%s'\n", p);
-#if 0
if (strcmp(tag, "lat") == 0) {
- sscanf(value, "%lf", &flat);
- ni.NodeLat = flat * 1000000;
- NodeLatRead++;
- } else if (strcmp(tag, "lon") == 0) {
- sscanf(value, "%lf", &flon);
- 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;
}
- return 0;
}
/**
@@ -330,10 +316,10 @@
* @param data point to the line buffer
* @return error indication
*/
-int
-buildmap_osm_text_node_end_and_process(char *data)
+void
+buildmap_osm_text_node_finish(void)
{
- int npoints;
+ int npoints, s;
if (ni.NodeFakeFips) {
if (ni.NodePlace && (strcmp(ni.NodePlace, "town") == 0
@@ -352,7 +338,9 @@
}
if (ni.NodePostalCode) {
int zip = 0;
- sscanf(ni.NodePostalCode, "%d", &zip);
+ s = sscanf(ni.NodePostalCode, "%d", &zip);
+ if (s != 1)
+ buildmap_fatal(0, "bad zip read at '%s'\n", ni.NodePostalCode);
if (zip)
buildmap_zip_add(zip, ni.NodeLon, ni.NodeLat);
}
@@ -364,7 +352,6 @@
buildmap_osm_text_point_add(ni.NodeId, npoints);
buildmap_osm_text_reset_node();
- return 0;
}
/**
@@ -385,45 +372,12 @@
*/
static struct shapeinfo *shapes;
-/**
- * @brief
- * @param data
- * @return
- *
- * Sample XML :
- * <way id="75146" timestamp="2006-04-28T15:24:05Z" user="Mercator">
- * <nd ref="997466"/>
- * <nd ref="997470"/>
- * <nd ref="1536769"/>
- * <nd ref="997472"/>
- * <nd ref="1536770"/>
- * <nd ref="997469"/>
- * <tag k="highway" v="residential"/>
- * <tag k="name" v="Rue de Thiribut"/>
- * <tag k="created_by" v="JOSM"/>
- * </way>
- */
-static int
-buildmap_osm_text_way(char *data)
-{
- /* Severely cut in pieces.
- * This only remembers which way we're in...
- */
- sscanf(data, "way id=%*[\"']%u%*[\"']", &wi.WayId);
- wi.WayNotInteresting = 0;
-
- if (wi.WayId == 0)
- buildmap_fatal(0, "buildmap_osm_text_way(%s) error", data);
-
- return 0;
-}
-
static int maxWayTable = 0;
int nWayTable = 0;
unsigned int *WayTable = NULL;
static void
-WayIsInteresting(unsigned int wayid)
+saveInterestingWay(unsigned int wayid)
{
if (nWayTable == maxWayTable) {
@@ -458,7 +412,7 @@
* Note : relies on the order of ways encountered in the file, for performance
*/
static unsigned int
-IsWayInteresting(unsigned int wayid)
+isWayInteresting(unsigned int wayid)
{
int *r;
r = bsearch(&wayid, WayTable, nWayTable,
@@ -490,7 +444,7 @@
static void
-NodeIsInteresting(unsigned int node)
+saveInterestingNode(unsigned int node)
{
if (nNodeTable == maxNodeTable) {
@@ -507,7 +461,7 @@
}
static int
-IsNodeInteresting(unsigned int nodeid)
+isNodeInteresting(unsigned int nodeid)
{
int *r;
@@ -518,46 +472,8 @@
return *r;
}
-static int
-buildmap_osm_text_node_interesting(char *data)
-{
- /*
- * Avoid figuring out whether we're in a
- * <node ... />
- * or
- * <node ... >
- * ..
- * </node>
- * case, by resetting first if needed.
- */
- if (ni.NodeId && IsNodeInteresting(ni.NodeId)) {
- buildmap_osm_text_node_end_and_process("");
- }
- if (sscanf(data, "node id=%*[\"']%u%*[\"']", &ni.NodeId) != 1) {
- return -1;
- }
-
- buildmap_osm_text_node(data);
-
- return 0;
-}
-
/**
- * @build this is called on every node, but should figure out whether
- * it is interesting
- */
-static int
-buildmap_osm_text_node_interesting_end(char *data)
-{
- if (IsNodeInteresting(ni.NodeId)) {
- buildmap_osm_text_node_end_and_process(data);
- }
- return 0;
-}
-
-
-/**
* @brief
* @param data points into the line of text being processed
* @return error indication
@@ -569,23 +485,21 @@
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)
+void
+buildmap_osm_text_save_way_nodes(char *data)
{
unsigned int node;
- int ix;
+ int s;
- if (! wi.WayId)
+ if (!wi.WayId)
buildmap_fatal(0, "Wasn't in a way (%s)", data);
- if (sscanf(data, "nd ref=%*[\"']%u%*[\"']", &node) != 1) {
- buildmap_error(0, "fail to scanf interesting nd");
- return -1;
- }
+ s = sscanf(data, "nd ref=%*[\"']%u%*[\"']", &node);
+ if (s != 1)
+ buildmap_fatal(0, "fail to scanf interesting nd");
- ix = buildmap_osm_text_point_get(node);
- if (ix < 0) {
- return 0;
+ if (buildmap_osm_text_point_get(node) < 0) {
+ return;
}
if (wi.nWayNodes == nWayNodeAlloc) {
@@ -600,8 +514,6 @@
(0, "allocation failed for %d ints", nWayNodeAlloc);
}
WayNodes[wi.nWayNodes++] = node;
-
- return 0;
}
/**
@@ -609,41 +521,42 @@
* @param data points into the line of text being processed
* @return error indication
*/
-static int
+void
buildmap_osm_text_node_tag(char *data, int catalog)
{
static char *tagk = 0;
static char *tagv = 0;
+ int s;
if (! tagk)
tagk = malloc(512);
if (! tagv)
tagv = malloc(512);
- sscanf(data, "tag k=%*['\"]%[^\"']%*['\"] v=%*['\"]%[^\"']%*['\"]",
+ s = sscanf(data, "tag k=%*['\"]%[^\"']%*['\"] v=%*['\"]%[^\"']%*['\"]",
tagk, tagv);
+ if (s != 2)
+ buildmap_fatal(0, "fail to scanf tag k and v (%s)", data);
if (strcmp(tagk, "postal_code") == 0) {
/* <tag k="postal_code" v="3020"/> */
if (ni.NodePostalCode)
free(ni.NodePostalCode);
ni.NodePostalCode = strdup(tagv);
- if (catalog) NodeIsInteresting(ni.NodeId);
+ if (catalog) saveInterestingNode(ni.NodeId);
} else if (strcmp(tagk, "place") == 0) {
/* <tag k="place" v="town"/> */
if (ni.NodePlace)
free(ni.NodePlace);
ni.NodePlace = strdup(tagv);
- if (catalog) NodeIsInteresting(ni.NodeId);
+ if (catalog) saveInterestingNode(ni.NodeId);
} else if (strcmp(tagk, "name") == 0) {
/* <tag k="name" v="Herent"/> */
if (ni.NodeTownName)
free(ni.NodeTownName);
ni.NodeTownName = FromXmlAndDup(tagv);
- if (catalog) NodeIsInteresting(ni.NodeId);
+ if (catalog) saveInterestingNode(ni.NodeId);
}
-
- return 0;
}
/**
@@ -658,76 +571,72 @@
* <tag k="ref" v="E40">
* <tag k="int_ref" v="E 40">
*/
-static int
+void
buildmap_osm_text_way_tag(char *data)
{
static char *tag = 0, *value = 0;
- int i, found;
+ int i, s;
layer_info_t *list;
- int ret = 0;
+ /* have we already decided this way is uninteresting? */
+ if (!wi.WayIsInteresting)
+ return;
+
if (! tag) tag = malloc(512);
if (! value) value = malloc(512);
- sscanf(data, "tag k=%*[\"']%[^\"']%*[\"'] v=%*[\"']%[^\"']%*[\"']", tag, value);
+ s = sscanf(data, "tag k=%*[\"']%[^\"']%*[\"'] v=%*[\"']%[^\"']%*[\"']",
+ tag, value);
+ if (s != 2)
+ buildmap_fatal(0, "fail to scanf tag and value (%s)", data);
/* street names */
if (strcasecmp(tag, "name") == 0) {
if (wi.WayStreetName)
free(wi.WayStreetName);
wi.WayStreetName = FromXmlAndDup(value);
- return 0; /* FIX ME ?? */
+ return;
+ } else if (strcasecmp(tag, "ref") == 0) {
+ if (wi.WayStreetRef)
+ free(wi.WayStreetRef);
+ wi.WayStreetRef = FromXmlAndDup(value);
+ return;
} else if (strcasecmp(tag, "landuse") == 0) {
- wi.WayNotInteresting = 1;
+ wi.WayIsInteresting = 0;
+ return;
} else if (strcasecmp(tag, "oneway") == 0 && strcasecmp(value, "yes") == 0) {
wi.WayIsOneWay = ROADMAP_LINE_DIRECTION_ONEWAY;
} else if (strcasecmp(tag, "building") == 0) {
if (strcasecmp(value, "yes") == 0) {
- wi.WayNotInteresting = 1;
+ wi.WayIsInteresting = 0;
+ return;
}
- } else if (strcasecmp(tag, "ref") == 0) {
- if (wi.WayStreetRef)
- free(wi.WayStreetRef);
- wi.WayStreetRef = FromXmlAndDup(value);
- return 0; /* FIX ME ?? */
} else if (strcasecmp(tag, "admin_level") == 0) {
wi.WayAdminLevel = atoi(value);
- } else if (strcasecmp(tag, "natural") == 0 && strcasecmp(value, "coastline") == 0) {
+ } else if (strcasecmp(tag, "natural") == 0 &&
+ strcasecmp(value, "coastline") == 0) {
wi.WayCoast = 1;
}
- /* Scan list_info
- *
- * This will map tags such as highway and cycleway.
+ /*
+ * Get layer info
*/
- found = 0;
- for (i=1; found == 0 && list_info[i].name != 0; i++) {
- if (strcmp(tag, list_info[i].name) == 0) {
- list = list_info[i].list;
- found = 1;
- break;
- }
- }
-
- if (found) {
+ for (i=1; list_info[i].name != 0; i++) {
+ if (strcmp(tag, list_info[i].name) == 0) {
+ list = list_info[i].list;
if (list) {
- for (i=1; list[i].name; i++) {
- if (strcmp(value, list[i].name) == 0) {
- wi.WayFlags = list[i].flags;
- if (list[i].layerp)
- ret = *(list[i].layerp);
- }
+ for (i=1; list[i].name; i++) {
+ if (strcmp(value, list[i].name) == 0) {
+ wi.WayFlags = list[i].flags;
+ if (list[i].layerp)
+ wi.WayLayer = *(list[i].layerp);
+ break;
}
- } else {
- /* */
+ }
}
+ break;
+ }
}
-
- /* FIX ME When are we supposed to do this */
- if (ret)
- wi.WayLayer = ret;
-
- return 0;
}
/**
@@ -736,8 +645,8 @@
* @param data points to the line of text being processed
* @return error indication
*/
-static int
-buildmap_osm_text_way_end(char *data)
+void
+buildmap_osm_text_way_finish(char *data)
{
int from_point, to_point, line, street;
int fromlon, tolon, fromlat, tolat;
@@ -752,40 +661,33 @@
if (l_boundary == 0)
l_boundary = buildmap_layer_get("boundaries");;
- if (wi.WayInvalid) { // REMOVEME
- buildmap_osm_text_reset_way();
- return 0;
- }
-
if (wi.WayId == 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 (wi.WayCoast) {
- wi.WayNotInteresting = 0;
+ wi.WayIsInteresting = 1;
wi.WayLayer = l_shoreline;
} else if (wi.WayAdminLevel) {
/* national == 2, state == 4, ignore lesser boundaries */
if (wi.WayAdminLevel > 4) {
- wi.WayNotInteresting = 1;
+ wi.WayIsInteresting = 0;
}
wi.WayLayer = l_boundary;
}
- if (wi.WayNotInteresting || wi.WayLayer == 0) {
+ if ( !wi.WayIsInteresting || wi.WayLayer == 0) {
buildmap_verbose("discarding way %d, not interesting (%s)", wi.WayId, data);
- wi.WayNotInteresting = 0;
buildmap_osm_text_reset_way();
- return 0;
+ return;
}
if (wi.nWayNodes < 1) {
buildmap_osm_text_reset_way();
- wi.WayNotInteresting = 1;
- return 0;
+ return;
}
RoadMapString rms_dirp = str2dict(DictionaryPrefix, "");
@@ -940,7 +842,6 @@
buildmap_osm_text_reset_way();
- return 0;
}
/**
@@ -1041,14 +942,13 @@
*
* All underlying processing is passed to other functions.
*/
-int
+void
buildmap_osm_text_read(char *fn, int country_num, int division_num)
{
FILE *fdata;
int lines;
char *got;
static char buf[LINELEN];
- int ret = 0;
char *p;
time_t t[10];
int passid, NumNodes, NumWays;
@@ -1058,6 +958,7 @@
int need_xml_header = 1;
int need_osm_header = 1;
int need_osm_trailer = 1;
+ int s;
fdata = buildmap_osm_text_fopen(fn);
fstat(fileno(fdata), &st);
@@ -1079,7 +980,6 @@
/*
* 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");
@@ -1118,15 +1018,8 @@
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;
+ * <tag k='opening_hours' v='Sa 09:30-19:00;
* Su 10:00-14:00'/>
- *
* and just continue with the next line and hope we'll pick up
* a new tag soon.
*/
@@ -1138,32 +1031,49 @@
in_relation = 0;
if (strncasecmp(p, "relation", 8) == 0) {
+
in_relation = 1;
+ continue;
+
} else if (strncasecmp(p, "/relation", 9) == 0) {
+
in_relation = 0;
+ continue;
+
} else if (in_relation) {
+
continue;
+
} else if (strncasecmp(p, "way", 3) == 0) {
- wi.WayNotInteresting = 0;
- if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId) != 1) {
- wi.WayId = 0;
- }
+
+ // assume ways are interesting, to begin with
+ wi.WayIsInteresting = 1;
+ s = sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) way error", p);
+
NumWays++;
continue;
+
} else if (strncasecmp(p, "/way", 4) == 0) {
- if (wi.WayId && ! wi.WayNotInteresting) {
- WayIsInteresting(wi.WayId);
+
+ /* if the way is still flagged interesting, save it */
+ if (wi.WayId && wi.WayIsInteresting) {
+ saveInterestingWay(wi.WayId);
}
buildmap_osm_text_reset_way();
continue;
+
} else if (strncasecmp(p, "tag", 3) == 0) {
- if (! wi.WayId)
- ret += buildmap_osm_text_node_tag(p, 1);
- else
- ret += buildmap_osm_text_way_tag(p);
+
+ if (wi.WayId)
+ buildmap_osm_text_way_tag(p);
continue;
+
} else if (strncasecmp(p, "/osm>", 5) == 0) {
+
need_osm_trailer = 0;
+
}
}
buildmap_progress(LineNo, 0);
@@ -1213,32 +1123,52 @@
for (; *p && isspace(*p); p++) ;
if (strncasecmp(p, "relation", 8) == 0) {
+
in_relation = 1;
+ continue;
+
} else if (strncasecmp(p, "/relation", 9) == 0) {
+
in_relation = 0;
+ continue;
+
} else if (in_relation) {
+
continue;
+
} else if (strncasecmp(p, "way", 3) == 0) {
- if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId) == 1) {
- interesting_way = IsWayInteresting(wi.WayId);
- } else {
- wi.WayId = 0;
- interesting_way = 0;
- }
+
+ s = sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) way error", p);
+
+ interesting_way = isWayInteresting(wi.WayId);
continue;
+
} else if (strncasecmp(p, "/way", 4) == 0) {
- interesting_way = 0;
+
+ wi.WayId = 0;
buildmap_osm_text_reset_way();
continue;
+
} else if (strncasecmp(p, "nd", 2) == 0) {
+
unsigned int node;
/* nodes referenced by interesting ways are interesting */
if (wi.WayId && interesting_way) {
- if (sscanf(p, "nd ref=%*[\"']%u%*[\"']", &node) == 1) {
- NodeIsInteresting(node);
- }
+ s = sscanf(p, "nd ref=%*[\"']%u%*[\"']", &node);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) way error", p);
+
+ saveInterestingNode(node);
}
continue;
+
+ } else if (strncasecmp(p, "tag", 3) == 0) {
+
+ if (!wi.WayId)
+ buildmap_osm_text_node_tag(p, 1);
+ continue;
}
}
buildmap_progress(LineNo, lines);
@@ -1286,36 +1216,68 @@
if (strncasecmp(p, "relation", 8) == 0) {
in_relation = 1;
+ continue;
+
} else if (strncasecmp(p, "/relation", 9) == 0) {
in_relation = 0;
+ continue;
+
} else if (in_relation) {
continue;
+
} else if (strncasecmp(p, "node", 4) == 0) {
- // nodes get added to the buildmap tables here...
- ret += buildmap_osm_text_node_interesting(p);
+ /*
+ * Avoid figuring out whether we're in a
+ * <node ... />
+ * or
+ * <node ... >
+ * ..
+ * </node>
+ * case, by resetting first if needed.
+ */
+ if (ni.NodeId && isNodeInteresting(ni.NodeId))
+ buildmap_osm_text_node_finish();
+
+ s = sscanf(p, "node id=%*[\"']%u%*[\"']", &ni.NodeId);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) node error", p);
+
+ buildmap_osm_text_node_read_lat_lon(p);
+
NumNodes++;
continue;
} else if (strncasecmp(p, "/node", 5) == 0) {
- // ...and here
- ret += buildmap_osm_text_node_interesting_end(p);
+
+ if (isNodeInteresting(ni.NodeId))
+ buildmap_osm_text_node_finish();
continue;
+
} else if (strncasecmp(p, "tag", 3) == 0) {
- if (! wi.WayId)
- ret += buildmap_osm_text_node_tag(p, 0);
+
+ if (!wi.WayId)
+ buildmap_osm_text_node_tag(p, 0);
else
- ret += buildmap_osm_text_way_tag(p);
+ buildmap_osm_text_way_tag(p);
continue;
+
} else if (strncasecmp(p, "way", 3) == 0) {
- // ways get added to the buildmap tables (if interesting) here...
- ret += buildmap_osm_text_way(p);
+
+ s = sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId);
+ if (s != 1)
+ buildmap_fatal(0, "buildmap_osm_text(%s) way error", p);
+
+ wi.WayIsInteresting = 1;
continue;
+
} else if (strncasecmp(p, "/way", 4) == 0) {
- // ...and here
- ret += buildmap_osm_text_way_end(p);
+
+ buildmap_osm_text_way_finish(p);
continue;
+
} else if (strncasecmp(p, "nd", 2) == 0) {
+
// the nd node references gets put on WayNodes list
- ret += buildmap_osm_text_nd(p);
+ buildmap_osm_text_save_way_nodes(p);
continue;
}
}
@@ -1339,6 +1301,4 @@
buildmap_info("Final: (%d seconds)",
passid, t[passid] - t[passid - 1]);
-
- return ret;
}
Modified: trunk/roadmap/src/buildmap_osm_text.h
===================================================================
--- trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:24:01 UTC (rev 2739)
+++ trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:24:06 UTC (rev 2740)
@@ -29,5 +29,5 @@
#define LINELEN 2048
void buildmap_osm_text_find_layers (void);
-int buildmap_osm_text_read(char *filename, int country_num, int division_num);
+void buildmap_osm_text_read(char *filename, 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:24:03
|
Revision: 2739
http://sourceforge.net/p/roadmap/code/2739
Author: pgf
Date: 2014-06-07 20:24:01 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: add error checks for valid start/end of xml
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:23:55 UTC (rev 2738)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:24:01 UTC (rev 2739)
@@ -1055,6 +1055,9 @@
struct stat st;
unsigned int interesting_way;
int in_relation;
+ int need_xml_header = 1;
+ int need_osm_header = 1;
+ int need_osm_trailer = 1;
fdata = buildmap_osm_text_fopen(fn);
fstat(fileno(fdata), &st);
@@ -1083,7 +1086,7 @@
LineNo = 0;
NumWays = 0;
- while (! feof(fdata)) {
+ while (! feof(fdata) && need_osm_trailer) {
buildmap_set_line(++LineNo);
if (LineNo % 1000 == 0) buildmap_progress(LineNo, 0);
got = fgets(buf, LINELEN, fdata);
@@ -1097,6 +1100,21 @@
for (p=buf; *p && isspace(*p); p++) ;
if (*p == '\n' || *p == '\r')
continue;
+
+ /* do some error checking in the first pass */
+ if (need_xml_header) {
+ if (strncmp(p, "<?xml ", 6))
+ buildmap_fatal(0, "bad input from %s, no <?xml line", fn);
+ need_xml_header = 0;
+ continue;
+ }
+ if (need_osm_header) {
+ if (strncmp(p, "<osm ", 5))
+ buildmap_fatal(0, "bad input from %s, no <osm line", fn);
+ need_osm_header = 0;
+ continue;
+ }
+
if (*p != '<') {
/*
* Assume we're in a continuation line such as
@@ -1144,12 +1162,17 @@
else
ret += buildmap_osm_text_way_tag(p);
continue;
+ } else if (strncasecmp(p, "/osm>", 5) == 0) {
+ need_osm_trailer = 0;
}
}
buildmap_progress(LineNo, 0);
putchar('\n');
lines = LineNo;
+ if (need_osm_trailer)
+ buildmap_fatal(0, "bad input from %s, no </osm> line", fn);
+
qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds);
(void) time(&t[passid]);
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:58
|
Revision: 2738
http://sourceforge.net/p/roadmap/code/2738
Author: pgf
Date: 2014-06-07 20:23:55 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm: store the fetched .osm files in .osm.gz format
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_main.c
trunk/roadmap/src/buildmap_osm_text.c
trunk/roadmap/src/buildmap_osm_text.h
trunk/roadmap/src/osm_fetch_tile
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:23:50 UTC (rev 2737)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:23:55 UTC (rev 2738)
@@ -206,7 +206,6 @@
char cmd[512];
char bbox[100], *bbp;
- FILE *fdata;
int have = 0;
int ret, bits, trutile;
RoadMapArea edges[1];
@@ -237,12 +236,12 @@
/* create all parents of our file */
parent = roadmap_path_parent(BuildMapResult,
- roadmap_osm_filename(0, 1, tileid, ".osm"));
+ roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
roadmap_path_create(parent);
roadmap_path_free(parent);
xmlfile = roadmap_path_join(BuildMapResult,
- roadmap_osm_filename(0, 1, tileid, ".osm"));
+ roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
snprintf(cmd, sizeof(cmd), "%s --trutile %d "
"--bits %d --have %d --bbox %s --xmlfile %s",
@@ -251,6 +250,8 @@
// sprintf(cmd, "cat /tmp/out.xml > %s", xmlfile);
if (strcasecmp(format, "osmbinary") == 0) {
+ FILE *fdata;
+
buildmap_info("command is \"%s\"", cmd);
fdata = popen(cmd, "r");
@@ -292,25 +293,13 @@
}
} else {
- struct stat statbuf;
- if (/* !BuildMapReplaceAll && */
- stat(xmlfile, &statbuf) == 0 &&
- statbuf.st_size != 0)
- ret = 0;
- else
- ret = system(cmd);
-
+ 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);
+ ret = buildmap_osm_text_read(xmlfile, 0, 0);
}
}
@@ -342,17 +331,10 @@
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) {
- buildmap_fatal(0, "couldn't open \"%s\"", fn);
- return -1;
- }
-
if ((n = buildmap_osm_filename_iso(fn, country, division, ".osm"))) {
buildmap_metadata_add_attribute ("Territory", "Id", country);
buildmap_metadata_add_attribute ("Territory", "Parent", country);
@@ -387,12 +369,11 @@
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));
- ret = -1;
- }
+ ret = buildmap_osm_text_read(fn, country_num, division_num);
+ if (ret < 0)
+ return ret;
+
buildmap_db_sort();
ret2 = buildmap_osm_save_custom(ofn, (ret == 0) ? 1 : 0);
if (ret2 != 0)
Modified: trunk/roadmap/src/buildmap_osm_text.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:50 UTC (rev 2737)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:55 UTC (rev 2738)
@@ -989,6 +989,40 @@
return 1;
}
+
+static int text_file_is_pipe;
+FILE *buildmap_osm_text_fopen(char *fn)
+{
+ FILE *fdata;
+ int len;
+
+ len = strlen(fn);
+ if (len > 3 && strcmp(&fn[len-3], ".gz") == 0) {
+ char command[1024];
+ sprintf(command, "gzip -d -c %s", fn);
+ fdata = popen(command, "r");
+ text_file_is_pipe = 1;
+ } else {
+ fdata = fopen(fn, "r");
+ text_file_is_pipe = 0;
+ }
+
+ if (fdata == NULL) {
+ buildmap_fatal(0, "couldn't open \"%s\"", fn);
+ return NULL;
+ }
+
+ return fdata;
+}
+
+int buildmap_osm_text_fclose(FILE *fp)
+{
+ if (text_file_is_pipe)
+ return pclose(fp);
+ else
+ return fclose(fp);
+}
+
/**
* @brief This is the gut of buildmap_osm_text : parse an OSM XML file
* @param fdata an open file pointer, this will get read twice
@@ -1008,8 +1042,10 @@
* All underlying processing is passed to other functions.
*/
int
-buildmap_osm_text_read(FILE * fdata, int country_num, int division_num)
+buildmap_osm_text_read(char *fn, int country_num, int division_num)
{
+ FILE *fdata;
+ int lines;
char *got;
static char buf[LINELEN];
int ret = 0;
@@ -1020,6 +1056,7 @@
unsigned int interesting_way;
int in_relation;
+ fdata = buildmap_osm_text_fopen(fn);
fstat(fileno(fdata), &st);
ni.NodeFakeFips = 1000000 + country_num * 1000 + division_num;
@@ -1047,8 +1084,8 @@
NumWays = 0;
while (! feof(fdata)) {
- buildmap_progress(ftell(fdata), st.st_size);
buildmap_set_line(++LineNo);
+ if (LineNo % 1000 == 0) buildmap_progress(LineNo, 0);
got = fgets(buf, LINELEN, fdata);
if (got == NULL) {
if (feof(fdata))
@@ -1109,8 +1146,9 @@
continue;
}
}
- buildmap_progress(ftell(fdata), st.st_size);
+ buildmap_progress(LineNo, 0);
putchar('\n');
+ lines = LineNo;
qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds);
@@ -1125,12 +1163,13 @@
*/
LineNo = 0;
buildmap_set_source("pass 2");
- fseek(fdata, 0L, SEEK_SET);
+ buildmap_osm_text_fclose(fdata);
+ buildmap_osm_text_fopen(fn);
buildmap_osm_text_reset_way();
buildmap_osm_text_reset_node();
while (! feof(fdata)) {
- buildmap_progress(ftell(fdata), st.st_size);
+ buildmap_progress(LineNo, lines);
buildmap_set_line(++LineNo);
got = fgets(buf, LINELEN, fdata);
if (got == NULL) {
@@ -1179,7 +1218,7 @@
continue;
}
}
- buildmap_progress(ftell(fdata), st.st_size);
+ buildmap_progress(LineNo, lines);
putchar('\n');
qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_unsigneds);
@@ -1196,12 +1235,13 @@
LineNo = 0;
NumNodes = 0;
buildmap_set_source("pass 3");
- fseek(fdata, 0L, SEEK_SET);
+ buildmap_osm_text_fclose(fdata);
+ buildmap_osm_text_fopen(fn);
buildmap_osm_text_reset_way();
buildmap_osm_text_reset_node();
while (! feof(fdata)) {
- buildmap_progress(ftell(fdata), st.st_size);
+ buildmap_progress(LineNo, lines);
buildmap_set_line(++LineNo);
got = fgets(buf, LINELEN, fdata);
if (got == NULL) {
@@ -1256,9 +1296,11 @@
continue;
}
}
- buildmap_progress(ftell(fdata), st.st_size);
+ buildmap_progress(LineNo, lines);
putchar('\n');
+ buildmap_osm_text_fclose(fdata);
+
(void) time(&t[passid]);
buildmap_info("Pass %d : %d lines read (%d seconds)",
passid, LineNo, t[passid] - t[passid - 1]);
Modified: trunk/roadmap/src/buildmap_osm_text.h
===================================================================
--- trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:23:50 UTC (rev 2737)
+++ trunk/roadmap/src/buildmap_osm_text.h 2014-06-07 20:23:55 UTC (rev 2738)
@@ -29,5 +29,5 @@
#define LINELEN 2048
void buildmap_osm_text_find_layers (void);
-int buildmap_osm_text_read(FILE * fdata, int country_num, int division_num);
+int buildmap_osm_text_read(char *filename, int country_num, int division_num);
void buildmap_osm_text_save_wayids(const char *path, const char *outfile);
Modified: trunk/roadmap/src/osm_fetch_tile
===================================================================
--- trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:23:50 UTC (rev 2737)
+++ trunk/roadmap/src/osm_fetch_tile 2014-06-07 20:23:55 UTC (rev 2738)
@@ -44,8 +44,16 @@
bbox="[bbox=$bbox]"
-if wget -O $xmlfile.tmp "http://$server$bbox$query$me"
+case $xmlfile in
+*.gz) pipe="gzip -c" ;;
+*) pipe="cat" ;;
+esac
+
+if [ -e $xmlfile ]
then
+ echo Already have $xmlfile
+elif wget -O - "http://$server$bbox$query$me" | $pipe >$xmlfile.tmp
+then
mv $xmlfile.tmp $xmlfile
else
rm $xmlfile.tmp
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:53
|
Revision: 2737
http://sourceforge.net/p/roadmap/code/2737
Author: pgf
Date: 2014-06-07 20:23:50 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm: separate multiple route numbers with endash instead of slash
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:23:45 UTC (rev 2736)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:50 UTC (rev 2737)
@@ -742,7 +742,7 @@
int from_point, to_point, line, street;
int fromlon, tolon, fromlat, tolat;
int j;
- char compound_name[512];
+ char compound_name[1024];
char *n;
static int l_shoreline = 0,
l_boundary = 0;
@@ -848,35 +848,35 @@
// to_point = buildmap_osm_text_point_get(WayNodes[wi.nWayNodes-1]);
/* Street name */
-#if 0
- 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.WayId,
wi.WayStreetName ? wi.WayStreetName : "",
wi.WayStreetRef ? wi.WayStreetRef : "");
-#else
if (wi.WayStreetRef) {
- char *p = wi.WayStreetRef;
- do { /* OSM separates multi-value refs with ';' */
- if (*p == ';') *p = '/';
- } while (*p++);
+ char *d = compound_name;
+ char *s = wi.WayStreetRef;
+#define ENDASHSEP " \xe2\x80\x93 "
+#define EMDASHSEP " \xe2\x80\x94 "
+ while (*s) { /* OSM separates multi-value refs with ';' */
+ if (*s == ';') {
+ d += sprintf(d, ENDASHSEP);
+ } else {
+ *d++ = *s;
+ }
+ s++;
+ }
+ n = compound_name;
+ *d = '\0';
if (wi.WayStreetName) {
- snprintf(compound_name, sizeof(compound_name),
- "%s/%s", wi.WayStreetRef, wi.WayStreetName);
- n = compound_name;
- } else {
- n = wi.WayStreetRef;
+ // sprintf(d, ", %s", wi.WayStreetName);
+ sprintf(d, "%s%s", ENDASHSEP, wi.WayStreetName);
}
} else {
n = wi.WayStreetName;
}
rms_name = str2dict(DictionaryStreet, n);
-#endif
+
LineId++;
line = buildmap_line_add(LineId,
wi.WayLayer, from_point, to_point, wi.WayIsOneWay);
@@ -969,7 +969,7 @@
if (count <= 2)
continue;
- buildmap_verbose("trying line %d, %d points", lineid, count);
+ // buildmap_verbose("trying line %d, %d points", lineid, count);
lineid = shapes[i].lineid;
line_index = buildmap_line_find_sorted(lineid);
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:48
|
Revision: 2736
http://sourceforge.net/p/roadmap/code/2736
Author: pgf
Date: 2014-06-07 20:23:45 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm: add route numbers to street names
OSM puts route numbers into the "ref" key for ways. this duplicates
current roadmap_osm_binary.c behavior.
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:23:41 UTC (rev 2735)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:45 UTC (rev 2736)
@@ -742,6 +742,8 @@
int from_point, to_point, line, street;
int fromlon, tolon, fromlat, tolat;
int j;
+ char compound_name[512];
+ char *n;
static int l_shoreline = 0,
l_boundary = 0;
@@ -846,14 +848,35 @@
// to_point = buildmap_osm_text_point_get(WayNodes[wi.nWayNodes-1]);
/* Street name */
+#if 0
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.WayId,
wi.WayStreetName ? wi.WayStreetName : "",
wi.WayStreetRef ? wi.WayStreetRef : "");
+#else
+ if (wi.WayStreetRef) {
+ char *p = wi.WayStreetRef;
+ do { /* OSM separates multi-value refs with ';' */
+ if (*p == ';') *p = '/';
+ } while (*p++);
+
+ if (wi.WayStreetName) {
+ snprintf(compound_name, sizeof(compound_name),
+ "%s/%s", wi.WayStreetRef, wi.WayStreetName);
+ n = compound_name;
+ } else {
+ n = wi.WayStreetRef;
+ }
+ } else {
+ n = wi.WayStreetName;
+ }
+ rms_name = str2dict(DictionaryStreet, n);
+#endif
LineId++;
line = buildmap_line_add(LineId,
wi.WayLayer, from_point, to_point, wi.WayIsOneWay);
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:43
|
Revision: 2735
http://sourceforge.net/p/roadmap/code/2735
Author: pgf
Date: 2014-06-07 20:23:41 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm: --replace should only replace .rdm files, not precious .osm
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:23:36 UTC (rev 2734)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:23:41 UTC (rev 2735)
@@ -69,7 +69,7 @@
{"bits", "b", opt_int, ROADMAP_OSM_DEFAULT_BITS,
"The number of bits of quadtile address"},
{"replace", "r", opt_flag, "0",
- "Re-request maps that are already present"},
+ "Rebuild .rdm files, reuse existing .osm if possible"},
{"maps", "m", opt_string, "",
"Location for the generated map files"},
{"fetcher", "F", opt_string, "osm_fetch_tile",
@@ -293,7 +293,7 @@
} else {
struct stat statbuf;
- if (!BuildMapReplaceAll &&
+ if (/* !BuildMapReplaceAll && */
stat(xmlfile, &statbuf) == 0 &&
statbuf.st_size != 0)
ret = 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:23:39
|
Revision: 2734
http://sourceforge.net/p/roadmap/code/2734
Author: pgf
Date: 2014-06-07 20:23:36 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: rename inWay --> WayId for clarity
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:23:30 UTC (rev 2733)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:36 UTC (rev 2734)
@@ -71,7 +71,7 @@
* @brief a couple of variables to keep track of the way we're dealing with
*/
static struct WayInfo {
- unsigned int inWay; /**< are we in a way (its id) */
+ unsigned int WayId; /**< are we in a way (its id) */
int nWayNodes; /**< number of nodes known for
this way */
int WayLayer; /**< the layer for this way */
@@ -409,10 +409,10 @@
/* Severely cut in pieces.
* This only remembers which way we're in...
*/
- sscanf(data, "way id=%*[\"']%u%*[\"']", &wi.inWay);
+ sscanf(data, "way id=%*[\"']%u%*[\"']", &wi.WayId);
wi.WayNotInteresting = 0;
- if (wi.inWay == 0)
+ if (wi.WayId == 0)
buildmap_fatal(0, "buildmap_osm_text_way(%s) error", data);
return 0;
@@ -575,7 +575,7 @@
unsigned int node;
int ix;
- if (! wi.inWay)
+ if (! wi.WayId)
buildmap_fatal(0, "Wasn't in a way (%s)", data);
if (sscanf(data, "nd ref=%*[\"']%u%*[\"']", &node) != 1) {
@@ -755,7 +755,7 @@
return 0;
}
- if (wi.inWay == 0)
+ if (wi.WayId == 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 */
@@ -773,7 +773,7 @@
}
if (wi.WayNotInteresting || wi.WayLayer == 0) {
- buildmap_verbose("discarding way %d, not interesting (%s)", wi.inWay, data);
+ buildmap_verbose("discarding way %d, not interesting (%s)", wi.WayId, data);
wi.WayNotInteresting = 0;
buildmap_osm_text_reset_way();
@@ -850,7 +850,7 @@
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,
+ buildmap_verbose ("Way %d [%s] ref [%s]", wi.WayId,
wi.WayStreetName ? wi.WayStreetName : "",
wi.WayStreetRef ? wi.WayStreetRef : "");
@@ -1067,19 +1067,19 @@
continue;
} else if (strncasecmp(p, "way", 3) == 0) {
wi.WayNotInteresting = 0;
- if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.inWay) != 1) {
- wi.inWay = 0;
+ if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId) != 1) {
+ wi.WayId = 0;
}
NumWays++;
continue;
} else if (strncasecmp(p, "/way", 4) == 0) {
- if (wi.inWay && ! wi.WayNotInteresting) {
- WayIsInteresting(wi.inWay);
+ if (wi.WayId && ! wi.WayNotInteresting) {
+ WayIsInteresting(wi.WayId);
}
buildmap_osm_text_reset_way();
continue;
} else if (strncasecmp(p, "tag", 3) == 0) {
- if (! wi.inWay)
+ if (! wi.WayId)
ret += buildmap_osm_text_node_tag(p, 1);
else
ret += buildmap_osm_text_way_tag(p);
@@ -1134,10 +1134,10 @@
} else if (in_relation) {
continue;
} else if (strncasecmp(p, "way", 3) == 0) {
- if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.inWay) == 1) {
- interesting_way = IsWayInteresting(wi.inWay);
+ if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId) == 1) {
+ interesting_way = IsWayInteresting(wi.WayId);
} else {
- wi.inWay = 0;
+ wi.WayId = 0;
interesting_way = 0;
}
continue;
@@ -1148,7 +1148,7 @@
} else if (strncasecmp(p, "nd", 2) == 0) {
unsigned int node;
/* nodes referenced by interesting ways are interesting */
- if (wi.inWay && interesting_way) {
+ if (wi.WayId && interesting_way) {
if (sscanf(p, "nd ref=%*[\"']%u%*[\"']", &node) == 1) {
NodeIsInteresting(node);
}
@@ -1214,7 +1214,7 @@
ret += buildmap_osm_text_node_interesting_end(p);
continue;
} else if (strncasecmp(p, "tag", 3) == 0) {
- if (! wi.inWay)
+ if (! wi.WayId)
ret += buildmap_osm_text_node_tag(p, 0);
else
ret += buildmap_osm_text_way_tag(p);
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:33
|
Revision: 2733
http://sourceforge.net/p/roadmap/code/2733
Author: pgf
Date: 2014-06-07 20:23:30 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: node and way ids should be treated as unsigned
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:23:25 UTC (rev 2732)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:30 UTC (rev 2733)
@@ -71,7 +71,7 @@
* @brief a couple of variables to keep track of the way we're dealing with
*/
static struct WayInfo {
- int inWay; /**< are we in a way (its id) */
+ unsigned 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 */
@@ -91,7 +91,7 @@
* @brief variables referring to the current node
*/
static struct NodeInfo {
- int NodeId; /**< which node */
+ unsigned int NodeId; /**< which node */
char *NodePlace; /**< what kind of place is this */
char *NodeTownName; /**< which town */
char *NodePostalCode; /**< postal code */
@@ -285,7 +285,7 @@
int NodeLatRead, NodeLonRead;
char tag[512], value[512];
- sscanf(data, "node id=%*[\"']%d%*[\"']%n", &ni.NodeId, &nchars);
+ sscanf(data, "node id=%*[\"']%u%*[\"']%n", &ni.NodeId, &nchars);
p = data + nchars;
ni.NodeLat = ni.NodeLon = 0;
@@ -409,7 +409,7 @@
/* Severely cut in pieces.
* This only remembers which way we're in...
*/
- sscanf(data, "way id=%*[\"']%d%*[\"']", &wi.inWay);
+ sscanf(data, "way id=%*[\"']%u%*[\"']", &wi.inWay);
wi.WayNotInteresting = 0;
if (wi.inWay == 0)
@@ -420,10 +420,10 @@
static int maxWayTable = 0;
int nWayTable = 0;
-int *WayTable = NULL;
+unsigned int *WayTable = NULL;
static void
-WayIsInteresting(int wayid)
+WayIsInteresting(unsigned int wayid)
{
if (nWayTable == maxWayTable) {
@@ -431,8 +431,8 @@
maxWayTable *= 2;
else
maxWayTable = 1000;
- WayTable = (int *) realloc(WayTable,
- sizeof(int) * maxWayTable);
+ WayTable = (unsigned int *) realloc(WayTable,
+ sizeof(unsigned int) * maxWayTable);
}
WayTable[nWayTable] = wayid;
@@ -440,9 +440,14 @@
}
int
-qsort_compare_ints(const void *id1, const void *id2)
+qsort_compare_unsigneds(const void *id1, const void *id2)
{
- return *(int *)id1 - *(int *)id2;
+ if (*(unsigned int *)id1 < *(unsigned int *)id2)
+ return -1;
+ else if (*(unsigned int *)id1 > *(unsigned int *)id2)
+ return 1;
+ else
+ return 0;
}
/**
@@ -452,12 +457,12 @@
*
* Note : relies on the order of ways encountered in the file, for performance
*/
-static int
-IsWayInteresting(int wayid)
+static unsigned int
+IsWayInteresting(unsigned int wayid)
{
int *r;
r = bsearch(&wayid, WayTable, nWayTable,
- sizeof(*WayTable), qsort_compare_ints);
+ sizeof(*WayTable), qsort_compare_unsigneds);
if (!r) return 0;
return *r;
@@ -465,7 +470,7 @@
static int maxNodeTable = 0;
static int nNodeTable = 0;
-static int *NodeTable = NULL;
+static unsigned int *NodeTable = NULL;
void
@@ -480,12 +485,12 @@
strcat(nfn, ".ways");
- roadmap_file_save(path, nfn, WayTable, nWayTable * sizeof(int));
+ roadmap_file_save(path, nfn, WayTable, nWayTable * sizeof(*WayTable));
}
static void
-NodeIsInteresting(int node)
+NodeIsInteresting(unsigned int node)
{
if (nNodeTable == maxNodeTable) {
@@ -493,8 +498,8 @@
maxNodeTable *= 2;
else
maxNodeTable = 1000;
- NodeTable = (int *) realloc(NodeTable,
- sizeof(int) * maxNodeTable);
+ NodeTable = (unsigned int *) realloc(NodeTable,
+ sizeof(*NodeTable) * maxNodeTable);
}
NodeTable[nNodeTable] = node;
@@ -502,12 +507,12 @@
}
static int
-IsNodeInteresting(int nodeid)
+IsNodeInteresting(unsigned int nodeid)
{
int *r;
r = bsearch(&nodeid, NodeTable, nNodeTable,
- sizeof(*NodeTable), qsort_compare_ints);
+ sizeof(*NodeTable), qsort_compare_unsigneds);
if (!r) return 0;
return *r;
@@ -525,10 +530,11 @@
* </node>
* case, by resetting first if needed.
*/
- if (ni.NodeId && IsNodeInteresting(ni.NodeId))
+ if (ni.NodeId && IsNodeInteresting(ni.NodeId)) {
buildmap_osm_text_node_end_and_process("");
+ }
- if (sscanf(data, "node id=%*[\"']%d%*[\"']", &ni.NodeId) != 1) {
+ if (sscanf(data, "node id=%*[\"']%u%*[\"']", &ni.NodeId) != 1) {
return -1;
}
@@ -544,8 +550,9 @@
static int
buildmap_osm_text_node_interesting_end(char *data)
{
- if (IsNodeInteresting(ni.NodeId))
+ if (IsNodeInteresting(ni.NodeId)) {
buildmap_osm_text_node_end_and_process(data);
+ }
return 0;
}
@@ -565,13 +572,16 @@
static int
buildmap_osm_text_nd(char *data)
{
- int node, ix;
+ unsigned int node;
+ int ix;
if (! wi.inWay)
buildmap_fatal(0, "Wasn't in a way (%s)", data);
- if (sscanf(data, "nd ref=%*[\"']%d%*[\"']", &node) != 1)
+ if (sscanf(data, "nd ref=%*[\"']%u%*[\"']", &node) != 1) {
+ buildmap_error(0, "fail to scanf interesting nd");
return -1;
+ }
ix = buildmap_osm_text_point_get(node);
if (ix < 0) {
@@ -584,7 +594,7 @@
else
nWayNodeAlloc = 1000;
WayNodes =
- (int *)realloc(WayNodes, sizeof(int) * nWayNodeAlloc);
+ (int *)realloc(WayNodes, sizeof(*WayNodes) * nWayNodeAlloc);
if (WayNodes == 0)
buildmap_fatal
(0, "allocation failed for %d ints", nWayNodeAlloc);
@@ -984,7 +994,7 @@
time_t t[10];
int passid, NumNodes, NumWays;
struct stat st;
- int interesting_way;
+ unsigned int interesting_way;
int in_relation;
fstat(fileno(fdata), &st);
@@ -1057,14 +1067,15 @@
continue;
} else if (strncasecmp(p, "way", 3) == 0) {
wi.WayNotInteresting = 0;
- if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) != 1) {
+ if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.inWay) != 1) {
wi.inWay = 0;
}
NumWays++;
continue;
} else if (strncasecmp(p, "/way", 4) == 0) {
- if (wi.inWay && ! wi.WayNotInteresting)
+ if (wi.inWay && ! wi.WayNotInteresting) {
WayIsInteresting(wi.inWay);
+ }
buildmap_osm_text_reset_way();
continue;
} else if (strncasecmp(p, "tag", 3) == 0) {
@@ -1078,7 +1089,7 @@
buildmap_progress(ftell(fdata), st.st_size);
putchar('\n');
- qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_ints);
+ qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds);
(void) time(&t[passid]);
buildmap_info("Pass %d : %d lines read (%d seconds)",
@@ -1123,7 +1134,7 @@
} else if (in_relation) {
continue;
} else if (strncasecmp(p, "way", 3) == 0) {
- if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) == 1) {
+ if (sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.inWay) == 1) {
interesting_way = IsWayInteresting(wi.inWay);
} else {
wi.inWay = 0;
@@ -1131,13 +1142,14 @@
}
continue;
} else if (strncasecmp(p, "/way", 4) == 0) {
+ interesting_way = 0;
buildmap_osm_text_reset_way();
continue;
} else if (strncasecmp(p, "nd", 2) == 0) {
+ unsigned int node;
/* nodes referenced by interesting ways are interesting */
if (wi.inWay && interesting_way) {
- int node;
- if (sscanf(p, "nd ref=%*[\"']%d%*[\"']", &node) == 1) {
+ if (sscanf(p, "nd ref=%*[\"']%u%*[\"']", &node) == 1) {
NodeIsInteresting(node);
}
}
@@ -1147,7 +1159,7 @@
buildmap_progress(ftell(fdata), st.st_size);
putchar('\n');
- qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_ints);
+ qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_unsigneds);
(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:23:28
|
Revision: 2732
http://sourceforge.net/p/roadmap/code/2732
Author: pgf
Date: 2014-06-07 20:23:25 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
roadmap_label: bump the max-label limit
Modified Paths:
--------------
trunk/roadmap/src/roadmap_label.c
Modified: trunk/roadmap/src/roadmap_label.c
===================================================================
--- trunk/roadmap/src/roadmap_label.c 2014-06-07 20:23:21 UTC (rev 2731)
+++ trunk/roadmap/src/roadmap_label.c 2014-06-07 20:23:25 UTC (rev 2732)
@@ -94,7 +94,7 @@
ROADMAP_CONFIG_ITEM("Labels", "Font Size");
/* this is fairly arbitrary */
-#define MAX_LABELS 4096
+#define MAX_LABELS 8192
typedef struct {
RoadMapListItem link;
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:23
|
Revision: 2731
http://sourceforge.net/p/roadmap/code/2731
Author: pgf
Date: 2014-06-07 20:23:21 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_main: make --listonly more useful
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:23:16 UTC (rev 2730)
+++ trunk/roadmap/src/buildmap_osm_main.c 2014-06-07 20:23:21 UTC (rev 2731)
@@ -1019,12 +1019,13 @@
*/
buildmap_osm_sort_tiles(&tileslist, count);
- if (listonly) {
- buildmap_osm_list_tiles(tileslist, count);
- exit(0);
- }
}
+ if (listonly) {
+ buildmap_osm_list_tiles(tileslist, count);
+ exit(0);
+ }
+
error = buildmap_osm_process_tiles
(tileslist, osm_bits, count, fetcher, format);
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:19
|
Revision: 2730
http://sourceforge.net/p/roadmap/code/2730
Author: pgf
Date: 2014-06-07 20:23:16 +0000 (Sat, 07 Jun 2014)
Log Message:
-----------
buildmap_osm_text: further cleanup/speedup
replaced linear searches with qsort/bsearch -- much faster.
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:23:11 UTC (rev 2729)
+++ trunk/roadmap/src/buildmap_osm_text.c 2014-06-07 20:23:16 UTC (rev 2730)
@@ -414,6 +414,7 @@
if (wi.inWay == 0)
buildmap_fatal(0, "buildmap_osm_text_way(%s) error", data);
+
return 0;
}
@@ -422,11 +423,9 @@
int *WayTable = NULL;
static void
-WayIsInteresting(int wayid, int ni)
+WayIsInteresting(int wayid)
{
- if (ni) return;
-
if (nWayTable == maxWayTable) {
if (WayTable)
maxWayTable *= 2;
@@ -440,6 +439,12 @@
nWayTable++;
}
+int
+qsort_compare_ints(const void *id1, const void *id2)
+{
+ return *(int *)id1 - *(int *)id2;
+}
+
/**
* @brief find out if this way is interesting
* @param wayid
@@ -450,36 +455,19 @@
static int
IsWayInteresting(int wayid)
{
- static int ptr = 0;
+ int *r;
+ r = bsearch(&wayid, WayTable, nWayTable,
+ sizeof(*WayTable), qsort_compare_ints);
+ if (!r) return 0;
- if ((ptr < nWayTable) && wayid == WayTable[ptr])
- return 1;
- if ((ptr < nWayTable - 1) && wayid == WayTable[ptr+1]) {
- ptr++;
- return 1;
- }
-
- for (ptr=0; ptr<nWayTable; ptr++)
- if (wayid == WayTable[ptr])
- return 1;
-
- return 0;
+ return *r;
}
static int maxNodeTable = 0;
static int nNodeTable = 0;
-typedef struct NodeTableStruct {
- int nodeid;
-} NodeTableStruct;
-static NodeTableStruct *NodeTable = NULL;
+static int *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)
{
@@ -491,7 +479,6 @@
if (p) *p = '\0';
strcat(nfn, ".ways");
- qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_wayid);
roadmap_file_save(path, nfn, WayTable, nWayTable * sizeof(int));
}
@@ -506,39 +493,24 @@
maxNodeTable *= 2;
else
maxNodeTable = 1000;
- NodeTable = (struct NodeTableStruct *) realloc(NodeTable,
- sizeof(struct NodeTableStruct) * maxNodeTable);
+ NodeTable = (int *) realloc(NodeTable,
+ sizeof(int) * maxNodeTable);
}
- NodeTable[nNodeTable].nodeid = node;
+ NodeTable[nNodeTable] = node;
nNodeTable++;
}
-/* FIX ME */
static int
-IsNodeInteresting(int node)
+IsNodeInteresting(int nodeid)
{
- return 1;
-}
+ int *r;
-/**
- * @brief this <nd> is interesting, register it so we can later treat its <node>
- * @param data
- * @return
- */
-static int
-buildmap_osm_text_nd_interesting(char *data)
-{
- int node;
+ r = bsearch(&nodeid, NodeTable, nNodeTable,
+ sizeof(*NodeTable), qsort_compare_ints);
+ if (!r) return 0;
- if (sscanf(data, "nd ref=%*[\"']%d%*[\"']", &node) != 1) {
- return -1;
- }
-
- NodeIsInteresting(node);
-
- // CountNode(node);
- return 0;
+ return *r;
}
static int
@@ -553,7 +525,7 @@
* </node>
* case, by resetting first if needed.
*/
- if (ni.NodeId)
+ if (ni.NodeId && IsNodeInteresting(ni.NodeId))
buildmap_osm_text_node_end_and_process("");
if (sscanf(data, "node id=%*[\"']%d%*[\"']", &ni.NodeId) != 1) {
@@ -566,7 +538,8 @@
}
/**
- * @build this is called on every node, but should figure out whether it is interesting
+ * @build this is called on every node, but should figure out whether
+ * it is interesting
*/
static int
buildmap_osm_text_node_interesting_end(char *data)
@@ -627,7 +600,7 @@
* @return error indication
*/
static int
-buildmap_osm_text_node_tag(char *data)
+buildmap_osm_text_node_tag(char *data, int catalog)
{
static char *tagk = 0;
static char *tagv = 0;
@@ -645,19 +618,19 @@
if (ni.NodePostalCode)
free(ni.NodePostalCode);
ni.NodePostalCode = strdup(tagv);
- NodeIsInteresting(ni.NodeId);
+ if (catalog) NodeIsInteresting(ni.NodeId);
} else if (strcmp(tagk, "place") == 0) {
/* <tag k="place" v="town"/> */
if (ni.NodePlace)
free(ni.NodePlace);
ni.NodePlace = strdup(tagv);
- NodeIsInteresting(ni.NodeId);
+ if (catalog) NodeIsInteresting(ni.NodeId);
} else if (strcmp(tagk, "name") == 0) {
/* <tag k="name" v="Herent"/> */
if (ni.NodeTownName)
free(ni.NodeTownName);
ni.NodeTownName = FromXmlAndDup(tagv);
- NodeIsInteresting(ni.NodeId);
+ if (catalog) NodeIsInteresting(ni.NodeId);
}
return 0;
@@ -859,8 +832,8 @@
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[wi.nWayNodes-1]);
+ // from_point = buildmap_osm_text_point_get(WayNodes[0]);
+ // to_point = buildmap_osm_text_point_get(WayNodes[wi.nWayNodes-1]);
/* Street name */
if (wi.WayStreetName)
@@ -995,8 +968,8 @@
* (Note that this simplistic approach may raise eyebrows, but this is
* not a big time consumer !)
*
- * Pass 1 deals with way definitions.
- * Pass 2 deals with node definitions only.
+ * Pass 1 deals with way definitions -- make a list of interesting ways.
+ * Pass 2 catalogs interesting nodes, based on references from ways.
* Pass 3 interprets ways and a few tags.
*
* All underlying processing is passed to other functions.
@@ -1012,6 +985,7 @@
int passid, NumNodes, NumWays;
struct stat st;
int interesting_way;
+ int in_relation;
fstat(fileno(fdata), &st);
@@ -1074,7 +1048,14 @@
p++; /* point to character after '<' now */
for (; *p && isspace(*p); p++) ;
- if (strncasecmp(p, "way", 3) == 0) {
+ in_relation = 0;
+ if (strncasecmp(p, "relation", 8) == 0) {
+ in_relation = 1;
+ } else if (strncasecmp(p, "/relation", 9) == 0) {
+ in_relation = 0;
+ } else if (in_relation) {
+ continue;
+ } else if (strncasecmp(p, "way", 3) == 0) {
wi.WayNotInteresting = 0;
if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) != 1) {
wi.inWay = 0;
@@ -1082,13 +1063,13 @@
NumWays++;
continue;
} else if (strncasecmp(p, "/way", 4) == 0) {
- if (wi.inWay)
- WayIsInteresting(wi.inWay, wi.WayNotInteresting);
+ if (wi.inWay && ! wi.WayNotInteresting)
+ WayIsInteresting(wi.inWay);
buildmap_osm_text_reset_way();
continue;
} else if (strncasecmp(p, "tag", 3) == 0) {
if (! wi.inWay)
- ret += buildmap_osm_text_node_tag(p);
+ ret += buildmap_osm_text_node_tag(p, 1);
else
ret += buildmap_osm_text_way_tag(p);
continue;
@@ -1097,6 +1078,8 @@
buildmap_progress(ftell(fdata), st.st_size);
putchar('\n');
+ qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_ints);
+
(void) time(&t[passid]);
buildmap_info("Pass %d : %d lines read (%d seconds)",
passid, LineNo, t[passid] - t[passid - 1]);
@@ -1126,48 +1109,46 @@
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.
- */
+ if (*p != '<') // continuation line?
continue;
- }
+ in_relation = 0;
p++; /* point to character after '<' now */
for (; *p && isspace(*p); p++) ;
- if (strncasecmp(p, "way", 3) == 0) {
- if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) != 1) {
+ if (strncasecmp(p, "relation", 8) == 0) {
+ in_relation = 1;
+ } else if (strncasecmp(p, "/relation", 9) == 0) {
+ in_relation = 0;
+ } else if (in_relation) {
+ continue;
+ } else if (strncasecmp(p, "way", 3) == 0) {
+ if (sscanf(p, "way id=%*[\"']%d%*[\"']", &wi.inWay) == 1) {
+ interesting_way = IsWayInteresting(wi.inWay);
+ } else {
wi.inWay = 0;
interesting_way = 0;
- } else {
- interesting_way = IsWayInteresting(wi.inWay);
}
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 (wi.inWay && interesting_way)
- buildmap_osm_text_nd_interesting(p);
+ /* nodes referenced by interesting ways are interesting */
+ if (wi.inWay && interesting_way) {
+ int node;
+ if (sscanf(p, "nd ref=%*[\"']%d%*[\"']", &node) == 1) {
+ NodeIsInteresting(node);
+ }
+ }
continue;
}
}
buildmap_progress(ftell(fdata), st.st_size);
putchar('\n');
+ qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_ints);
+
(void) time(&t[passid]);
buildmap_info("Pass %d : %d lines read (%d seconds)",
passid, LineNo, t[passid] - t[passid - 1]);
@@ -1198,52 +1179,44 @@
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.
- */
+ if (*p != '<') // continuation line?
continue;
- }
+ in_relation = 0;
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) {
+ if (strncasecmp(p, "relation", 8) == 0) {
+ in_relation = 1;
+ } else if (strncasecmp(p, "/relation", 9) == 0) {
+ in_relation = 0;
+ } else if (in_relation) {
+ continue;
+ } else if (strncasecmp(p, "node", 4) == 0) {
+ // nodes get added to the buildmap tables here...
ret += buildmap_osm_text_node_interesting(p);
NumNodes++;
continue;
- // ...and here
} else if (strncasecmp(p, "/node", 5) == 0) {
+ // ...and here
ret += buildmap_osm_text_node_interesting_end(p);
continue;
} else if (strncasecmp(p, "tag", 3) == 0) {
if (! wi.inWay)
- ret += buildmap_osm_text_node_tag(p);
+ ret += buildmap_osm_text_node_tag(p, 0);
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) {
+ // ways get added to the buildmap tables (if interesting) here...
ret += buildmap_osm_text_way(p);
continue;
- // ...and here
} else if (strncasecmp(p, "/way", 4) == 0) {
+ // ...and here
ret += buildmap_osm_text_way_end(p);
continue;
- // the nd node references gets put on WayNodes list
} else if (strncasecmp(p, "nd", 2) == 0) {
+ // the nd node references gets put on WayNodes list
ret += buildmap_osm_text_nd(p);
continue;
}
@@ -1266,5 +1239,6 @@
buildmap_info("Final: (%d seconds)",
passid, t[passid] - t[passid - 1]);
+
return ret;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|