1 #include "strongcalc.h"
14 if(s != NULL && e != NULL){
19 if(s == NULL && e == NULL){
28 *N = this->N = hmmax / hs->
hmstep + 1;
39 runmode = RMcalcClimbRestricted;
41 void STRONGcalc::exit(){}
42 void STRONGcalc::run(){
60 case RMcalcRestricted:
62 calc<STRONGPlusfib>(
fplus);
67 case RMcalcClimbRestricted:
69 calc<STRONGClimbfib>(
fclimb);
85 for(
int i = 0; i < N; i++){
87 T* t;
float d;
STRONG* cS;
int si = -1;
89 do{ t = f[i]->extmin();
90 }
while(t != NULL && t->d < 0);
99 cS = &(t->k->cd->s[i]);
102 n = t->k->cd->neighbours;
105 if( n->
nb->cd->
s != NULL
114 if( n->
nb->cd->
s[si].
from == NULL
115 && n->
nb->cd->
s[si].
via == NULL){
123 if( n->
nb->cd->
s[si].
via == NULL &&
124 ((T*)(n->
nb->cd->
s[si].
from))->
d > d + n->
d){
126 ((T*)(n->
nb->cd->
s[si].
from))->d = -1;
136 if( i >= 0 &&
mind[i] > d ){
149 }
while(t != NULL && d < 0);
167 mind =
new double[N];
172 for(
int j = 0; j < N; j++){
175 mind[j] = 100000000000000000.;
206 mind =
new double[N];
210 for(
int j = 0; j < N; j++){
213 mind[j] = 100000000000000000.;
247 mind =
new double[N];
251 for(
int j = 0; j < N; j++){
254 mind[j] = 100000000000000000.;
293 k->cd->
s[0].
from = t;
310 k->cd->
s[0].
from = t;
329 k->cd->
s[0].
from = t;
340 if(
s == NULL ||
e == NULL ||
341 distance(k->
lat,k->lon,
s->
lat,
s->lon)
344 for(
int i = 0; i < N; i++){
345 k->cd->
s[i].
from = NULL;
346 k->cd->
s[i].
via = NULL;
360 if(
e->cd->
s[i].
via != NULL){
365 (*trck)[i] =
new Track(&(n[1]),nbc-1);
378 (*trck)[i] =
new Track(&(n[1]),nbc-1);
431 for(
int i = 1; i < n->
tpc; i++){
432 if(n->
tp[i].h > n->
tp[i-1].h)
453 for(
int i = n->
tpc-2; i >= 0; i--){
454 if(n->
tp[i].h > n->
tp[i+1].h)
481 for(
int i = 1; i < n->
tpc; i++){
482 if(n->
tp[i].h > n->
tp[i-1].h){
484 dd = n->
tp[i].d - n->
tp[i-1].d;
486 slope = qMin(
float(0.28),(n->
tp[i].h - n->
tp[i-1].h)/(dd*1000));
488 dP += slope*slope*dd*1000;
513 for(
int i = n->
tpc-2; i >= 0; i--){
514 if(n->
tp[i].h > n->
tp[i+1].h){
516 dd = n->
tp[i+1].d - n->
tp[i].d;
518 slope = qMin(
float(0.28),(n->
tp[i].h - n->
tp[i+1].h)/(dd*1000));
520 dP += slope*slope*dd*1000;
559 (*nl)[nct] = st->
via;
567 t2->
from = &(t->
k->cd->
s[i]);
577 t2->
from = &(t->
k->cd->
s[i]);
588 t2->
from = &(t->
k->cd->
s[i]);
605 strcpy(this->filename,filename);
608 this->
trck = results;
612 if(k->cd != NULL && k->cd->
s != NULL){
613 fwrite(&(k->
id),
sizeof(qint64),1,f);
614 for(
int i = 0; i < N; i++)
615 if(k->cd->
s[i].
from != NULL){
616 fwrite(&(k->cd->
s[i].
via->
brthr->
nb->
id),
sizeof(qint64),1,f);
617 fwrite(&(k->cd->
s[i].
via->
way->
id),
sizeof(qint64),1,f);
620 fwrite(&(sindex),
sizeof(
int),1,f);
625 fwrite(&(buf64),
sizeof(qint64),1,f);
626 fwrite(&(buf64),
sizeof(qint64),1,f);
627 fwrite(&(bufint),
sizeof(
int),1,f);
637 fread(&(kid),
sizeof(qint64),1,f);
639 if(k != NULL && k->cd != NULL){
641 for(
int i = 0; i < N; i++){
642 fread(&(kid),
sizeof(qint64),1,f);
643 fread(&(wid),
sizeof(qint64),1,f);
644 fread(&(sindex),
sizeof(
int),1,f);
647 while(nb != NULL && (nb->
nb->
id != kid || nb->
way->
id != wid))
651 k->cd->
s[i].
from = &(nb->
nb->cd->
s[sindex]);
655 k->cd->
s[i].
from = NULL;
660 fseek(f,N*(2*
sizeof(qint64)+
sizeof(
int)),SEEK_CUR);
666 strcpy(this->filename,filename);
669 this->
trck = results;
676 fread(Nout,
sizeof(
int),1,f);
684 fread(&(crosscount),
sizeof(
int),1,f);
685 for(
int i = 0; i < crosscount; i++)
688 for(
int i = 0; i < N; i++){
689 fread(&(kid),
sizeof(qint64),1,f);
691 if(k != NULL && k->cd != NULL){
711 fwrite(&(N),
sizeof(
int),1,f);
713 fwrite(&(crosscount),
sizeof(
int),1,f);
715 for(
int i = 0; i < N; i++)
716 if((*
trck)[i] != NULL)
717 fwrite(&((*
trck)[i]->get_last_KOO()->
id),
sizeof(qint64),1,f);
720 fwrite(&(buf64),
sizeof(qint64),1,f);
double hmperkm
hmmax=max(hmmax,radius*hmperkm)
void calc(FibunacciHeap< T > **f)
core function of the algorithm
Neighbour * via
connection to reach this STRONG
Track *** trck
intermediate results of iterations
void extract_neighbourlist(STRONG *s, STRONG *e, Neighbour ***nl, long int *nc)
reconstructs link between start STRONG and end STRONG
void STRONG_to_trck(int i)
Way * way
Neighbour lives uses this Way.
FibunacciHeap< STRONGClimbfib > ** fclimb
FibunacciHeap element to store STRONG data with climb restrictions.
int hmmax
finalization criterium absolute
void refresh_progress(int step)
emitted if iteration step has finished
char filename[999]
for save and load
STRONGsetting * hs
major settings of the calculation
float minP
defines climb: min. difficulty
KOO * get_first_KOO()
returns root of node-AVL tree
container struct to hold data of a coordinate
int count_STRONG(KOO *k)
counts STRONG data recursivly
STRONG * from
pointer to related STRONG struct
int extract_STRONGPlus_restriciton(Neighbour *n)
checks if STRONG can expand concerning restrictions
float downtoupmax
defines climb: allowed down Hm
FibunacciHeap element to store STRONG data.
void reset_Hm(KOO *k)
resets Neighbour Hm to ascenting vertical meters
routing container struct, connects cross via Way with each other
int hmstep
Additional criteria for STRONGPlus defining climb.
STRONGcalc(OSM *o, KOO *s, KOO *e, char max, char min, STRONGsetting *hs, Track ***trck, int *N, bool Hmonly)
STRONG calculation.
int extract_STRONGClimb_restriciton(Neighbour *n)
checks if STRONG can expand concerning restrictions
void init_AreaStrongClimb(KOO *k)
Neighbour * next
next Neighbour, set to NULL if last
void load_STRONG()
executes the loading of a STRONG network from file filename
FibunacciHeap element to store STRONG data with climb analysis.
bool noSTRONGPlus
dont apply climb restrictions
void init_AreaStrongPlus(KOO *k)
float hmup
Hm ascenting since last big descent section.
STRONG * s
memory for routing algorithms
RunMode runmode
type of STRONGcalc to be executed
qint64 id
id inherited from OSM data
void points_Hm(KOO *k)
accumulates section difficulties instead of vertical meters in Neighbour relation ...
void load_crossdata(FILE *f)
low level load routine of load_STRONG
official representation of Track in BTP3
FibunacciHeap< STRONGfib > ** f
void save_STRONG()
executes the save of a STRONG network to file filename
float d
current distance at STRONG
void finished(int succesful)
returns succes if a track was extracted from the STRONG network
char min
restrictions on Neighbour Way type
void init_AreaStrong(KOO *k)
double rfac
Area restricitions of STRONG routing.
Neighbour * via
connection to STRONG
void stop_calculations()
sets STRONGcalc::calcstopped and stops algorithm in next iteration
KOO * search(qint64 id, KOO *s)
void * from
< pointer to STRONG or FibunacciHeap
STRONG ** mindSTRONG
end point array of shortest track at specific strong index
short traceback(STRONG *s, Neighbour *n)
reconstructs track and checks if Neighbour n was already used
float hmdown
Hm descenting since last big descenting section.
int index_STRONG(STRONGfib *t, Neighbour *n)
FibunacciHeap< STRONGPlusfib > ** fplus
int tpc
count of trackpoint
Neighbour * neighbours
neigbours to link to other cross
BTP3 database, created from OpenStreetMap data.
void store_STRONG(STRONGfib *t, Neighbour *n, int si, int i)
float hm
current Hm at STRONG
OSM * o
dataset to operate on
float hm
total height meter, for routing
short dhmin
defines climb: min. Hm
trackpoint * tp
heighdata of this Neighbour
short foundSTRONG
if 1 return succes when finished
float radius
data ellipse radius calculated from STRONGsetting and start/ end point
void save_crossdata(KOO *k, FILE *f)
low level save routine of save_STRONG
Neighbour * brthr
related Neighbour with opposite read direction supposed to store brthr
main struct for routing purpose