summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
Diffstat (limited to 'navit')
-rw-r--r--navit/maptool/boundaries.c5
-rw-r--r--navit/maptool/coastline.c29
-rw-r--r--navit/maptool/itembin.c2
-rw-r--r--navit/maptool/maptool.c62
-rw-r--r--navit/maptool/misc.c10
-rw-r--r--navit/maptool/osm.c18
-rw-r--r--navit/maptool/osm_xml.c9
-rw-r--r--navit/maptool/tempfile.c2
-rw-r--r--navit/maptool/tile.c8
-rw-r--r--navit/maptool/zip.c6
10 files changed, 106 insertions, 45 deletions
diff --git a/navit/maptool/boundaries.c b/navit/maptool/boundaries.c
index 85e484c55..033e81149 100644
--- a/navit/maptool/boundaries.c
+++ b/navit/maptool/boundaries.c
@@ -19,6 +19,9 @@
#include <stdio.h>
#include <string.h>
#include "maptool.h"
+#ifdef _MSC_VER
+#define strcasecmp _stricmp
+#endif
char *
osm_tag_value(struct item_bin *ib, char *key)
@@ -128,6 +131,7 @@ boundary_find_matches(GList *l, struct coord *c)
return ret;
}
+#if 0
static void
test(GList *boundaries_list)
{
@@ -172,6 +176,7 @@ boundary_bbox_compare(gconstpointer a, gconstpointer b)
return -1;
return 0;
}
+#endif
static GList *
process_boundaries_insert(GList *list, struct boundary *boundary)
diff --git a/navit/maptool/coastline.c b/navit/maptool/coastline.c
index 042fb2bfd..9765d2f11 100644
--- a/navit/maptool/coastline.c
+++ b/navit/maptool/coastline.c
@@ -354,7 +354,6 @@ ocean_tile(GHashTable *hash, char *tile, char c, osmid wayid, struct item_bin_si
char *tile2=g_alloca(sizeof(char)*(len+1));
struct rect bbox;
struct item_bin *ib;
- struct coord co;
struct coastline_tile *ct=g_new0(struct coastline_tile, 1);
strcpy(tile2, tile);
@@ -379,10 +378,14 @@ ocean_tile(GHashTable *hash, char *tile, char c, osmid wayid, struct item_bin_si
item_bin_add_attr_string(ib, attr_debug, tile2);
item_bin_write_to_sink(ib, out, NULL);
#endif
- co.x=(bbox.l.x+bbox.h.x)/2;
- co.y=(bbox.l.y+bbox.h.y)/2;
- //item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
-
+#if 0
+ {
+ struct coord co;
+ co.x=(bbox.l.x+bbox.h.x)/2;
+ co.y=(bbox.l.y+bbox.h.y)/2;
+ item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
+ }
+#endif
}
/* ba */
@@ -437,6 +440,7 @@ tile_sibling_edges(GHashTable *hash, char *tile, char c)
return 15;
}
+#if 0
static void
ocean_tile2(struct rect *r, int dx, int dy, int wf, int hf, struct item_bin_sink *out)
{
@@ -445,7 +449,6 @@ ocean_tile2(struct rect *r, int dx, int dy, int wf, int hf, struct item_bin_sink
int h=r->h.y-r->l.y;
char tile2[32];
struct rect bbox;
- struct coord co;
bbox.l.x=r->l.x+dx*w;
bbox.l.y=r->l.y+dy*h;
bbox.h.x=bbox.l.x+w*wf;
@@ -461,10 +464,16 @@ ocean_tile2(struct rect *r, int dx, int dy, int wf, int hf, struct item_bin_sink
item_bin_write_to_sink(ib, out, NULL);
#endif
tile(&bbox, NULL, tile2, 32, 0, NULL);
- co.x=(bbox.l.x+bbox.h.x)/2;
- co.y=(bbox.l.y+bbox.h.y)/2;
- //item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
+#if 0
+ {
+ struct coord co;
+ co.x=(bbox.l.x+bbox.h.x)/2;
+ co.y=(bbox.l.y+bbox.h.y)/2;
+ item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
+ }
+#endif
}
+#endif
static void
tile_collector_add_siblings2(char *tile, struct coastline_tile *ct, struct coastline_tile_data *data)
@@ -473,11 +482,11 @@ tile_collector_add_siblings2(char *tile, struct coastline_tile *ct, struct coast
int pedges=0;
int debug=0;
int len=strlen(tile);
+ struct coastline_tile *cn, *co;
char *tile2=g_alloca(sizeof(char)*(len+1));
char t=tile[len-1];
strcpy(tile2, tile);
tile2[len-1]='\0';
- struct coastline_tile *cn, *co;
#if 0
if (!strncmp(tile,"bcacccaadbdcd",10))
debug=1;
diff --git a/navit/maptool/itembin.c b/navit/maptool/itembin.c
index f2dce72f0..2df467722 100644
--- a/navit/maptool/itembin.c
+++ b/navit/maptool/itembin.c
@@ -19,6 +19,7 @@
#include <string.h>
#include <stdlib.h>
+#include <assert.h>
#include "maptool.h"
#include "linguistics.h"
#include "file.h"
@@ -105,7 +106,6 @@ item_bin_copy_attr(struct item_bin *ib, struct item_bin *from, enum attr_type at
struct attr_bin *ab=item_bin_get_attr_bin(from, attr, NULL);
if (ab)
item_bin_add_attr_data(ib, ab->type, (void *)(ab+1), (ab->len-1)*4);
-#include <assert.h>
assert(attr == attr_osm_wayid);
assert(item_bin_get_wayid(ib) == item_bin_get_wayid(from));
}
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index 10201a2cd..a921b1cfc 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -28,11 +28,15 @@
#include <signal.h>
#include <stdio.h>
#include <math.h>
-#include <getopt.h>
+#ifdef _MSC_VER
+#include "getopt_long.h"
+#define atoll _atoi64
+#else
#include <unistd.h>
+#include <sys/time.h>
+#endif
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <zlib.h>
#include "file.h"
#include "item.h"
@@ -115,14 +119,17 @@ static struct plugins *plugins;
static void add_plugin(char *path)
{
- struct attr **attrs;
+ struct attr pa_attr={attr_path};
+ struct attr pl_attr={attr_plugins};
+ struct attr *attrs[2]={&pa_attr,NULL};
if (! plugins) {
file_init();
plugins=plugins_new();
}
- attrs=(struct attr*[]){&(struct attr){attr_path,{path}},NULL};
- plugin_new(&(struct attr){attr_plugins,.u.plugins=plugins}, attrs);
+ pa_attr.u.str=path;
+ pl_attr.u.plugins=plugins;
+ plugin_new(&pl_attr,attrs);
}
static void
@@ -141,11 +148,11 @@ usage(FILE *f)
fprintf(f,"maptool - parse osm textfile and convert to Navit binfile format\n\n");
fprintf(f,"Usage (for OSM XML data):\n");
fprintf(f,"bzcat planet.osm.bz2 | maptool mymap.bin\n");
- fprintf(f,"Usage (for OSM Protobuf/PBF data):\n");
- fprintf(f,"maptool --protobuf -i planet.osm.pbf planet.bin\n");
+ fprintf(f,"Usage (for OSM Protobuf/PBF data):\n");
+ fprintf(f,"maptool --protobuf -i planet.osm.pbf planet.bin\n");
fprintf(f,"Available switches:\n");
fprintf(f,"-h (--help) : this screen\n");
- fprintf(f,"-5 (--md5) <file> : set file where to write md5 sum\n");
+ fprintf(f,"-5 (--md5) <file> : set file where to write md5 sum\n");
fprintf(f,"-6 (--64bit) : set zip 64 bit compression\n");
fprintf(f,"-a (--attr-debug-level) <level> : control which data is included in the debug attribute\n");
fprintf(f,"-c (--dump-coordinates) : dump coordinates after phase 1\n");
@@ -160,20 +167,20 @@ usage(FILE *f)
fprintf(f,"-N (--nodes-only) : process only nodes\n");
fprintf(f,"-o (--coverage) : map every street to item coverage\n");
fprintf(f,"-P (--protobuf) : input file is protobuf\n");
- fprintf(f,"-r (--rule-file) <file> : read mapping rules from specified file\n");
+ fprintf(f,"-r (--rule-file) <file> : read mapping rules from specified file\n");
fprintf(f,"-s (--start) <phase> : start at specified phase\n");
fprintf(f,"-S (--slice-size) <size> : defines the amount of memory to use, in bytes. Default is 1GB\n");
fprintf(f,"-t (--timestamp) y-m-dTh:m:s : Set zip timestamp\n");
fprintf(f,"-w (--dedupe-ways) : ensure no duplicate ways or nodes. useful when using several input files\n");
fprintf(f,"-W (--ways-only) : process only ways\n");
fprintf(f,"-U (--unknown-country) : add objects with unknown country to index\n");
- fprintf(f,"-z (--compression-level) <level> : set the compression level\n");
- fprintf(f,"Internal options (undocumented):\n");
- fprintf(f,"-b (--binfile)\n");
- fprintf(f,"-B \n");
- fprintf(f,"-m (--map) \n");
- fprintf(f,"-O \n");
- fprintf(f,"-p (--plugin) \n");
+ fprintf(f,"-z (--compression-level) <level> : set the compression level\n");
+ fprintf(f,"Internal options (undocumented):\n");
+ fprintf(f,"-b (--binfile)\n");
+ fprintf(f,"-B \n");
+ fprintf(f,"-m (--map) \n");
+ fprintf(f,"-O \n");
+ fprintf(f,"-p (--plugin) \n");
exit(1);
}
@@ -439,8 +446,14 @@ osm_collect_data(struct maptool_params *p, char *suffix)
l=g_list_next(l);
}
}
- else if (p->protobuf)
+ else if (p->protobuf) {
+#ifdef _MSC_VER
+ fprintf(stderr,"Option -P not yet supported on MSVC\n");
+ exit(1);
+#else
map_collect_data_osm_protobuf(p->input_file,&p->osm);
+#endif
+ }
else if (p->o5m)
map_collect_data_osm_o5m(p->input_file,&p->osm);
else
@@ -772,10 +785,10 @@ int main(int argc, char **argv)
int suffix_count=sizeof(suffixes)/sizeof(char *);
int i;
- main_init(argv[0]);
int suffix_start=0;
- int option_index = 0;
-
+ int option_index=0;
+ main_init(argv[0]);
+
#ifndef HAVE_GLIB
_g_slice_thread_init_nomessage();
#endif
@@ -820,15 +833,20 @@ int main(int argc, char **argv)
p.result=argv[optind];
- // initialize plugins and OSM mappings
+ // initialize plugins and OSM mappings
maptool_init(p.rule_file);
if (p.protobufdb_operation) {
+#ifdef _MSC_VER
+ fprintf(stderr,"Option -O not yet supported on MSVC\n");
+ exit(1);
+#else
osm_protobufdb_load(p.input_file, p.protobufdb);
return 0;
+#endif
}
phase=0;
- // input from an OSM file
+ // input from an OSM file
if (p.input == 0) {
if (start_phase(&p, "collecting data")) {
osm_collect_data(&p, suffix);
diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c
index 5e6c39e74..e9ce88341 100644
--- a/navit/maptool/misc.c
+++ b/navit/maptool/misc.c
@@ -28,8 +28,10 @@
#include <signal.h>
#include <stdio.h>
#include <math.h>
+#ifndef _MSC_VER
#include <getopt.h>
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <zlib.h>
@@ -43,6 +45,8 @@
#include "plugin.h"
#include "maptool.h"
+#define phase1_coord_max 16384
+
struct rect world_bbox = {
{ -20000000, -20000000},
{ 20000000, 20000000},
@@ -131,15 +135,15 @@ phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes)
{
struct map_rect *mr;
struct item *item;
- int count,max=16384;
- struct coord ca[max];
+ int count;
+ struct coord ca[phase1_coord_max];
struct attr attr;
struct item_bin *item_bin;
while (maps) {
mr=map_rect_new(maps->data, NULL);
while ((item = map_rect_get_item(mr))) {
- count=item_coord_get(item, ca, item->type < type_line ? 1: max);
+ count=item_coord_get(item, ca, item->type < type_line ? 1: phase1_coord_max);
item_bin=init_item(item->type);
item_bin_add_coord(item_bin, ca, count);
while (item_attr_get(item, attr_any, &attr)) {
diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c
index 090d209da..523d5bdd0 100644
--- a/navit/maptool/osm.c
+++ b/navit/maptool/osm.c
@@ -16,7 +16,12 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
+#ifdef _MSC_VER
+#define strcasecmp _stricmp
+#define snprintf _snprintf
+#else
#include <unistd.h>
+#endif
#include <string.h>
#include <stdlib.h>
#include <math.h>
@@ -27,6 +32,11 @@
#include "file.h"
#include "profile.h"
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#define M_PI_4 0.785398163397448309616
+#endif
+
extern int doway2poi;
static int in_way, in_node, in_relation;
@@ -1555,7 +1565,8 @@ relation_add_tag(char *k, char *v)
strcpy(iso_code, v);
}
if (add_tag) {
- char tag[strlen(k)+strlen(v)+2];
+ char *tag;
+ tag=g_alloca(strlen(k)+strlen(v)+2);
sprintf(tag,"%s=%s",k,v);
item_bin_add_attr_string(item_bin, attr_osm_tag, tag);
}
@@ -1850,7 +1861,8 @@ void
osm_process_towns(FILE *in, FILE *boundaries, FILE *ways)
{
struct item_bin *ib;
- GList *bl=NULL;
+ GList *bl;
+ GHashTable *town_hash;
struct attr attrs[11];
profile(0,NULL);
@@ -1858,7 +1870,7 @@ osm_process_towns(FILE *in, FILE *boundaries, FILE *ways)
profile(1,"processed boundraries\n");
- GHashTable *town_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ town_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
while ((ib=read_item(in))) {
if (!item_is_district(*ib))
{
diff --git a/navit/maptool/osm_xml.c b/navit/maptool/osm_xml.c
index 1aef43e08..3bc5a70d8 100644
--- a/navit/maptool/osm_xml.c
+++ b/navit/maptool/osm_xml.c
@@ -19,14 +19,19 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
+#ifdef _MSC_VER
+#define atoll _atoi64
+#else
#include <unistd.h>
+#endif
#include "maptool.h"
int
osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size)
{
int len=strlen(attribute);
- char *pos,*i,s,attr[len+2];
+ char *pos,*i,s,*attr;
+ attr=g_alloca(len+2);
strcpy(attr, attribute);
strcpy(attr+len, "=");
pos=strstr(xml, attr);
@@ -186,7 +191,7 @@ int
map_collect_data_osm(FILE *in, struct maptool_osm *osm)
{
int size=BUFFER_SIZE;
- char buffer[size];
+ char buffer[BUFFER_SIZE];
char *p;
sig_alrm(0);
if (!fgets(buffer, size, in) || !xml_declaration_in_line(buffer)){
diff --git a/navit/maptool/tempfile.c b/navit/maptool/tempfile.c
index cf78028cf..41aef0cb5 100644
--- a/navit/maptool/tempfile.c
+++ b/navit/maptool/tempfile.c
@@ -16,7 +16,9 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include "maptool.h"
#include "debug.h"
diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c
index 1817ba6d5..9727bbf97 100644
--- a/navit/maptool/tile.c
+++ b/navit/maptool/tile.c
@@ -28,8 +28,10 @@
#include <signal.h>
#include <stdio.h>
#include <math.h>
+#ifndef _MSC_VER
#include <getopt.h>
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <zlib.h>
@@ -464,9 +466,10 @@ load_tilesdir(FILE *in)
{
char tile[32],subtile[32],c;
int size,zipnum=0;
+ struct tile_head **last;
create_tile_hash();
tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
- struct tile_head **last=&tile_head_root;
+ last=&tile_head_root;
while (fscanf(in,"%[^:]:%d",tile,&size) == 2) {
struct tile_head *th=malloc(sizeof(struct tile_head));
if (!strcmp(tile,"index"))
@@ -655,10 +658,11 @@ index_submap_add(struct tile_info *info, struct tile_head *th)
{
int tlen=tile_len(th->name);
int len=tlen;
- char index_tile[len+1+strlen(info->suffix)];
+ char *index_tile;
struct rect r;
struct item_bin *item_bin;
+ index_tile=g_alloca(len+1+strlen(info->suffix));
strcpy(index_tile, th->name);
if (len > 6)
len=6;
diff --git a/navit/maptool/zip.c b/navit/maptool/zip.c
index 349bc0241..db41e0a20 100644
--- a/navit/maptool/zip.c
+++ b/navit/maptool/zip.c
@@ -149,7 +149,7 @@ write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data,
};
unsigned char salt[8], key[34], verify[2], mac[10];
#endif
- char filename[filelen+1];
+ char *filename;
int crc=0,len,comp_size=data_size;
uLongf destlen=data_size+data_size/500+12;
char *compbuffer;
@@ -214,6 +214,7 @@ write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data,
cd.zipcflg|=1;
}
#endif
+ filename=g_alloca(filelen+1);
strcpy(filename, name);
len=strlen(filename);
while (len < filelen) {
@@ -281,8 +282,9 @@ void
zip_write_index(struct zip_info *info)
{
int size=ftell(info->index);
- char buffer[size];
+ char *buffer;
+ buffer=g_alloca(size);
fseek(info->index, 0, SEEK_SET);
fread(buffer, size, 1, info->index);
write_zipmember(info, "index", strlen("index"), buffer, size);