Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/filedumper.c
Parent Directory
|
Revision Log
Revision 1263 -
(hide annotations)
(download)
(as text)
Sat Mar 2 14:13:14 2013 UTC (12 years ago) by amb
File MIME type: text/x-csrc
File size: 33522 byte(s)
Sat Mar 2 14:13:14 2013 UTC (12 years ago) by amb
File MIME type: text/x-csrc
File size: 33522 byte(s)
Recognise mini-roundabouts tagged as junction=roundabout (as well as highway=mini_roundabout). Pass them through the parser as roundabout=yes. Output them from the filedumper as junction=roundabout. Update the documentation for mini-roundabouts.
1 | amb | 2 | /*************************************** |
2 | Memory file dumper. | ||
3 | amb | 151 | |
4 | Part of the Routino routing software. | ||
5 | amb | 2 | ******************/ /****************** |
6 | amb | 1263 | This file Copyright 2008-2013 Andrew M. Bishop |
7 | amb | 2 | |
8 | amb | 151 | 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 | amb | 2 | ***************************************/ |
21 | |||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | amb | 107 | #include <string.h> |
26 | amb | 185 | #include <sys/stat.h> |
27 | #include <sys/time.h> | ||
28 | #include <time.h> | ||
29 | amb | 669 | #include <math.h> |
30 | amb | 2 | |
31 | amb | 97 | #include "types.h" |
32 | #include "nodes.h" | ||
33 | #include "segments.h" | ||
34 | #include "ways.h" | ||
35 | amb | 542 | #include "relations.h" |
36 | amb | 449 | |
37 | #include "files.h" | ||
38 | #include "visualiser.h" | ||
39 | amb | 405 | #include "xmlparse.h" |
40 | amb | 2 | |
41 | amb | 405 | |
42 | amb | 185 | /* Local functions */ |
43 | amb | 2 | |
44 | amb | 681 | static void print_node(Nodes *nodes,index_t item); |
45 | amb | 202 | static void print_segment(Segments *segments,index_t item); |
46 | static void print_way(Ways *ways,index_t item); | ||
47 | amb | 1150 | static void print_turn_relation(Relations *relations,index_t item,Segments *segments,Nodes *nodes); |
48 | amb | 185 | |
49 | amb | 917 | static void print_head_osm(int coordcount,double latmin,double latmax,double lonmin,double lonmax); |
50 | amb | 918 | static void print_region_osm(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations, |
51 | double latmin,double latmax,double lonmin,double lonmax,int option_no_super); | ||
52 | amb | 681 | static void print_node_osm(Nodes *nodes,index_t item); |
53 | amb | 405 | static void print_segment_osm(Segments *segments,index_t item,Ways *ways); |
54 | amb | 1150 | static void print_turn_relation_osm(Relations *relations,index_t item,Segments *segments,Nodes *nodes); |
55 | amb | 405 | static void print_tail_osm(void); |
56 | |||
57 | static char *RFC822Date(time_t t); | ||
58 | |||
59 | amb | 490 | static void print_usage(int detail,const char *argerr,const char *err); |
60 | amb | 342 | |
61 | |||
62 | /*++++++++++++++++++++++++++++++++++++++ | ||
63 | amb | 405 | The main program for the file dumper. |
64 | amb | 342 | ++++++++++++++++++++++++++++++++++++++*/ |
65 | |||
66 | amb | 2 | int main(int argc,char** argv) |
67 | { | ||
68 | amb | 26 | Nodes *OSMNodes; |
69 | amb | 66 | Segments *OSMSegments; |
70 | amb | 26 | Ways *OSMWays; |
71 | amb | 542 | Relations*OSMRelations; |
72 | amb | 405 | int arg; |
73 | char *dirname=NULL,*prefix=NULL; | ||
74 | amb | 542 | char *nodes_filename,*segments_filename,*ways_filename,*relations_filename; |
75 | amb | 405 | int option_statistics=0; |
76 | int option_visualiser=0,coordcount=0; | ||
77 | double latmin=0,latmax=0,lonmin=0,lonmax=0; | ||
78 | char *option_data=NULL; | ||
79 | int option_dump=0; | ||
80 | amb | 413 | int option_dump_osm=0,option_no_super=0; |
81 | amb | 13 | |
82 | amb | 107 | /* Parse the command line arguments */ |
83 | |||
84 | amb | 202 | for(arg=1;arg<argc;arg++) |
85 | amb | 107 | { |
86 | amb | 202 | if(!strcmp(argv[arg],"--help")) |
87 | amb | 490 | print_usage(1,NULL,NULL); |
88 | amb | 202 | else if(!strncmp(argv[arg],"--dir=",6)) |
89 | dirname=&argv[arg][6]; | ||
90 | else if(!strncmp(argv[arg],"--prefix=",9)) | ||
91 | prefix=&argv[arg][9]; | ||
92 | amb | 405 | else if(!strcmp(argv[arg],"--statistics")) |
93 | amb | 185 | option_statistics=1; |
94 | amb | 405 | else if(!strcmp(argv[arg],"--visualiser")) |
95 | amb | 185 | option_visualiser=1; |
96 | amb | 405 | else if(!strcmp(argv[arg],"--dump")) |
97 | amb | 202 | option_dump=1; |
98 | amb | 405 | else if(!strcmp(argv[arg],"--dump-osm")) |
99 | option_dump_osm=1; | ||
100 | amb | 202 | else if(!strncmp(argv[arg],"--latmin",8) && argv[arg][8]=='=') |
101 | {latmin=degrees_to_radians(atof(&argv[arg][9]));coordcount++;} | ||
102 | else if(!strncmp(argv[arg],"--latmax",8) && argv[arg][8]=='=') | ||
103 | {latmax=degrees_to_radians(atof(&argv[arg][9]));coordcount++;} | ||
104 | else if(!strncmp(argv[arg],"--lonmin",8) && argv[arg][8]=='=') | ||
105 | {lonmin=degrees_to_radians(atof(&argv[arg][9]));coordcount++;} | ||
106 | else if(!strncmp(argv[arg],"--lonmax",8) && argv[arg][8]=='=') | ||
107 | {lonmax=degrees_to_radians(atof(&argv[arg][9]));coordcount++;} | ||
108 | else if(!strncmp(argv[arg],"--data",6) && argv[arg][6]=='=') | ||
109 | option_data=&argv[arg][7]; | ||
110 | amb | 413 | else if(!strcmp(argv[arg],"--no-super")) |
111 | option_no_super=1; | ||
112 | amb | 202 | else if(!strncmp(argv[arg],"--node=",7)) |
113 | ; | ||
114 | else if(!strncmp(argv[arg],"--segment=",10)) | ||
115 | ; | ||
116 | else if(!strncmp(argv[arg],"--way=",6)) | ||
117 | ; | ||
118 | amb | 565 | else if(!strncmp(argv[arg],"--turn-relation=",16)) |
119 | ; | ||
120 | amb | 107 | else |
121 | amb | 490 | print_usage(0,argv[arg],NULL); |
122 | amb | 107 | } |
123 | |||
124 | amb | 490 | if((option_statistics + option_visualiser + option_dump + option_dump_osm)!=1) |
125 | print_usage(0,NULL,"Must choose --visualiser, --statistics, --dump or --dump-osm."); | ||
126 | amb | 2 | |
127 | amb | 329 | /* Load in the data - Note: No error checking because Load*List() will call exit() in case of an error. */ |
128 | amb | 2 | |
129 | amb | 185 | OSMNodes=LoadNodeList(nodes_filename=FileName(dirname,prefix,"nodes.mem")); |
130 | amb | 6 | |
131 | amb | 185 | OSMSegments=LoadSegmentList(segments_filename=FileName(dirname,prefix,"segments.mem")); |
132 | amb | 99 | |
133 | amb | 185 | OSMWays=LoadWayList(ways_filename=FileName(dirname,prefix,"ways.mem")); |
134 | amb | 66 | |
135 | amb | 542 | OSMRelations=LoadRelationList(relations_filename=FileName(dirname,prefix,"relations.mem")); |
136 | |||
137 | amb | 185 | /* Write out the visualiser data */ |
138 | amb | 66 | |
139 | amb | 185 | if(option_visualiser) |
140 | { | ||
141 | amb | 1003 | Highway highway; |
142 | amb | 1002 | Transport transport; |
143 | amb | 1248 | Property property; |
144 | amb | 1002 | |
145 | amb | 185 | if(coordcount!=4) |
146 | amb | 490 | print_usage(0,NULL,"The --visualiser option must have --latmin, --latmax, --lonmin, --lonmax.\n"); |
147 | amb | 66 | |
148 | amb | 185 | if(!option_data) |
149 | amb | 490 | print_usage(0,NULL,"The --visualiser option must have --data.\n"); |
150 | amb | 2 | |
151 | amb | 185 | if(!strcmp(option_data,"junctions")) |
152 | amb | 623 | OutputJunctions(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
153 | amb | 185 | else if(!strcmp(option_data,"super")) |
154 | amb | 623 | OutputSuper(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
155 | amb | 185 | else if(!strcmp(option_data,"oneway")) |
156 | amb | 623 | OutputOneway(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
157 | amb | 1174 | else if(!strncmp(option_data,"highway",7) && option_data[7]=='-' && (highway=HighwayType(option_data+8))!=Highway_None) |
158 | amb | 1003 | OutputHighway(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,highway); |
159 | amb | 1002 | else if(!strncmp(option_data,"transport",9) && option_data[9]=='-' && (transport=TransportType(option_data+10))!=Transport_None) |
160 | OutputTransport(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,transport); | ||
161 | amb | 1077 | else if(!strncmp(option_data,"barrier",7) && option_data[7]=='-' && (transport=TransportType(option_data+8))!=Transport_None) |
162 | OutputBarrier(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,transport); | ||
163 | amb | 623 | else if(!strcmp(option_data,"turns")) |
164 | OutputTurnRestrictions(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); | ||
165 | amb | 185 | else if(!strcmp(option_data,"speed")) |
166 | amb | 623 | OutputSpeedLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
167 | amb | 185 | else if(!strcmp(option_data,"weight")) |
168 | amb | 623 | OutputWeightLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
169 | amb | 185 | else if(!strcmp(option_data,"height")) |
170 | amb | 623 | OutputHeightLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
171 | amb | 185 | else if(!strcmp(option_data,"width")) |
172 | amb | 623 | OutputWidthLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
173 | amb | 185 | else if(!strcmp(option_data,"length")) |
174 | amb | 623 | OutputLengthLimits(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax); |
175 | amb | 1248 | else if(!strncmp(option_data,"property",8) && option_data[8]=='-' && (property=PropertyType(option_data+9))!=Property_None) |
176 | OutputProperty(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,property); | ||
177 | amb | 185 | else |
178 | amb | 490 | print_usage(0,option_data,NULL); |
179 | amb | 185 | } |
180 | amb | 6 | |
181 | amb | 185 | /* Print out statistics */ |
182 | amb | 6 | |
183 | amb | 185 | if(option_statistics) |
184 | { | ||
185 | struct stat buf; | ||
186 | amb | 6 | |
187 | amb | 185 | /* Examine the files */ |
188 | |||
189 | printf("Files\n"); | ||
190 | printf("-----\n"); | ||
191 | printf("\n"); | ||
192 | |||
193 | stat(nodes_filename,&buf); | ||
194 | |||
195 | amb | 1235 | printf("'%s%snodes.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size); |
196 | amb | 185 | printf("%s\n",RFC822Date(buf.st_mtime)); |
197 | printf("\n"); | ||
198 | |||
199 | stat(segments_filename,&buf); | ||
200 | |||
201 | amb | 1235 | printf("'%s%ssegments.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size); |
202 | amb | 185 | printf("%s\n",RFC822Date(buf.st_mtime)); |
203 | printf("\n"); | ||
204 | |||
205 | stat(ways_filename,&buf); | ||
206 | |||
207 | amb | 1235 | printf("'%s%sways.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size); |
208 | amb | 185 | printf("%s\n",RFC822Date(buf.st_mtime)); |
209 | printf("\n"); | ||
210 | |||
211 | amb | 625 | stat(relations_filename,&buf); |
212 | |||
213 | amb | 1235 | printf("'%s%srelations.mem' - %9"PRIu64" Bytes\n",prefix?prefix:"",prefix?"-":"",(uint64_t)buf.st_size); |
214 | amb | 625 | printf("%s\n",RFC822Date(buf.st_mtime)); |
215 | printf("\n"); | ||
216 | |||
217 | amb | 185 | /* Examine the nodes */ |
218 | |||
219 | printf("Nodes\n"); | ||
220 | printf("-----\n"); | ||
221 | printf("\n"); | ||
222 | |||
223 | amb | 879 | printf("sizeof(Node) =%9lu Bytes\n",(unsigned long)sizeof(Node)); |
224 | printf("Number =%9"Pindex_t"\n",OSMNodes->file.number); | ||
225 | printf("Number(super)=%9"Pindex_t"\n",OSMNodes->file.snumber); | ||
226 | amb | 185 | printf("\n"); |
227 | |||
228 | amb | 879 | printf("Lat bins= %4d\n",(int)OSMNodes->file.latbins); |
229 | printf("Lon bins= %4d\n",(int)OSMNodes->file.lonbins); | ||
230 | amb | 185 | printf("\n"); |
231 | |||
232 | amb | 879 | printf("Lat zero=%5d (%8.4f deg)\n",(int)OSMNodes->file.latzero,radians_to_degrees(latlong_to_radians(bin_to_latlong(OSMNodes->file.latzero)))); |
233 | printf("Lon zero=%5d (%8.4f deg)\n",(int)OSMNodes->file.lonzero,radians_to_degrees(latlong_to_radians(bin_to_latlong(OSMNodes->file.lonzero)))); | ||
234 | amb | 185 | |
235 | /* Examine the segments */ | ||
236 | |||
237 | printf("\n"); | ||
238 | printf("Segments\n"); | ||
239 | printf("--------\n"); | ||
240 | printf("\n"); | ||
241 | |||
242 | amb | 879 | printf("sizeof(Segment)=%9lu Bytes\n",(unsigned long)sizeof(Segment)); |
243 | printf("Number(total) =%9"Pindex_t"\n",OSMSegments->file.number); | ||
244 | printf("Number(super) =%9"Pindex_t"\n",OSMSegments->file.snumber); | ||
245 | printf("Number(normal) =%9"Pindex_t"\n",OSMSegments->file.nnumber); | ||
246 | amb | 185 | |
247 | /* Examine the ways */ | ||
248 | |||
249 | printf("\n"); | ||
250 | printf("Ways\n"); | ||
251 | printf("----\n"); | ||
252 | printf("\n"); | ||
253 | |||
254 | amb | 1103 | printf("sizeof(Way)=%9lu Bytes\n",(unsigned long)sizeof(Way)); |
255 | printf("Number =%9"Pindex_t"\n",OSMWays->file.number); | ||
256 | amb | 202 | printf("\n"); |
257 | |||
258 | amb | 628 | stat(ways_filename,&buf); |
259 | amb | 1103 | printf("Total names=%9lu Bytes\n",(unsigned long)buf.st_size-(unsigned long)sizeof(Ways)-(unsigned long)OSMWays->file.number*(unsigned long)sizeof(Way)); |
260 | amb | 307 | printf("\n"); |
261 | |||
262 | amb | 526 | printf("Included highways : %s\n",HighwaysNameList(OSMWays->file.highways)); |
263 | amb | 460 | printf("Included transports: %s\n",AllowedNameList(OSMWays->file.allow)); |
264 | printf("Included properties: %s\n",PropertiesNameList(OSMWays->file.props)); | ||
265 | amb | 565 | |
266 | /* Examine the relations */ | ||
267 | |||
268 | printf("\n"); | ||
269 | printf("Relations\n"); | ||
270 | printf("---------\n"); | ||
271 | printf("\n"); | ||
272 | |||
273 | amb | 879 | printf("sizeof(TurnRelation)=%9lu Bytes\n",(unsigned long)sizeof(TurnRelation)); |
274 | printf("Number =%9"Pindex_t"\n",OSMRelations->file.trnumber); | ||
275 | amb | 185 | } |
276 | |||
277 | amb | 680 | /* Print out internal data (in plain text format) */ |
278 | amb | 202 | |
279 | if(option_dump) | ||
280 | { | ||
281 | index_t item; | ||
282 | |||
283 | for(arg=1;arg<argc;arg++) | ||
284 | amb | 254 | if(!strcmp(argv[arg],"--node=all")) |
285 | amb | 202 | { |
286 | amb | 453 | for(item=0;item<OSMNodes->file.number;item++) |
287 | amb | 254 | print_node(OSMNodes,item); |
288 | } | ||
289 | else if(!strncmp(argv[arg],"--node=",7)) | ||
290 | { | ||
291 | amb | 202 | item=atoi(&argv[arg][7]); |
292 | |||
293 | amb | 453 | if(item>=0 && item<OSMNodes->file.number) |
294 | amb | 301 | print_node(OSMNodes,item); |
295 | else | ||
296 | amb | 790 | printf("Invalid node number; minimum=0, maximum=%"Pindex_t".\n",OSMNodes->file.number-1); |
297 | amb | 202 | } |
298 | amb | 254 | else if(!strcmp(argv[arg],"--segment=all")) |
299 | { | ||
300 | amb | 459 | for(item=0;item<OSMSegments->file.number;item++) |
301 | amb | 254 | print_segment(OSMSegments,item); |
302 | } | ||
303 | amb | 202 | else if(!strncmp(argv[arg],"--segment=",10)) |
304 | { | ||
305 | item=atoi(&argv[arg][10]); | ||
306 | |||
307 | amb | 459 | if(item>=0 && item<OSMSegments->file.number) |
308 | amb | 301 | print_segment(OSMSegments,item); |
309 | else | ||
310 | amb | 790 | printf("Invalid segment number; minimum=0, maximum=%"Pindex_t".\n",OSMSegments->file.number-1); |
311 | amb | 202 | } |
312 | amb | 254 | else if(!strcmp(argv[arg],"--way=all")) |
313 | { | ||
314 | amb | 460 | for(item=0;item<OSMWays->file.number;item++) |
315 | amb | 254 | print_way(OSMWays,item); |
316 | } | ||
317 | amb | 202 | else if(!strncmp(argv[arg],"--way=",6)) |
318 | { | ||
319 | item=atoi(&argv[arg][6]); | ||
320 | |||
321 | amb | 460 | if(item>=0 && item<OSMWays->file.number) |
322 | amb | 301 | print_way(OSMWays,item); |
323 | else | ||
324 | amb | 790 | printf("Invalid way number; minimum=0, maximum=%"Pindex_t".\n",OSMWays->file.number-1); |
325 | amb | 202 | } |
326 | amb | 565 | else if(!strcmp(argv[arg],"--turn-relation=all")) |
327 | { | ||
328 | for(item=0;item<OSMRelations->file.trnumber;item++) | ||
329 | amb | 1150 | print_turn_relation(OSMRelations,item,OSMSegments,OSMNodes); |
330 | amb | 565 | } |
331 | else if(!strncmp(argv[arg],"--turn-relation=",16)) | ||
332 | { | ||
333 | amb | 626 | item=atoi(&argv[arg][16]); |
334 | amb | 565 | |
335 | if(item>=0 && item<OSMRelations->file.trnumber) | ||
336 | amb | 1150 | print_turn_relation(OSMRelations,item,OSMSegments,OSMNodes); |
337 | amb | 565 | else |
338 | amb | 790 | printf("Invalid turn relation number; minimum=0, maximum=%"Pindex_t".\n",OSMRelations->file.trnumber-1); |
339 | amb | 565 | } |
340 | amb | 202 | } |
341 | |||
342 | amb | 680 | /* Print out internal data (in OSM XML format) */ |
343 | amb | 405 | |
344 | if(option_dump_osm) | ||
345 | { | ||
346 | amb | 413 | if(coordcount>0 && coordcount!=4) |
347 | amb | 490 | print_usage(0,NULL,"The --dump-osm option must have all of --latmin, --latmax, --lonmin, --lonmax or none.\n"); |
348 | amb | 405 | |
349 | amb | 917 | print_head_osm(coordcount,latmin,latmax,lonmin,lonmax); |
350 | amb | 405 | |
351 | amb | 413 | if(coordcount) |
352 | amb | 918 | print_region_osm(OSMNodes,OSMSegments,OSMWays,OSMRelations,latmin,latmax,lonmin,lonmax,option_no_super); |
353 | amb | 413 | else |
354 | { | ||
355 | index_t item; | ||
356 | |||
357 | amb | 453 | for(item=0;item<OSMNodes->file.number;item++) |
358 | amb | 413 | print_node_osm(OSMNodes,item); |
359 | |||
360 | amb | 459 | for(item=0;item<OSMSegments->file.number;item++) |
361 | if(!option_no_super || IsNormalSegment(LookupSegment(OSMSegments,item,1))) | ||
362 | amb | 413 | print_segment_osm(OSMSegments,item,OSMWays); |
363 | amb | 565 | |
364 | for(item=0;item<OSMRelations->file.trnumber;item++) | ||
365 | amb | 1150 | print_turn_relation_osm(OSMRelations,item,OSMSegments,OSMNodes); |
366 | amb | 413 | } |
367 | |||
368 | amb | 405 | print_tail_osm(); |
369 | } | ||
370 | |||
371 | amb | 2 | return(0); |
372 | } | ||
373 | amb | 185 | |
374 | |||
375 | amb | 202 | /*++++++++++++++++++++++++++++++++++++++ |
376 | amb | 680 | Print out the contents of a node from the routing database (as plain text). |
377 | amb | 202 | |
378 | Nodes *nodes The set of nodes to use. | ||
379 | |||
380 | index_t item The node index to print. | ||
381 | ++++++++++++++++++++++++++++++++++++++*/ | ||
382 | |||
383 | amb | 681 | static void print_node(Nodes *nodes,index_t item) |
384 | amb | 202 | { |
385 | amb | 1078 | Node *nodep=LookupNode(nodes,item,1); |
386 | amb | 219 | double latitude,longitude; |
387 | amb | 202 | |
388 | GetLatLong(nodes,item,&latitude,&longitude); | ||
389 | |||
390 | amb | 790 | printf("Node %"Pindex_t"\n",item); |
391 | amb | 1078 | printf(" firstseg=%"Pindex_t"\n",nodep->firstseg); |
392 | printf(" latoffset=%d lonoffset=%d (latitude=%.6f longitude=%.6f)\n",nodep->latoffset,nodep->lonoffset,radians_to_degrees(latitude),radians_to_degrees(longitude)); | ||
393 | printf(" allow=%02x (%s)\n",nodep->allow,AllowedNameList(nodep->allow)); | ||
394 | if(IsSuperNode(nodep)) | ||
395 | amb | 202 | printf(" Super-Node\n"); |
396 | amb | 1263 | if(nodep->flags & NODE_MINIRNDBT) |
397 | printf(" Mini-roundabout\n"); | ||
398 | amb | 202 | } |
399 | |||
400 | |||
401 | /*++++++++++++++++++++++++++++++++++++++ | ||
402 | amb | 680 | Print out the contents of a segment from the routing database (as plain text). |
403 | amb | 202 | |
404 | Segments *segments The set of segments to use. | ||
405 | |||
406 | index_t item The segment index to print. | ||
407 | ++++++++++++++++++++++++++++++++++++++*/ | ||
408 | |||
409 | static void print_segment(Segments *segments,index_t item) | ||
410 | { | ||
411 | amb | 1078 | Segment *segmentp=LookupSegment(segments,item,1); |
412 | amb | 202 | |
413 | amb | 790 | printf("Segment %"Pindex_t"\n",item); |
414 | amb | 1078 | printf(" node1=%"Pindex_t" node2=%"Pindex_t"\n",segmentp->node1,segmentp->node2); |
415 | printf(" next2=%"Pindex_t"\n",segmentp->next2); | ||
416 | printf(" way=%"Pindex_t"\n",segmentp->way); | ||
417 | amb | 1168 | printf(" distance=%d (%.3f km)\n",DISTANCE(segmentp->distance),distance_to_km(DISTANCE(segmentp->distance))); |
418 | amb | 1078 | if(IsSuperSegment(segmentp) && IsNormalSegment(segmentp)) |
419 | amb | 202 | printf(" Super-Segment AND normal Segment\n"); |
420 | amb | 1078 | else if(IsSuperSegment(segmentp) && !IsNormalSegment(segmentp)) |
421 | amb | 202 | printf(" Super-Segment\n"); |
422 | amb | 1078 | if(IsOnewayTo(segmentp,segmentp->node1)) |
423 | amb | 202 | printf(" One-Way from node2 to node1\n"); |
424 | amb | 1078 | if(IsOnewayTo(segmentp,segmentp->node2)) |
425 | amb | 202 | printf(" One-Way from node1 to node2\n"); |
426 | } | ||
427 | |||
428 | |||
429 | /*++++++++++++++++++++++++++++++++++++++ | ||
430 | amb | 680 | Print out the contents of a way from the routing database (as plain text). |
431 | amb | 202 | |
432 | Ways *ways The set of ways to use. | ||
433 | |||
434 | index_t item The way index to print. | ||
435 | ++++++++++++++++++++++++++++++++++++++*/ | ||
436 | |||
437 | static void print_way(Ways *ways,index_t item) | ||
438 | { | ||
439 | amb | 1078 | Way *wayp=LookupWay(ways,item,1); |
440 | char *name=WayName(ways,wayp); | ||
441 | amb | 202 | |
442 | amb | 790 | printf("Way %"Pindex_t"\n",item); |
443 | amb | 705 | if(*name) |
444 | printf(" name=%s\n",name); | ||
445 | amb | 1174 | printf(" type=%02x (%s%s%s)\n",wayp->type,HighwayName(HIGHWAY(wayp->type)),wayp->type&Highway_OneWay?",One-Way":"",wayp->type&Highway_Roundabout?",Roundabout":""); |
446 | amb | 1078 | printf(" allow=%02x (%s)\n",wayp->allow,AllowedNameList(wayp->allow)); |
447 | if(wayp->props) | ||
448 | printf(" props=%02x (%s)\n",wayp->props,PropertiesNameList(wayp->props)); | ||
449 | if(wayp->speed) | ||
450 | printf(" speed=%d (%d km/hr)\n",wayp->speed,speed_to_kph(wayp->speed)); | ||
451 | if(wayp->weight) | ||
452 | printf(" weight=%d (%.1f tonnes)\n",wayp->weight,weight_to_tonnes(wayp->weight)); | ||
453 | if(wayp->height) | ||
454 | printf(" height=%d (%.1f m)\n",wayp->height,height_to_metres(wayp->height)); | ||
455 | if(wayp->width) | ||
456 | printf(" width=%d (%.1f m)\n",wayp->width,width_to_metres(wayp->width)); | ||
457 | if(wayp->length) | ||
458 | printf(" length=%d (%.1f m)\n",wayp->length,length_to_metres(wayp->length)); | ||
459 | amb | 202 | } |
460 | |||
461 | |||
462 | amb | 405 | /*++++++++++++++++++++++++++++++++++++++ |
463 | amb | 680 | Print out the contents of a turn relation from the routing database (as plain text). |
464 | amb | 565 | |
465 | Relations *relations The set of relations to use. | ||
466 | |||
467 | index_t item The turn relation index to print. | ||
468 | |||
469 | Segments *segments The set of segments to use. | ||
470 | |||
471 | Nodes *nodes The set of nodes to use. | ||
472 | ++++++++++++++++++++++++++++++++++++++*/ | ||
473 | |||
474 | amb | 1150 | static void print_turn_relation(Relations *relations,index_t item,Segments *segments,Nodes *nodes) |
475 | amb | 565 | { |
476 | amb | 1078 | Segment *segmentp; |
477 | TurnRelation *relationp=LookupTurnRelation(relations,item,1); | ||
478 | Node *nodep=LookupNode(nodes,relationp->via,1); | ||
479 | amb | 565 | index_t from_way=NO_WAY,to_way=NO_WAY; |
480 | amb | 599 | index_t from_node=NO_NODE,to_node=NO_NODE; |
481 | amb | 565 | |
482 | amb | 1078 | segmentp=FirstSegment(segments,nodep,1); |
483 | amb | 565 | |
484 | do | ||
485 | { | ||
486 | amb | 1078 | index_t seg=IndexSegment(segments,segmentp); |
487 | amb | 565 | |
488 | amb | 1078 | if(seg==relationp->from) |
489 | amb | 599 | { |
490 | amb | 1078 | from_node=OtherNode(segmentp,relationp->from); |
491 | from_way=segmentp->way; | ||
492 | amb | 599 | } |
493 | amb | 565 | |
494 | amb | 1078 | if(seg==relationp->to) |
495 | amb | 599 | { |
496 | amb | 1078 | to_node=OtherNode(segmentp,relationp->to); |
497 | to_way=segmentp->way; | ||
498 | amb | 599 | } |
499 | |||
500 | amb | 1078 | segmentp=NextSegment(segments,segmentp,relationp->via); |
501 | amb | 565 | } |
502 | amb | 1078 | while(segmentp); |
503 | amb | 565 | |
504 | amb | 790 | printf("Relation %"Pindex_t"\n",item); |
505 | amb | 1078 | printf(" from=%"Pindex_t" (segment) = %"Pindex_t" (way) = %"Pindex_t" (node)\n",relationp->from,from_way,from_node); |
506 | printf(" via=%"Pindex_t" (node)\n",relationp->via); | ||
507 | printf(" to=%"Pindex_t" (segment) = %"Pindex_t" (way) = %"Pindex_t" (node)\n",relationp->to,to_way,to_node); | ||
508 | if(relationp->except) | ||
509 | printf(" except=%02x (%s)\n",relationp->except,AllowedNameList(relationp->except)); | ||
510 | amb | 565 | } |
511 | |||
512 | |||
513 | /*++++++++++++++++++++++++++++++++++++++ | ||
514 | amb | 405 | Print out a header in OSM XML format. |
515 | amb | 918 | |
516 | int coordcount If true then include a bounding box. | ||
517 | |||
518 | double latmin The minimum latitude. | ||
519 | |||
520 | double latmax The maximum latitude. | ||
521 | |||
522 | double lonmin The minimum longitude. | ||
523 | |||
524 | double lonmax The maximum longitude. | ||
525 | amb | 405 | ++++++++++++++++++++++++++++++++++++++*/ |
526 | |||
527 | amb | 917 | static void print_head_osm(int coordcount,double latmin,double latmax,double lonmin,double lonmax) |
528 | amb | 405 | { |
529 | printf("<?xml version='1.0' encoding='UTF-8'?>\n"); | ||
530 | amb | 847 | printf("<osm version='0.6' generator='Routino'>\n"); |
531 | amb | 917 | |
532 | if(coordcount) | ||
533 | printf(" <bounds minlat='%.6f' maxlat='%.6f' minlon='%.6f' maxlon='%.6f' />\n", | ||
534 | radians_to_degrees(latmin),radians_to_degrees(latmax),radians_to_degrees(lonmin),radians_to_degrees(lonmax)); | ||
535 | amb | 405 | } |
536 | |||
537 | |||
538 | /*++++++++++++++++++++++++++++++++++++++ | ||
539 | amb | 918 | Print a region of the database in OSM XML format. |
540 | |||
541 | Nodes *nodes The set of nodes to use. | ||
542 | |||
543 | Segments *segments The set of segments to use. | ||
544 | |||
545 | Ways *ways The set of ways to use. | ||
546 | |||
547 | Relations *relations The set of relations to use. | ||
548 | |||
549 | double latmin The minimum latitude. | ||
550 | |||
551 | double latmax The maximum latitude. | ||
552 | |||
553 | double lonmin The minimum longitude. | ||
554 | |||
555 | double lonmax The maximum longitude. | ||
556 | |||
557 | int option_no_super The option to print no super-segments. | ||
558 | ++++++++++++++++++++++++++++++++++++++*/ | ||
559 | |||
560 | static void print_region_osm(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations, | ||
561 | double latmin,double latmax,double lonmin,double lonmax,int option_no_super) | ||
562 | { | ||
563 | ll_bin_t latminbin=latlong_to_bin(radians_to_latlong(latmin))-nodes->file.latzero; | ||
564 | ll_bin_t latmaxbin=latlong_to_bin(radians_to_latlong(latmax))-nodes->file.latzero; | ||
565 | ll_bin_t lonminbin=latlong_to_bin(radians_to_latlong(lonmin))-nodes->file.lonzero; | ||
566 | ll_bin_t lonmaxbin=latlong_to_bin(radians_to_latlong(lonmax))-nodes->file.lonzero; | ||
567 | ll_bin_t latb,lonb; | ||
568 | index_t item,index1,index2; | ||
569 | |||
570 | if(latminbin<0) latminbin=0; | ||
571 | if(latmaxbin>nodes->file.latbins) latmaxbin=nodes->file.latbins-1; | ||
572 | if(lonminbin<0) lonminbin=0; | ||
573 | if(lonmaxbin>nodes->file.lonbins) lonmaxbin=nodes->file.lonbins-1; | ||
574 | |||
575 | /* Loop through all of the nodes. */ | ||
576 | |||
577 | for(latb=latminbin;latb<=latmaxbin;latb++) | ||
578 | for(lonb=lonminbin;lonb<=lonmaxbin;lonb++) | ||
579 | { | ||
580 | ll_bin2_t llbin=lonb*nodes->file.latbins+latb; | ||
581 | |||
582 | if(llbin<0 || llbin>(nodes->file.latbins*nodes->file.lonbins)) | ||
583 | continue; | ||
584 | |||
585 | index1=LookupNodeOffset(nodes,llbin); | ||
586 | index2=LookupNodeOffset(nodes,llbin+1); | ||
587 | |||
588 | for(item=index1;item<index2;item++) | ||
589 | { | ||
590 | amb | 1078 | Node *nodep=LookupNode(nodes,item,1); |
591 | double lat=latlong_to_radians(bin_to_latlong(nodes->file.latzero+latb)+off_to_latlong(nodep->latoffset)); | ||
592 | double lon=latlong_to_radians(bin_to_latlong(nodes->file.lonzero+lonb)+off_to_latlong(nodep->lonoffset)); | ||
593 | amb | 918 | |
594 | if(lat>latmin && lat<latmax && lon>lonmin && lon<lonmax) | ||
595 | { | ||
596 | amb | 1078 | Segment *segmentp; |
597 | amb | 918 | |
598 | print_node_osm(nodes,item); | ||
599 | |||
600 | amb | 1078 | segmentp=FirstSegment(segments,nodep,1); |
601 | amb | 918 | |
602 | amb | 1078 | while(segmentp) |
603 | amb | 918 | { |
604 | double olat,olon; | ||
605 | amb | 1078 | index_t oitem=OtherNode(segmentp,item); |
606 | amb | 918 | |
607 | GetLatLong(nodes,oitem,&olat,&olon); | ||
608 | |||
609 | if(olat>latmin && olat<latmax && olon>lonmin && olon<lonmax) | ||
610 | if(item>oitem) | ||
611 | amb | 1078 | if(!option_no_super || IsNormalSegment(segmentp)) |
612 | print_segment_osm(segments,IndexSegment(segments,segmentp),ways); | ||
613 | amb | 918 | |
614 | amb | 1078 | segmentp=NextSegment(segments,segmentp,item); |
615 | amb | 918 | } |
616 | |||
617 | amb | 1078 | if(IsTurnRestrictedNode(nodep)) |
618 | amb | 918 | { |
619 | index_t relindex=FindFirstTurnRelation1(relations,item); | ||
620 | |||
621 | while(relindex!=NO_RELATION) | ||
622 | { | ||
623 | amb | 1150 | print_turn_relation_osm(relations,relindex,segments,nodes); |
624 | amb | 918 | |
625 | relindex=FindNextTurnRelation1(relations,relindex); | ||
626 | } | ||
627 | } | ||
628 | } | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | |||
633 | |||
634 | /*++++++++++++++++++++++++++++++++++++++ | ||
635 | amb | 680 | Print out the contents of a node from the routing database (in OSM XML format). |
636 | amb | 405 | |
637 | Nodes *nodes The set of nodes to use. | ||
638 | |||
639 | index_t item The node index to print. | ||
640 | ++++++++++++++++++++++++++++++++++++++*/ | ||
641 | |||
642 | amb | 681 | static void print_node_osm(Nodes *nodes,index_t item) |
643 | amb | 405 | { |
644 | amb | 1078 | Node *nodep=LookupNode(nodes,item,1); |
645 | amb | 405 | double latitude,longitude; |
646 | amb | 537 | int i; |
647 | amb | 405 | |
648 | GetLatLong(nodes,item,&latitude,&longitude); | ||
649 | |||
650 | amb | 1078 | if(nodep->allow==Transports_ALL && nodep->flags==0) |
651 | amb | 537 | printf(" <node id='%lu' lat='%.7f' lon='%.7f' version='1' />\n",(unsigned long)item+1,radians_to_degrees(latitude),radians_to_degrees(longitude)); |
652 | else | ||
653 | amb | 405 | { |
654 | printf(" <node id='%lu' lat='%.7f' lon='%.7f' version='1'>\n",(unsigned long)item+1,radians_to_degrees(latitude),radians_to_degrees(longitude)); | ||
655 | amb | 469 | |
656 | amb | 1078 | if(nodep->flags & NODE_SUPER) |
657 | amb | 537 | printf(" <tag k='routino:super' v='yes' />\n"); |
658 | |||
659 | amb | 1078 | if(nodep->flags & NODE_UTURN) |
660 | amb | 667 | printf(" <tag k='routino:uturn' v='yes' />\n"); |
661 | |||
662 | amb | 1078 | if(nodep->flags & NODE_MINIRNDBT) |
663 | amb | 1263 | printf(" <tag k='junction' v='roundabout' />\n"); |
664 | amb | 537 | |
665 | amb | 1078 | if(nodep->flags & NODE_TURNRSTRCT) |
666 | amb | 667 | printf(" <tag k='routino:turnrestriction' v='yes' />\n"); |
667 | |||
668 | amb | 469 | for(i=1;i<Transport_Count;i++) |
669 | amb | 1078 | if(!(nodep->allow & TRANSPORTS(i))) |
670 | amb | 470 | printf(" <tag k='%s' v='no' />\n",TransportName(i)); |
671 | amb | 469 | |
672 | amb | 405 | printf(" </node>\n"); |
673 | } | ||
674 | } | ||
675 | |||
676 | |||
677 | /*++++++++++++++++++++++++++++++++++++++ | ||
678 | amb | 680 | Print out the contents of a segment from the routing database (as a way in OSM XML format). |
679 | amb | 405 | |
680 | Segments *segments The set of segments to use. | ||
681 | |||
682 | index_t item The segment index to print. | ||
683 | |||
684 | Ways *ways The set of ways to use. | ||
685 | ++++++++++++++++++++++++++++++++++++++*/ | ||
686 | |||
687 | static void print_segment_osm(Segments *segments,index_t item,Ways *ways) | ||
688 | { | ||
689 | amb | 1078 | Segment *segmentp=LookupSegment(segments,item,1); |
690 | Way *wayp=LookupWay(ways,segmentp->way,1); | ||
691 | char *name=WayName(ways,wayp); | ||
692 | amb | 405 | int i; |
693 | |||
694 | printf(" <way id='%lu' version='1'>\n",(unsigned long)item+1); | ||
695 | |||
696 | amb | 1078 | if(IsOnewayTo(segmentp,segmentp->node1)) |
697 | amb | 405 | { |
698 | amb | 1078 | printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node2+1); |
699 | printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node1+1); | ||
700 | amb | 405 | } |
701 | else | ||
702 | { | ||
703 | amb | 1078 | printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node1+1); |
704 | printf(" <nd ref='%lu' />\n",(unsigned long)segmentp->node2+1); | ||
705 | amb | 405 | } |
706 | |||
707 | amb | 1078 | if(IsSuperSegment(segmentp)) |
708 | amb | 405 | printf(" <tag k='routino:super' v='yes' />\n"); |
709 | amb | 1078 | if(IsNormalSegment(segmentp)) |
710 | amb | 405 | printf(" <tag k='routino:normal' v='yes' />\n"); |
711 | |||
712 | amb | 1168 | printf(" <tag k='routino:distance' v='%.3f' />\n",distance_to_km(DISTANCE(segmentp->distance))); |
713 | amb | 667 | |
714 | amb | 1174 | if(wayp->type & Highway_OneWay) |
715 | amb | 405 | printf(" <tag k='oneway' v='yes' />\n"); |
716 | |||
717 | amb | 1174 | if(wayp->type & Highway_Roundabout) |
718 | amb | 923 | printf(" <tag k='roundabout' v='yes' />\n"); |
719 | |||
720 | amb | 1078 | printf(" <tag k='highway' v='%s' />\n",HighwayName(HIGHWAY(wayp->type))); |
721 | amb | 405 | |
722 | amb | 1078 | if(IsNormalSegment(segmentp) && *name) |
723 | amb | 705 | printf(" <tag k='name' v='%s' />\n",ParseXML_Encode_Safe_XML(name)); |
724 | amb | 405 | |
725 | for(i=1;i<Transport_Count;i++) | ||
726 | amb | 1078 | if(wayp->allow & TRANSPORTS(i)) |
727 | amb | 405 | printf(" <tag k='%s' v='yes' />\n",TransportName(i)); |
728 | |||
729 | for(i=1;i<Property_Count;i++) | ||
730 | amb | 1078 | if(wayp->props & PROPERTIES(i)) |
731 | amb | 405 | printf(" <tag k='%s' v='yes' />\n",PropertyName(i)); |
732 | |||
733 | amb | 1078 | if(wayp->speed) |
734 | printf(" <tag k='maxspeed' v='%d' />\n",speed_to_kph(wayp->speed)); | ||
735 | amb | 405 | |
736 | amb | 1078 | if(wayp->weight) |
737 | printf(" <tag k='maxweight' v='%.1f' />\n",weight_to_tonnes(wayp->weight)); | ||
738 | if(wayp->height) | ||
739 | printf(" <tag k='maxheight' v='%.1f' />\n",height_to_metres(wayp->height)); | ||
740 | if(wayp->width) | ||
741 | printf(" <tag k='maxwidth' v='%.1f' />\n",width_to_metres(wayp->width)); | ||
742 | if(wayp->length) | ||
743 | printf(" <tag k='maxlength' v='%.1f' />\n",length_to_metres(wayp->length)); | ||
744 | amb | 405 | |
745 | printf(" </way>\n"); | ||
746 | } | ||
747 | |||
748 | |||
749 | /*++++++++++++++++++++++++++++++++++++++ | ||
750 | amb | 680 | Print out the contents of a turn relation from the routing database (in OSM XML format). |
751 | amb | 565 | |
752 | Relations *relations The set of relations to use. | ||
753 | |||
754 | index_t item The relation index to print. | ||
755 | |||
756 | Segments *segments The set of segments to use. | ||
757 | |||
758 | Nodes *nodes The set of nodes to use. | ||
759 | ++++++++++++++++++++++++++++++++++++++*/ | ||
760 | |||
761 | amb | 1150 | static void print_turn_relation_osm(Relations *relations,index_t item,Segments *segments,Nodes *nodes) |
762 | amb | 565 | { |
763 | amb | 1078 | TurnRelation *relationp=LookupTurnRelation(relations,item,1); |
764 | amb | 565 | |
765 | amb | 1078 | Segment *segmentp_from=LookupSegment(segments,relationp->from,1); |
766 | Segment *segmentp_to =LookupSegment(segments,relationp->to ,2); | ||
767 | amb | 618 | |
768 | amb | 1078 | double angle=TurnAngle(nodes,segmentp_from,segmentp_to,relationp->via); |
769 | amb | 618 | |
770 | char *restriction; | ||
771 | |||
772 | if(angle>150 || angle<-150) | ||
773 | restriction="no_u_turn"; | ||
774 | else if(angle>30) | ||
775 | restriction="no_right_turn"; | ||
776 | else if(angle<-30) | ||
777 | restriction="no_left_turn"; | ||
778 | else | ||
779 | restriction="no_straight_on"; | ||
780 | |||
781 | amb | 565 | printf(" <relation id='%lu' version='1'>\n",(unsigned long)item+1); |
782 | printf(" <tag k='type' v='restriction' />\n"); | ||
783 | amb | 618 | printf(" <tag k='restriction' v='%s'/>\n",restriction); |
784 | amb | 565 | |
785 | amb | 1078 | if(relationp->except) |
786 | printf(" <tag k='except' v='%s' />\n",AllowedNameList(relationp->except)); | ||
787 | amb | 565 | |
788 | amb | 1078 | printf(" <member type='way' ref='%lu' role='from' />\n",(unsigned long)relationp->from+1); |
789 | printf(" <member type='node' ref='%lu' role='via' />\n",(unsigned long)relationp->via+1); | ||
790 | printf(" <member type='way' ref='%lu' role='to' />\n",(unsigned long)relationp->to+1); | ||
791 | amb | 565 | |
792 | printf(" </relation>\n"); | ||
793 | } | ||
794 | |||
795 | |||
796 | /*++++++++++++++++++++++++++++++++++++++ | ||
797 | amb | 405 | Print out a tail in OSM XML format. |
798 | ++++++++++++++++++++++++++++++++++++++*/ | ||
799 | |||
800 | static void print_tail_osm(void) | ||
801 | { | ||
802 | printf("</osm>\n"); | ||
803 | } | ||
804 | |||
805 | |||
806 | /*+ Conversion from time_t to date string (day of week). +*/ | ||
807 | amb | 185 | static const char* const weekdays[7]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; |
808 | |||
809 | amb | 405 | /*+ Conversion from time_t to date string (month of year). +*/ |
810 | amb | 185 | static const char* const months[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; |
811 | |||
812 | |||
813 | /*++++++++++++++++++++++++++++++++++++++ | ||
814 | Convert the time into an RFC 822 compliant date. | ||
815 | |||
816 | char *RFC822Date Returns a pointer to a fixed string containing the date. | ||
817 | |||
818 | time_t t The time. | ||
819 | ++++++++++++++++++++++++++++++++++++++*/ | ||
820 | |||
821 | static char *RFC822Date(time_t t) | ||
822 | { | ||
823 | static char value[32]; | ||
824 | char weekday[4]; | ||
825 | char month[4]; | ||
826 | struct tm *tim; | ||
827 | |||
828 | tim=gmtime(&t); | ||
829 | |||
830 | strcpy(weekday,weekdays[tim->tm_wday]); | ||
831 | strcpy(month,months[tim->tm_mon]); | ||
832 | |||
833 | /* Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 */ | ||
834 | |||
835 | sprintf(value,"%3s, %02d %3s %4d %02d:%02d:%02d %s", | ||
836 | weekday, | ||
837 | tim->tm_mday, | ||
838 | month, | ||
839 | tim->tm_year+1900, | ||
840 | tim->tm_hour, | ||
841 | tim->tm_min, | ||
842 | tim->tm_sec, | ||
843 | "GMT" | ||
844 | ); | ||
845 | |||
846 | return(value); | ||
847 | } | ||
848 | amb | 342 | |
849 | |||
850 | /*++++++++++++++++++++++++++++++++++++++ | ||
851 | Print out the usage information. | ||
852 | |||
853 | int detail The level of detail to use - 0 = low, 1 = high. | ||
854 | amb | 490 | |
855 | const char *argerr The argument that gave the error (if there is one). | ||
856 | |||
857 | const char *err Other error message (if there is one). | ||
858 | amb | 342 | ++++++++++++++++++++++++++++++++++++++*/ |
859 | |||
860 | amb | 490 | static void print_usage(int detail,const char *argerr,const char *err) |
861 | amb | 342 | { |
862 | fprintf(stderr, | ||
863 | "Usage: filedumper [--help]\n" | ||
864 | " [--dir=<dirname>] [--prefix=<name>]\n" | ||
865 | " [--statistics]\n" | ||
866 | " [--visualiser --latmin=<latmin> --latmax=<latmax>\n" | ||
867 | " --lonmin=<lonmin> --lonmax=<lonmax>\n" | ||
868 | " --data=<data-type>]\n" | ||
869 | " [--dump [--node=<node> ...]\n" | ||
870 | " [--segment=<segment> ...]\n" | ||
871 | amb | 1150 | " [--way=<way> ...]\n" |
872 | amb | 599 | " [--turn-relation=<rel> ...]]\n" |
873 | amb | 413 | " [--dump-osm [--no-super]\n" |
874 | " [--latmin=<latmin> --latmax=<latmax>\n" | ||
875 | " --lonmin=<lonmin> --lonmax=<lonmax>]]\n"); | ||
876 | amb | 342 | |
877 | amb | 490 | if(argerr) |
878 | fprintf(stderr, | ||
879 | "\n" | ||
880 | "Error with command line parameter: %s\n",argerr); | ||
881 | |||
882 | amb | 491 | if(err) |
883 | amb | 490 | fprintf(stderr, |
884 | "\n" | ||
885 | "Error: %s\n",err); | ||
886 | |||
887 | amb | 342 | if(detail) |
888 | fprintf(stderr, | ||
889 | "\n" | ||
890 | "--help Prints this information.\n" | ||
891 | "\n" | ||
892 | "--dir=<dirname> The directory containing the routing database.\n" | ||
893 | "--prefix=<name> The filename prefix for the routing database.\n" | ||
894 | "\n" | ||
895 | "--statistics Print statistics about the routing database.\n" | ||
896 | "\n" | ||
897 | "--visualiser Extract selected data from the routing database:\n" | ||
898 | " --latmin=<latmin> * the minimum latitude (degrees N).\n" | ||
899 | " --latmax=<latmax> * the maximum latitude (degrees N).\n" | ||
900 | " --lonmin=<lonmin> * the minimum longitude (degrees E).\n" | ||
901 | " --lonmax=<lonmax> * the maximum longitude (degrees E).\n" | ||
902 | " --data=<data-type> * the type of data to select.\n" | ||
903 | "\n" | ||
904 | " <data-type> can be selected from:\n" | ||
905 | amb | 1002 | " junctions = segment count at each junction.\n" |
906 | " super = super-node and super-segments.\n" | ||
907 | " oneway = oneway segments.\n" | ||
908 | amb | 1003 | " highway-* = segments of the specified highway type.\n" |
909 | amb | 1002 | " transport-* = segments allowing the specified transport type.\n" |
910 | amb | 1077 | " barrier-* = nodes disallowing the specified transport type.\n" |
911 | amb | 1002 | " turns = turn restrictions.\n" |
912 | " speed = speed limits.\n" | ||
913 | " weight = weight limits.\n" | ||
914 | " height = height limits.\n" | ||
915 | " width = width limits.\n" | ||
916 | " length = length limits.\n" | ||
917 | amb | 1248 | " property-* = segments with the specified property.\n" |
918 | amb | 342 | "\n" |
919 | "--dump Dump selected contents of the database.\n" | ||
920 | amb | 599 | " --node=<node> * the node with the selected index.\n" |
921 | " --segment=<segment> * the segment with the selected index.\n" | ||
922 | " --way=<way> * the way with the selected index.\n" | ||
923 | " --turn-relation=<rel> * the turn relation with the selected index.\n" | ||
924 | amb | 405 | " Use 'all' instead of a number to get all of them.\n" |
925 | "\n" | ||
926 | amb | 413 | "--dump-osm Dump all or part of the database as an XML file.\n" |
927 | " --no-super * exclude the super-segments.\n" | ||
928 | " --latmin=<latmin> * the minimum latitude (degrees N).\n" | ||
929 | " --latmax=<latmax> * the maximum latitude (degrees N).\n" | ||
930 | " --lonmin=<lonmin> * the minimum longitude (degrees E).\n" | ||
931 | " --lonmax=<lonmax> * the maximum longitude (degrees E).\n"); | ||
932 | amb | 342 | |
933 | exit(!detail); | ||
934 | } |
Properties
Name | Value |
---|---|
cvs:description | Test program for mmap files. |