/***************************************
- $Header: /home/amb/routino/src/RCS/output.c,v 1.33 2010/07/07 17:31:06 amb Exp $
+ $Header: /home/amb/routino/src/RCS/output.c,v 1.40 2010/09/15 18:30:08 amb Exp $
Routing output generator.
#include <unistd.h>
#include "types.h"
-#include "functions.h"
-#include "translations.h"
#include "nodes.h"
#include "segments.h"
#include "ways.h"
+
+#include "files.h"
+#include "functions.h"
+#include "translations.h"
#include "results.h"
#include "xmlparse.h"
/*+ Heuristics for determining if a junction is important. +*/
static char junction_other_way[Way_Count][Way_Count]=
- { /* M, T, P, S, T, U, R, S, T, C, P, S = Way type of route not taken */
- { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Motorway */
- { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Trunk */
- { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Primary */
- { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Secondary */
- { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, /* Tertiary */
- { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, /* Unclassified */
- { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, /* Residential */
- { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, /* Service */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, /* Track */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, /* Cycleway */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Path */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Steps */
+ { /* M, T, P, S, T, U, R, S, T, C, P, S, F = Way type of route not taken */
+ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Motorway */
+ { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Trunk */
+ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Primary */
+ { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Secondary */
+ { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 }, /* Tertiary */
+ { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1 }, /* Unclassified */
+ { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 }, /* Residential */
+ { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 }, /* Service */
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1 }, /* Track */
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1 }, /* Cycleway */
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Path */
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Steps */
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* Ferry */
};
fprintf(htmlfile,"<TITLE>");
fprintf(htmlfile,translate_html_title,option_quickest?translate_route_quickest:translate_route_shortest);
fprintf(htmlfile,"</TITLE>\n");
- fprintf(htmlfile,"<STYLE type='text/css'>\n");
+ fprintf(htmlfile,"<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
+ fprintf(htmlfile,"<STYLE type=\"text/css\">\n");
fprintf(htmlfile,"<!--\n");
fprintf(htmlfile," table {table-layout: fixed; border: none; border-collapse: collapse;}\n");
fprintf(htmlfile," table.c {color: grey; font-size: x-small;} /* copyright */\n");
{
double latitude,longitude;
Result *nextresult;
+ Segment *nextresultsegment;
if(result->node==results[point]->start)
{latitude=start_lat; longitude=start_lon;}
break;
}
+ if(nextresult)
+ {
+ if(IsFakeSegment(nextresult->segment))
+ nextresultsegment=LookupFakeSegment(nextresult->segment);
+ else
+ nextresultsegment=LookupSegment(segments,nextresult->segment,2);
+ }
+ else
+ nextresultsegment=NULL;
+
if(result->node!=results[point]->start)
{
distance_t seg_distance=0;
duration_t seg_duration=0;
+ Segment *resultsegment;
Way *resultway;
int important=0;
/* Cache the values to be printed rather than calculating them repeatedly for each output format */
- char *waynameraw=NULL,*wayname=NULL,*waynamexml=NULL;
+ char *waynameraw=NULL,*waynamexml=NULL;
+ const char *wayname=NULL;
int bearing_int=0,bearing_next_int=0,turn_int=0;
char *bearing_str=NULL,*bearing_next_str=NULL,*turn_str=NULL;
/* Get the properties of this segment */
- resultway=LookupWay(ways,result->segment->way);
+ if(IsFakeSegment(result->segment))
+ resultsegment=LookupFakeSegment(result->segment);
+ else
+ resultsegment=LookupSegment(segments,result->segment,3);
+ resultway=LookupWay(ways,resultsegment->way,1);
- seg_distance+=DISTANCE(result->segment->distance);
- seg_duration+=Duration(result->segment,resultway,profile);
+ seg_distance+=DISTANCE(resultsegment->distance);
+ seg_duration+=Duration(resultsegment,resultway,profile);
junc_distance+=seg_distance;
junc_duration+=seg_duration;
cum_distance+=seg_distance;
{
index_t othernode=OtherNode(segment,result->node);
- if(othernode!=result->prev && segment!=result->segment)
+ if(othernode!=result->prev && segment!=resultsegment)
if(IsNormalSegment(segment) && (!profile->oneway || !IsOnewayTo(segment,result->node)))
{
- Way *way=LookupWay(ways,segment->way);
+ Way *way=LookupWay(ways,segment->way,2);
if(othernode==result->next) /* the next segment that we follow */
{
if(!waynameraw)
{
- waynameraw=WayNameRaw(ways,resultway);
+ waynameraw=WayName(ways,resultway);
if(!*waynameraw)
waynameraw=translate_highway[HIGHWAY(resultway->type)];
}
{
if(!turn_str)
{
- turn_int=turn_angle(nodes,result->segment,nextresult->segment,result->node);
+ turn_int=turn_angle(nodes,resultsegment,nextresultsegment,result->node);
turn_str=translate_turn[(4+(22+turn_int)/45)%8];
}
if(!bearing_next_str)
{
- bearing_next_int=bearing_angle(nodes,nextresult->segment,nextresult->node);
+ bearing_next_int=bearing_angle(nodes,nextresultsegment,nextresult->node);
bearing_next_str=translate_heading[(4+(22+bearing_next_int)/45)%8];
}
{
if(!waynameraw)
{
- waynameraw=WayNameRaw(ways,resultway);
+ waynameraw=WayName(ways,resultway);
if(!*waynameraw)
waynameraw=translate_highway[HIGHWAY(resultway->type)];
}
if(!bearing_str)
{
- bearing_int=bearing_angle(nodes,result->segment,result->node);
+ bearing_int=bearing_angle(nodes,resultsegment,result->node);
bearing_str=translate_heading[(4+(22+bearing_int)/45)%8];
}
type="Junct";
if(!wayname)
- wayname=(char*)WayNameHighway(ways,resultway);
+ {
+ wayname=WayName(ways,resultway);
+ if(!*wayname)
+ wayname=HighwayName(HIGHWAY(resultway->type));
+ }
if(nextresult)
{
if(!turn_str)
{
- turn_int=turn_angle(nodes,result->segment,nextresult->segment,result->node);
+ turn_int=turn_angle(nodes,resultsegment,nextresultsegment,result->node);
turn_str=translate_turn[(4+(22+turn_int)/45)%8];
}
if(!bearing_next_str)
{
- bearing_next_int=bearing_angle(nodes,nextresult->segment,nextresult->node);
+ bearing_next_int=bearing_angle(nodes,nextresultsegment,nextresult->node);
bearing_next_str=translate_heading[(4+(22+bearing_next_int)/45)%8];
}
type="Inter";
if(!wayname)
- wayname=(char*)WayNameHighway(ways,resultway);
+ {
+ wayname=WayName(ways,resultway);
+ if(!*wayname)
+ wayname=HighwayName(HIGHWAY(resultway->type));
+ }
if(!bearing_str)
{
- bearing_int=bearing_angle(nodes,result->segment,result->node);
+ bearing_int=bearing_angle(nodes,resultsegment,result->node);
bearing_str=translate_heading[(4+(22+bearing_int)/45)%8];
}
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",
radians_to_degrees(latitude),radians_to_degrees(longitude),
- IsFakeNode(result->node)?-(result->node&(~NODE_SUPER)):result->node,
+ IsFakeNode(result->node)?(NODE_FAKE-result->node):result->node,
(!IsFakeNode(result->node) && IsSuperNode(nodes,result->node))?'*':' ',type,
distance_to_km(seg_distance),duration_to_minutes(seg_duration),
distance_to_km(cum_distance),duration_to_minutes(cum_duration),
}
else if(!cum_distance)
{
- int bearing_next_int=bearing_angle(nodes,nextresult->segment,nextresult->node);
+ int bearing_next_int=bearing_angle(nodes,nextresultsegment,nextresult->node);
char *bearing_next_str=translate_heading[(4+(22+bearing_next_int)/45)%8];
/* Print out the very first start point */
if(textallfile)
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",
radians_to_degrees(latitude),radians_to_degrees(longitude),
- IsFakeNode(result->node)?-(result->node&(~NODE_SUPER)):result->node,
+ IsFakeNode(result->node)?(NODE_FAKE-result->node):result->node,
(!IsFakeNode(result->node) && IsSuperNode(nodes,result->node))?'*':' ',"Waypt",
0.0,0.0,0.0,0.0);
}