From cfdba5ab04b36a07a43f86b35155ea3d1ea0fdea Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 10 Nov 2009 21:11:31 +0000 Subject: [PATCH] Fix:maptool:Better specifying of map to use as input git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2738 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/maptool/Makefile.am | 2 +- navit/navit/maptool/maptool.c | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/navit/navit/maptool/Makefile.am b/navit/navit/maptool/Makefile.am index 358e982..71bd0cd 100644 --- a/navit/navit/maptool/Makefile.am +++ b/navit/navit/maptool/Makefile.am @@ -3,6 +3,6 @@ if !SUPPORT_ANDROID bin_PROGRAMS = maptool endif -AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit @ZLIB_CFLAGS@ @POSTGRESQL_CFLAGS@ +AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit @ZLIB_CFLAGS@ @POSTGRESQL_CFLAGS@ -DMODULE=maptool maptool_SOURCES = buffer.c ch.c coastline.c geom.c itembin.c maptool.c misc.c osm.c sourcesink.c tempfile.c tile.c zip.c maptool.h maptool_LDADD = ../libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @POSTGRESQL_LIBS@ @INTLLIBS@ @LIBC_LIBS@ diff --git a/navit/navit/maptool/maptool.c b/navit/navit/maptool/maptool.c index eacd59e..a5fb4a5 100644 --- a/navit/navit/maptool/maptool.c +++ b/navit/navit/maptool/maptool.c @@ -148,13 +148,13 @@ int main(int argc, char **argv) #endif int output=0; int input=0; - int f; - char *result; + int f,pos; + char *result,*optarg_cp,*attr_name,*attr_value; #ifdef HAVE_POSTGRESQL char *dbstr=NULL; #endif FILE* input_file = stdin; - struct attr **attrs; + struct attr *attrs[10]; struct map *map_handle=NULL; #if 0 char *suffixes[]={"m0l0", "m0l1","m0l2","m0l3","m0l4","m0l5","m0l6"}; @@ -242,12 +242,28 @@ int main(int argc, char **argv) usage(stdout); break; case 'm': - attrs=(struct attr*[]){ - &(struct attr){attr_type,{"textfile"}}, - &(struct attr){attr_data,{optarg}}, - NULL}; - add_plugin("$NAVIT_LIBDIR/*/${NAVIT_LIBPREFIX}libmap_textfile.so"); + optarg_cp=g_strdup(optarg); + pos=0; + i=0; + attr_name=g_strdup(optarg); + attr_value=g_strdup(optarg); + while (i < 9 && attr_from_line(optarg_cp, NULL, &pos, attr_value, attr_name)) { + attrs[i]=attr_new_from_text(attr_name,attr_value); + if (attrs[i]) { + i++; + } else { + fprintf(stderr,"Failed to convert %s=%s to attribute\n",attr_name,attr_value); + } + attr_value=g_strdup(optarg); + } + attrs[i++]=NULL; + g_free(attr_value); + g_free(optarg_cp); map_handle=map_new(NULL, attrs); + if (! map_handle) { + fprintf(stderr,"Failed to create map from attributes\n"); + exit(1); + } break; case 'n': fprintf(stderr,"I will IGNORE unknown types\n"); -- 2.7.4