summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-01-02 15:46:16 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-01-02 15:46:16 +0000
commit2fb7cce312659b2674f8369d20d309d1bb10ae68 (patch)
treea416a002637b8ffd83648a57a269fb36e78a96be
parenta0932d4bc9d059e1bfe373efbabbcce0addbbd6e (diff)
downloadnavit-2fb7cce312659b2674f8369d20d309d1bb10ae68.tar.gz
Fix:maptool:Some cleanups
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3845 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r--navit/maptool/Makefile.am2
-rw-r--r--navit/maptool/maptool.c2
-rw-r--r--navit/maptool/maptool.h15
-rw-r--r--navit/maptool/misc.c3
-rw-r--r--navit/maptool/osm.c268
-rw-r--r--navit/maptool/osm_psql.c171
-rw-r--r--navit/maptool/tile.c3
-rwxr-xr-xnavit/script/compare_map26
8 files changed, 259 insertions, 231 deletions
diff --git a/navit/maptool/Makefile.am b/navit/maptool/Makefile.am
index 1aa53e1fd..5ca52e6c9 100644
--- a/navit/maptool/Makefile.am
+++ b/navit/maptool/Makefile.am
@@ -5,6 +5,6 @@ if !SUPPORT_ANDROID
endif
AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit @ZLIB_CFLAGS@ @POSTGRESQL_CFLAGS@ -DMODULE=maptool
-libmaptool_la_SOURCES = boundaries.c buffer.c ch.c coastline.c geom.c itembin.c itembin_buffer.c misc.c osm.c sourcesink.c tempfile.c tile.c zip.c maptool.h
+libmaptool_la_SOURCES = boundaries.c buffer.c ch.c coastline.c geom.c itembin.c itembin_buffer.c misc.c osm.c osm_psql.c sourcesink.c tempfile.c tile.c zip.c maptool.h
maptool_SOURCES = maptool.c
maptool_LDADD = libmaptool.la ../libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @POSTGRESQL_LIBS@ @CRYPTO_LIBS@ @INTLLIBS@ @LIBC_LIBS@
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index e9b2834cc..5c87ffff1 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -333,7 +333,7 @@ int main(int argc, char **argv)
fprintf(stderr,"PROGRESS: Phase 1: collecting data\n");
#ifdef HAVE_POSTGRESQL
if (dbstr)
- map_collect_data_osm_db(dbstr,ways,nodes);
+ map_collect_data_osm_db(dbstr,ways,nodes,turn_restrictions,boundaries);
else
#endif
if (map_handles) {
diff --git a/navit/maptool/maptool.h b/navit/maptool/maptool.h
index bfe1923c2..e35486168 100644
--- a/navit/maptool/maptool.h
+++ b/navit/maptool/maptool.h
@@ -216,19 +216,30 @@ void cat(FILE *in, FILE *out);
/* osm.c */
-
+typedef long int osmid;
+
+void osm_add_tag(char *k, char *v);
+void osm_add_node(osmid id, double lat, double lon);
+void osm_add_way(osmid id);
+void osm_add_relation(osmid id);
+void osm_end_relation(FILE *turn_restrictions, FILE *boundaries);
+void osm_end_way(FILE *out);
+void osm_end_node(FILE *out);
+void osm_add_nd(osmid ref);
long long item_bin_get_id(struct item_bin *ib);
void flush_nodes(int final);
void sort_countries(int keep_tmpfiles);
void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out);
int resolve_ways(FILE *in, FILE *out);
int map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries);
-int map_collect_data_osm_db(char *dbstr, FILE *out_ways, FILE *out_nodes);
int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final);
void write_countrydir(struct zip_info *zip_info);
void remove_countryfiles(void);
void osm_init(void);
+/* osm_psql.c */
+int map_collect_data_osm_db(char *dbstr, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries);
+
/* sourcesink.c */
struct item_bin_sink *item_bin_sink_new(void);
diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c
index 5e5f1e5ef..1d5f70b98 100644
--- a/navit/maptool/misc.c
+++ b/navit/maptool/misc.c
@@ -41,9 +41,6 @@
#include "config.h"
#include "linguistics.h"
#include "plugin.h"
-#ifdef HAVE_POSTGRESQL
-#include <libpq-fe.h>
-#endif
#include "maptool.h"
struct rect world_bbox = {
diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c
index dacb0283d..db8bf2faf 100644
--- a/navit/maptool/osm.c
+++ b/navit/maptool/osm.c
@@ -6,12 +6,6 @@
#include "debug.h"
#include "linguistics.h"
#include "file.h"
-#ifdef HAVE_POSTGRESQL
-#include <libpq-fe.h>
-#endif
-
-
-typedef long int osmid;
static int in_way, in_node, in_relation;
static int nodeid,wayid;
@@ -887,11 +881,15 @@ access_value(char *v)
return 3;
}
-static void
-add_tag(char *k, char *v)
+void
+osm_add_tag(char *k, char *v)
{
int idx,level=2;
char buffer[BUFFER_SIZE*2+2];
+ if (in_relation) {
+ relation_add_tag(k,v);
+ return;
+ }
if (! strcmp(k,"ele"))
level=9;
if (! strcmp(k,"time"))
@@ -1146,10 +1144,7 @@ parse_tag(char *p)
if (!xml_get_attribute(p, "v", v_buffer, BUFFER_SIZE))
return 0;
decode_entities(v_buffer);
- if (in_relation)
- relation_add_tag(k_buffer, v_buffer);
- else
- add_tag(k_buffer, v_buffer);
+ osm_add_tag(k_buffer, v_buffer);
return 1;
}
@@ -1202,9 +1197,10 @@ flush_nodes(int final)
slices++;
}
-static void
-add_node(int id, double lat, double lon)
+void
+osm_add_node(osmid id, double lat, double lon)
{
+ in_node=1;
if (node_buffer.size + sizeof(struct node_item) > node_buffer.malloced)
extend_buffer(&node_buffer);
attr_strings_clear();
@@ -1259,7 +1255,7 @@ parse_node(char *p)
return 0;
if (!xml_get_attribute(p, "lon", lon_buffer, BUFFER_SIZE))
return 0;
- add_node(atoi(id_buffer), atof(lat_buffer), atof(lon_buffer));
+ osm_add_node(atoll(id_buffer), atof(lat_buffer), atof(lon_buffer));
return 1;
}
@@ -1396,10 +1392,12 @@ node_item_get_from_file(FILE *coords, int id, struct node_item *ret)
}
}
-static void
-add_way(int id)
+void
+osm_add_way(osmid id)
{
static int wayid_last;
+
+ in_way=1;
wayid=id;
coord_count=0;
attr_strings_clear();
@@ -1423,20 +1421,7 @@ parse_way(char *p)
char id_buffer[BUFFER_SIZE];
if (!xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
return 0;
- add_way(atoi(id_buffer));
- return 1;
-}
-
-static int
-add_id_attr(char *p, enum attr_type attr_type)
-{
- struct attr idattr = { attr_type };
- char id_buffer[BUFFER_SIZE];
- if (!xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
- return 0;
- current_id=atoll(id_buffer);
- idattr.u.num64=&current_id;
- item_bin_add_attr(item_bin, &idattr);
+ osm_add_way(atoll(id_buffer));
return 1;
}
@@ -1445,24 +1430,36 @@ char iso_code[BUFFER_SIZE];
int admin_level;
int boundary;
-
-static int
-parse_relation(char *p)
+void
+osm_add_relation(osmid id)
{
+ struct attr idattr = { attr_type };
+ current_id=id;
+ in_relation=1;
debug_attr_buffer[0]='\0';
relation_type[0]='\0';
iso_code[0]='\0';
admin_level=-1;
boundary=0;
item_bin_init(item_bin, type_none);
- if (!add_id_attr(p, attr_osm_relationid))
+ idattr.u.num64=&current_id;
+ item_bin_add_attr(item_bin, &idattr);
+}
+
+static int
+parse_relation(char *p)
+{
+ char id_buffer[BUFFER_SIZE];
+ if (!xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
return 0;
+ osm_add_relation(atoll(id_buffer));
return 1;
}
-static void
-end_relation(FILE *turn_restrictions, FILE *boundaries)
+void
+osm_end_relation(FILE *turn_restrictions, FILE *boundaries)
{
+ in_relation=0;
if ((!strcmp(relation_type, "multipolygon") || !strcmp(relation_type, "boundary")) && boundary) {
#if 0
if (admin_level == 2) {
@@ -1583,14 +1580,16 @@ attr_longest_match(struct attr_mapping **mapping, int mapping_count, enum item_t
return ret;
}
-static void
-end_way(FILE *out)
+void
+osm_end_way(FILE *out)
{
int i,count;
int *def_flags,add_flags;
enum item_type types[10];
struct item_bin *item_bin;
+ in_way=0;
+
if (! out)
return;
if (dedupe_ways_hash) {
@@ -1634,14 +1633,15 @@ end_way(FILE *out)
}
}
-static void
-end_node(FILE *out)
+void
+osm_end_node(FILE *out)
{
int conflict,count,i;
char *postal;
enum item_type types[10];
struct country_table *result=NULL, *lookup;
struct item_bin *item_bin;
+ in_node=0;
if (!out || ! node_is_tagged || ! nodeid)
return;
@@ -2073,8 +2073,8 @@ resolve_ways(FILE *in, FILE *out)
return 0;
}
-static void
-add_nd(char *p, osmid ref)
+void
+osm_add_nd(osmid ref)
{
SET_REF(coord_buffer[coord_count], ref);
node_ref_way(ref);
@@ -2091,7 +2091,7 @@ parse_nd(char *p)
char ref_buffer[BUFFER_SIZE];
if (!xml_get_attribute(p, "ref", ref_buffer, BUFFER_SIZE))
return 0;
- add_nd(p, atoi(ref_buffer));
+ osm_add_nd(atoll(ref_buffer));
return 1;
}
@@ -2114,13 +2114,11 @@ map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_r
} else if (!strncmp(p, "<node ",6)) {
if (!parse_node(p))
fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- in_node=1;
processed_nodes++;
} else if (!strncmp(p, "<tag ",5)) {
if (!parse_tag(p))
fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
} else if (!strncmp(p, "<way ",5)) {
- in_way=1;
if (!parse_way(p))
fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
processed_ways++;
@@ -2128,7 +2126,6 @@ map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_r
if (!parse_nd(p))
fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
} else if (!strncmp(p, "<relation ",10)) {
- in_relation=1;
if (!parse_relation(p))
fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
processed_relations++;
@@ -2136,14 +2133,11 @@ map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_r
if (!parse_member(p))
fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
} else if (!strncmp(p, "</node>",7)) {
- in_node=0;
- end_node(out_nodes);
+ osm_end_node(out_nodes);
} else if (!strncmp(p, "</way>",6)) {
- in_way=0;
- end_way(out_ways);
+ osm_end_way(out_ways);
} else if (!strncmp(p, "</relation>",11)) {
- in_relation=0;
- end_relation(out_turn_restrictions, out_boundaries);
+ osm_end_relation(out_turn_restrictions, out_boundaries);
} else if (!strncmp(p, "</osm>",6)) {
} else {
fprintf(stderr,"WARNING: unknown tag in %s\n", buffer);
@@ -2154,174 +2148,6 @@ map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_r
return 1;
}
-#ifdef HAVE_POSTGRESQL
-int
-map_collect_data_osm_db(char *dbstr, FILE *out_ways, FILE *out_nodes)
-{
- PGconn *conn;
- PGresult *res,*node,*way,*tag;
- int count,tagged,i,j,k;
- long min, max, id, tag_id, node_id;
- char query[256];
-
- sig_alrm(0);
- conn=PQconnectdb(dbstr);
- if (! conn) {
- fprintf(stderr,"Failed to connect to database with '%s'\n",dbstr);
- exit(1);
- }
- res=PQexec(conn, "begin");
- if (! res) {
- fprintf(stderr, "Cannot begin transaction: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "set transaction isolation level serializable");
- if (! res) {
- fprintf(stderr, "Cannot set isolation level: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "declare node cursor for select id,x(coordinate),y(coordinate) from node order by id");
- if (! res) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "declare way cursor for select id from way order by id");
- if (! res) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "declare relation cursor for select id from relation order by id");
- if (! res) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- for (;;) {
- node=PQexec(conn, "fetch 100000 from node");
- if (! node) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(node);
- exit(1);
- }
- count=PQntuples(node);
- if (! count)
- break;
- min=atol(PQgetvalue(node, 0, 0));
- max=atol(PQgetvalue(node, count-1, 0));
- sprintf(query,"select node_id,name,value from node_tag where node_id >= %ld and node_id <= %ld order by node_id", min, max);
- tag=PQexec(conn, query);
- if (! tag) {
- fprintf(stderr, "Cannot query node_tag: %s\n", PQerrorMessage(conn));
- exit(1);
- }
- j=0;
- for (i = 0 ; i < count ; i++) {
- id=atol(PQgetvalue(node, i, 0));
- add_node(id, atof(PQgetvalue(node, i, 1)), atof(PQgetvalue(node, i, 2)));
- tagged=0;
- in_node=1;
- processed_nodes++;
- while (j < PQntuples(tag)) {
- tag_id=atol(PQgetvalue(tag, j, 0));
- if (tag_id == id) {
- add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
- tagged=1;
- j++;
- }
- if (tag_id < id)
- j++;
- if (tag_id > id)
- break;
- }
- if (tagged)
- end_node(out_nodes);
- in_node=0;
- }
- PQclear(tag);
- PQclear(node);
- }
- for (;;) {
- way=PQexec(conn, "fetch 100000 from way");
- if (! way) {
- fprintf(stderr, "Cannot setup cursor for ways: %s\n", PQerrorMessage(conn));
- PQclear(node);
- exit(1);
- }
- count=PQntuples(way);
- if (! count)
- break;
- min=atol(PQgetvalue(way, 0, 0));
- max=atol(PQgetvalue(way, count-1, 0));
- sprintf(query,"select way_id,node_id from way_node where way_id >= %ld and way_id <= %ld order by way_id,sequence_id", min, max);
- node=PQexec(conn, query);
- if (! node) {
- fprintf(stderr, "Cannot query way_node: %s\n", PQerrorMessage(conn));
- exit(1);
- }
- sprintf(query,"select way_id,name,value from way_tag where way_id >= %ld and way_id <= %ld order by way_id", min, max);
- tag=PQexec(conn, query);
- if (! tag) {
- fprintf(stderr, "Cannot query way_tag: %s\n", PQerrorMessage(conn));
- exit(1);
- }
- j=0;
- k=0;
- for (i = 0 ; i < count ; i++) {
- id=atol(PQgetvalue(way, i, 0));
- add_way(id);
- tagged=0;
- in_way=1;
- processed_ways++;
- while (k < PQntuples(node)) {
- node_id=atol(PQgetvalue(node, k, 0));
- if (node_id == id) {
- add_nd("",atol(PQgetvalue(node, k, 1)));
- tagged=1;
- k++;
- }
- if (node_id < id)
- k++;
- if (node_id > id)
- break;
- }
- while (j < PQntuples(tag)) {
- tag_id=atol(PQgetvalue(tag, j, 0));
- if (tag_id == id) {
- add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
- tagged=1;
- j++;
- }
- if (tag_id < id)
- j++;
- if (tag_id > id)
- break;
- }
- if (tagged)
- end_way(out_ways);
- in_way=0;
- }
- PQclear(tag);
- PQclear(node);
- PQclear(way);
- }
-
- res=PQexec(conn, "commit");
- if (! res) {
- fprintf(stderr, "Cannot commit transaction: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- sig_alrm(0);
- sig_alrm_end();
- return 1;
-}
-#endif
-
-
static void
write_item_part(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, int first, int last, long long *last_id)
{
diff --git a/navit/maptool/osm_psql.c b/navit/maptool/osm_psql.c
new file mode 100644
index 000000000..f21d04ad2
--- /dev/null
+++ b/navit/maptool/osm_psql.c
@@ -0,0 +1,171 @@
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#include <unistd.h>
+#include "maptool.h"
+#include "debug.h"
+#include "linguistics.h"
+#include "file.h"
+#ifdef HAVE_POSTGRESQL
+#include <libpq-fe.h>
+
+int
+map_collect_data_osm_db(char *dbstr, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries)
+{
+ PGconn *conn;
+ PGresult *res,*node,*way,*tag;
+ int count,tagged,i,j,k;
+ long min, max, id, tag_id, node_id;
+ char query[256];
+
+ sig_alrm(0);
+ conn=PQconnectdb(dbstr);
+ if (! conn) {
+ fprintf(stderr,"Failed to connect to database with '%s'\n",dbstr);
+ exit(1);
+ }
+ res=PQexec(conn, "begin");
+ if (! res) {
+ fprintf(stderr, "Cannot begin transaction: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "set transaction isolation level serializable");
+ if (! res) {
+ fprintf(stderr, "Cannot set isolation level: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "declare node cursor for select id,x(coordinate),y(coordinate) from node order by id");
+ if (! res) {
+ fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "declare way cursor for select id from way order by id");
+ if (! res) {
+ fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "declare relation cursor for select id from relation order by id");
+ if (! res) {
+ fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ for (;;) {
+ node=PQexec(conn, "fetch 100000 from node");
+ if (! node) {
+ fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
+ PQclear(node);
+ exit(1);
+ }
+ count=PQntuples(node);
+ if (! count)
+ break;
+ min=atol(PQgetvalue(node, 0, 0));
+ max=atol(PQgetvalue(node, count-1, 0));
+ sprintf(query,"select node_id,name,value from node_tag where node_id >= %ld and node_id <= %ld order by node_id", min, max);
+ tag=PQexec(conn, query);
+ if (! tag) {
+ fprintf(stderr, "Cannot query node_tag: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ j=0;
+ for (i = 0 ; i < count ; i++) {
+ id=atol(PQgetvalue(node, i, 0));
+ osm_add_node(id, atof(PQgetvalue(node, i, 1)), atof(PQgetvalue(node, i, 2)));
+ tagged=0;
+ processed_nodes++;
+ while (j < PQntuples(tag)) {
+ tag_id=atol(PQgetvalue(tag, j, 0));
+ if (tag_id == id) {
+ osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
+ tagged=1;
+ j++;
+ }
+ if (tag_id < id)
+ j++;
+ if (tag_id > id)
+ break;
+ }
+ osm_end_node(out_nodes);
+ }
+ PQclear(tag);
+ PQclear(node);
+ }
+ for (;;) {
+ way=PQexec(conn, "fetch 100000 from way");
+ if (! way) {
+ fprintf(stderr, "Cannot setup cursor for ways: %s\n", PQerrorMessage(conn));
+ PQclear(node);
+ exit(1);
+ }
+ count=PQntuples(way);
+ if (! count)
+ break;
+ min=atol(PQgetvalue(way, 0, 0));
+ max=atol(PQgetvalue(way, count-1, 0));
+ sprintf(query,"select way_id,node_id from way_node where way_id >= %ld and way_id <= %ld order by way_id,sequence_id", min, max);
+ node=PQexec(conn, query);
+ if (! node) {
+ fprintf(stderr, "Cannot query way_node: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ sprintf(query,"select way_id,name,value from way_tag where way_id >= %ld and way_id <= %ld order by way_id", min, max);
+ tag=PQexec(conn, query);
+ if (! tag) {
+ fprintf(stderr, "Cannot query way_tag: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ j=0;
+ k=0;
+ for (i = 0 ; i < count ; i++) {
+ id=atol(PQgetvalue(way, i, 0));
+ osm_add_way(id);
+ tagged=0;
+ processed_ways++;
+ while (k < PQntuples(node)) {
+ node_id=atol(PQgetvalue(node, k, 0));
+ if (node_id == id) {
+ osm_add_nd(atoll(PQgetvalue(node, k, 1)));
+ tagged=1;
+ k++;
+ }
+ if (node_id < id)
+ k++;
+ if (node_id > id)
+ break;
+ }
+ while (j < PQntuples(tag)) {
+ tag_id=atol(PQgetvalue(tag, j, 0));
+ if (tag_id == id) {
+ osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
+ tagged=1;
+ j++;
+ }
+ if (tag_id < id)
+ j++;
+ if (tag_id > id)
+ break;
+ }
+ if (tagged)
+ osm_end_way(out_ways);
+ }
+ PQclear(tag);
+ PQclear(node);
+ PQclear(way);
+ }
+
+ res=PQexec(conn, "commit");
+ if (! res) {
+ fprintf(stderr, "Cannot commit transaction: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ sig_alrm(0);
+ sig_alrm_end();
+ return 1;
+}
+#endif
diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c
index 203f228c7..d33d1c67e 100644
--- a/navit/maptool/tile.c
+++ b/navit/maptool/tile.c
@@ -41,9 +41,6 @@
#include "config.h"
#include "linguistics.h"
#include "plugin.h"
-#ifdef HAVE_POSTGRESQL
-#include <libpq-fe.h>
-#endif
#include "maptool.h"
diff --git a/navit/script/compare_map b/navit/script/compare_map
new file mode 100755
index 000000000..f16e3c5e8
--- /dev/null
+++ b/navit/script/compare_map
@@ -0,0 +1,26 @@
+#! /bin/sh
+maptool=$0
+maptool=${maptool%/*}
+maptool=$maptool/../maptool/maptool
+dir=compare.$$
+mkdir $dir
+file1=$1
+file2=$2
+unzip -vl $file1 | sed "s/[0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]//" | egrep -v '^Archive| files$' >$dir/dir1.txt
+unzip -vl $file2 | sed "s/[0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]//" | egrep -v '^Archive| files$' >$dir/dir2.txt
+diff $dir/dir1.txt $dir/dir2.txt | egrep "^<|^>" |
+while read line
+do
+ echo $line
+ case $line in
+ \>*)
+ name=${line##*\ }
+ echo $name
+ unzip -p $file1 $name >$dir/ways_split_.tmp
+ ( cd $dir && ../$maptool -D -s3 >data1.txt) 2>/dev/null
+ unzip -p $file2 $name >$dir/ways_split_.tmp
+ ( cd $dir && ../$maptool -D -s3 >data2.txt) 2>/dev/null
+ diff $dir/data1.txt $dir/data2.txt
+ ;;
+ esac
+done