Commit c9d3632a authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

state,status on stderr

parent 92aa7027
...@@ -29,5 +29,6 @@ ...@@ -29,5 +29,6 @@
#define RV_MAXIMUM_USED_ANGLE 3 // rad #define RV_MAXIMUM_USED_ANGLE 3 // rad
#define RV_MAXIMUM_RADIUS_OF_CURVATURE 500 // m #define RV_MAXIMUM_RADIUS_OF_CURVATURE 500 // m
#define RV_STATUS_SCALE 1000
#endif #endif
...@@ -4,9 +4,13 @@ std::list<std::list<route_point_t> > get_routes( ...@@ -4,9 +4,13 @@ std::list<std::list<route_point_t> > get_routes(
route_db_t* route_db, route_db_t* route_db,
parameters_t & parameters, parameters_t & parameters,
std::list< std::pair<double,double> > & geos, std::list< std::pair<double,double> > & geos,
stdout_output_t stdout_output) stdout_output_t stdout_output,
bool state_status_on_stderr)
{ {
std::list<nid_t> nids; std::list<nid_t> nids;
if(state_status_on_stderr)
fprintf(stderr,"## state: lookup\n");
route_db->lookup(geos, nids); route_db->lookup(geos, nids);
std::list<std::list<route_point_t> > ret; std::list<std::list<route_point_t> > ret;
...@@ -20,13 +24,20 @@ std::list<std::list<route_point_t> > get_routes( ...@@ -20,13 +24,20 @@ std::list<std::list<route_point_t> > get_routes(
nids_it_next++; nids_it_next++;
if(nids_it_next!=nids.end()) if(nids_it_next!=nids.end())
{ {
if(state_status_on_stderr)
fprintf(stderr,"## status: routing_track %lu\n",track);
std::list<route_point_t> current_route = std::list<route_point_t> current_route =
get_route_between_nids( get_route_between_nids(
route_db, route_db,
parameters, parameters,
*nids_it, *nids_it,
*nids_it_next); *nids_it_next,
state_status_on_stderr);
ret.push_back(current_route); ret.push_back(current_route);
if(state_status_on_stderr)
fprintf(stderr,"## status: end_track %lu\n",track);
if(stdout_output == RV_STDOUT_OUTPUT_TEXT) if(stdout_output == RV_STDOUT_OUTPUT_TEXT)
write_to_stdout(route_db, track, current_route); write_to_stdout(route_db, track, current_route);
...@@ -41,7 +52,8 @@ std::list<route_point_t> get_route_between_nids( ...@@ -41,7 +52,8 @@ std::list<route_point_t> get_route_between_nids(
route_db_t* route_db, route_db_t* route_db,
parameters_t & parameters, parameters_t & parameters,
nid_t & nid_initial, nid_t & nid_initial,
nid_t & nid_final) nid_t & nid_final,
bool state_status_on_stderr)
{ {
std::priority_queue<edge_in_queue_t> queue; // This is the ordoned queue used to explore std::priority_queue<edge_in_queue_t> queue; // This is the ordoned queue used to explore
edge_map_t edges_map; edge_map_t edges_map;
...@@ -50,6 +62,13 @@ std::list<route_point_t> get_route_between_nids( ...@@ -50,6 +62,13 @@ std::list<route_point_t> get_route_between_nids(
// first we add edge starting from the initial node in the queue // first we add edge starting from the initial node in the queue
node_info_t* initial_node = route_db->get_node(nid_initial); node_info_t* initial_node = route_db->get_node(nid_initial);
node_info_t* final_node = route_db->get_node(nid_final); node_info_t* final_node = route_db->get_node(nid_final);
double total_flight_distance = rv_distance(
initial_node->fixed->lon,
initial_node->fixed->lat,
final_node->fixed->lon,
final_node->fixed->lat);
unsigned int last_printed_status = 0;
edge_t null_edge; edge_t null_edge;
null_edge.A = 0; null_edge.A = 0;
...@@ -98,6 +117,23 @@ std::list<route_point_t> get_route_between_nids( ...@@ -98,6 +117,23 @@ std::list<route_point_t> get_route_between_nids(
node_info_t* A_node = route_db->get_node(running_edge_in_queue.edge.A); node_info_t* A_node = route_db->get_node(running_edge_in_queue.edge.A);
node_info_t* B_node = route_db->get_node(running_edge_in_queue.edge.B); node_info_t* B_node = route_db->get_node(running_edge_in_queue.edge.B);
if(state_status_on_stderr)
{
double flight_distance = rv_distance(
final_node->fixed->lon,
final_node->fixed->lat,
B_node->fixed->lon,
B_node->fixed->lat);
double status = 1 - flight_distance / total_flight_distance;
status = status*status;
if( (unsigned int)(status*RV_STATUS_SCALE) > last_printed_status)
{
last_printed_status = (unsigned int)(status*RV_STATUS_SCALE);
fprintf(stderr,"## status: %lu\n",last_printed_status);
}
}
if(running_edge_in_queue.edge.B == nid_final) // We are near the end if(running_edge_in_queue.edge.B == nid_final) // We are near the end
{ {
......
...@@ -12,12 +12,14 @@ std::list<route_point_t> get_route_between_nids( ...@@ -12,12 +12,14 @@ std::list<route_point_t> get_route_between_nids(
route_db_t* route_db, route_db_t* route_db,
parameters_t & parameters, parameters_t & parameters,
nid_t & nid_from, nid_t & nid_from,
nid_t & nid_to); nid_t & nid_to,
bool state_status_on_stderr = false);
std::list<std::list<route_point_t> > get_routes( std::list<std::list<route_point_t> > get_routes(
route_db_t* route_db, route_db_t* route_db,
parameters_t & parameters, parameters_t & parameters,
std::list< std::pair<double,double> > & geos, std::list< std::pair<double,double> > & geos,
stdout_output_t stdout_output = RV_STDOUT_OUTPUT_NONE); stdout_output_t stdout_output = RV_STDOUT_OUTPUT_NONE,
bool state_status_on_stderr = false);
#endif #endif
...@@ -10,7 +10,7 @@ int main(int argc, char** argv) ...@@ -10,7 +10,7 @@ int main(int argc, char** argv)
parameters_t parameters = read_parameters_from_stdin(); parameters_t parameters = read_parameters_from_stdin();
std::list<std::pair<double,double>> geos = read_points_from_stdin(); std::list<std::pair<double,double>> geos = read_points_from_stdin();
get_routes(&route_db, parameters, geos, RV_STDOUT_OUTPUT_TEXT); get_routes(&route_db, parameters, geos, RV_STDOUT_OUTPUT_TEXT, true);
return(0); return(0);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment