Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/src/filedumper.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1599 - (show annotations) (download) (as text)
Tue Sep 30 18:31:51 2014 UTC (10 years, 5 months ago) by amb
File MIME type: text/x-csrc
File size: 46737 byte(s)
Use exit() when exiting the program other than at the end of the main function.

1 /***************************************
2 Memory file dumper.
3
4 Part of the Routino routing software.
5 ******************/ /******************
6 This file Copyright 2008-2014 Andrew M. Bishop
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
17
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ***************************************/
21
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <sys/stat.h>
27 #include <sys/time.h>
28 #include <time.h>
29 #include <math.h>
30
31 #include "types.h"
32 #include "nodes.h"
33 #include "segments.h"
34 #include "ways.h"
35 #include "relations.h"
36 #include "errorlog.h"
37
38 #include "files.h"
39 #include "visualiser.h"
40 #include "xmlparse.h"
41
42
43 /* Local functions */
44
45 static void print_node(Nodes *nodes,index_t item);
46 static void print_segment(Segments *segments,index_t item);
47 static void print_way(Ways *ways,index_t item);
48 static void print_turn_relation(Relations *relations,index_t item,Segments *segments,Nodes *nodes);
49 static void print_errorlog(ErrorLogs *errorlogs,index_t item);
50
51 static void print_head_osm(int coordcount,double latmin,double latmax,double lonmin,double lonmax);
52 static void print_region_osm(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,
53 double latmin,double latmax,double lonmin,double lonmax,int option_no_super);
54 static void print_node_osm(Nodes *nodes,index_t item);
55 static void print_segment_osm(Segments *segments,index_t item,Ways *ways);
56 static void print_turn_relation_osm(Relations *relations,index_t item,Segments *segments,Nodes *nodes);
57 static void print_tail_osm(void);
58
59 static void print_node_visualiser(Nodes *nodes,index_t item);
60 static void print_segment_visualiser(Segments *segments,index_t item,Ways *ways);
61 static void print_turn_relation_visualiser(Relations *relations,index_t item,Segments *segments,Nodes *nodes);
62 static void print_errorlog_visualiser(ErrorLogs *errorlogs,index_t item);
63
64 static char *RFC822Date(time_t t);
65
66 static void print_usage(int detail,const char *argerr,const char *err);
67
68
69 /*++++++++++++++++++++++++++++++++++++++
70 The main program for the file dumper.
71 ++++++++++++++++++++++++++++++++++++++*/
72
73 int main(int argc,char** argv)
74 {
75 Nodes *OSMNodes;
76 Segments *OSMSegments;
77 Ways *OSMWays;
78 Relations*OSMRelations;
79 ErrorLogs*OSMErrorLogs=NULL;
80 int arg;
81 char *dirname=NULL,*prefix=NULL;
82 char *nodes_filename,*segments_filename,*ways_filename,*relations_filename,*errorlogs_filename;
83 int option_statistics=0;
84 int option_visualiser=0,coordcount=0;
85 double latmin=0,latmax=0,lonmin=0,lonmax=0;
86 char *option_data=NULL;
87 int option_dump=0;
88 int option_dump_osm=0,option_no_super=0;
89 int option_dump_visualiser=0;
90
91 /* Parse the command line arguments */
92
93 for(arg=1;arg<argc;arg++)
94 {
95 if(!strcmp(argv[arg],"--help"))
96 print_usage(1,NULL,NULL);
97 else if(!strncmp(argv[arg],"--dir=",6))
98 dirname=&argv[arg][6];
99 else if(!strncmp(argv[arg],"--prefix=",9))
100 prefix=&argv[arg][9];
101 else if(!strcmp(argv[arg],"--statistics"))
102 option_statistics=1;
103 else if(!strcmp(argv[arg],"--visualiser"))
104 option_visualiser=1;
105 else if(!strcmp(argv[arg],"--dump"))
106 option_dump=1;
107 else if(!strcmp(argv[arg],"--dump-osm"))
108 option_dump_osm=1;
109 else if(!strcmp(argv[arg],"--dump-visualiser"))
110 option_dump_visualiser=1;
111 else if(!strncmp(argv[arg],"--latmin",8) && argv[arg][8]=='=')
112 {latmin=degrees_to_radians(atof(&argv[arg][9]));coordcount++;}
113 else if(!strncmp(argv[arg],"--latmax",8) && argv[arg][8]=='=')
114 {latmax=degrees_to_radians(atof(&argv[arg][9]));coordcount++;}
115 else if(!strncmp(argv[arg],"--lonmin",8) && argv[arg][8]=='=')
116 {lonmin=degrees_to_radians(atof(&argv[arg][9]));coordcount++;}
117 else if(!strncmp(argv[arg],"--lonmax",8) && argv[arg][8]=='=')
118 {lonmax=degrees_to_radians(atof(&argv[arg][9]));coordcount++;}
119 else if(!strncmp(argv[arg],"--data",6) && argv[arg][6]=='=')
120 option_data=&argv[arg][7];
121 else if(!strcmp(argv[arg],"--no-super"))
122 option_no_super=1;
123 else if(!strncmp(argv[arg],"--node=",7))
124 ;
125 else if(!strncmp(argv[arg],"--segment=",10))
126 ;
127 else if(!strncmp(argv[arg],"--way=",6))
128 ;
129 else if(!strncmp(argv[arg],"--turn-relation=",16))
130 ;
131 else if(!strncmp(argv[arg],"--errorlog=",11))
132 ;
133 else
134 print_usage(0,argv[arg],NULL);
135 }
136
137 if((option_statistics + option_visualiser + option_dump + option_dump_osm + option_dump_visualiser)!=1)
138 print_usage(0,NULL,"Must choose --visualiser, --statistics, --dump, --dump-osm or --dump-visualiser.");
139
140 /* Load in the data - Note: No error checking because Load*List() will call exit() in case of an error. */
141
142 OSMNodes=LoadNodeList(nodes_filename=FileName(dirname,prefix,"nodes.mem"));
143
144 OSMSegments=LoadSegmentList(segments_filename=FileName(dirname,prefix,"segments.mem"));
145
146 OSMWays=LoadWayList(ways_filename=FileName(dirname,prefix,"ways.mem"));
147
148 OSMRelations=LoadRelationList(relations_filename=FileName(dirname,prefix,"relations.mem"));
149
150 if(ExistsFile(errorlogs_filename=FileName(dirname,prefix,"errorlogs.mem")))
151 OSMErrorLogs=LoadErrorLogs(errorlogs_filename);
152 else
153 errorlogs_filename=NULL;
154
155 /* Write out the visualiser data */
156
157 if(option_visualiser)
158 {
159 Highway highway;
160 Transport transport;
161 Property property;
162
163 if(coordcount!=4)
164 print_usage(0,NULL,"The --visualiser option must have --latmin, --latmax, --lonmin, --lonmax.\n");
165
166 if(!option_data)
167 print_usage(0,NULL,"The --visualiser option must have --data.\n");
168
169 if(!strcmp(option_data,"junctions"))
170 OutputJunctions(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
171 else if(!strcmp(option_data,"super"))
172 OutputSuper(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
173 else if(!strcmp(option_data,"waytype-oneway"))
174 OutputWaytype(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,Highway_OneWay);
175 else if(!strcmp(option_data,"waytype-cyclebothways"))
176 OutputWaytype(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,Highway_CycleBothWays);
177 else if(!strcmp(option_data,"waytype-roundabout"))
178 OutputWaytype(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,Highway_Roundabout);
179 else if(!strncmp(option_data,"highway",7) && option_data[7]=='-' && (highway=HighwayType(option_data+8))!=Highway_None)
180 OutputHighway(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,highway);
181 else if(!strncmp(option_data,"transport",9) && option_data[9]=='-' && (transport=TransportType(option_data+10))!=Transport_None)
182 OutputTransport(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,transport);
183 else if(!strncmp(option_data,"barrier",7) && option_data[7]=='-' && (transport=TransportType(option_data+8))!=Transport_None)
184 OutputBarrier(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,transport);
185 else if(!strcmp(option_data,"turns"))
186 OutputTurnRestrictions(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
187 else if(!strcmp(option_data,"speed"))
188 OutputSpeedLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
189 else if(!strcmp(option_data,"weight"))
190 OutputWeightLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
191 else if(!strcmp(option_data,"height"))
192 OutputHeightLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
193 else if(!strcmp(option_data,"width"))
194 OutputWidthLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
195 else if(!strcmp(option_data,"length"))
196 OutputLengthLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax);
197 else if(!strncmp(option_data,"property",8) && option_data[8]=='-' && (property=PropertyType(option_data+9))!=Property_None)
198 OutputProperty(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,property);
199 else if(!strcmp(option_data,"errorlogs"))
200 OutputErrorLog(OSMErrorLogs,latmin,latmax,lonmin,lonmax);
201 else
202 print_usage(0,option_data,NULL);
203 }
204
205 /* Print out statistics */
206
207 if(option_statistics)
208 {
209 struct stat buf;
210
211 /* Examine the files */
212
213 printf("Files\n");
214 printf("-----\n");
215 printf("\n");
216
217 stat(nodes_filename,&buf);
218
219 printf("'%s%snodes.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size);
220 printf("%s\n",RFC822Date(buf.st_mtime));
221 printf("\n");
222
223 stat(segments_filename,&buf);
224
225 printf("'%s%ssegments.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size);
226 printf("%s\n",RFC822Date(buf.st_mtime));
227 printf("\n");
228
229 stat(ways_filename,&buf);
230
231 printf("'%s%sways.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size);
232 printf("%s\n",RFC822Date(buf.st_mtime));
233 printf("\n");
234
235 stat(relations_filename,&buf);
236
237 printf("'%s%srelations.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size);
238 printf("%s\n",RFC822Date(buf.st_mtime));
239 printf("\n");
240
241 if(errorlogs_filename)
242 {
243 stat(errorlogs_filename,&buf);
244
245 printf("'%s%serrorlogs.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size);
246 printf("%s\n",RFC822Date(buf.st_mtime));
247 printf("\n");
248 }
249
250 /* Examine the nodes */
251
252 printf("Nodes\n");
253 printf("-----\n");
254 printf("\n");
255
256 printf("sizeof(Node) =%9lu Bytes\n",(unsigned long)sizeof(Node));
257 printf("Number =%9"Pindex_t"\n",OSMNodes->file.number);
258 printf("Number(super)=%9"Pindex_t"\n",OSMNodes->file.snumber);
259 printf("\n");
260
261 printf("Lat bins= %4d\n",(int)OSMNodes->file.latbins);
262 printf("Lon bins= %4d\n",(int)OSMNodes->file.lonbins);
263 printf("\n");
264
265 printf("Lat zero=%5d (%8.4f deg)\n",(int)OSMNodes->file.latzero,radians_to_degrees(latlong_to_radians(bin_to_latlong(OSMNodes->file.latzero))));
266 printf("Lon zero=%5d (%8.4f deg)\n",(int)OSMNodes->file.lonzero,radians_to_degrees(latlong_to_radians(bin_to_latlong(OSMNodes->file.lonzero))));
267
268 /* Examine the segments */
269
270 printf("\n");
271 printf("Segments\n");
272 printf("--------\n");
273 printf("\n");
274
275 printf("sizeof(Segment)=%9lu Bytes\n",(unsigned long)sizeof(Segment));
276 printf("Number(total) =%9"Pindex_t"\n",OSMSegments->file.number);
277 printf("Number(super) =%9"Pindex_t"\n",OSMSegments->file.snumber);
278 printf("Number(normal) =%9"Pindex_t"\n",OSMSegments->file.nnumber);
279
280 /* Examine the ways */
281
282 printf("\n");
283 printf("Ways\n");
284 printf("----\n");
285 printf("\n");
286
287 printf("sizeof(Way)=%9lu Bytes\n",(unsigned long)sizeof(Way));
288 printf("Number =%9"Pindex_t"\n",OSMWays->file.number);
289 printf("\n");
290
291 stat(ways_filename,&buf);
292 printf("Total names=%9lu Bytes\n",(unsigned long)buf.st_size-(unsigned long)sizeof(Ways)-(unsigned long)OSMWays->file.number*(unsigned long)sizeof(Way));
293 printf("\n");
294
295 printf("Included highways : %s\n",HighwaysNameList(OSMWays->file.highways));
296 printf("Included transports: %s\n",AllowedNameList(OSMWays->file.allow));
297 printf("Included properties: %s\n",PropertiesNameList(OSMWays->file.props));
298
299 /* Examine the relations */
300
301 printf("\n");
302 printf("Relations\n");
303 printf("---------\n");
304 printf("\n");
305
306 printf("sizeof(TurnRelation)=%9lu Bytes\n",(unsigned long)sizeof(TurnRelation));
307 printf("Number =%9"Pindex_t"\n",OSMRelations->file.trnumber);
308
309 if(errorlogs_filename)
310 {
311 printf("\n");
312 printf("Error Logs\n");
313 printf("----------\n");
314 printf("\n");
315
316 printf("Number(total) =%9"Pindex_t"\n",OSMErrorLogs->file.number);
317 printf("Number(geographical) =%9"Pindex_t"\n",OSMErrorLogs->file.number_geo);
318 printf("Number(non-geographical)=%9"Pindex_t"\n",OSMErrorLogs->file.number_nongeo);
319
320 printf("\n");
321 stat(errorlogs_filename,&buf);
322 #if !SLIM
323 printf("Total strings=%9lu Bytes\n",(unsigned long)buf.st_size-(unsigned long)(OSMErrorLogs->strings-(char*)OSMErrorLogs->data));
324 #else
325 printf("Total strings=%9lu Bytes\n",(unsigned long)buf.st_size-(unsigned long)OSMErrorLogs->stringsoffset);
326 #endif
327 }
328 }
329
330 /* Print out internal data (in plain text format) */
331
332 if(option_dump)
333 {
334 index_t item;
335
336 for(arg=1;arg<argc;arg++)
337 if(!strcmp(argv[arg],"--node=all"))
338 {
339 for(item=0;item<OSMNodes->file.number;item++)
340 print_node(OSMNodes,item);
341 }
342 else if(!strncmp(argv[arg],"--node=",7))
343 {
344 item=atoi(&argv[arg][7]);
345
346 if(item<OSMNodes->file.number)
347 print_node(OSMNodes,item);
348 else
349 printf("Invalid node number; minimum=0, maximum=%"Pindex_t".\n",OSMNodes->file.number-1);
350 }
351 else if(!strcmp(argv[arg],"--segment=all"))
352 {
353 for(item=0;item<OSMSegments->file.number;item++)
354 print_segment(OSMSegments,item);
355 }
356 else if(!strncmp(argv[arg],"--segment=",10))
357 {
358 item=atoi(&argv[arg][10]);
359
360 if(item<OSMSegments->file.number)
361 print_segment(OSMSegments,item);
362 else
363 printf("Invalid segment number; minimum=0, maximum=%"Pindex_t".\n",OSMSegments->file.number-1);
364 }
365 else if(!strcmp(argv[arg],"--way=all"))
366 {
367 for(item=0;item<OSMWays->file.number;item++)
368 print_way(OSMWays,item);
369 }
370 else if(!strncmp(argv[arg],"--way=",6))
371 {
372 item=atoi(&argv[arg][6]);
373
374 if(item<OSMWays->file.number)
375 print_way(OSMWays,item);
376 else
377 printf("Invalid way number; minimum=0, maximum=%"Pindex_t".\n",OSMWays->file.number-1);
378 }
379 else if(!strcmp(argv[arg],"--turn-relation=all"))
380 {
381 for(item=0;item<OSMRelations->file.trnumber;item++)
382 print_turn_relation(OSMRelations,item,OSMSegments,OSMNodes);
383 }
384 else if(!strncmp(argv[arg],"--turn-relation=",16))
385 {
386 item=atoi(&argv[arg][16]);
387
388 if(item<OSMRelations->file.trnumber)
389 print_turn_relation(OSMRelations,item,OSMSegments,OSMNodes);
390 else
391 printf("Invalid turn relation number; minimum=0, maximum=%"Pindex_t".\n",OSMRelations->file.trnumber-1);
392 }
393 else if(!strcmp(argv[arg],"--errorlog=all"))
394 {
395 for(item=0;item<OSMErrorLogs->file.number;item++)
396 print_errorlog(OSMErrorLogs,item);
397 }
398 else if(!strncmp(argv[arg],"--errorlog=",11))
399 {
400 item=atoi(&argv[arg][11]);
401
402 if(item<OSMErrorLogs->file.number)
403 print_errorlog(OSMErrorLogs,item);
404 else
405 printf("Invalid error log number; minimum=0, maximum=%"Pindex_t".\n",OSMErrorLogs->file.number-1);
406 }
407 }
408
409 /* Print out internal data (in OSM XML format) */
410
411 if(option_dump_osm)
412 {
413 if(coordcount>0 && coordcount!=4)
414 print_usage(0,NULL,"The --dump-osm option must have all of --latmin, --latmax, --lonmin, --lonmax or none.\n");
415
416 print_head_osm(coordcount,latmin,latmax,lonmin,lonmax);
417
418 if(coordcount)
419 print_region_osm(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,option_no_super);
420 else
421 {
422 index_t item;
423
424 for(item=0;item<OSMNodes->file.number;item++)
425 print_node_osm(OSMNodes,item);
426
427 for(item=0;item<OSMSegments->file.number;item++)
428 if(!option_no_super || IsNormalSegment(LookupSegment(OSMSegments,item,1)))
429 print_segment_osm(OSMSegments,item,OSMWays);
430
431 for(item=0;item<OSMRelations->file.trnumber;item++)
432 print_turn_relation_osm(OSMRelations,item,OSMSegments,OSMNodes);
433 }
434
435 print_tail_osm();
436 }
437
438 /* Print out internal data (in HTML format for the visualiser) */
439
440 if(option_dump_visualiser)
441 {
442 index_t item;
443
444 if(!option_data)
445 print_usage(0,NULL,"The --dump-visualiser option must have --data.\n");
446
447 for(arg=1;arg<argc;arg++)
448 if(!strncmp(argv[arg],"--data=node",11))
449 {
450 item=atoi(&argv[arg][11]);
451
452 if(item<OSMNodes->file.number)
453 print_node_visualiser(OSMNodes,item);
454 else
455 printf("Invalid node number; minimum=0, maximum=%"Pindex_t".\n",OSMNodes->file.number-1);
456 }
457 else if(!strncmp(argv[arg],"--data=segment",14))
458 {
459 item=atoi(&argv[arg][14]);
460
461 if(item<OSMSegments->file.number)
462 print_segment_visualiser(OSMSegments,item,OSMWays);
463 else
464 printf("Invalid segment number; minimum=0, maximum=%"Pindex_t".\n",OSMSegments->file.number-1);
465 }
466 else if(!strncmp(argv[arg],"--data=turn-relation",20))
467 {
468 item=atoi(&argv[arg][20]);
469
470 if(item<OSMRelations->file.trnumber)
471 print_turn_relation_visualiser(OSMRelations,item,OSMSegments,OSMNodes);
472 else
473 printf("Invalid turn relation number; minimum=0, maximum=%"Pindex_t".\n",OSMRelations->file.trnumber-1);
474 }
475 else if(!strncmp(argv[arg],"--data=errorlog",15))
476 {
477 item=atoi(&argv[arg][15]);
478
479 if(item<OSMErrorLogs->file.number)
480 print_errorlog_visualiser(OSMErrorLogs,item);
481 else
482 printf("Invalid error log number; minimum=0, maximum=%"Pindex_t".\n",OSMErrorLogs->file.number-1);
483 }
484 }
485
486 exit(EXIT_SUCCESS);
487 }
488
489
490 /*++++++++++++++++++++++++++++++++++++++
491 Print out the contents of a node from the routing database (as plain text).
492
493 Nodes *nodes The set of nodes to use.
494
495 index_t item The node index to print.
496 ++++++++++++++++++++++++++++++++++++++*/
497
498 static void print_node(Nodes *nodes,index_t item)
499 {
500 Node *nodep=LookupNode(nodes,item,1);
501 double latitude,longitude;
502
503 GetLatLong(nodes,item,nodep,&latitude,&longitude);
504
505 printf("Node %"Pindex_t"\n",item);
506 printf(" firstseg=%"Pindex_t"\n",nodep->firstseg);
507 printf(" latoffset=%d lonoffset=%d (latitude=%.6f longitude=%.6f)\n",nodep->latoffset,nodep->lonoffset,radians_to_degrees(latitude),radians_to_degrees(longitude));
508 printf(" allow=%02x (%s)\n",nodep->allow,AllowedNameList(nodep->allow));
509 if(IsSuperNode(nodep))
510 printf(" Super-Node\n");
511 if(nodep->flags & NODE_MINIRNDBT)
512 printf(" Mini-roundabout\n");
513 }
514
515
516 /*++++++++++++++++++++++++++++++++++++++
517 Print out the contents of a segment from the routing database (as plain text).
518
519 Segments *segments The set of segments to use.
520
521 index_t item The segment index to print.
522 ++++++++++++++++++++++++++++++++++++++*/
523
524 static void print_segment(Segments *segments,index_t item)
525 {
526 Segment *segmentp=LookupSegment(segments,item,1);
527
528 printf("Segment %"Pindex_t"\n",item);
529 printf(" node1=%"Pindex_t" node2=%"Pindex_t"\n",segmentp->node1,segmentp->node2);
530 printf(" next2=%"Pindex_t"\n",segmentp->next2);
531 printf(" way=%"Pindex_t"\n",segmentp->way);
532 printf(" distance=%d (%.3f km)\n",DISTANCE(segmentp->distance),distance_to_km(DISTANCE(segmentp->distance)));
533 if(IsSuperSegment(segmentp) && IsNormalSegment(segmentp))
534 printf(" Super-Segment AND normal Segment\n");
535 else if(IsSuperSegment(segmentp) && !IsNormalSegment(segmentp))
536 printf(" Super-Segment\n");
537 if(IsOnewayTo(segmentp,segmentp->node1))
538 printf(" One-Way from node2 to node1\n");
539 if(IsOnewayTo(segmentp,segmentp->node2))
540 printf(" One-Way from node1 to node2\n");
541 }
542
543
544 /*++++++++++++++++++++++++++++++++++++++
545 Print out the contents of a way from the routing database (as plain text).
546
547 Ways *ways The set of ways to use.
548
549 index_t item The way index to print.
550 ++++++++++++++++++++++++++++++++++++++*/
551
552 static void print_way(Ways *ways,index_t item)
553 {
554 Way *wayp=LookupWay(ways,item,1);
555 char *name=WayName(ways,wayp);
556
557 printf("Way %"Pindex_t"\n",item);
558 if(*name)
559 printf(" name=%s\n",name);
560 printf(" type=%02x (%s%s%s%s)\n",wayp->type,
561 HighwayName(HIGHWAY(wayp->type)),
562 wayp->type&Highway_OneWay?",One-Way":"",
563 wayp->type&Highway_CycleBothWays?",Cycle-Both-Ways":"",
564 wayp->type&Highway_Roundabout?",Roundabout":"");
565 printf(" allow=%02x (%s)\n",wayp->allow,AllowedNameList(wayp->allow));
566 if(wayp->props)
567 printf(" props=%02x (%s)\n",wayp->props,PropertiesNameList(wayp->props));
568 if(wayp->speed)
569 printf(" speed=%d (%d km/hr)\n",wayp->speed,speed_to_kph(wayp->speed));
570 if(wayp->weight)
571 printf(" weight=%d (%.1f tonnes)\n",wayp->weight,weight_to_tonnes(wayp->weight));
572 if(wayp->height)
573 printf(" height=%d (%.1f m)\n",wayp->height,height_to_metres(wayp->height));
574 if(wayp->width)
575 printf(" width=%d (%.1f m)\n",wayp->width,width_to_metres(wayp->width));
576 if(wayp->length)
577 printf(" length=%d (%.1f m)\n",wayp->length,length_to_metres(wayp->length));
578 }
579
580
581 /*++++++++++++++++++++++++++++++++++++++
582 Print out the contents of a turn relation from the routing database (as plain text).
583
584 Relations *relations The set of relations to use.
585
586 index_t item The turn relation index to print.
587
588 Segments *segments The set of segments to use.
589
590 Nodes *nodes The set of nodes to use.
591 ++++++++++++++++++++++++++++++++++++++*/
592
593 static void print_turn_relation(Relations *relations,index_t item,Segments *segments,Nodes *nodes)
594 {
595 Segment *segmentp;
596 TurnRelation *relationp=LookupTurnRelation(relations,item,1);
597 Node *nodep=LookupNode(nodes,relationp->via,1);
598 index_t from_way=NO_WAY,to_way=NO_WAY;
599 index_t from_node=NO_NODE,to_node=NO_NODE;
600
601 segmentp=FirstSegment(segments,nodep,1);
602
603 do
604 {
605 index_t seg=IndexSegment(segments,segmentp);
606
607 if(seg==relationp->from)
608 {
609 from_node=OtherNode(segmentp,relationp->from);
610 from_way=segmentp->way;
611 }
612
613 if(seg==relationp->to)
614 {
615 to_node=OtherNode(segmentp,relationp->to);
616 to_way=segmentp->way;
617 }
618
619 segmentp=NextSegment(segments,segmentp,relationp->via);
620 }
621 while(segmentp);
622
623 printf("Relation %"Pindex_t"\n",item);
624 printf(" from=%"Pindex_t" (segment) = %"Pindex_t" (way) = %"Pindex_t" (node)\n",relationp->from,from_way,from_node);
625 printf(" via=%"Pindex_t" (node)\n",relationp->via);
626 printf(" to=%"Pindex_t" (segment) = %"Pindex_t" (way) = %"Pindex_t" (node)\n",relationp->to,to_way,to_node);
627 if(relationp->except)
628 printf(" except=%02x (%s)\n",relationp->except,AllowedNameList(relationp->except));
629 }
630
631
632 /*++++++++++++++++++++++++++++++++++++++
633 Print out the contents of an error log from the routing database (as plain text).
634
635 ErrorLogs *errorlogs The set of error logs to use.
636
637 index_t item The error log index to print.
638 ++++++++++++++++++++++++++++++++++++++*/
639
640 static void print_errorlog(ErrorLogs *errorlogs,index_t item)
641 {
642 ErrorLog *errorlogp=LookupErrorLog(errorlogs,item,1);
643
644 printf("Error Log %"Pindex_t"\n",item);
645
646 if(item<errorlogs->file.number_geo)
647 {
648 double latitude,longitude;
649
650 GetErrorLogLatLong(errorlogs,item,errorlogp,&latitude,&longitude);
651
652 printf(" latoffset=%d lonoffset=%d (latitude=%.6f longitude=%.6f)\n",errorlogp->latoffset,errorlogp->lonoffset,radians_to_degrees(latitude),radians_to_degrees(longitude));
653 }
654 else
655 printf(" No geographical information\n");
656
657 printf(" '%s'\n",LookupErrorLogString(errorlogs,item));
658 }
659
660
661 /*++++++++++++++++++++++++++++++++++++++
662 Print out a header in OSM XML format.
663
664 int coordcount If true then include a bounding box.
665
666 double latmin The minimum latitude.
667
668 double latmax The maximum latitude.
669
670 double lonmin The minimum longitude.
671
672 double lonmax The maximum longitude.
673 ++++++++++++++++++++++++++++++++++++++*/
674
675 static void print_head_osm(int coordcount,double latmin,double latmax,double lonmin,double lonmax)
676 {
677 printf("<?xml version='1.0' encoding='UTF-8'?>\n");
678 printf("<osm version='0.6' generator='Routino'>\n");
679
680 if(coordcount)
681 printf(" <bounds minlat='%.6f' maxlat='%.6f' minlon='%.6f' maxlon='%.6f' />\n",
682 radians_to_degrees(latmin),radians_to_degrees(latmax),radians_to_degrees(lonmin),radians_to_degrees(lonmax));
683 }
684
685
686 /*++++++++++++++++++++++++++++++++++++++
687 Print a region of the database in OSM XML format.
688
689 Nodes *nodes The set of nodes to use.
690
691 Segments *segments The set of segments to use.
692
693 Ways *ways The set of ways to use.
694
695 Relations *relations The set of relations to use.
696
697 double latmin The minimum latitude.
698
699 double latmax The maximum latitude.
700
701 double lonmin The minimum longitude.
702
703 double lonmax The maximum longitude.
704
705 int option_no_super The option to print no super-segments.
706 ++++++++++++++++++++++++++++++++++++++*/
707
708 static void print_region_osm(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,
709 double latmin,double latmax,double lonmin,double lonmax,int option_no_super)
710 {
711 ll_bin_t latminbin=latlong_to_bin(radians_to_latlong(latmin))-nodes->file.latzero;
712 ll_bin_t latmaxbin=latlong_to_bin(radians_to_latlong(latmax))-nodes->file.latzero;
713 ll_bin_t lonminbin=latlong_to_bin(radians_to_latlong(lonmin))-nodes->file.lonzero;
714 ll_bin_t lonmaxbin=latlong_to_bin(radians_to_latlong(lonmax))-nodes->file.lonzero;
715 ll_bin_t latb,lonb;
716 index_t item,index1,index2;
717
718 if(latminbin<0) latminbin=0;
719 if(latmaxbin>nodes->file.latbins) latmaxbin=nodes->file.latbins-1;
720 if(lonminbin<0) lonminbin=0;
721 if(lonmaxbin>nodes->file.lonbins) lonmaxbin=nodes->file.lonbins-1;
722
723 /* Loop through all of the nodes. */
724
725 for(latb=latminbin;latb<=latmaxbin;latb++)
726 for(lonb=lonminbin;lonb<=lonmaxbin;lonb++)
727 {
728 ll_bin2_t llbin=lonb*nodes->file.latbins+latb;
729
730 if(llbin<0 || llbin>(nodes->file.latbins*nodes->file.lonbins))
731 continue;
732
733 index1=LookupNodeOffset(nodes,llbin);
734 index2=LookupNodeOffset(nodes,llbin+1);
735
736 for(item=index1;item<index2;item++)
737 {
738 Node *nodep=LookupNode(nodes,item,1);
739 double lat=latlong_to_radians(bin_to_latlong(nodes->file.latzero+latb)+off_to_latlong(nodep->latoffset));
740 double lon=latlong_to_radians(bin_to_latlong(nodes->file.lonzero+lonb)+off_to_latlong(nodep->lonoffset));
741
742 if(lat>latmin && lat<latmax && lon>lonmin && lon<lonmax)
743 {
744 Segment *segmentp;
745
746 print_node_osm(nodes,item);
747
748 segmentp=FirstSegment(segments,nodep,1);
749
750 while(segmentp)
751 {
752 double olat,olon;
753 index_t oitem=OtherNode(segmentp,item);
754
755 GetLatLong(nodes,oitem,NULL,&olat,&olon);
756
757 if(olat>latmin && olat<latmax && olon>lonmin && olon<lonmax)
758 if(item>oitem)
759 if(!option_no_super || IsNormalSegment(segmentp))
760 print_segment_osm(segments,IndexSegment(segments,segmentp),ways);
761
762 segmentp=NextSegment(segments,segmentp,item);
763 }
764
765 if(IsTurnRestrictedNode(nodep))
766 {
767 index_t relindex=FindFirstTurnRelation1(relations,item);
768
769 while(relindex!=NO_RELATION)
770 {
771 print_turn_relation_osm(relations,relindex,segments,nodes);
772
773 relindex=FindNextTurnRelation1(relations,relindex);
774 }
775 }
776 }
777 }
778 }
779 }
780
781
782 /*++++++++++++++++++++++++++++++++++++++
783 Print out the contents of a node from the routing database (in OSM XML format).
784
785 Nodes *nodes The set of nodes to use.
786
787 index_t item The node index to print.
788 ++++++++++++++++++++++++++++++++++++++*/
789
790 static void print_node_osm(Nodes *nodes,index_t item)
791 {
792 Node *nodep=LookupNode(nodes,item,1);
793 double latitude,longitude;
794 int i;
795
796 GetLatLong(nodes,item,nodep,&latitude,&longitude);
797
798 if(nodep->allow==Transports_ALL && nodep->flags==0)
799 printf(" <node id='%lu' lat='%.7f' lon='%.7f' version='1' />\n",(unsigned long)item+1,radians_to_degrees(latitude),radians_to_degrees(longitude));
800 else
801 {
802 printf(" <node id='%lu' lat='%.7f' lon='%.7f' version='1'>\n",(unsigned long)item+1,radians_to_degrees(latitude),radians_to_degrees(longitude));
803
804 if(nodep->flags & NODE_SUPER)
805 printf(" <tag k='routino:super' v='yes' />\n");
806
807 if(nodep->flags & NODE_UTURN)
808 printf(" <tag k='routino:uturn' v='yes' />\n");
809
810 if(nodep->flags & NODE_MINIRNDBT)
811 printf(" <tag k='junction' v='roundabout' />\n");
812
813 if(nodep->flags & NODE_TURNRSTRCT)
814 printf(" <tag k='routino:turnrestriction' v='yes' />\n");
815
816 for(i=1;i<Transport_Count;i++)
817 if(!(nodep->allow & TRANSPORTS(i)))
818 printf(" <tag k='%s' v='no' />\n",TransportName(i));
819
820 printf(" </node>\n");
821 }
822 }
823
824
825 /*++++++++++++++++++++++++++++++++++++++
826 Print out the contents of a segment from the routing database (as a way in OSM XML format).
827
828 Segments *segments The set of segments to use.
829
830 index_t item The segment index to print.
831
832 Ways *ways The set of ways to use.
833 ++++++++++++++++++++++++++++++++++++++*/
834
835 static void print_segment_osm(Segments *segments,index_t item,Ways *ways)
836 {
837 Segment *segmentp=LookupSegment(segments,item,1);
838 Way *wayp=LookupWay(ways,segmentp->way,1);
839 char *name=WayName(ways,wayp);
840 int i;
841
842 printf(" <way id='%lu' version='1'>\n",(unsigned long)item+1);
843
844 if(IsOnewayTo(segmentp,segmentp->node1))
845 {
846 printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node2+1);
847 printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node1+1);
848 }
849 else
850 {
851 printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node1+1);
852 printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node2+1);
853 }
854
855 if(IsSuperSegment(segmentp))
856 printf(" <tag k='routino:super' v='yes' />\n");
857 if(IsNormalSegment(segmentp))
858 printf(" <tag k='routino:normal' v='yes' />\n");
859
860 printf(" <tag k='routino:distance' v='%.3f' />\n",distance_to_km(DISTANCE(segmentp->distance)));
861
862 if(wayp->type & Highway_OneWay)
863 printf(" <tag k='oneway' v='yes' />\n");
864
865 if(wayp->type & Highway_CycleBothWays)
866 printf(" <tag k='cyclebothways' v='yes' />\n");
867
868 if(wayp->type & Highway_Roundabout)
869 printf(" <tag k='roundabout' v='yes' />\n");
870
871 printf(" <tag k='highway' v='%s' />\n",HighwayName(HIGHWAY(wayp->type)));
872
873 if(IsNormalSegment(segmentp) && *name)
874 printf(" <tag k='name' v='%s' />\n",ParseXML_Encode_Safe_XML(name));
875
876 for(i=1;i<Transport_Count;i++)
877 if(wayp->allow & TRANSPORTS(i))
878 printf(" <tag k='%s' v='yes' />\n",TransportName(i));
879
880 for(i=1;i<Property_Count;i++)
881 if(wayp->props & PROPERTIES(i))
882 printf(" <tag k='%s' v='yes' />\n",PropertyName(i));
883
884 if(wayp->speed)
885 printf(" <tag k='maxspeed' v='%d' />\n",speed_to_kph(wayp->speed));
886
887 if(wayp->weight)
888 printf(" <tag k='maxweight' v='%.1f' />\n",weight_to_tonnes(wayp->weight));
889 if(wayp->height)
890 printf(" <tag k='maxheight' v='%.1f' />\n",height_to_metres(wayp->height));
891 if(wayp->width)
892 printf(" <tag k='maxwidth' v='%.1f' />\n",width_to_metres(wayp->width));
893 if(wayp->length)
894 printf(" <tag k='maxlength' v='%.1f' />\n",length_to_metres(wayp->length));
895
896 printf(" </way>\n");
897 }
898
899
900 /*++++++++++++++++++++++++++++++++++++++
901 Print out the contents of a turn relation from the routing database (in OSM XML format).
902
903 Relations *relations The set of relations to use.
904
905 index_t item The relation index to print.
906
907 Segments *segments The set of segments to use.
908
909 Nodes *nodes The set of nodes to use.
910 ++++++++++++++++++++++++++++++++++++++*/
911
912 static void print_turn_relation_osm(Relations *relations,index_t item,Segments *segments,Nodes *nodes)
913 {
914 TurnRelation *relationp=LookupTurnRelation(relations,item,1);
915
916 Segment *segmentp_from=LookupSegment(segments,relationp->from,1);
917 Segment *segmentp_to =LookupSegment(segments,relationp->to ,2);
918
919 double angle=TurnAngle(nodes,segmentp_from,segmentp_to,relationp->via);
920
921 char *restriction;
922
923 if(angle>150 || angle<-150)
924 restriction="no_u_turn";
925 else if(angle>30)
926 restriction="no_right_turn";
927 else if(angle<-30)
928 restriction="no_left_turn";
929 else
930 restriction="no_straight_on";
931
932 printf(" <relation id='%lu' version='1'>\n",(unsigned long)item+1);
933 printf(" <tag k='type' v='restriction' />\n");
934 printf(" <tag k='restriction' v='%s'/>\n",restriction);
935
936 if(relationp->except)
937 printf(" <tag k='except' v='%s' />\n",AllowedNameList(relationp->except));
938
939 printf(" <member type='way' ref='%lu' role='from' />\n",(unsigned long)relationp->from+1);
940 printf(" <member type='node' ref='%lu' role='via' />\n",(unsigned long)relationp->via+1);
941 printf(" <member type='way' ref='%lu' role='to' />\n",(unsigned long)relationp->to+1);
942
943 printf(" </relation>\n");
944 }
945
946
947 /*++++++++++++++++++++++++++++++++++++++
948 Print out a tail in OSM XML format.
949 ++++++++++++++++++++++++++++++++++++++*/
950
951 static void print_tail_osm(void)
952 {
953 printf("</osm>\n");
954 }
955
956
957 /*++++++++++++++++++++++++++++++++++++++
958 Print out the contents of a node from the routing database (in visualiser format).
959
960 Nodes *nodes The set of nodes to use.
961
962 index_t item The node index to print.
963 ++++++++++++++++++++++++++++++++++++++*/
964
965 static void print_node_visualiser(Nodes *nodes,index_t item)
966 {
967 Node *nodep=LookupNode(nodes,item,1);
968 double latitude,longitude;
969 int i;
970
971 GetLatLong(nodes,item,nodep,&latitude,&longitude);
972
973 if(nodep->allow==Transports_ALL && nodep->flags==0)
974 printf("&lt;routino:node id='%lu' lat='%.7f' lon='%.7f' /&gt;\n",(unsigned long)item+1,radians_to_degrees(latitude),radians_to_degrees(longitude));
975 else
976 {
977 printf("&lt;routino:node id='%lu' lat='%.7f' lon='%.7f'&gt;\n",(unsigned long)item+1,radians_to_degrees(latitude),radians_to_degrees(longitude));
978
979 if(nodep->flags & NODE_SUPER)
980 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='routino:super' v='yes' /&gt;\n");
981
982 if(nodep->flags & NODE_UTURN)
983 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='routino:uturn' v='yes' /&gt;\n");
984
985 if(nodep->flags & NODE_MINIRNDBT)
986 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='junction' v='roundabout' /&gt;\n");
987
988 if(nodep->flags & NODE_TURNRSTRCT)
989 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='routino:turnrestriction' v='yes' /&gt;\n");
990
991 for(i=1;i<Transport_Count;i++)
992 if(!(nodep->allow & TRANSPORTS(i)))
993 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='%s' v='no' /&gt;\n",TransportName(i));
994
995 printf("&lt;/routino:node&gt;\n");
996 }
997 }
998
999
1000 /*++++++++++++++++++++++++++++++++++++++
1001 Print out the contents of a segment from the routing database (as a way in visualiser format).
1002
1003 Segments *segments The set of segments to use.
1004
1005 index_t item The segment index to print.
1006
1007 Ways *ways The set of ways to use.
1008 ++++++++++++++++++++++++++++++++++++++*/
1009
1010 static void print_segment_visualiser(Segments *segments,index_t item,Ways *ways)
1011 {
1012 Segment *segmentp=LookupSegment(segments,item,1);
1013 Way *wayp=LookupWay(ways,segmentp->way,1);
1014 char *name=WayName(ways,wayp);
1015 int i;
1016
1017 printf("&lt;routino:way id='%lu'&gt;\n",(unsigned long)item+1);
1018
1019 if(IsOnewayTo(segmentp,segmentp->node1))
1020 {
1021 printf("&nbsp;&nbsp;&nbsp;&lt;nd ref='%lu' /&gt;\n",(unsigned long)segmentp->node2+1);
1022 printf("&nbsp;&nbsp;&nbsp;&lt;nd ref='%lu' /&gt;\n",(unsigned long)segmentp->node1+1);
1023 }
1024 else
1025 {
1026 printf("&nbsp;&nbsp;&nbsp;&lt;nd ref='%lu' /&gt;\n",(unsigned long)segmentp->node1+1);
1027 printf("&nbsp;&nbsp;&nbsp;&lt;nd ref='%lu' /&gt;\n",(unsigned long)segmentp->node2+1);
1028 }
1029
1030 if(IsSuperSegment(segmentp))
1031 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='routino:super' v='yes' /&gt;\n");
1032 if(IsNormalSegment(segmentp))
1033 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='routino:normal' v='yes' /&gt;\n");
1034
1035 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='routino:distance' v='%.3f km' /&gt;\n",distance_to_km(DISTANCE(segmentp->distance)));
1036
1037 if(wayp->type & Highway_OneWay)
1038 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='oneway' v='yes' /&gt;\n");
1039
1040 if(wayp->type & Highway_CycleBothWays)
1041 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='cyclebothways' v='yes' /&gt;\n");
1042
1043 if(wayp->type & Highway_Roundabout)
1044 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='roundabout' v='yes' /&gt;\n");
1045
1046 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='highway' v='%s' /&gt;\n",HighwayName(HIGHWAY(wayp->type)));
1047
1048 if(IsNormalSegment(segmentp) && *name)
1049 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='name' v='%s' /&gt;\n",ParseXML_Encode_Safe_XML(name));
1050
1051 for(i=1;i<Transport_Count;i++)
1052 if(wayp->allow & TRANSPORTS(i))
1053 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='%s' v='yes' /&gt;\n",TransportName(i));
1054
1055 for(i=1;i<Property_Count;i++)
1056 if(wayp->props & PROPERTIES(i))
1057 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='%s' v='yes' /&gt;\n",PropertyName(i));
1058
1059 if(wayp->speed)
1060 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='maxspeed' v='%d kph' /&gt;\n",speed_to_kph(wayp->speed));
1061
1062 if(wayp->weight)
1063 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='maxweight' v='%.1f t' /&gt;\n",weight_to_tonnes(wayp->weight));
1064 if(wayp->height)
1065 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='maxheight' v='%.1f m' /&gt;\n",height_to_metres(wayp->height));
1066 if(wayp->width)
1067 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='maxwidth' v='%.1f m' /&gt;\n",width_to_metres(wayp->width));
1068 if(wayp->length)
1069 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='maxlength' v='%.1f m' /&gt;\n",length_to_metres(wayp->length));
1070
1071 printf("&lt;/routino:way&gt;\n");
1072 }
1073
1074
1075 /*++++++++++++++++++++++++++++++++++++++
1076 Print out the contents of a turn relation from the routing database (in visualiser format).
1077
1078 Relations *relations The set of relations to use.
1079
1080 index_t item The relation index to print.
1081
1082 Segments *segments The set of segments to use.
1083
1084 Nodes *nodes The set of nodes to use.
1085 ++++++++++++++++++++++++++++++++++++++*/
1086
1087 static void print_turn_relation_visualiser(Relations *relations,index_t item,Segments *segments,Nodes *nodes)
1088 {
1089 TurnRelation *relationp=LookupTurnRelation(relations,item,1);
1090
1091 Segment *segmentp_from=LookupSegment(segments,relationp->from,1);
1092 Segment *segmentp_to =LookupSegment(segments,relationp->to ,2);
1093
1094 double angle=TurnAngle(nodes,segmentp_from,segmentp_to,relationp->via);
1095
1096 char *restriction;
1097
1098 if(angle>150 || angle<-150)
1099 restriction="no_u_turn";
1100 else if(angle>30)
1101 restriction="no_right_turn";
1102 else if(angle<-30)
1103 restriction="no_left_turn";
1104 else
1105 restriction="no_straight_on";
1106
1107 printf("&lt;routino:relation id='%lu'&gt;\n",(unsigned long)item+1);
1108 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='type' v='restriction' /&gt;\n");
1109 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='restriction' v='%s'/&gt;\n",restriction);
1110
1111 if(relationp->except)
1112 printf("&nbsp;&nbsp;&nbsp;&lt;tag k='except' v='%s' /&gt;\n",AllowedNameList(relationp->except));
1113
1114 printf("&nbsp;&nbsp;&nbsp;&lt;member type='way' ref='%lu' role='from' /&gt;\n",(unsigned long)relationp->from+1);
1115 printf("&nbsp;&nbsp;&nbsp;&lt;member type='node' ref='%lu' role='via' /&gt;\n",(unsigned long)relationp->via+1);
1116 printf("&nbsp;&nbsp;&nbsp;&lt;member type='way' ref='%lu' role='to' /&gt;\n",(unsigned long)relationp->to+1);
1117
1118 printf("&lt;/routino:relation&gt;\n");
1119 }
1120
1121
1122 /*++++++++++++++++++++++++++++++++++++++
1123 Print out an error log entry from the database (in visualiser format).
1124
1125 ErrorLogs *errorlogs The set of error logs to use.
1126
1127 index_t item The error log index to print.
1128 ++++++++++++++++++++++++++++++++++++++*/
1129
1130 static void print_errorlog_visualiser(ErrorLogs *errorlogs,index_t item)
1131 {
1132 char *string=LookupErrorLogString(errorlogs,item);
1133
1134 printf("%s\n",ParseXML_Encode_Safe_XML(string));
1135 }
1136
1137
1138 /*+ Conversion from time_t to date string (day of week). +*/
1139 static const char* const weekdays[7]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
1140
1141 /*+ Conversion from time_t to date string (month of year). +*/
1142 static const char* const months[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
1143
1144
1145 /*++++++++++++++++++++++++++++++++++++++
1146 Convert the time into an RFC 822 compliant date.
1147
1148 char *RFC822Date Returns a pointer to a fixed string containing the date.
1149
1150 time_t t The time.
1151 ++++++++++++++++++++++++++++++++++++++*/
1152
1153 static char *RFC822Date(time_t t)
1154 {
1155 static char value[32];
1156 char weekday[4];
1157 char month[4];
1158 struct tm *tim;
1159
1160 tim=gmtime(&t);
1161
1162 strcpy(weekday,weekdays[tim->tm_wday]);
1163 strcpy(month,months[tim->tm_mon]);
1164
1165 /* Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 */
1166
1167 sprintf(value,"%3s, %02d %3s %4d %02d:%02d:%02d %s",
1168 weekday,
1169 tim->tm_mday,
1170 month,
1171 tim->tm_year+1900,
1172 tim->tm_hour,
1173 tim->tm_min,
1174 tim->tm_sec,
1175 "GMT"
1176 );
1177
1178 return(value);
1179 }
1180
1181
1182 /*++++++++++++++++++++++++++++++++++++++
1183 Print out the usage information.
1184
1185 int detail The level of detail to use - 0 = low, 1 = high.
1186
1187 const char *argerr The argument that gave the error (if there is one).
1188
1189 const char *err Other error message (if there is one).
1190 ++++++++++++++++++++++++++++++++++++++*/
1191
1192 static void print_usage(int detail,const char *argerr,const char *err)
1193 {
1194 fprintf(stderr,
1195 "Usage: filedumper [--help]\n"
1196 " [--dir=<dirname>] [--prefix=<name>]\n"
1197 " [--statistics]\n"
1198 " [--visualiser --latmin=<latmin> --latmax=<latmax>\n"
1199 " --lonmin=<lonmin> --lonmax=<lonmax>\n"
1200 " --data=<data-type>]\n"
1201 " [--dump [--node=<node> ...]\n"
1202 " [--segment=<segment> ...]\n"
1203 " [--way=<way> ...]\n"
1204 " [--turn-relation=<rel> ...]\n"
1205 " [--errorlog=<number> ...]]\n"
1206 " [--dump-osm [--no-super]\n"
1207 " [--latmin=<latmin> --latmax=<latmax>\n"
1208 " --lonmin=<lonmin> --lonmax=<lonmax>]]\n"
1209 " [--dump-visualiser [--data=node<node>]\n"
1210 " [--data=segment<segment>]\n"
1211 " [--data=turn-relation<rel>]\n"
1212 " [--data=errorlog<number>]]\n");
1213
1214 if(argerr)
1215 fprintf(stderr,
1216 "\n"
1217 "Error with command line parameter: %s\n",argerr);
1218
1219 if(err)
1220 fprintf(stderr,
1221 "\n"
1222 "Error: %s\n",err);
1223
1224 if(detail)
1225 fprintf(stderr,
1226 "\n"
1227 "--help Prints this information.\n"
1228 "\n"
1229 "--dir=<dirname> The directory containing the routing database.\n"
1230 "--prefix=<name> The filename prefix for the routing database.\n"
1231 "\n"
1232 "--statistics Print statistics about the routing database.\n"
1233 "\n"
1234 "--visualiser Extract selected data from the routing database:\n"
1235 " --latmin=<latmin> * the minimum latitude (degrees N).\n"
1236 " --latmax=<latmax> * the maximum latitude (degrees N).\n"
1237 " --lonmin=<lonmin> * the minimum longitude (degrees E).\n"
1238 " --lonmax=<lonmax> * the maximum longitude (degrees E).\n"
1239 " --data=<data-type> * the type of data to select.\n"
1240 "\n"
1241 " <data-type> can be selected from:\n"
1242 " junctions = segment count at each junction.\n"
1243 " super = super-node and super-segments.\n"
1244 " waytype-* = segments of oneway, cyclebothways or roundabout type.\n"
1245 " highway-* = segments of the specified highway type.\n"
1246 " transport-* = segments allowing the specified transport type.\n"
1247 " barrier-* = nodes disallowing the specified transport type.\n"
1248 " turns = turn restrictions.\n"
1249 " speed = speed limits.\n"
1250 " weight = weight limits.\n"
1251 " height = height limits.\n"
1252 " width = width limits.\n"
1253 " length = length limits.\n"
1254 " property-* = segments with the specified property.\n"
1255 " errorlogs = errors logged during parsing.\n"
1256 "\n"
1257 "--dump Dump selected contents of the database.\n"
1258 " --node=<node> * the node with the selected index.\n"
1259 " --segment=<segment> * the segment with the selected index.\n"
1260 " --way=<way> * the way with the selected index.\n"
1261 " --turn-relation=<rel> * the turn relation with the selected index.\n"
1262 " --errorlog=<number> * the error log with the selected index.\n"
1263 " Use 'all' instead of a number to get all of them.\n"
1264 "\n"
1265 "--dump-osm Dump all or part of the database as an XML file.\n"
1266 " --no-super * exclude the super-segments.\n"
1267 " --latmin=<latmin> * the minimum latitude (degrees N).\n"
1268 " --latmax=<latmax> * the maximum latitude (degrees N).\n"
1269 " --lonmin=<lonmin> * the minimum longitude (degrees E).\n"
1270 " --lonmax=<lonmax> * the maximum longitude (degrees E).\n"
1271 "\n"
1272 "--dump-visualiser Dump selected contents of the database in HTML.\n"
1273 " --data=node<node> * the node with the selected index.\n"
1274 " --data=segment<segment> * the segment with the selected index.\n"
1275 " --data=turn-relation<rel> * the turn relation with the selected index.\n"
1276 " --data=errorlog<number> * the error log with the selected index.\n");
1277
1278 exit(!detail);
1279 }

Properties

Name Value
cvs:description Test program for mmap files.