Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /branches/MSVC/src/output.c
Parent Directory
|
Revision Log
Revision 1078 -
(hide annotations)
(download)
(as text)
Fri Sep 28 16:34:20 2012 UTC (12 years, 5 months ago) by amb
Original Path: trunk/src/output.c
File MIME type: text/x-csrc
File size: 35846 byte(s)
Fri Sep 28 16:34:20 2012 UTC (12 years, 5 months ago) by amb
Original Path: trunk/src/output.c
File MIME type: text/x-csrc
File size: 35846 byte(s)
Rename some variables so that pointers to nodes, segments, ways and relations use the Hungarian notation "p" suffix (only applies to the router, not planetsplitter).
1 | amb | 160 | /*************************************** |
2 | Routing output generator. | ||
3 | |||
4 | Part of the Routino routing software. | ||
5 | ******************/ /****************** | ||
6 | amb | 955 | This file Copyright 2008-2012 Andrew M. Bishop |
7 | amb | 160 | |
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 | amb | 165 | #include <stdlib.h> |
24 | amb | 160 | #include <string.h> |
25 | amb | 164 | #include <ctype.h> |
26 | amb | 160 | #include <stdio.h> |
27 | amb | 316 | #include <math.h> |
28 | amb | 330 | #include <errno.h> |
29 | amb | 164 | #include <unistd.h> |
30 | amb | 160 | |
31 | #include "types.h" | ||
32 | #include "nodes.h" | ||
33 | #include "segments.h" | ||
34 | #include "ways.h" | ||
35 | amb | 449 | |
36 | #include "functions.h" | ||
37 | amb | 532 | #include "fakes.h" |
38 | amb | 449 | #include "translations.h" |
39 | amb | 160 | #include "results.h" |
40 | amb | 378 | #include "xmlparse.h" |
41 | amb | 160 | |
42 | amb | 955 | |
43 | amb | 927 | /* Constants */ |
44 | amb | 160 | |
45 | amb | 927 | #define IMP_IGNORE -1 /*+ Ignore this point. +*/ |
46 | #define IMP_UNIMPORTANT 0 /*+ An unimportant, intermediate, node. +*/ | ||
47 | #define IMP_RB_NOT_EXIT 1 /*+ A roundabout exit that is not taken. +*/ | ||
48 | #define IMP_JUNCT_CONT 2 /*+ An un-interesting junction where the route continues without comment. +*/ | ||
49 | #define IMP_CHANGE 3 /*+ The highway changes type but nothing else happens. +*/ | ||
50 | #define IMP_JUNCT_IMPORT 4 /*+ An interesting junction to be described. +*/ | ||
51 | #define IMP_RB_ENTRY 5 /*+ The entrance to a roundabout. +*/ | ||
52 | #define IMP_RB_EXIT 6 /*+ The exit from a roundabout. +*/ | ||
53 | amb | 929 | #define IMP_MINI_RB 7 /*+ The location of a mini-roundabout. +*/ |
54 | #define IMP_UTURN 8 /*+ The location of a U-turn. +*/ | ||
55 | #define IMP_WAYPOINT 9 /*+ A waypoint. +*/ | ||
56 | amb | 927 | |
57 | amb | 955 | |
58 | amb | 360 | /* Global variables */ |
59 | |||
60 | amb | 160 | /*+ The option to calculate the quickest route insted of the shortest. +*/ |
61 | extern int option_quickest; | ||
62 | |||
63 | amb | 324 | /*+ The options to select the format of the output. +*/ |
64 | extern int option_html,option_gpx_track,option_gpx_route,option_text,option_text_all; | ||
65 | |||
66 | amb | 955 | |
67 | amb | 360 | /* Local variables */ |
68 | |||
69 | amb | 171 | /*+ Heuristics for determining if a junction is important. +*/ |
70 | amb | 300 | static char junction_other_way[Way_Count][Way_Count]= |
71 | amb | 492 | { /* M, T, P, S, T, U, R, S, T, C, P, S, F = Way type of route not taken */ |
72 | { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Motorway */ | ||
73 | { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Trunk */ | ||
74 | { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Primary */ | ||
75 | { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Secondary */ | ||
76 | { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Tertiary */ | ||
77 | { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1 }, /* Unclassified */ | ||
78 | { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 }, /* Residential */ | ||
79 | { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 }, /* Service */ | ||
80 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1 }, /* Track */ | ||
81 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1 }, /* Cycleway */ | ||
82 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Path */ | ||
83 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Steps */ | ||
84 | { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Ferry */ | ||
85 | amb | 171 | }; |
86 | amb | 165 | |
87 | amb | 360 | |
88 | amb | 160 | /*++++++++++++++++++++++++++++++++++++++ |
89 | amb | 379 | Print the optimum route between two nodes. |
90 | |||
91 | Results **results The set of results to print (some may be NULL - ignore them). | ||
92 | |||
93 | int nresults The number of results in the list. | ||
94 | |||
95 | amb | 680 | Nodes *nodes The set of nodes to use. |
96 | amb | 379 | |
97 | Segments *segments The set of segments to use. | ||
98 | |||
99 | amb | 680 | Ways *ways The set of ways to use. |
100 | amb | 379 | |
101 | Profile *profile The profile containing the transport type, speeds and allowed highways. | ||
102 | amb | 164 | ++++++++++++++++++++++++++++++++++++++*/ |
103 | amb | 160 | |
104 | amb | 379 | void PrintRoute(Results **results,int nresults,Nodes *nodes,Segments *segments,Ways *ways,Profile *profile) |
105 | amb | 164 | { |
106 | amb | 379 | FILE *htmlfile=NULL,*gpxtrackfile=NULL,*gpxroutefile=NULL,*textfile=NULL,*textallfile=NULL; |
107 | |||
108 | amb | 922 | char *prev_bearing=NULL,*prev_wayname=NULL; |
109 | amb | 379 | distance_t cum_distance=0; |
110 | duration_t cum_duration=0; | ||
111 | amb | 922 | |
112 | int point=1; | ||
113 | amb | 683 | int segment_count=0,route_count=0; |
114 | int point_count=0; | ||
115 | amb | 926 | int roundabout=0; |
116 | amb | 379 | |
117 | amb | 164 | /* Open the files */ |
118 | amb | 160 | |
119 | if(option_quickest==0) | ||
120 | { | ||
121 | /* Print the result for the shortest route */ | ||
122 | |||
123 | amb | 324 | if(option_html) |
124 | htmlfile =fopen("shortest.html","w"); | ||
125 | if(option_gpx_track) | ||
126 | gpxtrackfile=fopen("shortest-track.gpx","w"); | ||
127 | if(option_gpx_route) | ||
128 | gpxroutefile=fopen("shortest-route.gpx","w"); | ||
129 | if(option_text) | ||
130 | textfile =fopen("shortest.txt","w"); | ||
131 | if(option_text_all) | ||
132 | textallfile =fopen("shortest-all.txt","w"); | ||
133 | amb | 177 | |
134 | amb | 324 | if(option_html && !htmlfile) |
135 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'shortest.html' for writing [%s].\n",strerror(errno)); |
136 | amb | 324 | if(option_gpx_track && !gpxtrackfile) |
137 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'shortest-track.gpx' for writing [%s].\n",strerror(errno)); |
138 | amb | 324 | if(option_gpx_route && !gpxroutefile) |
139 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'shortest-route.gpx' for writing [%s].\n",strerror(errno)); |
140 | amb | 324 | if(option_text && !textfile) |
141 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'shortest.txt' for writing [%s].\n",strerror(errno)); |
142 | amb | 324 | if(option_text_all && !textallfile) |
143 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'shortest-all.txt' for writing [%s].\n",strerror(errno)); |
144 | amb | 160 | } |
145 | else | ||
146 | { | ||
147 | /* Print the result for the quickest route */ | ||
148 | |||
149 | amb | 324 | if(option_html) |
150 | htmlfile =fopen("quickest.html","w"); | ||
151 | if(option_gpx_track) | ||
152 | gpxtrackfile=fopen("quickest-track.gpx","w"); | ||
153 | if(option_gpx_route) | ||
154 | gpxroutefile=fopen("quickest-route.gpx","w"); | ||
155 | if(option_text) | ||
156 | textfile =fopen("quickest.txt","w"); | ||
157 | if(option_text_all) | ||
158 | textallfile =fopen("quickest-all.txt","w"); | ||
159 | amb | 177 | |
160 | amb | 324 | if(option_html && !htmlfile) |
161 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'quickest.html' for writing [%s].\n",strerror(errno)); |
162 | amb | 324 | if(option_gpx_track && !gpxtrackfile) |
163 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'quickest-track.gpx' for writing [%s].\n",strerror(errno)); |
164 | amb | 324 | if(option_gpx_route && !gpxroutefile) |
165 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'quickest-route.gpx' for writing [%s].\n",strerror(errno)); |
166 | amb | 324 | if(option_text && !textfile) |
167 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'quickest.txt' for writing [%s].\n",strerror(errno)); |
168 | amb | 324 | if(option_text_all && !textallfile) |
169 | amb | 330 | fprintf(stderr,"Warning: Cannot open file 'quickest-all.txt' for writing [%s].\n",strerror(errno)); |
170 | amb | 160 | } |
171 | |||
172 | amb | 164 | /* Print the head of the files */ |
173 | amb | 160 | |
174 | amb | 323 | if(htmlfile) |
175 | { | ||
176 | fprintf(htmlfile,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"); | ||
177 | fprintf(htmlfile,"<HTML>\n"); | ||
178 | amb | 893 | if(translate_xml_copyright_creator[0] && translate_xml_copyright_creator[1]) |
179 | fprintf(htmlfile,"<!-- %s : %s -->\n",translate_xml_copyright_creator[0],translate_xml_copyright_creator[1]); | ||
180 | if(translate_xml_copyright_source[0] && translate_xml_copyright_source[1]) | ||
181 | fprintf(htmlfile,"<!-- %s : %s -->\n",translate_xml_copyright_source[0],translate_xml_copyright_source[1]); | ||
182 | if(translate_xml_copyright_license[0] && translate_xml_copyright_license[1]) | ||
183 | fprintf(htmlfile,"<!-- %s : %s -->\n",translate_xml_copyright_license[0],translate_xml_copyright_license[1]); | ||
184 | amb | 323 | fprintf(htmlfile,"<HEAD>\n"); |
185 | amb | 378 | fprintf(htmlfile,"<TITLE>"); |
186 | amb | 893 | fprintf(htmlfile,translate_html_title,option_quickest?translate_xml_route_quickest:translate_xml_route_shortest); |
187 | amb | 378 | fprintf(htmlfile,"</TITLE>\n"); |
188 | amb | 485 | fprintf(htmlfile,"<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"); |
189 | fprintf(htmlfile,"<STYLE type=\"text/css\">\n"); | ||
190 | amb | 323 | fprintf(htmlfile,"<!--\n"); |
191 | amb | 376 | fprintf(htmlfile," table {table-layout: fixed; border: none; border-collapse: collapse;}\n"); |
192 | fprintf(htmlfile," table.c {color: grey; font-size: x-small;} /* copyright */\n"); | ||
193 | fprintf(htmlfile," tr {border: 0px;}\n"); | ||
194 | fprintf(htmlfile," tr.c {display: none;} /* coords */\n"); | ||
195 | fprintf(htmlfile," tr.n {} /* node */\n"); | ||
196 | fprintf(htmlfile," tr.s {} /* segment */\n"); | ||
197 | fprintf(htmlfile," tr.t {font-weight: bold;} /* total */\n"); | ||
198 | fprintf(htmlfile," td.l {font-weight: bold;}\n"); | ||
199 | fprintf(htmlfile," td.r {}\n"); | ||
200 | fprintf(htmlfile," span.w {font-weight: bold;} /* waypoint */\n"); | ||
201 | fprintf(htmlfile," span.h {text-decoration: underline;} /* highway */\n"); | ||
202 | fprintf(htmlfile," span.d {} /* segment distance */\n"); | ||
203 | fprintf(htmlfile," span.j {font-style: italic;} /* total journey distance */\n"); | ||
204 | fprintf(htmlfile," span.t {font-variant: small-caps;} /* turn */\n"); | ||
205 | fprintf(htmlfile," span.b {font-variant: small-caps;} /* bearing */\n"); | ||
206 | amb | 323 | fprintf(htmlfile,"-->\n"); |
207 | fprintf(htmlfile,"</STYLE>\n"); | ||
208 | fprintf(htmlfile,"</HEAD>\n"); | ||
209 | fprintf(htmlfile,"<BODY>\n"); | ||
210 | amb | 378 | fprintf(htmlfile,"<H1>"); |
211 | amb | 893 | fprintf(htmlfile,translate_html_title,option_quickest?translate_xml_route_quickest:translate_xml_route_shortest); |
212 | amb | 378 | fprintf(htmlfile,"</H1>\n"); |
213 | amb | 323 | fprintf(htmlfile,"<table>\n"); |
214 | } | ||
215 | |||
216 | amb | 177 | if(gpxtrackfile) |
217 | { | ||
218 | fprintf(gpxtrackfile,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | ||
219 | fprintf(gpxtrackfile,"<gpx version=\"1.1\" creator=\"Routino\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"); | ||
220 | amb | 160 | |
221 | amb | 177 | fprintf(gpxtrackfile,"<metadata>\n"); |
222 | amb | 893 | fprintf(gpxtrackfile,"<desc>%s : %s</desc>\n",translate_xml_copyright_creator[0],translate_xml_copyright_creator[1]); |
223 | if(translate_xml_copyright_source[1]) | ||
224 | amb | 376 | { |
225 | amb | 893 | fprintf(gpxtrackfile,"<copyright author=\"%s\">\n",translate_xml_copyright_source[1]); |
226 | amb | 376 | |
227 | amb | 893 | if(translate_xml_copyright_license[1]) |
228 | fprintf(gpxtrackfile,"<license>%s</license>\n",translate_xml_copyright_license[1]); | ||
229 | amb | 376 | |
230 | amb | 177 | fprintf(gpxtrackfile,"</copyright>\n"); |
231 | amb | 376 | } |
232 | amb | 177 | fprintf(gpxtrackfile,"</metadata>\n"); |
233 | amb | 160 | |
234 | amb | 177 | fprintf(gpxtrackfile,"<trk>\n"); |
235 | amb | 376 | fprintf(gpxtrackfile,"<name>"); |
236 | amb | 893 | fprintf(gpxtrackfile,translate_gpx_name,option_quickest?translate_xml_route_quickest:translate_xml_route_shortest); |
237 | amb | 376 | fprintf(gpxtrackfile,"</name>\n"); |
238 | fprintf(gpxtrackfile,"<desc>"); | ||
239 | amb | 893 | fprintf(gpxtrackfile,translate_gpx_desc,option_quickest?translate_xml_route_quickest:translate_xml_route_shortest); |
240 | amb | 376 | fprintf(gpxtrackfile,"</desc>\n"); |
241 | amb | 177 | } |
242 | amb | 160 | |
243 | amb | 177 | if(gpxroutefile) |
244 | { | ||
245 | fprintf(gpxroutefile,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | ||
246 | fprintf(gpxroutefile,"<gpx version=\"1.1\" creator=\"Routino\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"); | ||
247 | amb | 160 | |
248 | amb | 177 | fprintf(gpxroutefile,"<metadata>\n"); |
249 | amb | 893 | fprintf(gpxroutefile,"<desc>%s : %s</desc>\n",translate_xml_copyright_creator[0],translate_xml_copyright_creator[1]); |
250 | if(translate_xml_copyright_source[1]) | ||
251 | amb | 376 | { |
252 | amb | 893 | fprintf(gpxroutefile,"<copyright author=\"%s\">\n",translate_xml_copyright_source[1]); |
253 | amb | 376 | |
254 | amb | 893 | if(translate_xml_copyright_license[1]) |
255 | fprintf(gpxroutefile,"<license>%s</license>\n",translate_xml_copyright_license[1]); | ||
256 | amb | 376 | |
257 | amb | 177 | fprintf(gpxroutefile,"</copyright>\n"); |
258 | amb | 376 | } |
259 | amb | 177 | fprintf(gpxroutefile,"</metadata>\n"); |
260 | amb | 160 | |
261 | amb | 177 | fprintf(gpxroutefile,"<rte>\n"); |
262 | amb | 360 | fprintf(gpxroutefile,"<name>"); |
263 | amb | 893 | fprintf(gpxroutefile,translate_gpx_name,option_quickest?translate_xml_route_quickest:translate_xml_route_shortest); |
264 | amb | 360 | fprintf(gpxroutefile,"</name>\n"); |
265 | amb | 376 | fprintf(gpxroutefile,"<desc>"); |
266 | amb | 893 | fprintf(gpxroutefile,translate_gpx_desc,option_quickest?translate_xml_route_quickest:translate_xml_route_shortest); |
267 | amb | 376 | fprintf(gpxroutefile,"</desc>\n"); |
268 | amb | 177 | } |
269 | amb | 160 | |
270 | amb | 177 | if(textfile) |
271 | { | ||
272 | amb | 893 | if(translate_raw_copyright_creator[0] && translate_raw_copyright_creator[1]) |
273 | fprintf(textfile,"# %s : %s\n",translate_raw_copyright_creator[0],translate_raw_copyright_creator[1]); | ||
274 | if(translate_raw_copyright_source[0] && translate_raw_copyright_source[1]) | ||
275 | fprintf(textfile,"# %s : %s\n",translate_raw_copyright_source[0],translate_raw_copyright_source[1]); | ||
276 | if(translate_raw_copyright_license[0] && translate_raw_copyright_license[1]) | ||
277 | fprintf(textfile,"# %s : %s\n",translate_raw_copyright_license[0],translate_raw_copyright_license[1]); | ||
278 | if((translate_raw_copyright_creator[0] && translate_raw_copyright_creator[1]) || | ||
279 | (translate_raw_copyright_source[0] && translate_raw_copyright_source[1]) || | ||
280 | (translate_raw_copyright_license[0] && translate_raw_copyright_license[1])) | ||
281 | amb | 177 | fprintf(textfile,"#\n"); |
282 | amb | 376 | |
283 | amb | 316 | fprintf(textfile,"#Latitude\tLongitude\tSection \tSection \tTotal \tTotal \tPoint\tTurn\tBearing\tHighway\n"); |
284 | fprintf(textfile,"# \t \tDistance\tDuration\tDistance\tDuration\tType \t \t \t \n"); | ||
285 | /* "%10.6f\t%11.6f\t%6.3f km\t%4.1f min\t%5.1f km\t%4.0f min\t%s\t %+d\t %+d\t%s\n" */ | ||
286 | amb | 177 | } |
287 | amb | 160 | |
288 | amb | 177 | if(textallfile) |
289 | { | ||
290 | amb | 893 | if(translate_raw_copyright_creator[0] && translate_raw_copyright_creator[1]) |
291 | fprintf(textallfile,"# %s : %s\n",translate_raw_copyright_creator[0],translate_raw_copyright_creator[1]); | ||
292 | if(translate_raw_copyright_source[0] && translate_raw_copyright_source[1]) | ||
293 | fprintf(textallfile,"# %s : %s\n",translate_raw_copyright_source[0],translate_raw_copyright_source[1]); | ||
294 | if(translate_raw_copyright_license[0] && translate_raw_copyright_license[1]) | ||
295 | fprintf(textallfile,"# %s : %s\n",translate_raw_copyright_license[0],translate_raw_copyright_license[1]); | ||
296 | if((translate_raw_copyright_creator[0] && translate_raw_copyright_creator[1]) || | ||
297 | (translate_raw_copyright_source[0] && translate_raw_copyright_source[1]) || | ||
298 | (translate_raw_copyright_license[0] && translate_raw_copyright_license[1])) | ||
299 | amb | 177 | fprintf(textallfile,"#\n"); |
300 | amb | 376 | |
301 | amb | 316 | fprintf(textallfile,"#Latitude\tLongitude\t Node\tType\tSegment\tSegment\tTotal\tTotal \tSpeed\tBearing\tHighway\n"); |
302 | fprintf(textallfile,"# \t \t \t \tDist \tDurat'n\tDist \tDurat'n\t \t \t \n"); | ||
303 | /* "%10.6f\t%11.6f\t%8d%c\t%s\t%5.3f\t%5.2f\t%5.2f\t%5.1f\t%3d\t%4d\t%s\n" */ | ||
304 | amb | 177 | } |
305 | amb | 160 | |
306 | amb | 922 | /* Loop through all the sections of the route and print them */ |
307 | amb | 164 | |
308 | amb | 316 | while(!results[point]) |
309 | point++; | ||
310 | amb | 164 | |
311 | amb | 316 | while(point<=nresults) |
312 | { | ||
313 | amb | 922 | int next_point=point; |
314 | amb | 316 | distance_t junc_distance=0; |
315 | duration_t junc_duration=0; | ||
316 | Result *result; | ||
317 | amb | 160 | |
318 | amb | 922 | result=FindResult(results[point],results[point]->start_node,results[point]->prev_segment); |
319 | |||
320 | /* Print the start of the segment */ | ||
321 | |||
322 | amb | 324 | if(gpxtrackfile) |
323 | fprintf(gpxtrackfile,"<trkseg>\n"); | ||
324 | amb | 303 | |
325 | amb | 922 | /* Loop through all the points within a section of the route and print them */ |
326 | amb | 165 | |
327 | amb | 316 | do |
328 | amb | 160 | { |
329 | amb | 316 | double latitude,longitude; |
330 | amb | 1078 | Node *resultnodep=NULL; |
331 | amb | 922 | index_t realsegment=NO_SEGMENT,next_realsegment=NO_SEGMENT; |
332 | amb | 1078 | Segment *resultsegmentp=NULL,*next_resultsegmentp=NULL; |
333 | Way *resultwayp=NULL,*next_resultwayp=NULL; | ||
334 | amb | 922 | Result *next_result; |
335 | amb | 927 | int important=IMP_UNIMPORTANT; |
336 | amb | 160 | |
337 | amb | 922 | distance_t seg_distance=0; |
338 | duration_t seg_duration=0; | ||
339 | speed_t seg_speed=0; | ||
340 | char *waynameraw=NULL,*wayname=NULL,*next_waynameraw=NULL,*next_wayname=NULL; | ||
341 | int bearing_int=0,turn_int=0,next_bearing_int=0; | ||
342 | char *turn=NULL,*next_bearing=NULL; | ||
343 | |||
344 | /* Calculate the information about this point */ | ||
345 | |||
346 | if(IsFakeNode(result->node)) | ||
347 | GetFakeLatLong(result->node,&latitude,&longitude); | ||
348 | amb | 316 | else |
349 | GetLatLong(nodes,result->node,&latitude,&longitude); | ||
350 | amb | 171 | |
351 | amb | 922 | if(!IsFakeNode(result->node)) |
352 | amb | 1078 | resultnodep=LookupNode(nodes,result->node,6); |
353 | amb | 171 | |
354 | amb | 922 | /* Calculate the next result */ |
355 | amb | 171 | |
356 | amb | 922 | next_result=result->next; |
357 | |||
358 | if(!next_result) | ||
359 | for(next_point=point+1;next_point<=nresults;next_point++) | ||
360 | if(results[next_point]) | ||
361 | amb | 316 | { |
362 | amb | 922 | next_result=FindResult(results[next_point],results[next_point]->start_node,results[next_point]->prev_segment); |
363 | next_result=next_result->next; | ||
364 | amb | 316 | break; |
365 | } | ||
366 | amb | 171 | |
367 | amb | 922 | /* Calculate the information about this segment */ |
368 | amb | 459 | |
369 | amb | 922 | if(result->node!=results[point]->start_node) /* not first point of a section of the route */ |
370 | amb | 169 | { |
371 | amb | 605 | if(IsFakeSegment(result->segment)) |
372 | amb | 633 | { |
373 | amb | 1078 | resultsegmentp=LookupFakeSegment(result->segment); |
374 | amb | 695 | realsegment=IndexRealSegment(result->segment); |
375 | amb | 633 | } |
376 | amb | 459 | else |
377 | amb | 633 | { |
378 | amb | 1078 | resultsegmentp=LookupSegment(segments,result->segment,2); |
379 | amb | 695 | realsegment=result->segment; |
380 | amb | 633 | } |
381 | amb | 922 | |
382 | amb | 1078 | resultwayp=LookupWay(ways,resultsegmentp->way,1); |
383 | amb | 316 | |
384 | amb | 1078 | seg_distance+=DISTANCE(resultsegmentp->distance); |
385 | seg_duration+=Duration(resultsegmentp,resultwayp,profile); | ||
386 | amb | 922 | |
387 | /* Calculate the cumulative distance/duration */ | ||
388 | |||
389 | amb | 316 | junc_distance+=seg_distance; |
390 | junc_duration+=seg_duration; | ||
391 | cum_distance+=seg_distance; | ||
392 | cum_duration+=seg_duration; | ||
393 | amb | 922 | } |
394 | amb | 316 | |
395 | amb | 922 | /* Calculate the information about the next segment */ |
396 | amb | 316 | |
397 | amb | 922 | if(next_result) |
398 | { | ||
399 | if(IsFakeSegment(next_result->segment)) | ||
400 | { | ||
401 | amb | 1078 | next_resultsegmentp=LookupFakeSegment(next_result->segment); |
402 | amb | 922 | next_realsegment=IndexRealSegment(next_result->segment); |
403 | } | ||
404 | amb | 316 | else |
405 | amb | 303 | { |
406 | amb | 1078 | next_resultsegmentp=LookupSegment(segments,next_result->segment,1); |
407 | amb | 922 | next_realsegment=next_result->segment; |
408 | } | ||
409 | } | ||
410 | amb | 160 | |
411 | amb | 926 | /* Decide if this is a roundabout */ |
412 | |||
413 | if(next_result) | ||
414 | { | ||
415 | amb | 1078 | next_resultwayp=LookupWay(ways,next_resultsegmentp->way,2); |
416 | amb | 926 | |
417 | amb | 1078 | if(next_resultwayp->type&Way_Roundabout) |
418 | amb | 926 | { |
419 | if(roundabout==0) | ||
420 | { | ||
421 | roundabout++; | ||
422 | amb | 927 | important=IMP_RB_ENTRY; |
423 | amb | 926 | } |
424 | else | ||
425 | { | ||
426 | amb | 1078 | Segment *segmentp=FirstSegment(segments,resultnodep,3); |
427 | amb | 926 | |
428 | do | ||
429 | { | ||
430 | amb | 1078 | index_t othernode=OtherNode(segmentp,result->node); |
431 | amb | 926 | |
432 | amb | 1078 | if(othernode!=result->prev->node && IndexSegment(segments,segmentp)!=realsegment) |
433 | if(IsNormalSegment(segmentp) && (!profile->oneway || !IsOnewayTo(segmentp,result->node))) | ||
434 | amb | 926 | { |
435 | amb | 1078 | Way *wayp=LookupWay(ways,segmentp->way,3); |
436 | amb | 926 | |
437 | amb | 1078 | if(!(wayp->type&Way_Roundabout)) |
438 | amb | 926 | if(othernode!=next_result->node) |
439 | amb | 927 | { |
440 | amb | 926 | roundabout++; |
441 | amb | 927 | important=IMP_RB_NOT_EXIT; |
442 | } | ||
443 | amb | 926 | } |
444 | |||
445 | amb | 1078 | segmentp=NextSegment(segments,segmentp,result->node); |
446 | amb | 926 | } |
447 | amb | 1078 | while(segmentp); |
448 | amb | 926 | } |
449 | } | ||
450 | else | ||
451 | if(roundabout) | ||
452 | { | ||
453 | roundabout++; | ||
454 | amb | 927 | important=IMP_RB_EXIT; |
455 | amb | 926 | } |
456 | } | ||
457 | |||
458 | amb | 922 | /* Decide if this is an important junction */ |
459 | amb | 303 | |
460 | amb | 926 | if(roundabout) /* roundabout */ |
461 | ; | ||
462 | else if(point_count==0) /* first point overall = Waypoint */ | ||
463 | amb | 927 | important=IMP_WAYPOINT; |
464 | amb | 922 | else if(result->node==results[point]->finish_node) /* Waypoint */ |
465 | amb | 927 | important=IMP_WAYPOINT; |
466 | amb | 922 | else if(result->node==results[point]->start_node) /* first point of a section of the route */ |
467 | amb | 927 | important=IMP_IGNORE; |
468 | amb | 922 | else if(realsegment==next_realsegment) /* U-turn */ |
469 | amb | 927 | important=IMP_UTURN; |
470 | amb | 1078 | else if(resultnodep && (resultnodep->flags&NODE_MINIRNDBT)) |
471 | amb | 929 | important=IMP_MINI_RB; /* mini-roundabout */ |
472 | amb | 922 | else |
473 | { | ||
474 | amb | 1078 | Segment *segmentp=FirstSegment(segments,resultnodep,3); |
475 | amb | 316 | |
476 | amb | 922 | do |
477 | { | ||
478 | amb | 1078 | index_t seg=IndexSegment(segments,segmentp); |
479 | amb | 316 | |
480 | amb | 1074 | if(seg!=realsegment) |
481 | amb | 1078 | if(IsNormalSegment(segmentp) && (!profile->oneway || !IsOnewayTo(segmentp,result->node))) |
482 | amb | 922 | { |
483 | amb | 1078 | Way *wayp=LookupWay(ways,segmentp->way,3); |
484 | amb | 922 | |
485 | amb | 1074 | if(seg==next_realsegment) /* the next segment that we follow */ |
486 | amb | 922 | { |
487 | amb | 1078 | if(HIGHWAY(wayp->type)!=HIGHWAY(resultwayp->type)) |
488 | amb | 927 | if(important<IMP_CHANGE) |
489 | important=IMP_CHANGE; | ||
490 | amb | 303 | } |
491 | amb | 922 | else /* a segment that we don't follow */ |
492 | { | ||
493 | amb | 1078 | if(junction_other_way[HIGHWAY(resultwayp->type)-1][HIGHWAY(wayp->type)-1]) |
494 | amb | 927 | if(important<IMP_JUNCT_IMPORT) |
495 | important=IMP_JUNCT_IMPORT; | ||
496 | amb | 160 | |
497 | amb | 927 | if(important<IMP_JUNCT_CONT) |
498 | important=IMP_JUNCT_CONT; | ||
499 | amb | 922 | } |
500 | } | ||
501 | |||
502 | amb | 1078 | segmentp=NextSegment(segments,segmentp,result->node); |
503 | amb | 303 | } |
504 | amb | 1078 | while(segmentp); |
505 | amb | 922 | } |
506 | amb | 169 | |
507 | amb | 922 | /* Calculate the strings to be used */ |
508 | amb | 169 | |
509 | amb | 1078 | if(resultwayp && textallfile) |
510 | amb | 922 | { |
511 | amb | 1078 | waynameraw=WayName(ways,resultwayp); |
512 | amb | 922 | if(!*waynameraw) |
513 | amb | 1078 | waynameraw=translate_raw_highway[HIGHWAY(resultwayp->type)]; |
514 | amb | 922 | |
515 | amb | 1078 | bearing_int=(int)BearingAngle(nodes,resultsegmentp,result->node); |
516 | amb | 922 | |
517 | amb | 1078 | seg_speed=profile->speed[HIGHWAY(resultwayp->type)]; |
518 | amb | 922 | } |
519 | |||
520 | amb | 927 | if(next_result && important>IMP_JUNCT_CONT) |
521 | amb | 922 | { |
522 | amb | 1078 | if(resultsegmentp && (htmlfile || textfile)) |
523 | amb | 177 | { |
524 | amb | 1078 | turn_int=(int)TurnAngle(nodes,resultsegmentp,next_resultsegmentp,result->node); |
525 | amb | 922 | turn=translate_xml_turn[((202+turn_int)/45)%8]; |
526 | } | ||
527 | amb | 303 | |
528 | amb | 922 | if(gpxroutefile || htmlfile) |
529 | { | ||
530 | amb | 1078 | next_waynameraw=WayName(ways,next_resultwayp); |
531 | amb | 922 | if(!*next_waynameraw) |
532 | amb | 1078 | next_waynameraw=translate_raw_highway[HIGHWAY(next_resultwayp->type)]; |
533 | amb | 378 | |
534 | amb | 922 | next_wayname=ParseXML_Encode_Safe_XML(next_waynameraw); |
535 | } | ||
536 | amb | 411 | |
537 | amb | 922 | if(htmlfile || gpxroutefile || textfile) |
538 | { | ||
539 | amb | 1078 | next_bearing_int=(int)BearingAngle(nodes,next_resultsegmentp,next_result->node); |
540 | amb | 922 | next_bearing=translate_xml_heading[(4+(22+next_bearing_int)/45)%8]; |
541 | } | ||
542 | } | ||
543 | amb | 378 | |
544 | amb | 922 | /* Print out the important points (junctions / waypoints) */ |
545 | |||
546 | amb | 927 | if(important>IMP_JUNCT_CONT) |
547 | amb | 922 | { |
548 | if(htmlfile) | ||
549 | { | ||
550 | char *type; | ||
551 | |||
552 | amb | 927 | if(important==IMP_WAYPOINT) |
553 | amb | 922 | type=translate_html_waypoint; |
554 | amb | 929 | else if(important==IMP_MINI_RB) |
555 | type=translate_html_roundabout; | ||
556 | amb | 922 | else |
557 | type=translate_html_junction; | ||
558 | |||
559 | if(point_count>0) /* not the first point */ | ||
560 | { | ||
561 | /* <tr class='s'><td class='l'>Follow:<td class='r'><span class='h'>*highway name*</span> for <span class='d'>*distance* km, *time* min</span> [<span class='j'>*distance* km, *time* minutes</span>] */ | ||
562 | amb | 378 | fprintf(htmlfile,"<tr class='s'><td class='l'>%s:<td class='r'>",translate_html_segment[0]); |
563 | fprintf(htmlfile,translate_html_segment[1], | ||
564 | amb | 926 | (roundabout>1?translate_html_roundabout:prev_wayname), |
565 | amb | 922 | distance_to_km(junc_distance),duration_to_minutes(junc_duration)); |
566 | amb | 379 | fprintf(htmlfile," [<span class='j'>"); |
567 | amb | 378 | fprintf(htmlfile,translate_html_total[1], |
568 | amb | 922 | distance_to_km(cum_distance),duration_to_minutes(cum_duration)); |
569 | amb | 378 | fprintf(htmlfile,"</span>]\n"); |
570 | amb | 922 | } |
571 | amb | 378 | |
572 | amb | 922 | /* <tr class='c'><td class='l'>*N*:<td class='r'>*latitude* *longitude* */ |
573 | fprintf(htmlfile,"<tr class='c'><td class='l'>%d:<td class='r'>%.6f %.6f\n", | ||
574 | point_count+1, | ||
575 | radians_to_degrees(latitude),radians_to_degrees(longitude)); | ||
576 | amb | 378 | |
577 | amb | 922 | if(point_count==0) /* first point */ |
578 | { | ||
579 | /* <tr class='n'><td class='l'>Start:<td class='r'>At <span class='w'>Waypoint</span>, head <span class='b'>*heading*</span> */ | ||
580 | fprintf(htmlfile,"<tr class='n'><td class='l'>%s:<td class='r'>",translate_html_start[0]); | ||
581 | fprintf(htmlfile,translate_html_start[1], | ||
582 | translate_html_waypoint, | ||
583 | next_bearing); | ||
584 | fprintf(htmlfile,"\n"); | ||
585 | } | ||
586 | else if(next_result) /* middle point */ | ||
587 | { | ||
588 | amb | 926 | if(roundabout>1) |
589 | { | ||
590 | /* <tr class='n'><td class='l'>At:<td class='r'>Roundabout, take <span class='t'>the *Nth* exit</span> heading <span class='b'>*heading*</span> */ | ||
591 | fprintf(htmlfile,"<tr class='n'><td class='l'>%s:<td class='r'>",translate_html_rbnode[0]); | ||
592 | fprintf(htmlfile,translate_html_rbnode[1], | ||
593 | translate_html_roundabout, | ||
594 | translate_xml_ordinal[roundabout-2], | ||
595 | next_bearing); | ||
596 | fprintf(htmlfile,"\n"); | ||
597 | } | ||
598 | else | ||
599 | { | ||
600 | /* <tr class='n'><td class='l'>At:<td class='r'>Junction, go <span class='t'>*direction*</span> heading <span class='b'>*heading*</span> */ | ||
601 | fprintf(htmlfile,"<tr class='n'><td class='l'>%s:<td class='r'>",translate_html_node[0]); | ||
602 | fprintf(htmlfile,translate_html_node[1], | ||
603 | type, | ||
604 | turn, | ||
605 | next_bearing); | ||
606 | fprintf(htmlfile,"\n"); | ||
607 | } | ||
608 | amb | 922 | } |
609 | else /* end point */ | ||
610 | { | ||
611 | /* <tr class='n'><td class='l'>Stop:<td class='r'>At <span class='w'>Waypoint</span> */ | ||
612 | fprintf(htmlfile,"<tr class='n'><td class='l'>%s:<td class='r'>",translate_html_stop[0]); | ||
613 | fprintf(htmlfile,translate_html_stop[1], | ||
614 | translate_html_waypoint); | ||
615 | fprintf(htmlfile,"\n"); | ||
616 | amb | 378 | |
617 | amb | 922 | /* <tr class='t'><td class='l'>Total:<td class='r'><span class='j'>*distance* km, *time* minutes</span> */ |
618 | fprintf(htmlfile,"<tr class='t'><td class='l'>%s:<td class='r'><span class='j'>",translate_html_total[0]); | ||
619 | fprintf(htmlfile,translate_html_total[1], | ||
620 | distance_to_km(cum_distance),duration_to_minutes(cum_duration)); | ||
621 | fprintf(htmlfile,"</span>\n"); | ||
622 | amb | 378 | } |
623 | amb | 922 | } |
624 | amb | 378 | |
625 | amb | 922 | if(gpxroutefile) |
626 | { | ||
627 | if(point_count>0) /* not first point */ | ||
628 | amb | 332 | { |
629 | amb | 378 | fprintf(gpxroutefile,"<desc>"); |
630 | amb | 360 | fprintf(gpxroutefile,translate_gpx_step, |
631 | amb | 922 | prev_bearing, |
632 | prev_wayname, | ||
633 | amb | 378 | distance_to_km(junc_distance),duration_to_minutes(junc_duration)); |
634 | fprintf(gpxroutefile,"</desc></rtept>\n"); | ||
635 | amb | 922 | } |
636 | amb | 316 | |
637 | amb | 922 | if(point_count==0) /* first point */ |
638 | { | ||
639 | fprintf(gpxroutefile,"<rtept lat=\"%.6f\" lon=\"%.6f\"><name>%s</name>\n", | ||
640 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
641 | translate_gpx_start); | ||
642 | } | ||
643 | else if(!next_result) /* end point */ | ||
644 | { | ||
645 | fprintf(gpxroutefile,"<rtept lat=\"%.6f\" lon=\"%.6f\"><name>%s</name>\n", | ||
646 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
647 | translate_gpx_finish); | ||
648 | fprintf(gpxroutefile,"<desc>"); | ||
649 | fprintf(gpxroutefile,translate_gpx_final, | ||
650 | distance_to_km(cum_distance),duration_to_minutes(cum_duration)); | ||
651 | fprintf(gpxroutefile,"</desc></rtept>\n"); | ||
652 | } | ||
653 | else /* middle point */ | ||
654 | { | ||
655 | amb | 927 | if(important==IMP_WAYPOINT) |
656 | amb | 360 | fprintf(gpxroutefile,"<rtept lat=\"%.6f\" lon=\"%.6f\"><name>%s%d</name>\n", |
657 | amb | 378 | radians_to_degrees(latitude),radians_to_degrees(longitude), |
658 | translate_gpx_inter,++segment_count); | ||
659 | amb | 332 | else |
660 | amb | 360 | fprintf(gpxroutefile,"<rtept lat=\"%.6f\" lon=\"%.6f\"><name>%s%03d</name>\n", |
661 | amb | 378 | radians_to_degrees(latitude),radians_to_degrees(longitude), |
662 | translate_gpx_trip,++route_count); | ||
663 | amb | 332 | } |
664 | amb | 922 | } |
665 | amb | 316 | |
666 | amb | 922 | if(textfile) |
667 | { | ||
668 | char *type; | ||
669 | amb | 316 | |
670 | amb | 927 | if(important==IMP_WAYPOINT) |
671 | amb | 922 | type="Waypt"; |
672 | else | ||
673 | type="Junct"; | ||
674 | amb | 316 | |
675 | amb | 922 | if(point_count==0) /* first point */ |
676 | { | ||
677 | fprintf(textfile,"%10.6f\t%11.6f\t%6.3f km\t%4.1f min\t%5.1f km\t%4.0f min\t%s\t\t %+d\t%s\n", | ||
678 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
679 | 0.0,0.0,0.0,0.0, | ||
680 | type, | ||
681 | ((22+next_bearing_int)/45+4)%8-4, | ||
682 | next_waynameraw); | ||
683 | } | ||
684 | else if(!next_result) /* end point */ | ||
685 | { | ||
686 | fprintf(textfile,"%10.6f\t%11.6f\t%6.3f km\t%4.1f min\t%5.1f km\t%4.0f min\t%s\t\t\t\n", | ||
687 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
688 | distance_to_km(junc_distance),duration_to_minutes(junc_duration), | ||
689 | distance_to_km(cum_distance),duration_to_minutes(cum_duration), | ||
690 | type); | ||
691 | } | ||
692 | else /* middle point */ | ||
693 | { | ||
694 | fprintf(textfile,"%10.6f\t%11.6f\t%6.3f km\t%4.1f min\t%5.1f km\t%4.0f min\t%s\t %+d\t %+d\t%s\n", | ||
695 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
696 | distance_to_km(junc_distance),duration_to_minutes(junc_duration), | ||
697 | distance_to_km(cum_distance),duration_to_minutes(cum_duration), | ||
698 | type, | ||
699 | (22+turn_int)/45, | ||
700 | ((22+next_bearing_int)/45+4)%8-4, | ||
701 | next_waynameraw); | ||
702 | } | ||
703 | } | ||
704 | amb | 322 | |
705 | amb | 922 | junc_distance=0; |
706 | junc_duration=0; | ||
707 | amb | 322 | |
708 | amb | 922 | if(htmlfile || gpxroutefile) |
709 | { | ||
710 | if(prev_wayname) | ||
711 | free(prev_wayname); | ||
712 | amb | 322 | |
713 | amb | 922 | if(next_wayname) |
714 | prev_wayname=strcpy((char*)malloc(strlen(next_wayname)+1),next_wayname); | ||
715 | else | ||
716 | prev_wayname=NULL; | ||
717 | amb | 316 | |
718 | amb | 922 | if(next_wayname && next_wayname!=next_waynameraw) |
719 | free(next_wayname); | ||
720 | amb | 165 | } |
721 | amb | 160 | |
722 | amb | 922 | if(gpxroutefile) |
723 | prev_bearing=next_bearing; | ||
724 | amb | 926 | |
725 | if(roundabout>1) | ||
726 | roundabout=0; | ||
727 | amb | 922 | } |
728 | amb | 303 | |
729 | amb | 922 | /* Print out all of the results */ |
730 | |||
731 | if(gpxtrackfile) | ||
732 | fprintf(gpxtrackfile,"<trkpt lat=\"%.6f\" lon=\"%.6f\"/>\n", | ||
733 | radians_to_degrees(latitude),radians_to_degrees(longitude)); | ||
734 | |||
735 | amb | 927 | if(important>IMP_IGNORE) |
736 | amb | 922 | { |
737 | amb | 316 | if(textallfile) |
738 | { | ||
739 | char *type; | ||
740 | |||
741 | amb | 927 | if(important==IMP_WAYPOINT) |
742 | amb | 316 | type="Waypt"; |
743 | amb | 927 | else if(important==IMP_UTURN) |
744 | amb | 926 | type="U-turn"; |
745 | amb | 929 | else if(important==IMP_MINI_RB) |
746 | type="Mini-RB"; | ||
747 | amb | 927 | else if(important==IMP_CHANGE) |
748 | amb | 316 | type="Change"; |
749 | amb | 1075 | else if(important==IMP_JUNCT_CONT || important==IMP_RB_NOT_EXIT) |
750 | type="Junct-"; | ||
751 | amb | 927 | else if(important==IMP_UNIMPORTANT) |
752 | type="Inter"; | ||
753 | else | ||
754 | amb | 316 | type="Junct"; |
755 | |||
756 | amb | 922 | if(point_count==0) /* first point */ |
757 | amb | 474 | { |
758 | amb | 922 | fprintf(textallfile,"%10.6f\t%11.6f\t%8d%c\t%s\t%5.3f\t%5.2f\t%5.2f\t%5.1f\t\t\t\n", |
759 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
760 | IsFakeNode(result->node)?(NODE_FAKE-result->node):result->node, | ||
761 | amb | 1078 | (resultnodep && IsSuperNode(resultnodep))?'*':' ',type, |
762 | amb | 922 | 0.0,0.0,0.0,0.0); |
763 | amb | 474 | } |
764 | amb | 927 | else /* not the first point */ |
765 | amb | 378 | { |
766 | amb | 922 | fprintf(textallfile,"%10.6f\t%11.6f\t%8d%c\t%s\t%5.3f\t%5.2f\t%5.2f\t%5.1f\t%3d\t%4d\t%s\n", |
767 | radians_to_degrees(latitude),radians_to_degrees(longitude), | ||
768 | IsFakeNode(result->node)?(NODE_FAKE-result->node):result->node, | ||
769 | amb | 1078 | (resultnodep && IsSuperNode(resultnodep))?'*':' ',type, |
770 | amb | 922 | distance_to_km(seg_distance),duration_to_minutes(seg_duration), |
771 | distance_to_km(cum_distance),duration_to_minutes(cum_duration), | ||
772 | speed_to_kph(seg_speed), | ||
773 | bearing_int, | ||
774 | waynameraw); | ||
775 | amb | 378 | } |
776 | amb | 316 | } |
777 | amb | 160 | } |
778 | amb | 378 | |
779 | amb | 922 | if(wayname && wayname!=waynameraw) |
780 | free(wayname); | ||
781 | amb | 160 | |
782 | amb | 922 | result=next_result; |
783 | amb | 323 | |
784 | amb | 927 | if(important>IMP_JUNCT_CONT) |
785 | amb | 922 | point_count++; |
786 | } | ||
787 | while(point==next_point); | ||
788 | amb | 171 | |
789 | amb | 922 | /* Print the end of the segment */ |
790 | amb | 171 | |
791 | amb | 316 | if(gpxtrackfile) |
792 | fprintf(gpxtrackfile,"</trkseg>\n"); | ||
793 | amb | 160 | |
794 | amb | 922 | point=next_point; |
795 | amb | 160 | } |
796 | |||
797 | amb | 164 | /* Print the tail of the files */ |
798 | |||
799 | amb | 323 | if(htmlfile) |
800 | { | ||
801 | fprintf(htmlfile,"</table>\n"); | ||
802 | amb | 376 | |
803 | amb | 893 | if((translate_xml_copyright_creator[0] && translate_xml_copyright_creator[1]) || |
804 | (translate_xml_copyright_source[0] && translate_xml_copyright_source[1]) || | ||
805 | (translate_xml_copyright_license[0] && translate_xml_copyright_license[1])) | ||
806 | amb | 376 | { |
807 | fprintf(htmlfile,"<p>\n"); | ||
808 | fprintf(htmlfile,"<table class='c'>\n"); | ||
809 | amb | 893 | if(translate_xml_copyright_creator[0] && translate_xml_copyright_creator[1]) |
810 | fprintf(htmlfile,"<tr><td class='l'>%s:<td class='r'>%s\n",translate_xml_copyright_creator[0],translate_xml_copyright_creator[1]); | ||
811 | if(translate_xml_copyright_source[0] && translate_xml_copyright_source[1]) | ||
812 | fprintf(htmlfile,"<tr><td class='l'>%s:<td class='r'>%s\n",translate_xml_copyright_source[0],translate_xml_copyright_source[1]); | ||
813 | if(translate_xml_copyright_license[0] && translate_xml_copyright_license[1]) | ||
814 | fprintf(htmlfile,"<tr><td class='l'>%s:<td class='r'>%s\n",translate_xml_copyright_license[0],translate_xml_copyright_license[1]); | ||
815 | amb | 376 | fprintf(htmlfile,"</table>\n"); |
816 | } | ||
817 | |||
818 | amb | 323 | fprintf(htmlfile,"</BODY>\n"); |
819 | fprintf(htmlfile,"</HTML>\n"); | ||
820 | } | ||
821 | |||
822 | amb | 177 | if(gpxtrackfile) |
823 | { | ||
824 | fprintf(gpxtrackfile,"</trk>\n"); | ||
825 | fprintf(gpxtrackfile,"</gpx>\n"); | ||
826 | } | ||
827 | amb | 160 | |
828 | amb | 177 | if(gpxroutefile) |
829 | { | ||
830 | fprintf(gpxroutefile,"</rte>\n"); | ||
831 | fprintf(gpxroutefile,"</gpx>\n"); | ||
832 | } | ||
833 | amb | 160 | |
834 | amb | 164 | /* Close the files */ |
835 | |||
836 | amb | 323 | if(htmlfile) |
837 | fclose(htmlfile); | ||
838 | amb | 177 | if(gpxtrackfile) |
839 | fclose(gpxtrackfile); | ||
840 | if(gpxroutefile) | ||
841 | fclose(gpxroutefile); | ||
842 | if(textfile) | ||
843 | fclose(textfile); | ||
844 | if(textallfile) | ||
845 | fclose(textallfile); | ||
846 | amb | 160 | } |
Properties
Name | Value |
---|---|
cvs:description | New file to contain the function to print the output. |