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 1989 - (show annotations) (download) (as text)
Wed Apr 17 17:54:45 2019 UTC (5 years, 11 months ago) by amb
File MIME type: text/x-csrc
File size: 47006 byte(s)
Rename some structure members and function names to reflect more
clearly their meaning (mostly change "allow" to "transport").  No
changes to file formats or API.

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

Properties

Name Value
cvs:description Test program for mmap files.