You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spOSMroute/main/routing.h

132 lines
2.6 KiB

/***************************************************************************
* routing.h
*
* Copyright 2011 - Steffen Pohle
* steffen@gulpe.de
****************************************************************************/
#ifndef _ROUTING_H_
#define _ROUTING_H_
#include "map.h"
#define RT_ALLOC 512
#define RT_ALLOCREFS 128
#define RT_ALLOCSTACK 256
#define RT_F_HIGHWAY 1.5
#define RT_F_TERTIARY 2.0
#define RT_F_RESIDENTIAL 4.0
#define RT_F_ROAD 5.0
enum {
ROUTING_NONE = 0, // no routing active
ROUTING_INIT, // routing : initialized
ROUTING_CALC, // routing : calculating
ROUTING_OPTIMIZE, // routing : optimizing the way
ROUTING_ONWAY, // routing : we're on the way
ROUTING_ABORT // routing : aborted
};
struct rtwayid {
unsigned long long int id;
unsigned short int sid;
unsigned char type;
};
struct rtway {
struct rtwayid way;
struct map_pos pos;
int pnr; // pointnr where we entered
float dist2dest; // way distance from destination
float dist2pos; // distance to current position
int step;
float priority;
int cycle1;
int cycle2;
float deltadist;
};
struct rtwaylist {
struct rtway *array;
int max;
int cnt;
};
/* structure to cache the references and ways.. needed for optimizing */
struct rtrefway {
struct rtwayid way;
struct map_pos pos;
int nr;
};
struct rtref {
char refname[MAP_W_NAMELEN];
struct rtrefway *ways;
int lastnr;
int cnt;
int max;
};
struct rtreflist {
struct rtref *refs;
int cnt;
int max;
};
/* routing data structures */
struct rtdata {
struct map_pos start;
unsigned long long int start_way_id;
unsigned short int start_way_sid;
unsigned long long int pos_way_id;
unsigned short int pos_way_sid;
struct map_pos pos;
struct map_pos dest;
struct map_pos pos_dest; // distance between pos and dest.
unsigned long long int dest_way_id;
unsigned short int dest_way_sid;
struct map_pos dest_way_pos;
char dest_way_name[MAP_W_NAMELEN];
fPoint dest_km;
struct rtreflist reflist;
int state;
float distance;
float angle;
float closest_distance;
float closest_lon; // debugging //
float closest_lat; // debugging //
// ways which are calculated
struct rtwaylist ways;
// elements needed to be calculated for routeing. (pointers only)
// there are three different stack levels..
// needed to seperate the different roads therefor we can ignore
// uninteresting routes.
struct rtwaylist stack1;
struct rtwaylist stack2;
struct rtwaylist stack3;
// elements which are on our way
struct rtwaylist route;
int cycle;
};
extern struct rtdata *route;
extern void route_start (struct map_pos startpos);
extern void route_stop ();
#endif