"n railway=level_crossing poi_level_crossing\n"
"n railway=station poi_rail_station\n"
"n railway=tram_stop poi_rail_tram_stop\n"
+ "n amenity=park_bench poi_bench\n"
+ "n amenity=bench poi_bench\n"
+ "n amenity=biergarten poi_biergarten\n"
+ "n historic=boundary_stone poi_boundary_stone\n"
+ "n historic=castle poi_castle\n"
+ "n historic=ruins poi_ruins\n"
+ "n Annehmlichkeit=Hochsitz poi_hunting_stand\n"
+ "n amenity=hunting_stand poi_hunting_stand\n"
+ "n historic=memorial poi_memorial\n"
+ "n historic=monument poi_monument\n"
+ "n amenity=shelter poi_shelter\n"
+ "n amenity=fountain poi_fountain\n"
+ "n amenity=drinking_water poi_potable_water\n"
+ "n amenity=toilets poi_toilets\n"
+ "n tourism=viewpoint poi_viewpoint\n"
"w *=* street_unkn\n"
+ "w contour_ext=elevation_major height_line_1\n"
+ "w contour_ext=elevation_medium height_line_2\n"
+ "w contour_ext=elevation_minor height_line_3\n"
"w amenity=place_of_worship poly_building\n"
"w building=* poly_building\n"
"w aeroway=aerodrome poly_airport\n"
"w aeroway=taxiway aeroway_taxiway\n"
"w aeroway=terminal poly_terminal\n"
"w highway=bridleway bridleway\n"
+ "w highway=path,horse=designated bridleway\n"
"w highway=cycleway cycleway\n"
"w highway=cyclepath cycleway\n"
+ "w highway=path,bicycle=designated cycleway\n"
"w highway=footway footway\n"
- "w highway=steps steps\n"
+ "w piste:type=nordic piste_nordic\n"
+ "w highway=footway,piste:type=nordic footway_and_piste_nordic\n"
+ "w route=ski piste_nordic\n"
+ "w piste:type=downhill,piste:difficulty=novice piste_downhill_novice\n"
+ "w piste:type=downhill,piste:difficulty=easy piste_downhill_easy\n"
+ "w piste:type=downhill,piste:difficulty=intermediate piste_downhill_intermediate\n"
+ "w piste:type=downhill,piste:difficulty=advanced piste_downhill_advanced\n"
+ "w piste:type=downhill,piste:difficulty=expert piste_downhill_expert\n"
+ "w piste:type=downhill,piste:difficulty=freeride piste_downhill_freeride\n"
+ "w highway=path,foot=designated footway\n"
+ "w highway=steps steps\n"
+ "w highway=path path\n"
+ "w highway=path,sac_scale=hiking hiking\n"
+ "w highway=path,sac_scale=mountain_hiking hiking_mountain\n"
+ "w highway=path,sac_scale=demanding_mountain_hiking hiking_mountain_demanding\n"
+ "w highway=path,sac_scale=alpine_hiking hiking_alpine\n"
+ "w highway=path,sac_scale=demanding_alpine_hiking hiking_alpine_demanding\n"
+ "w highway=path,sac_scale=difficult_alpine_hiking hiking_alpine_difficult\n"
"w highway=unsurfaced track_gravelled\n"
"w highway=track track_gravelled\n"
"w highway=track,tracktype=grade1 track_paved\n"
"w highway=track,surface=ground track_ground\n"
"w highway=track,tracktype=grade5 track_grass\n"
"w highway=track,surface=grass track_grass\n"
+ "w highway=parking_lane street_parking_lane\n"
+ "w highway=service,service=parking_aisle street_parking_lane\n"
"w highway=service street_service\n"
+ "w highway=service,area=1 poly_service\n"
"w highway=construction street_construction\n"
"w highway=pedestrian street_pedestrian\n"
"w highway=pedestrian,area=1 poly_pedestrian\n"
"w highway=plaza poly_plaza\n"
"w landuse=plaza poly_plaza\n"
"w highway=residential street_1_city\n"
+ "w highway=residential,area=1 poly_street_1\n"
"w highway=living_street living_street\n"
"w highway=unclassified street_1_city\n"
+ "w highway=unclassified,area=1 poly_street_1\n"
"w highway=road street_1_city\n"
"w highway=minor street_1_land\n"
"w highway=tertiary street_2_city\n"
+ "w highway=tertiary,area=1 poly_street_2\n"
"w highway=tertiary_link ramp\n"
"w highway=secondary street_3_city\n"
+ "w highway=secondary,area=1 poly_street_3\n"
"w highway=secondary_link ramp\n"
"w highway=primary street_4_city\n"
"w highway=primary_link ramp\n"
int count;
struct rect r;
} country_table[] = {
- { 40,"Austria,Österreich,AUT"},
+ { 40,"Austria,�sterreich,AUT"},
{124,"Canada"},
+ {208,"Denmark,Danmark,DK"},
+ {246,"Finland,Suomi"},
+ {250,"France,R�publique fran�aise,FR"},
{276,"Germany,Deutschland,Bundesrepublik Deutschland"},
+ {380,"Italy,Italia"},
{528,"Nederland,The Netherlands,Niederlande,NL"},
- {756,"Schweiz"},
- {840,"USA"}
+ {578,"Norway,Norge,Noreg,NO"},
+ {724,"Spain,Espana,Espana,Reino de Espana"},
+ {752,"Sweden,Sverige,Konungariket Sverige,SE"},
+ {756,"Schweiz"},
+ {826,"United Kingdom,UK"},
+ {840,"USA"}
};
static GHashTable *country_table_hash;
}
static void
+item_buffer_set_type(char *buffer, enum item_type type)
+{
+ struct item_bin *ib=(struct item_bin *) buffer;
+ ib->clen=0;
+ ib->len=2;
+ ib->type=type;
+}
+
+static void
+item_buffer_add_coord(char *buffer, struct coord *c, int count)
+{
+ struct item_bin *ib=(struct item_bin *) buffer;
+ struct coord *c2=(struct coord *)(ib+1);
+ c2+=ib->clen/2;
+ memcpy(c2, c, count*sizeof(struct coord));
+ ib->clen+=count*2;
+ ib->len+=count*2;
+}
+
+static void
+item_buffer_add_attr(char *buffer, struct attr *attr)
+{
+ struct item_bin *ib=(struct item_bin *) buffer;
+ struct attr_bin *ab=(struct attr_bin *)((int *)ib+ib->len+1);
+ if (attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end) {
+ ab->type=attr->type;
+ strcpy((char *)(ab+1),attr->u.str);
+ pad_text_attr(ab, (char *)(ab+1));
+ ib->len+=ab->len+1;
+ }
+}
+
+static void
+item_buffer_write(char *buffer, FILE *out)
+{
+ struct item_bin *ib=(struct item_bin *) buffer;
+ fwrite(buffer, (ib->len+1)*4, 1, out);
+}
+
+static void
write_attr(FILE *out, struct attr_bin *attr, void *buffer)
{
if (attr->len) {
}
#endif
-static char buffer[150000];
+static char buffer[200000];
+
+static void
+phase1_map(struct map *map, FILE *out_ways, FILE *out_nodes)
+{
+ struct map_rect *mr=map_rect_new(map, NULL);
+ struct item *item;
+ int count,max=16384;
+ struct coord ca[max];
+ struct item_bin ib;
+ struct attr attr;
+ FILE *file;
+
+ while ((item = map_rect_get_item(mr))) {
+ count=item_coord_get(item, ca, item->type < type_line ? 1: max);
+ item_buffer_set_type(buffer, item->type);
+ item_buffer_add_coord(buffer, ca, count);
+ while (item_attr_get(item, attr_any, &attr)) {
+ item_buffer_add_attr(buffer, &attr);
+ }
+ if (item->type >= type_line)
+ item_buffer_write(buffer, out_ways);
+ else
+ item_buffer_write(buffer, out_nodes);
+ }
+ map_rect_destroy(mr);
+}
+
int bytes_read=0;
if (r != 1)
return NULL;
bytes_read+=r;
- assert((ib->len+1) < sizeof(buffer));
+ assert((ib->len+1)*4 < sizeof(buffer));
s=(ib->len+1)*4-sizeof(*ib);
r=fread(ib+1, s, 1, in);
if (r != 1)
}
}
-
static void
write_item_part(FILE *out, struct item_bin *orig, int first, int last)
{
struct index_item {
struct item_bin item;
struct rect r;
- struct attr_bin attr_order_limit;
+ struct attr_bin attr_order;
short min;
short max;
struct attr_bin attr_zipfile_ref;
ii.item.type=type_submap;
ii.item.clen=4;
- ii.attr_order_limit.len=2;
- ii.attr_order_limit.type=attr_order_limit;
+ ii.attr_order.len=2;
+ ii.attr_order.type=attr_order;
ii.attr_zipfile_ref.len=2;
ii.attr_zipfile_ref.type=attr_zipfile_ref;
}
+static void
+dump_coord(struct coord *c)
+{
+ printf("0x%x 0x%x",c->x, c->y);
+}
+
+static void
+dump(FILE *in)
+{
+ struct item_bin *ib;
+ struct coord *c;
+ struct attr_bin *a;
+ struct attr attr;
+ int *attr_start;
+ int *attr_end;
+ int i;
+ char *str;
+ while ((ib=read_item(in))) {
+ c=(struct coord *)(ib+1);
+ if (ib->type < type_line) {
+ dump_coord(c);
+ printf(" ");
+ }
+ attr_start=(int *)(ib+1)+ib->clen;
+ attr_end=(int *)ib+ib->len+1;
+ printf("type=%s", item_to_name(ib->type));
+ while (attr_start < attr_end) {
+ a=(struct attr_bin *)(attr_start);
+ attr_start+=a->len+1;
+ attr.type=a->type;
+ attr_data_set(&attr, (a+1));
+ str=attr_to_text(&attr, NULL, 1);
+ printf(" %s=\"%s\"", attr_to_name(a->type), str);
+ g_free(str);
+ }
+ printf(" debug=\"length=%d\"", ib->len);
+ printf("\n");
+ if (ib->type >= type_line) {
+ for (i = 0 ; i < ib->clen/2 ; i++) {
+ dump_coord(c+i);
+ printf("\n");
+ }
+
+ }
+ }
+}
+
static int
phase3(FILE *ways_in, FILE *nodes_in, FILE *tilesdir_out)
{
crc=crc32(0, NULL, 0);
crc=crc32(crc, (unsigned char *)data, data_size);
+#ifdef HAVE_ZLIB
if (compression_level) {
error=compress2_int((Byte *)compbuffer, &destlen, (Bytef *)data, data_size, compression_level);
if (error == Z_OK) {
fprintf(stderr,"compress2 returned %d\n", error);
}
}
+#endif
lfh.zipcrc=crc;
lfh.zipsize=comp_size;
lfh.zipuncmp=data_size;
static void
usage(FILE *f)
{
+ /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */
fprintf(f,"\n");
fprintf(f,"osm2navit - parse osm textfile and converts to NavIt binfile format\n\n");
fprintf(f,"Usage :\n");
exit(1);
}
+static void
+process_binfile(FILE *in, FILE *out)
+{
+ struct item_bin *ib;
+ while ((ib=read_item(in))) {
+ fwrite(ib, (ib->len+1)*4, 1, out);
+ }
+}
+
int main(int argc, char **argv)
{
FILE *ways=NULL,*ways_split=NULL,*nodes=NULL,*tilesdir,*zipdir,*res;
char *map=g_strdup(attrmap);
- int c,start=1,end=4,dump_coordinates=0;
+ int i,c,start=1,end=4,dump_coordinates=0;
int keep_tmpfiles=0;
int process_nodes=1, process_ways=1;
+#ifdef HAVE_ZLIB
int compression_level=9;
+#else
+ int compression_level=0;
+#endif
+ int output=0;
+ int input=0;
char *result,*dbstr=NULL;
FILE* input_file = stdin;
-
+ struct plugins *plugins=NULL;
+ struct attr **attrs;
+ struct map *map_handle=NULL;
while (1) {
#if 0
int option_index = 0;
static struct option long_options[] = {
{"attr-debug-level", 1, 0, 'a'},
+ {"binfile", 0, 0, 'b'},
{"compression-level", 1, 0, 'z'},
{"coverage", 0, 0, 'o'},
#ifdef HAVE_POSTGRESQL
{"db", 1, 0, 'd'},
#endif
{"dedupe-ways", 0, 0, 'w'},
+ {"dump", 0, 0, 'D'},
+ {"dump-coordinates", 0, 0, 'c'},
{"end", 1, 0, 'e'},
{"help", 0, 0, 'h'},
{"keep-tmpfiles", 0, 0, 'k'},
{"nodes-only", 0, 0, 'N'},
+ {"map", 1, 0, 'm'},
+ {"plugin", 1, 0, 'p'},
{"start", 1, 0, 's'},
{"input-file", 1, 0, 'i'},
{"ignore-unknown", 0, 0, 'n'},
{"ways-only", 0, 0, 'W'},
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv, "Nni:Wa:c"
+ c = getopt_long (argc, argv, "DNWa:bc"
#ifdef HAVE_POSTGRESQL
"d:"
#endif
- "e:hks:w", long_options, &option_index);
+ "e:hi:knm:p:s:w", long_options, &option_index);
if (c == -1)
break;
switch (c) {
+ case 'D':
+ output=1;
+ break;
case 'N':
process_ways=0;
break;
case 'a':
attr_debug_level=atoi(optarg);
break;
+ case 'b':
+ input=1;
+ break;
case 'c':
dump_coordinates=1;
break;
case 'h':
usage(stdout);
break;
+ case 'm':
+ attrs=(struct attr*[]){
+ &(struct attr){attr_type,{"textfile"}},
+ &(struct attr){attr_data,{"bookmark.txt"}},
+ NULL};
+ map_handle=map_new(attrs);
+ fprintf(stderr,"optarg=%s\n", optarg);
+ break;
case 'n':
fprintf(stderr,"I will IGNORE unknown types\n");
ignore_unkown=1;
case 'o':
coverage=1;
break;
+ case 'p':
+ if (! plugins)
+ plugins=plugins_new();
+ fprintf(stderr,"optarg=%s\n",optarg);
+ attrs=(struct attr*[]){&(struct attr){attr_path,{optarg}},NULL};
+ plugins_add_path(plugins, attrs);
+ break;
case 's':
start=atoi(optarg);
break;
exit( -1 );
}
break;
+#ifdef HAVE_ZLIB
case 'z':
compression_level=atoi(optarg);
break;
+#endif
case '?':
usage(stderr);
break;
}
}
- if (optind != argc-1)
+ if (optind != argc-(output == 1 ? 0:1))
usage(stderr);
+ if (plugins)
+ plugins_init(plugins);
result=argv[optind];
build_attrmap(map);
#ifdef GENERATE_INDEX
#endif
+ if (input == 0) {
if (start == 1) {
if (process_ways)
ways=fopen("ways.tmp","wb+");
phase1_db(dbstr,ways,nodes);
else
#endif
+ if (map_handle) {
+ phase1_map(map_handle,ways,nodes);
+ map_destroy(map_handle);
+ }
+ else
phase1(input_file,ways,nodes);
if (ways)
fclose(ways);
node_buffer.size=0;
if (end == 2)
exit(0);
+ } else {
+ ways_split=fopen("ways_split.tmp","wb+");
+ process_binfile(stdin, ways_split);
+ fclose(ways_split);
+ }
+ if (output == 1) {
+ fprintf(stderr,"PROGRESS: Phase 3: dumping\n");
+ if (process_nodes) {
+ nodes=fopen("nodes.tmp","rb");
+ if (nodes) {
+ dump(nodes);
+ fclose(nodes);
+ }
+ }
+ if (process_ways) {
+ ways_split=fopen("ways_split.tmp","rb");
+ if (ways_split) {
+ dump(ways_split);
+ fclose(ways_split);
+ }
+ }
+ exit(0);
+ }
if (start <= 3) {
phase=3;
fprintf(stderr,"PROGRESS: Phase 3: generating tiles\n");