\( \def\bold#1{\bf #1} \newcommand{\d}{\mathrm{d}} \) BTP: Manual and Source Code Documentation

Power Uphill

bike mass [kg]
body mass [kg]
altitude gain [m]
climb length [km]
gradient [%]
time [s]
speed [km/h]
power [W]
power/mass [W/kg]
climbrate [m/min]

average power on climb stage

BTP  3.0
Routing/ClimbAnalysis/PowerCalculation
mainwindow.cpp
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 
4 
5 
6 MainWindow::MainWindow(QWidget *parent) :
7  QMainWindow(parent),
8  ui(new Ui::MainWindow){
9  autoload_setting();
10  init();
11  ui->setupUi(this);
12  centralWidget()->setLayout(ui->verticalLayout);
13  showMaximized();
14  centralWidget()->setMouseTracking(true);
15  ui->MapLabel->setMouseTracking(true);
16  ui->profil->setMouseTracking(true);
17  ui->profil->settings(&(c.PS));
18  setMouseTracking(true);
19  statusBar()->addWidget(statusLeft, 1);
20  statusBar()->addWidget(statusMiddle, 2);
21  connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(close()));
22  connect(ui->actionSpecify_SRTM3_data_folder,SIGNAL(triggered()),this,SLOT(set_SRTM3_folder()));
23  connect(ui->actionLoad_btp,SIGNAL(triggered()),this,SLOT(load_btp()));
24  connect(ui->actionSave_btp,SIGNAL(triggered()),this,SLOT(save_btp()));
25  connect(ui->actionRead_osm,SIGNAL(triggered()),this,SLOT(read_osm()));
26  connect(ui->actionBtp_startup_file,SIGNAL(triggered()),this,SLOT(set_start_btp()));
27  connect(ui->profil,SIGNAL(mousex(double)),this,SLOT(profilinfo(double)));
28  connect(ui->actionSTRONG_settings,SIGNAL(triggered()),this,SLOT(STRONG_settings()));
29  connect(ui->actionClimbs,SIGNAL(triggered()),this,SLOT(AnalyseClimbs()));
30  connect(ui->actionToggle_Climblayer,SIGNAL(triggered()),this,SLOT(toggle_Climblayer()));
31  connect(ui->actionToggle_STRONGlayer,SIGNAL(triggered()),this,SLOT(toggle_STRONGlayer()));
32  connect(ui->actionLoad_Climblayer,SIGNAL(triggered()),this,SLOT(load_Climblayer()));
33  connect(ui->actionCreate_STRONGlayer,SIGNAL(triggered()),this,SLOT(create_STRONGlayer()));
34  connect(ui->actionLoad_STRONGlayer,SIGNAL(triggered()),this,SLOT(load_STRONGlayer()));
35  connect(ui->actionSave_STRONGlayer,SIGNAL(triggered()),this,SLOT(save_STRONGlayer()));
36  connect(ui->actionGenerateMap,SIGNAL(triggered()),this,SLOT(generate_Map()));
37  connect(ui->actionInvert_height_data,SIGNAL(triggered()),this,SLOT(invert_Hm()));
38  connect(ui->actionNormalize_height_data,SIGNAL(triggered()),this,SLOT(normalize_Hm()));
39  connect(ui->actionSave_gpx,SIGNAL(triggered()),SLOT(save_gpx()));
40  connect(ui->actionSave_Profil_as_png,SIGNAL(triggered()),SLOT(save_profile()));
41  connect(ui->actionSettings,SIGNAL(triggered()),SLOT(profil_settings()));
42  connect(ui->actionOn_off,SIGNAL(triggered()),this,SLOT(toggle_poweranalysis()));
43  connect(ui->actionSettings_2,SIGNAL(triggered()),this,SLOT(map_settings()));
44  connect(PA,SIGNAL(recalced()),this,SLOT(update_profil()));
45  connect(ui->profil,SIGNAL(clicked(double)),this,SLOT(center_track(double)));
46  connect(ui->profil,SIGNAL(call_zoom_repaint(double,double)),this,SLOT(zoom_profil(double,double)));
47  connect(ui->profil,SIGNAL(call_fullview()),this,SLOT(update_profil()));
48  connect(ui->actionShow_Power,SIGNAL(triggered()),this,SLOT(toggle_showpower()));
49  connect(ui->actionShow_Speed_in_plot,SIGNAL(triggered()),this,SLOT(toggle_showspeed()));
50  connect(ui->actionAnalyse_gpx,SIGNAL(triggered()),this,SLOT(analyse_gpx()));
51  connect(ui->actionLoad_STRONG_calculation,SIGNAL(triggered()),this,SLOT(load_STRONGcalc()));
52  connect(ui->actionSave_STRONG_calculation,SIGNAL(triggered()),this,SLOT(save_STRONGcalc()));
53  connect(ui->actionGenerate_tiles,SIGNAL(triggered()),this,SLOT(generate_tiles()));
54  connect(ui->actionSplit_pbf,SIGNAL(triggered()),this,SLOT(split_europe_pbf()));
55  connect(ui->actionCorrect_hgt_Files,SIGNAL(triggered()),this,SLOT(correct_hgt()));
56  connect(ui->actionRead_osm_2,SIGNAL(triggered()),this,SLOT(read_europe()));
57  connect(ui->actionGenerate_climbdata,SIGNAL(triggered()),this,SLOT(CA_europe()));
58  connect(ui->actionGenerate_STRONG_layer,SIGNAL(triggered()),this,SLOT(STRONG_europe()));
59  connect(ui->actionExtractZoom12,SIGNAL(triggered()),this,SLOT(zoom14_collection()));
60  /*QString filename = QString("D:\\ClimbProject\\pbf-Data\\%1-%2-%3.pbf").arg(0).arg(0).arg(0);
61  QString newfile = QString("D:\\ClimbProject\\pbf-Data\\%1-%2-%3.pbf").arg(0).arg(0).arg("c");
62  QString newfile2 = QString("D:\\ClimbProject\\pbf-Data\\%1-%2-%3.pbf").arg(0).arg(0).arg("d");
63  QString newfile3 = QString("D:\\ClimbProject\\pbf-Data\\%1-%2-%3.pbf").arg(0).arg(0).arg("e");
64  QString cmdline = QString("D:\\ClimbProject\\pbf-Data\\osmconvert.exe");
65  QStringList arguments;
66  arguments << filename;
67  arguments << QString("-b=%1,%2,%3,%4").arg(12.2)
68  .arg(49)
69  .arg(12.4)
70  .arg(50.2);
71  arguments << QString("-o=").append(newfile);
72  QProcess* System_Call = new QProcess;
73  System_Call->start(cmdline,arguments);
74  //System_Call.waitForFinished(-1);
75  QProcess* System_Call2 = new QProcess;
76  arguments.replace(2,QString("-o=").append(newfile2));
77  System_Call2->start(cmdline,arguments);
78  QProcess* System_Call3 = new QProcess;
79  arguments.replace(2,QString("-o=").append(newfile3));
80  System_Call3->start(cmdline,arguments);*/
81  //read_osm("D:\\ClimbProject\\pbf-Data\\test.osm");
82  //update_map_raw();
83  //analyse_gpx("C:\\Users\\User\\Sport\\Strecken\\activity_75990630.gpx");
84 }
85 
86 MainWindow::~MainWindow(){
87  if(autosave) autosave_setting();
88  delete map;
89  delete osm;
90  delete hd;
91  delete ui;
92 }
93 void MainWindow::closeEvent(QCloseEvent *){
94  PA->close();
95 }
96 
97 void MainWindow::resizeEvent ( QResizeEvent * event ){
98  QSize sold = event->oldSize();
99  if(sold.width()>0 && sold.height() > 0)
100  //not at programm start
101  update_map_raw();
102 }
103 void MainWindow::keyPressEvent(QKeyEvent *event){
104  switch(event->key()){
105  case Qt::Key_Right:
106  zoom(1. , 0.5, 0); break;
107  case Qt::Key_Left:
108  zoom(1. ,-0.5, 0); break;
109  case Qt::Key_Up:
110  zoom(1. , 0, 0.5); break;
111  case Qt::Key_Down:
112  zoom(1. , 0,-0.5); break;
113  case Qt::Key_Plus:
114  zoom(0.5, 0, 0); break;
115  case Qt::Key_Minus:
116  zoom(2. , 0, 0); break;
117  case Qt::Key_Escape:
118  if(c.input == routeshort ||
119  c.input == routeflat)
120  reset_track();
121  else
122  emit stop_STRONG();
123  break;
124  case Qt::Key_Z:
125  undo();
126  break;
127  case Qt::Key_Y:
128  redo();
129  break;
130  case Qt::Key_Delete:
131  reset_track();
132  break;
133  case Qt::Key_Backspace:
134  if(QApplication::keyboardModifiers() == Qt::ControlModifier)
135  delete_to_cross(10);
136  else
137  delete_to_cross(1);
138  break;
139  case Qt::Key_0:
140  if(QApplication::keyboardModifiers() == Qt::ControlModifier)
141  set_mintype(0);
142  else
143  set_maxtype(0);
144  break;
145  case Qt::Key_1:
146  if(QApplication::keyboardModifiers() == Qt::ControlModifier)
147  set_mintype(1);
148  else
149  set_maxtype(1);
150  break;
151  case Qt::Key_2:
152  if(QApplication::keyboardModifiers() == Qt::ControlModifier)
153  set_mintype(2);
154  else
155  set_maxtype(2);
156  break;
157  case Qt::Key_3:
158  if(QApplication::keyboardModifiers() == Qt::ControlModifier)
159  set_mintype(3);
160  else
161  set_maxtype(3);
162  break;
163  case Qt::Key_4:
164  if(QApplication::keyboardModifiers() == Qt::ControlModifier)
165  set_mintype(4);
166  else
167  set_maxtype(4);
168  break;
169  case Qt::Key_5:
170  if(QApplication::keyboardModifiers() && Qt::ControlModifier)
171  set_mintype(5);
172  else
173  set_maxtype(5);
174  break;
175  case Qt::Key_PageUp:
176  if(QApplication::keyboardModifiers() && Qt::ControlModifier)
177  selectSTRONG(fw,10);
178  else
179  selectSTRONG(fw,1);
180  break;
181  case Qt::Key_PageDown:
182  if(QApplication::keyboardModifiers() && Qt::ControlModifier)
183  selectSTRONG(bw,10);
184  else
185  selectSTRONG(bw,1);
186  break;
187  case Qt::Key_C:
188  set_routingmode(routeclimb); break;
189  case Qt::Key_E:
190  set_routingmode(editdata); break;
191  case Qt::Key_K:
192  set_routingmode(routeshort); break;
193  case Qt::Key_F:
194  set_routingmode(routeflat); break;
195  case Qt::Key_M:
196  set_routingmode(routemountain); break;
197  case Qt::Key_S:
198  set_routingmode(routeSTRONG); break;
199  case Qt::Key_L:
200  set_routingmode(selectlayer); break;
201  case Qt::Key_N:
202  toggle_preview(); break;
203  case Qt::Key_Return:
204  enter();break;
205  }
206 }
207 void MainWindow::zoom(double zoomfactor,double dlonfactor, double dlatfactor){
208  double dlat = (map->getmaxlat()-map->getminlat())*dlatfactor;
209  double dlon = (map->getmaxlon()-map->getminlon())*dlonfactor;
210  double mlat = (map->getmaxlat()+map->getminlat())/2+dlat;
211  double mlon = (map->getmaxlon()+map->getminlon())/2+dlon;
212  dlat = (map->getmaxlat()-map->getminlat())/2*zoomfactor;
213  dlon = (map->getmaxlon()-map->getminlon())/2*zoomfactor;
214 
215  //draw preview
216  QPixmap prev(ui->MapLabel->size());
217  prev.fill(Qt::black);
218  QRectF Rdest(-int(map->getwidth() /zoomfactor*(1/2.+dlonfactor-1/2.*zoomfactor)),
219  -int(map->getheight()/zoomfactor*(1/2.-dlatfactor-1/2.*zoomfactor)),
220  int(map->getwidth()/zoomfactor),
221  int(map->getheight()/zoomfactor));
222  QRectF Rsrc(0,0,map->getwidth(),map->getheight());
223  QPainter painter(&prev);
224  painter.drawPixmap(Rdest,*cmap,Rsrc);
225  ui->MapLabel->setPixmap(prev);
226  ui->MapLabel->repaint();
227 
228  /*calc the true picture*/
229  c.MS.minlat = mlat-dlat;
230  c.MS.maxlat = mlat+dlat;
231  c.MS.minlon = mlon-dlon;
232  c.MS.maxlon = mlon+dlon;
233  update_map_raw();
234 }
236  kold = knew = NULL;
237  anchorfrom = anchorto = NULL;
239  autosave = 1;
240  SL = NULL;
241  CL = NULL;
242  SLN = SLc = 0;
243  ct = new Track();
244  lrt = new Track();
245  cmap = new QPixmap;
246  osm = new OSM;
247  osm->load(c.start_btp);
248  hd = new HeightData();
250  map = new MAP(hd,osm);
251  map->settings(&(c.MS));
252  r = new Routing(osm);
253  UR = new UndoRedo;
254  PA = new PowerAnalysis(&(c.PA));
255  PA->show();
256  statusLeft = new QLabel("coordinates", this);
257  statusLeft->setFrameStyle(QFrame::Panel | QFrame::Sunken);
258  statusMiddle = new QLabel("further information", this);
259  statusMiddle->setFrameStyle(QFrame::Panel | QFrame::Sunken);
260 }
261 void MainWindow::autoload_setting(){
262  QString filename = QCoreApplication::applicationDirPath();
263  filename.append("/settings.stg");
264  FILE* f = fopen(filename.toLocal8Bit().data(),"rb");
265  if(f != NULL){
266  fread(&c,sizeof(config),1,f);
267  fclose(f);
268  }
269  else
270  init_config();
271 }
272 void MainWindow::autosave_setting(){
273  QString filename = QCoreApplication::applicationDirPath();
274  filename.append("/settings.stg");
275  FILE* f = fopen(filename.toLocal8Bit().data(),"wb");
276  fwrite(&c,sizeof(config),1,f);
277  fclose(f);
278 }
279 void MainWindow::init_config(){
280  c.mintype= 0;
281  c.maxtype= 4;
282  c.SRTM3folder[0] = '\0';
283  c.start_btp[0] = '\0';
284  BTP3setups(&(c.sconfig),&(c.mconfig),&(c.cconfig)).init();
285  BTP3setups(&(c.CA)).init();
286  BTP3setups(&(c.PS)).init();
287  BTP3setups(&(c.MS)).init();
288  c.input = routeshort;
289  c.drawSTRONGlayer = 1;
290  c.drawRoute = 0;
291  c.drawClimblayer = 1;
292  c.plotpower = 1;
293  c.plotspeed = 1;
294  PowerAnalysis().set_default(&(c.PA));
295 }
297  QString status2keep = status2;
298  status2 = "Map is rendering...";
299  update_statusbar();
300  map->set_borders(c.MS.minlat,c.MS.maxlat,c.MS.minlon,c.MS.maxlon);
301  map->resize(ui->MapLabel->width(),ui->MapLabel->height());
302  map->calc_borders();
303  climblayer* clt = NULL;
304  if(CL != NULL && c.drawClimblayer) clt = CL;
305  STRONGlayer* slt = NULL;
306  if(SL != NULL && c.drawSTRONGlayer) slt = SL;
307 
308  map->draw_map(slt,clt,NULL,1);
310  status2 = status2keep;
311  update_statusbar();
312 }
314  delete cmap;
315  cmap = new QPixmap(*(map->get_Map()));
316  QPainter p(cmap);
317  //p.setRenderHint(QPainter::Antialiasing);
318  drawCross(&p);
319  drawRoute(&p);
320  if(c.input == editdata
321  && selected_way != NULL){
322  p.setPen(QPen(Qt::red,5));
324  }
325  ui->MapLabel->setPixmap(*cmap);
326 }
328  if(w != NULL || dstate != nonedot){
329  QPixmap cmapt(*cmap);
330  QPainter p(&cmapt);
331  if(w != NULL){
332  p.setPen(QPen(Qt::red,5));
333  map->draw_line(&p,w->node,w->nodec);
334  }
335  p.setPen(Qt::NoPen);
336  if(dstate != nonedot){
337  if(dstate == waydot)
338  p.setBrush(QBrush(Qt::red));
339  if(dstate == crossdot)
340  p.setBrush(QBrush(Qt::yellow));
341  if(dstate == crossdotmarked)
342  p.setBrush(QBrush(Qt::black));
343  p.drawEllipse(xdot-8,ydot-8,17,17);
344  }
345  ui->MapLabel->setPixmap(cmapt);
346  }
347  else
348  ui->MapLabel->setPixmap(*cmap);
349 
350 }
352  if(ct != NULL){
353  double hm = ct->get_height_meters();
354  double d = ct->get_length();
355  if(ct == lrt && PA->isVisible() && PA->isready()){
356  ui->profil->set_labels(QString("%1 km %2 Hm %3 Hm/km %4 km/h %5 W")
357  .arg(d,0,'f',2)
358  .arg(hm,0,'f',0)
359  .arg(hm/d,0,'f',1)
360  .arg(PA->get_v(),0,'f',1)
361  .arg(PA->get_P(),0,'f',0),
362  "d [km]","h [m]");
363 
364  }
365  else
366  ui->profil->set_labels(QString("%1 km %2 Hm %3 Hm/km")
367  .arg(d,0,'f',2)
368  .arg(hm,0,'f',0)
369  .arg(hm/d,0,'f',1),
370  "d [km]","h [m]");
371  double **dt = NULL,**dt1 = NULL,**dt2 = NULL;
372  int tc=0,tc1=0,tc2=0;
373  dt = ct->get_d_h_array();
374  tc = ct->get_array_length();
375  if(c.plotspeed && ct == lrt && PA->isVisible() && PA->isready()){
376  dt1 = PA->get_vdata();
377  tc1 = PA->get_datacount();
378  }
379  if(c.plotpower && ct == lrt && PA->isVisible() && PA->isready()){
380  dt2 = PA->get_Pdata();
381  tc2 = PA->get_datacount();
382  }
383  ui->profil->set_data(dt,tc,dt1,tc1,dt2,tc2);
384  }
385 }
386 void MainWindow::drawCross(QPainter *p){
387  p->setPen(Qt::NoPen);
388  p->setBrush(QBrush(Qt::green));
389  if(kold != NULL)
390  p->drawEllipse(map->lon_to_x(kold->lon)-5,
391  map->lat_to_y(kold->lat)-5,
392  11,11);
393  if(knew != NULL)
394  p->drawEllipse(map->lon_to_x(knew->lon)-5,
395  map->lat_to_y(knew->lat)-5,
396  11,11);
397 }
398 void MainWindow::drawRoute(QPainter *p){
399  if(ct != NULL){
400  // draw line
401  p->setPen(QPen(Qt::green,5));
402  p->setBrush(QBrush(Qt::black));
403  map->draw_line(p,ct);
404  }
405 }
406 void MainWindow::set_SRTM3_folder(){
407  QString filename = QFileDialog::getExistingDirectory(this,"select SRTM3 data directory");
408  strcpy(c.SRTM3folder,filename.toLocal8Bit().data());
410  update_map_raw();
411 }
412 void MainWindow::mousePressEvent(QMouseEvent *event){
413  if(event->button()==Qt::LeftButton && !traceback){
414  xold = event->x()-centralWidget()->x();
415  yold = event->y()-centralWidget()->y();
416  // drag drop track modification might be activated
417  if( (c.input == routeshort || c.input == routeflat)
418  && ct->found_anchors(map->y_to_lat(yold),map->x_to_lon(xold),
419  map->scale()*5,&anchorfrom,&anchorto)){
420  // track was clicked at marked cross position, preparing for drag&drop
421  if(c.input == routeshort){
422  if(anchorfrom != NULL)
423  r->DijkstraFib(anchorfrom,NULL,c.maxtype,c.mintype,osm,0);
424  if(anchorto != NULL)
425  r->DijkstraFib(anchorto,NULL,c.maxtype,c.mintype,osm,1);
426  }
427  if(c.input == routeflat){
428  if(anchorfrom != NULL)
429  r->DijkstraFib_minHM(anchorfrom,NULL,c.maxtype,c.mintype,osm,0);
430  if(anchorto != NULL)
431  r->DijkstraFib_minHM(anchorto,NULL,c.maxtype,c.mintype,osm,1);
432  }
433  readytotrace = traceback = 1;
434  }
435  }
436 }
437 void MainWindow::mouseReleaseEvent(QMouseEvent *event){
438  x = event->x()-centralWidget()->x();
439  y = event->y()-centralWidget()->y();
440  if(event->button()==Qt::LeftButton){
441  if(traceback && (x != xold || y != yold))
442  accept_ct();
443  else{
444  if(x == xold || y == yold){
445  if(c.input == editdata){
446  // map element ist going to be edited
447  kold = NULL;
448  knew = NULL;
449  selected_way = osm->select_Way(map->y_to_lat(y),map->x_to_lon(x));
450  if(selected_way != NULL){
451  status2 = QString("Way %1 selected, typ: %2")
452  .arg(selected_way->id)
453  .arg((int)selected_way->type);
454  update_statusbar();
456  }
457  }
458  else{
459  // cross was was clicked
460  if( (dstate == crossdot || dstate == crossdotmarked)
461  && kdot != NULL){
462  // cross on ct was clicked
464  traceback = 0;
465  readytotrace = 0;
467  }
468  else{
469  // cross aside track was clicked
470  if(STRONGstate == 1){
471  status2 = "STRONG calculation still running. ESC to quit.";
472  update_statusbar();
473  return;
474  }
475  if(STRONGstate == 2)
476  acceptSTRONG();
477 
478  KOO* k = osm->get_first_KOO();
479  float d = 1e10;
480  osm->select_cross(map->y_to_lat(y),map->x_to_lon(x),&k,&d,k);
481  kold = knew;
482  knew = k;
483  if(kold != NULL && knew != NULL && kold != knew){
484  // start and end are known, algorithms are allowed to work
485  if(c.input == routeshort) route_short();
486  if(c.input == routeflat) route_flat();
487  if(c.input == routeSTRONG
488  ||c.input == routeclimb
489  ||c.input == routemountain)
490  route_STRONG();
491  }
492  else
494  // routing is finished, reset the old selected cross
495  kold = NULL;
496  }
497  }
498  }
499  else{
500  if(event->modifiers()==Qt::ControlModifier){
501  /*zoom box*/
502  zoom((1.*abs(x-xold)/map->getwidth()+1.*abs(y-yold)/map->getheight())/2.,
503  1.*((x+xold)/2.-map->getwidth()/2.)/map->getwidth(),
504  1.*(map->getheight()/2.-(yold+y)/2.)/map->getheight());
505  }
506  else{
507  /*move map*/
508  zoom(1.,1.*(xold-x)/map->getwidth(),1.*(y-yold)/map->getheight());
509  }
510  }
511  }
512  }
513 }
514 void MainWindow::mouseDoubleClickEvent(QMouseEvent *event){
515 
516 }
517 void MainWindow::mouseMoveEvent(QMouseEvent *event){
518  this->setFocus();
519  x = event->x()-centralWidget()->x();
520  y = event->y()-centralWidget()->y();
521  if(traceback){
522  KOO* k; float d = 1e15;
523  osm->select_cross(map->y_to_lat(y),map->x_to_lon(x),
524  &k,&d,osm->get_first_KOO());
525  status1 = QString("%1°N %2 °E %3 m")
526  .arg(map->y_to_lat(y),10,'f',6)
527  .arg(map->x_to_lon(x),10,'f',6)
528  .arg(map->xy_to_height(x,y),7,'f',1);
529  trace_back(k);
530  }
531  else{
532  if(event->buttons()==Qt::LeftButton){
533  if(event->modifiers()==Qt::ControlModifier){
534  /*zoom box*/
535  QPixmap prev(*cmap);
536  QPainter painter(&prev);
537  QRectF R(qMin(x,xold),qMin(y,yold),qAbs(x-xold),qAbs(y-yold));
538  painter.setBrush(QBrush(QColor(0,255,0,60)));
539  painter.drawRect(R);
540  ui->MapLabel->setPixmap(prev);
541  ui->MapLabel->repaint();
542  status1 = QString("%1°N %2°E %3 m")
543  .arg(map->y_to_lat(y),10,'f',6)
544  .arg(map->x_to_lon(x),10,'f',6)
545  .arg(map->xy_to_height(x,y),7,'f',1);
546  }
547  else{
548  /*move map*/
549  QPixmap prev(ui->MapLabel->size());
550  QPainter painter(&prev);
551  painter.drawPixmap(x-xold,y-yold,*cmap);
552  ui->MapLabel->setPixmap(prev);
553  ui->MapLabel->repaint();
554  status1 = "";
555  }
556  }
557  else{
558  status1 = QString("%1°N %2°E %3 m")
559  .arg(map->y_to_lat(y),10,'f',6)
560  .arg(map->x_to_lon(x),10,'f',6)
561  .arg(map->xy_to_height(x,y),7,'f',1);
562  MouseToTrack();
563  Way* w = NULL;
564  if(c.input == editdata){
565  w = osm->select_Way(map->y_to_lat(y),map->x_to_lon(x));
566  if(w != NULL)
567  status2 = QString("way id: %1").arg(w->id);
568  else
569  status2 = "";
570  }
572  }
573  }
574  update_statusbar();
575 }
576 void MainWindow::wheelEvent(QWheelEvent * event ){
577  x = event->x()-centralWidget()->x();
578  y = event->y()-centralWidget()->y();
579  int xmiddle = map->getwidth()/2;
580  int ymiddle = map->getheight()/2;
581  if (event->delta() < 0)
582  zoom(2. ,1.*(x-xmiddle)/map->getwidth(),
583  1.*(ymiddle-y)/map->getheight());
584  else
585  zoom(0.5,1.*(x-xmiddle)/map->getwidth(),
586  1.*(ymiddle-y)/map->getheight());
587 }
588 void MainWindow::update_statusbar(){
589  statusLeft->setText(status1);
590  statusMiddle->setText(status2);
591  ui->statusBar->update();//repaint();
592 }
593 void MainWindow::load_btp(){
594  QString filename = QFileDialog().getOpenFileName(this,"open BTP data","","BergTourenPlaner data (*.btp)");
595  if(!filename.isEmpty()){
596  status2 = QString("Loading %1 ...").arg(filename);
597  update_statusbar();
598  load_btp(filename);
599  }
600 }
601 void MainWindow::load_btp(QString filename){
602  bool centermap = (osm->get_status()<3);
603  osm->load(filename.toLocal8Bit().data());
605  if(centermap){
606  osm->calc_brect();
607  // if this is the first data loaded at this BTP instance
608  c.MS.minlat = osm->getminlat();
609  c.MS.maxlat = osm->getmaxlat();
610  c.MS.minlon = osm->getminlon();
611  c.MS.maxlon = osm->getmaxlon();
612  if(c.MS.minlat >= c.MS.maxlat){
613  c.MS.minlat = qMax(-90.,c.MS.maxlat-0.1);
614  c.MS.maxlat = qMin( 90.,c.MS.minlat+0.1);
615  }
616  if(c.MS.minlon >= c.MS.maxlon){
617  c.MS.minlon = qMax(-180.,c.MS.maxlon-0.1);
618  c.MS.maxlon = qMin( 180.,c.MS.minlon+0.1);
619  }
620  }
621  update_map_raw();
622 }
623 
624 void MainWindow::save_btp(){
625  QString filename = QFileDialog().getSaveFileName(this,"save BTP data","","BergTourenPlaner data (*.btp)");
626  if(!filename.isEmpty()){
627  status2 = QString("Saving data within window to %1 ...").arg(filename);
628  update_statusbar();
629  save_btp(filename,map->getminlat(),map->getmaxlat(), map->getminlon(),
630  map->getmaxlon());
632  update_map_raw();
633  }
634 }
635 void MainWindow::save_btp(QString filename, double minlat, double maxlat,
636  double minlon, double maxlon){
637  osm->save(filename.toLocal8Bit().data(), minlat, maxlat, minlon, maxlon);
638 }
639 void MainWindow::read_osm(){
640  QString filename = QFileDialog().getOpenFileName(this,"read OSM data","","OpenStreetMap data (*.osm)");
641  if(!filename.isEmpty()){
642  read_osm(filename);
643  update_map_raw();
644  }
645 }
646 void MainWindow::read_osm(QString filename){
647  status2 = "Data is processed. This may last several minutes.";
648  update_statusbar();
649  osm->setfilename(filename.toLocal8Bit().data());
650  osm->read_OSM();
651  status2 = "Data read. Continue with generating relational data base.";
652  update_statusbar();
653  osm->get_KOO_Waysavl();
654  osm->check_lines();
655  status2 = "Data base ready. Processing OSM-Relationdata.";
656  update_statusbar();
657  osm->RelationstoFace(osm->woodr,osm->wood);
658  osm->RelationstoFace(osm->waterr,osm->water);
659  status2 = "Relations processed. Loading heightdata server.";
660  update_statusbar();
661  osm->calc_brect();
662  HeightData h2;
663  h2.set_SRTM3_folder(&(c.SRTM3folder[0]));
664  h2.reset_t(osm->getminlat()-0.1,
665  osm->getmaxlat()+0.1,
666  osm->getminlon()-0.2,
667  osm->getmaxlon()+0.2);
668  status2 = "Heightdata ready. Ranking summits.";
669  update_statusbar();
670  osm->calc_peak_index_pro(&h2);
671  osm->sort_peaks();
672  status2 = "Summits ranked. Generating streets height data.";
673  update_statusbar();
674  WayHeight w(&h2,osm);
675  status2 = "OSM Processing has finished. First save data as *.btp an restart programm.";
676  update_statusbar();
678  c.MS.minlat = osm->getminlat();
679  c.MS.maxlat = osm->getmaxlat();
680  c.MS.minlon = osm->getminlon();
681  c.MS.maxlon = osm->getmaxlon();
682 }
683 
684 void MainWindow::set_start_btp(){
685  QString filename = QFileDialog().getOpenFileName(this,"select BTP file","","BergTourenPlaner data (*btp)");
686  if(filename.isEmpty()){
687  c.start_btp[0] = '\0';
688  status2 = QString("Loading no btp data at programm start.");
689  }
690  else{
691  strcpy(c.start_btp,filename.toLocal8Bit().data());
692  status2 = QString("Loading %1 at program start.").arg(filename);
693  }
694  update_statusbar();
695 }
696 void MainWindow::profilinfo(double x){
697  if(ct != NULL){
698  double h;
699  ct->extract_h(x,&h);
700  KOO k;
701  ct->extract_KOO(&k,x);
702  int xpx = map->lon_to_x(k.lon);
703  int ypx = map->lat_to_y(k.lat);
704  status1 = QString("%1°N %2°E %3 m [%4 km %5 m]")
705  .arg(k.lat,10,'f',6)
706  .arg(k.lon,10,'f',6)
707  .arg(map->xy_to_height(xpx,ypx),7,'f',1)
708  .arg(x,7,'f',3)
709  .arg(h,6,'f',1);
710  if(ct==lrt && PA->isready() && PA->isVisible()){
711  QTime time = QTime(0,0,0,0).addSecs(PA->get_t(x));
712  status1.append(QString("[%1 km/h %2 W %3]")
713  .arg(PA->get_v(x),0,'f',1)
714  .arg(PA->get_P(x),0,'f',0)
715  .arg(time.toString()));
716  }
717  update_statusbar();
718  xdot = map->lon_to_x(k.lon);
719  ydot = map->lat_to_y(k.lat);
720  dstate = waydot;
721  update_map_MovObj(NULL);
722  }
723 
724 }
726  if(readytotrace){
727  if(anchorto != NULL || anchorfrom != NULL){
728  Track *tfrom,*tto, start(lrt),end(lrt);
729  // first route wayfrom anchorfrom to new cross
730  if(anchorfrom != NULL){
731  /*ein Zwischenpunkt wird veraendert*/
732  start.trim_right(anchorfrom);
733  if(k->cd->s[0].from != NULL){
734  Neighbour** nl=NULL;
735  int nc;
736  r->extract_neighbourlist(&(anchorfrom->cd->s[0]),&(k->cd->s[0]),
737  &nl,&nc);
738  tfrom = new Track(nl,nc);
739  }
740  else
741  tfrom = new Track();
742  }
743  else{
744  /*Der Startpunkt wird veraendert*/
745  start.delete_complete();
746  tfrom = new Track();
747  }
748  // now route way from new cross to anchorto
749  if( anchorto != NULL){
750  /*ein Zwischenpunkt wird veraendert*/
751  end.trim_left(anchorto);
752  if(k->cd->s[1].from != NULL){
753  Neighbour** nl=NULL;
754  int nc;
755  r->extract_neighbourlist(&(anchorto->cd->s[1]),&(k->cd->s[1]),
756  &nl,&nc);
757  tto = new Track(nl,nc);
758  tto->invert();
759  }
760  else
761  tto = new Track();
762  }
763  else{
764  /*Der Endpunktt wird veraendert*/
765  end.delete_complete();
766  tto = new Track();
767  }
768  start.add(tfrom);
769  start.add(tto);
770  start.add(&end);
771  if(ct != lrt)
772  delete ct;
773  ct = new Track(&start);
775  update_profil();
776  return 1;
777  }
778  else{
779  if( k != knew && k->cd->s[STRONGindex].via != NULL){
780  Neighbour** nl = NULL; int nc;
781  if(ct != lrt)
782  delete ct;
783  ct = new Track(lrt);
784  r->extract_neighbourlist(NULL, &(k->cd->s[STRONGindex]),&nl,&nc);
785  Track ttemp(&(nl[1]),nc-1);
786  ct->add(&ttemp);
787  delete nl;
788  update_profil();
790  return 1;
791  }
792  else
793  return 0;
794 
795  }
796  }
797  else
798  return 0;
799 
800 }
802  status2 = "Shortest track is routing ...";
803  update_statusbar();
804  if(!r->DijkstraFib(kold,knew,c.maxtype,c.mintype,osm,0)){
805  knew = kold;
806  status2 = "Found no way!";
807  update_statusbar();
808  return;
809  }
810  Neighbour** nl=NULL;
811  int nc;
812  r->extract_neighbourlist(kold->cd->s,knew->cd->s,&nl,&nc);
813  Track tt(nl,nc);
814  UR->add(ct);
815  ct->add(&tt);
817  delete nl;
818  lrt = ct;
819  recalc_power();
821  update_profil();
822 }
824  status2 = "Least vertical meter track is routing ...";
825  update_statusbar();
826  if(!r->DijkstraFib_minHM(kold,knew,c.maxtype,c.mintype,osm,0)){
827  knew = kold;
828  status2 = "Found no way!";
829  update_statusbar();
830  return;
831  }
832  Neighbour** nl=NULL;
833  int nc;
834  r->extract_neighbourlist(kold->cd->s,knew->cd->s,&nl,&nc);
835  Track tt(nl,nc);
836  UR->add(lrt);
837  lrt->add(&tt);
838  if(ct != lrt)
839  delete ct;
840  ct = lrt;
841  recalc_power();
842  update_map_track();;
843  update_profil();
845  delete nl;
846 }
848  STRONGsetting* s;
849  bool hmonly = true;
850  if(c.input == routemountain) s = &(c.mconfig);
851  if(c.input == routeSTRONG) s = &(c.sconfig);
852  if(c.input == routeclimb){ s = &(c.cconfig); hmonly = false;}
853 
854  STRONGcalc* sc = new STRONGcalc(osm,kold,knew,c.maxtype,c.mintype,s,
855  &STRONGtracks,&sN,hmonly);
856  connect(sc,SIGNAL(refresh_progress(int)),this,SLOT(STRONG_preview(int)));
857  connect(sc,SIGNAL(finished(int)),this,SLOT(route_STRONG_finalize(int)));
858  connect(this,SIGNAL(stop_STRONG()),sc,SLOT(stop_calculations()));
859  STRONGstate = 1;
860  sc->start();
861 }
863  if(succes){
864  // STRONG algorithm has succesfully finsihed
865  STRONGindex = sN-1;
866  if(c.input == routemountain){
867  // search for the track with most Hm/km
868  double minQu = 0, Qut = -1;
869  for(int i = 0; i < sN; i++){
870  if(STRONGtracks[i] != NULL){
872  if(Qut > minQu){
873  STRONGindex = i;
874  minQu = Qut;
875  }
876  }
877  }
878  STRONGstate = 2;
879  acceptSTRONG();
880  kold = NULL;
881  }
882  else{
883  readytotrace = 1;
884  STRONGstate = 2;
885  if(STRONGtracks[STRONGindex] == NULL)
886  selectSTRONG(bw,1);
887  else{
888  status2 = QString("STRONG %1/%2, select with page up/down, ENTER to accept, 'm' to select any crossroad as end point")
889  .arg(STRONGindex+1)
890  .arg(sN);
891  update_statusbar();
892  }
893  kold = NULL;
894  }
895  }
896  else{
897  status2 = "Found no way. Free Memory ...";
898  update_statusbar();
899  r->finish_STRONG();
901  knew = kold;
904  status2 = "Found no way.";
905  update_statusbar();
906  }
907 }
908 void MainWindow::delete_STRONG_tracks(){
909  if(STRONGtracks != NULL){
910  for(int i = 0; i < sN; i++)
911  if(STRONGtracks[i] != NULL)
912  STRONGtracks[i]->~Track();
913  free(STRONGtracks);
914  STRONGtracks = NULL;
915  }
916 }
918  if( c.input == routeSTRONG
919  || c.input == routemountain
920  || c.input == routeclimb){
921  if(STRONGstate == 2){
922  status2 = "Free Memory ...";
923  update_statusbar();
924  r->finish_STRONG(); //allokierten Speicher freigeben
925  }
926  // add selected STRONG track to existing ct
927  UR->add(lrt);
928  if(lrt != ct)
929  delete lrt;
930  lrt = ct;
931  recalc_power();
932  update_profil();
933  knew = ct->get_last_KOO();
937  }
938 }
940  dstate = nonedot; //es gibt keinen Punkt mehr zu zeigen
941  if(c.input != editdata && !traceback){
942  /* if routing then clear tracks anyway*/
943  kold = NULL;
944  knew = NULL;
945  UR->add(lrt);
946  lrt->delete_complete();
947  ct->delete_complete();
948  }
949  switch(c.input){
950  case routeclimb:
951  case routeSTRONG:
952  acceptSTRONG();
954  break;
955  case routeshort:
956  case routeflat:
957  case routemountain:
959  break;
960  case editdata:
961  if(selected_way != NULL){
962  osm->del_Way(selected_way);
963  status2 = QString("Way %1 was deleted!").arg(selected_way->id);
964  update_statusbar();
965  selected_way = NULL;
966  update_map_raw();
967  }
968  break;
969  default: break;
970  }
971  recalc_power();
972  update_profil();
973  update_map_track();;
974 }
975 void MainWindow::set_routingmode(inputstate ip){
976  if(STRONGstate == 2)
977  acceptSTRONG();
978  c.input = ip;
979  selected_way = NULL;
980  switch(c.input){
981  case routeshort:
982  status2 = QString("[mint: %1, maxt: %2] Routet kuerzesten Weg; z fuer rueckgaengig, entf zum loeschen").arg(int(c.mintype)).arg(int(c.maxtype));
983  break;
984  case routeflat:
985  status2 = QString("[mint: %1, maxt: %2] Routet hoehenmeteraermsten Weg; z fuer rueckgaengig, entf zum loeschen").arg(int(c.mintype)).arg(int(c.maxtype));
986  break;
987  case routeclimb:
988  if(c.cconfig.noSTRONGPlus)
989  status2 = QString("[points: %1, step: %2, mint: %3, c.maxt: %4, maxhmperkm: %5] routing STRONG, ESC to cancel, z undo, r redo, entf to delete")
990  .arg(c.cconfig.hmmax)
991  .arg(c.cconfig.hmstep)
992  .arg(int(c.mintype))
993  .arg(int(c.maxtype))
994  .arg(c.cconfig.hmperkm);
995  else
996  status2 = QString("[points: %1, step: %2, mint: %3, c.maxt: %4, maxhmperkm: %5, dhmin: %6, minP: %7, downtoupmax: %8] routing STRONG with restrictions, ESC to cancel, z undo, r redo, entf to delete")
997  .arg(c.cconfig.hmmax)
998  .arg(c.cconfig.hmstep)
999  .arg(int(c.mintype))
1000  .arg(int(c.maxtype))
1001  .arg(c.cconfig.hmperkm)
1002  .arg(c.cconfig.dhmin)
1003  .arg(c.cconfig.minP)
1004  .arg(c.cconfig.downtoupmax);
1005  break;
1006  case routemountain:
1007  if(c.mconfig.noSTRONGPlus)
1008  status2 = QString("[HM: %1, step: %2, mint: %3, c.maxt: %4, maxhmperkm: %5] routing STRONG, ESC to cancel, z undo, r redo, entf to delete")
1009  .arg(c.mconfig.hmmax)
1010  .arg(c.mconfig.hmstep)
1011  .arg(int(c.mintype))
1012  .arg(int(c.maxtype))
1013  .arg(c.mconfig.hmperkm);
1014  else
1015  status2 = QString("[HM: %1, step: %2, mint: %3, c.maxt: %4, maxhmperkm: %5, dhmin: %6, minP: %7, downtoupmax: %8] routing STRONG with restrictions, ESC to cancel, z undo, r redo, entf to delete")
1016  .arg(c.mconfig.hmmax)
1017  .arg(c.mconfig.hmstep)
1018  .arg(int(c.mintype))
1019  .arg(int(c.maxtype))
1020  .arg(c.mconfig.hmperkm)
1021  .arg(c.mconfig.dhmin)
1022  .arg(c.mconfig.minP)
1023  .arg(c.mconfig.downtoupmax);
1024  break;
1025  case routeSTRONG:
1026  if(c.sconfig.noSTRONGPlus)
1027  status2 = QString("[HM: %1, step: %2, mint: %3, c.maxt: %4, maxhmperkm: %5] routing STRONG, ESC to cancel, z undo, r redo, entf to delete")
1028  .arg(c.sconfig.hmmax)
1029  .arg(c.sconfig.hmstep)
1030  .arg(int(c.mintype))
1031  .arg(int(c.maxtype))
1032  .arg(c.sconfig.hmperkm);
1033  else
1034  status2 = QString("[HM: %1, step: %2, mint: %3, c.maxt: %4, maxhmperkm: %5, dhmin: %6, minP: %7, downtoupmax: %8] routing STRONG with restrictions, ESC to cancel, z undo, r redo, entf to delete")
1035  .arg(c.sconfig.hmmax)
1036  .arg(c.sconfig.hmstep)
1037  .arg(int(c.mintype))
1038  .arg(int(c.maxtype))
1039  .arg(c.sconfig.hmperkm)
1040  .arg(c.sconfig.dhmin)
1041  .arg(c.sconfig.minP)
1042  .arg(c.sconfig.downtoupmax);
1043  break;
1044  case editdata:
1045  status2 = QString("Waehlen sie einen Weg durch Klicken zum Editieren aus; entf zum entfernen, Zahlen 0 bis 5 zum einstellen des Typ");
1046  break;
1047  case selectlayer:
1048  if(SL != NULL){
1049  status2 = QString("STRONGlayer %1 von %2 wird angezeigt; mit Bild auf/ab Layer auswaehlen").arg(SLc).arg(SLN);
1050  update_map_track();;
1051  }
1052  else
1053  status2 = QString("Kein STRONGlayer geladen");
1054  break;
1055  default: break;
1056  }
1057  update_statusbar();
1058 }
1060  UR->add(lrt);
1061  lrt->delete_cross(cc);
1062  if(ct != lrt)
1063  delete ct;
1064  ct = lrt;
1065  if(ct->notNULL())
1066  knew = ct->get_last_KOO();
1067  else
1068  knew = NULL;
1069  kold = NULL;
1070  recalc_power();
1071  update_profil();
1072  update_map_track();
1073 }
1075  c.mintype = qMin(mt,char(5));
1077 }
1079  if(c.input == editdata && selected_way != NULL){
1080  osm->change_Waytype(selected_way,mt);
1081  status2 = QString("Weg %i geaendert\nneuer Typ: %i ")
1082  .arg(selected_way->id)
1083  .arg(selected_way->type);
1084  selected_way = NULL;
1085  update_statusbar();
1086  update_map_raw();
1087  }
1088  else{
1089  c.maxtype = qMin(mt,char(5));
1091  }
1092 }
1094  if(lrt != ct)
1095  delete lrt;
1096  lrt = ct = UR->undo(ct);
1097  recalc_power();
1098  kold = NULL;
1099  knew = ct->get_last_KOO();
1100  update_profil();
1101  update_map_track();;
1102 }
1104  if(lrt != ct){
1105  delete lrt;
1106  delete ct;
1107  }
1108  else
1109  delete ct;
1110  lrt = ct = UR->redo();
1111  recalc_power();
1112  kold = NULL;
1113  knew = ct->get_last_KOO();
1114  update_profil();
1115  update_map_track();
1116 }
1117 void MainWindow::selectSTRONG(readdirection rd, short steps){
1118  if((c.input == routeSTRONG || c.input == routeclimb) && readytotrace){
1119  if( rd == fw ){
1120  STRONGindex = min( sN-1, STRONGindex + steps);
1121  while(STRONGindex < sN-1 && STRONGtracks[STRONGindex] == NULL)
1122  STRONGindex++;
1123  if(STRONGtracks[STRONGindex] == NULL)
1124  selectSTRONG(bw,1);
1125  }
1126  else{
1127  STRONGindex = max( 0, STRONGindex - steps);
1128  while(STRONGindex > 0 && STRONGtracks[STRONGindex] == NULL)
1129  STRONGindex--;
1130  if(STRONGtracks[STRONGindex] == NULL)
1131  selectSTRONG(fw,1);
1132  }
1133  status2 = QString("STRONG %1/%2, select with page up/down, ENTER to accept, 'm' to select any crossroad as end point")
1134  .arg(STRONGindex+1)
1135  .arg(sN);
1136  update_statusbar();
1138  }
1139  if(c.input == selectlayer && SL != NULL){
1140  if( rd == fw )
1141  SL = r->STRONGlayer_create(SL,qMin(sN-1,SLc + steps));
1142  else
1143  SL = r->STRONGlayer_create(SL,qMax(0 ,SLc - steps));
1144  status2 = QString("STRONGlayer %1 von %2 is shown. Select layer with page up/down").arg(SLc).arg(SLN);
1145  update_statusbar();
1146  update_map_raw();
1147  }
1148 }
1149 void MainWindow::MouseToTrack(){
1150  dstate = nonedot;
1151  double ddot;
1152  kdot = NULL;
1153  if( ct != NULL && ct->notNULL()){
1154  KOO ktt;
1155  switch(ct->next_cross(map->y_to_lat(y),map->x_to_lon(x),&kdot,map->scale()*5)){
1156  case 1:
1157  dstate = crossdot;
1158  xdot = map->lon_to_x(kdot->lon);
1159  ydot = map->lat_to_y(kdot->lat);
1160  return;
1161  case 2:
1162  dstate = crossdotmarked;
1163  xdot = map->lon_to_x(kdot->lon);
1164  ydot = map->lat_to_y(kdot->lat);
1165  return;
1166  }
1167  // there is no cross of ct in reach, search absolut nearest point on ct
1168  if(ct->near_check(map->y_to_lat(y),map->x_to_lon(x),
1169  (map->getmaxlat()-map->getminlat())*0.1))
1170  // the track is close to the mouse point
1171  if(ct->next_d(map->y_to_lat(y),map->x_to_lon(x),&ddot))
1172  // the neares point was found
1173  if(ct->extract_KOO(&ktt,ddot)){
1174  // calc with the nearest point
1175  xdot = map->lon_to_x(ktt.lon);
1176  ydot = map->lat_to_y(ktt.lat);
1177  dstate = waydot;
1178  ui->profil->set_marker(ddot);
1179  double h; ct->extract_h(ddot,&h);
1180  status1.append(QString(" [%1 km %2 m]")
1181  .arg(ddot,7,'f',3)
1182  .arg(h,6,'f',1));
1183  if(ct==lrt && PA->isready()&& PA->isVisible()){
1184  int timei = PA->get_t(ddot);
1185  QTime time = QTime(0,0,0,0).addSecs(timei);
1186  status1.append(QString("[%1 km/h %2 W %3]")
1187  .arg(PA->get_v(ddot),0,'f',1)
1188  .arg(PA->get_P(ddot),0,'f',0)
1189  .arg(time.toString()));
1190  }
1191  return;
1192  }
1193  }
1194  ui->profil->set_marker(ui->profil->get_xmin());
1195 }
1197  if(traceback)
1198  accept_ct();
1199  else{
1200  if(STRONGstate == 1){
1201  status2 = "STRONG calculation still running. ESC to quit.";
1202  update_statusbar();
1203  }
1204  else{
1205  if( c.input == routeSTRONG
1206  ||c.input == routeclimb
1207  ||c.input == routemountain){
1208  if(readytotrace)
1209  acceptSTRONG();
1210  else{
1211  kold = knew;
1212  knew = NULL;
1213  route_STRONG();
1214  }
1215  }
1216  if( c.input == routeflat && knew != NULL){
1217  status2 = "Hoehenmeteraermster Weg mit offenem Ende wird geroutet ...";
1218  update_statusbar();
1219  r->DijkstraFib_minHM(knew,NULL,c.maxtype,c.mintype,osm,0);
1220  readytotrace = 1; STRONGindex = 0; traceback = 1;
1221  anchorto = anchorfrom = NULL;
1222  status2 = "Hoehenmeterarme Wege bereit ...";
1223  update_statusbar();
1224  }
1225  if( c.input == routeshort && knew != NULL){
1226  status2 = "Kuerzester Weg mit offenem Ende wird geroutet ...";
1227  update_statusbar();
1228  r->DijkstraFib(knew,NULL,c.maxtype,c.mintype,osm,0);
1229  readytotrace = 1; STRONGindex = 0; traceback = 1;
1230  anchorto = anchorfrom = NULL;
1231  status2 = "Kurze Wege bereit ...";
1232  update_statusbar();
1233  }
1234  }
1235  }
1236 }
1238  UR->add(lrt);
1239  if(lrt != ct)
1240  delete lrt;
1241  lrt = ct;
1242  recalc_power();
1243  update_profil();
1244  traceback = 0;
1245  readytotrace = 0;
1246  if(STRONGstate == 1)
1247  acceptSTRONG();
1248  knew = ct->get_last_KOO();
1249  kold = NULL;
1250  update_map_track();
1252 }
1254  if(readytotrace){
1255  anchorto = anchorfrom = NULL;
1256  if(traceback == 0)
1257  traceback = 1;
1258  else
1259  traceback = 0;
1260  }
1261 }
1263  status2 = QString("STRONG calculation: %1/%2 steps done").arg(i).arg(sN);
1264  update_statusbar();
1265  if(STRONGtracks[i] != NULL){
1266  if(ct != lrt)
1267  delete ct;
1268  ct = new Track(lrt);
1269  ct->add(STRONGtracks[i]);
1270  update_map_track();
1271  update_profil();
1272  }
1273 }
1275  if( BTP3setups(&(c.sconfig),&(c.mconfig),&(c.cconfig)).exec())
1277 }
1278 void MainWindow::create_STRONGlayer(){
1279  if(STRONGstate == 2){
1280  SL = r->STRONGlayer_create(SL,STRONGindex);
1281  c.drawSTRONGlayer = 1;
1282  update_map_raw();
1283  }
1284  else{
1285  status2 = "There is no finished STRONG calculation to operate upon.";
1286  update_statusbar();
1287  }
1288 }
1289 void MainWindow::save_STRONGlayer(){
1290  QString filename = QFileDialog().getSaveFileName(this,"save STRONGlayer","","BTP STRONGlayer (*.bsl)");
1291  if(SL != NULL && !filename.isEmpty()){
1292  r->STRONGlayer_save(filename.toLocal8Bit().data(),SL);
1293  status2 = QString("saved STRONGlayer as %1").arg(filename);
1294  update_statusbar();
1295  }
1296 }
1297 void MainWindow::load_STRONGlayer(){
1298  QString filename = QFileDialog().getOpenFileName(this,"load STRONGlayer","","BTP STRONGlayer (*.bsl)");
1299  if(!filename.isEmpty()){
1300  c.drawSTRONGlayer = 1;
1301  SL = r->STRONGlayer_load(filename.toLocal8Bit().data());
1302  update_map_raw();
1303  }
1304 }
1305 void MainWindow::toggle_STRONGlayer(){
1306  if(c.drawSTRONGlayer)
1307  c.drawSTRONGlayer = 0;
1308  else
1309  c.drawSTRONGlayer = 1;
1310  update_map_raw();
1311 }
1312 void MainWindow::AnalyseClimbs(){
1313  if(BTP3setups(&(c.CA)).exec()){
1314  QString oldstatus2 = status2;
1315  status2 = "Analysing climbs ...";
1316  update_statusbar();
1317  ClimbAnalyse CA(osm,c.mintype,c.maxtype,c.CA.minP,c.CA.minS,c.CA.maxdwnHM,
1318  c.CA.minHM,hd);
1319  //QMessageBox(QMessageBox::NoIcon,"sdfg",QString("%1").arg(1)).exec();
1320  if(c.CA.list) CA.create_list(c.CA.ProjectName,c.CA.ProjectFolder);
1321  //QMessageBox(QMessageBox::NoIcon,"sdfg",QString("%1").arg(2)).exec();
1322  if(c.CA.Climblayer){
1323  status2 = "Creating Climblayer ...";
1324  update_statusbar();
1325  c.drawClimblayer = 1;
1326  //QMessageBox(QMessageBox::NoIcon,"sdfg",QString("%1").arg(3)).exec();
1327  CL = CA.get_ClimbLayer();
1328  //QMessageBox(QMessageBox::NoIcon,"sdfg",QString("%1").arg(4)).exec();
1329  CA.save_ClimbLayer(c.CA.ProjectName,c.CA.ProjectFolder,CL);
1330  //QMessageBox(QMessageBox::NoIcon,"sdfg",QString("%1").arg(5)).exec();
1331  update_map_raw();
1332  }
1333 
1334  if(c.CA.map){
1335  status2 = "Generating map ...";
1336  update_statusbar();
1337  MAP mt(hd,osm);
1338  mt.settings(&(c.MS));
1339  double widthtoheight = (osm->getmaxlon()-osm->getminlon())
1340  *cos(M_PI*(osm->getmaxlat()+osm->getminlat())/2./180.)
1341  /(osm->getmaxlat()-osm->getminlat());
1342  int height = int(sqrt(c.CA.mapsize*1000000/widthtoheight));
1343  int width= int(height*widthtoheight);
1344  mt.resize(width,height);
1345  mt.set_borders(osm->getminlat(),osm->getmaxlat(),osm->getminlon(),osm->getmaxlon());
1346  mt.calc_borders();
1347  climblayer *clt = NULL;
1348  if(c.CA.Climblayer) clt = CL;
1349  mt.draw_map(NULL,clt,NULL,0);
1350  QString filename = QString(c.CA.ProjectFolder)
1351  .append(c.CA.ProjectName).append(".png");
1352  mt.save_to_png(filename);
1353  }
1354  if(c.CA.html){
1355  status2 = "Generating html data ...";
1356  update_statusbar();
1357  CA.create_html(c.CA.ProjectName,c.CA.ProjectFolder);
1358  }
1359  //QMessageBox(QMessageBox::NoIcon,"sdfg",QString("%1").arg(6)).exec();
1360  status2 = oldstatus2;
1361  update_statusbar();
1362  }
1363 }
1364 void MainWindow::load_Climblayer(){
1365  QString filename = QFileDialog().getOpenFileName(this,"load climblayer","","BTP climblayer (*.bbl)");
1366  if(!filename.isEmpty()){
1367  c.drawClimblayer = 1;
1368  ClimbAnalyse CA;
1369  CL = CA.load_ClimbLayer(filename.toLocal8Bit().data());
1370  update_map_raw();
1371  }
1372 }
1373 void MainWindow::toggle_Climblayer(){
1374  if(c.drawClimblayer)
1375  c.drawClimblayer = 0;
1376  else
1377  c.drawClimblayer = 1;
1378  update_map_raw();
1379 }
1381  ExtMapSettings ems;
1382  ems.maxlat = map->getmaxlat();
1383  ems.minlat = map->getminlat();
1384  ems.maxlon = map->getmaxlon();
1385  ems.minlon = map->getminlon();
1386  ems.drawCL = c.drawClimblayer;
1387  ems.drawSL = c.drawSTRONGlayer;
1388  ems.drawct = ct->notNULL();
1389  ems.mapsize = 4;
1390  if(BTP3setups(&ems).exec()){
1391  MAP mt(hd,osm);
1392  mt.settings(&(c.MS));
1393  double widthtoheight = (ems.maxlon-ems.minlon)
1394  *cos(M_PI*(ems.maxlat+ems.minlat)/2./180.)
1395  /(ems.maxlat-ems.minlat);
1396  int height = int(sqrt(ems.mapsize*1000000/widthtoheight));
1397  int width= int(height*widthtoheight);
1398  mt.resize(width,height);
1399  mt.set_borders(ems.minlat,ems.maxlat,ems.minlon,ems.maxlon);
1400  mt.calc_borders();
1401  STRONGlayer *slt = NULL;
1402  climblayer *clt = NULL;
1403  Track *ctt = NULL;
1404  if(ems.drawCL) clt = CL;
1405  if(ems.drawSL) slt = SL;
1406  if(ems.drawct) ctt = ct;
1407  mt.draw_map(slt,clt,ctt,0);
1408 
1409  QString filename = QFileDialog().getSaveFileName(this,"save Map","","portable network graphic (*.png)");
1410  if(!filename.isEmpty())
1411  mt.save_to_png(filename);
1412  }
1413 }
1415  osm->normalize_Hm(osm->get_first_KOO());
1416  status2 = "Routing Height data is normalized.";
1417  update_statusbar();
1418 }
1420  osm->invert_Hm(osm->get_first_KOO());
1421  status2 = "Routing Height data is inverted.";
1422  update_statusbar();
1423 }
1424 void MainWindow::save_profile(){
1425  QString filename = QFileDialog().getSaveFileName(this,"save Profil","","portable network graphic (*.png)");
1426  if(ct != NULL && !filename.isEmpty()){
1427  plot2D pt(ui->profil);
1428  pt.resize(c.PS.width,c.PS.height);
1429  pt.save_to_png(filename.toLocal8Bit().data());
1430  status2 = QString("profil saved as %1").arg(filename);
1431  update_statusbar();
1432  }
1433 }
1434 void MainWindow::save_gpx(){
1435  QString filename = QFileDialog().getSaveFileName(this,"save track","","GPS exchange format (*.gpx)");
1436  if(ct != NULL && !filename.isEmpty()){
1437  ct->to_gpx(filename.toLocal8Bit().data());
1438  status2 = QString("track saved as %1").arg(filename);
1439  update_statusbar();
1440  }
1441 }
1442 void MainWindow::profil_settings(){
1443  BTP3setups(&(c.PS)).exec();
1444  update_profil();
1445 }
1446 void MainWindow::map_settings(){
1447  BTP3setups(&(c.MS)).exec();
1448  update_map_raw();
1449 }
1451  if(PA->isVisible())
1452  PA->calc_track(lrt);
1453 }
1455  if(PA->isVisible())
1456  PA->hide();
1457  else{
1458  PA->show();
1459  recalc_power();
1460  update_profil();
1461  }
1462 }
1464  if(ct->notNULL()){
1465  KOO k;
1466  ct->extract_KOO(&k,d);
1467  zoom(1,
1468  (k.lon-map->getmaxlon())/(map->getmaxlon()-map->getminlon())+0.5,
1469  (k.lat-map->getmaxlat())/(map->getmaxlat()-map->getminlat())+0.5);
1470  }
1471 }
1472 void MainWindow::zoom_profil(double dmin, double dmax){
1473  if(ct == lrt && PA->isready()){
1474  float hm = ct->get_height_meters(dmin,dmax);
1475  float d = dmax-dmin;
1476  ui->profil->set_labels(QString("%1 km %2 Hm %3 Hm/km %4 km/h %5 W")
1477  .arg(d,0,'f',2)
1478  .arg(hm,0,'f',0)
1479  .arg(hm/d,0,'f',1)
1480  .arg(PA->get_v(dmin,dmax),0,'f',1)
1481  .arg(PA->get_P(dmin,dmax),0,'f',0),
1482  "d [km]","h [m]");
1483  }
1484  ui->profil->refresh_pixmap();
1485 }
1487  if(c.plotpower)
1488  c.plotpower = 0;
1489  else
1490  c.plotpower = 1;
1491  update_profil();
1492 }
1493 
1495  if(c.plotspeed)
1496  c.plotspeed = 0;
1497  else
1498  c.plotspeed = 1;
1499  update_profil();
1500 }
1501 void MainWindow::analyse_gpx(QString filename){
1502  if(!filename.isEmpty()){
1503  gpx g(filename.toLocal8Bit().data());
1504  UR->add(ct);
1505  double** data; long int length;
1506  data = g.get_complete(&length);
1507  if(QMessageBox::Yes == QMessageBox::question(this,
1508  "Height data Handling",
1509  "Recalc height data?",
1510  QMessageBox::Yes|QMessageBox::No)){
1511  /*recalculate height data*/
1512  Neighbour *nb;
1513  WayHeight(hd,data[2],data[3],length,&nb);
1514  ct = new Track(&nb,1);
1515  }
1516  else{
1517  ct = new Track(data[0],data[1],data[2],data[3],length);
1518  }
1519  PA->calc_track(ct,data[0],data[4],length);
1520  for(long i = 0; i < 5; i++)
1521  free(data[i]);
1522  free(data);
1523 
1524  ct->get_brect(&(c.MS.minlat),&(c.MS.maxlat),
1525  &(c.MS.minlon),&(c.MS.maxlon));
1526  lrt = ct;
1527  update_map_raw();
1528  update_profil();
1529  }
1530 }
1531 void MainWindow::analyse_gpx(){
1532  QString filename = QFileDialog().getOpenFileName(this,"analyse gpx","","GPS exchange format (*.gpx)");
1533  analyse_gpx(filename);
1534 }
1535 void MainWindow::load_STRONGcalc(){
1536  QString filename = QFileDialog().getOpenFileName(this,"open STRONG calculation ","","STRONG calculation(*.sca)");
1537  //QString filename = "D:\\ClimbProject\\Osterzgebirge.sca";
1538  set_routingmode(routeSTRONG);
1539  STRONGcalc* sc = new STRONGcalc(osm,&sN,filename.toLocal8Bit().data(),
1540  &STRONGtracks);
1541  connect(sc,SIGNAL(finished(int)),this,SLOT(route_STRONG_finalize(int)));
1542  connect(sc,SIGNAL(status(QString)),this,SLOT(show_STRONG_status(QString)));
1543 
1544  STRONGstate = 1;
1545  sc->start();
1546 }
1547 
1548 void MainWindow::save_STRONGcalc(){
1549  if(STRONGstate == 2){
1550  QString filename = QFileDialog().getSaveFileName(this,"save STRONG calculation ","","STRONG calculation(*.sca)");
1551  //QString filename = "D:\\ClimbProject\\Osterzgebirge.sca";
1552  STRONGcalc* sc = new STRONGcalc(osm,sN,filename.toLocal8Bit().data(),
1553  &STRONGtracks);
1554  connect(sc,SIGNAL(finished(int)),this,SLOT(route_STRONG_finalize(int)));
1555  STRONGstate = 1;
1556  sc->start();
1557  }
1558  else{
1559  status2 = "There is no finished STRONG calculation to operate upon.";
1560  update_statusbar();
1561  }
1562 }
1564  double maxlat0 = 52;
1565  double minlat0 = 36;
1566  double minlon0 = -11;
1567  double maxlon0 = 30;
1568  maxlon0 = -1.;
1569  /*maxlat0 = 60.0;
1570  minlat0 = 50.0;
1571  minlon0 = -11.0;
1572  malon0 = 2;*/
1573 
1574 
1575  int xmin, xmax, ymin, ymax;
1576  double step;
1577  maxlon0 += 180.;
1578  minlon0 += 180.;
1579  QString folderpath = "D:\\ClimbProject\\Tiles\\";
1580  Cmdl.clear();
1581  QString btppath = "D:\\ClimbProject\\btp-Data\\";
1582  for(int z = 9; z < 10; z++){
1583  step = 360. / pow(2.,z);
1584  xmin = int(floor(minlon0/step));
1585  xmax = int(floor(maxlon0/step));
1586  ymin = int(floor((180.-lattomercator(maxlat0))/step));
1587  ymax = int(floor((180.-lattomercator(minlat0))/step));
1588  for(int x = xmax; x >= xmin; x--)
1589  //for(int x = xmin; x <= xmax; x++)
1590  for(int y = ymin; y <= ymax; y++){
1591  webdatacmd w;
1592  w.x = x;
1593  w.z = z;
1594  w.y = y;
1595  w.dest = folderpath;
1596  w.src = btppath;
1597  w.mode = CreateTilesBTP;
1598  w.width = 256;
1599  w.height = 256;
1600  w.c = &c;
1601  w.osm = osm;
1602  Cmdl.append(w);
1603  }
1604  }
1605  /*for(int z = 5; z < 9; z++){
1606  step = 360. / pow(2.,z);
1607  xmin = int(floor(minlon0/step));
1608  xmax = int(floor(maxlon0/step));
1609  ymin = int(floor((180.-lattomercator(maxlat0))/step));
1610  ymax = int(floor((180.-lattomercator(minlat0))/step));
1611  for(int x = xmin; x <= xmax; x++)
1612  for(int y = ymin; y <= ymax; y++){
1613  webdatacmd w;
1614  w.x = x;
1615  w.z = z;
1616  w.y = y;
1617  w.dest = folderpath;
1618  w.mode = CreateTiles;
1619  w.width = 256;
1620  w.height = 256;
1621  w.c = &c;
1622  w.osm = osm;
1623  Cmdl.append(w);
1624  }
1625  }*/
1626  threadscount = 1;
1627  next_command();
1628 }
1630  double maxlat0 = 52;
1631  double minlat0 = 36;
1632  double minlon0 = -11;
1633  double maxlon0 = 30;
1634 
1635  /*maxlat0 = 60.0;
1636  minlat0 = 50.0;
1637  minlon0 = -11.0;
1638  maxlon0 = 2;*/
1639 
1640  int xmin, xmax, ymin, ymax;
1641  double step;
1642  maxlon0 += 180.;
1643  minlon0 += 180.;
1644  QString folderpath = "D:\\ClimbProject\\STRONGLayers\\";
1645  Cmdl.clear();
1646  QString btppath = "D:\\ClimbProject\\btp-Data\\";
1647  for(int z = 9; z < 10; z++){
1648  step = 360. / pow(2.,z);
1649  xmin = int(floor(minlon0/step));
1650  xmax = int(floor(maxlon0/step));
1651  ymin = int(floor((180.-lattomercator(maxlat0))/step));
1652  ymax = int(floor((180.-lattomercator(minlat0))/step));
1653  for(int x = xmin; x <= xmax; x++)
1654  for(int y = ymin; y <= ymax; y++){
1655  webdatacmd w;
1656  w.x = x;
1657  w.z = z;
1658  w.y = y;
1659  w.dest = folderpath;
1660  w.src = btppath;
1661  w.mode = CreateSTRONGLayers;
1662  w.width = 256;
1663  w.height = 256;
1664  w.c = &c;
1665  w.osm = osm;
1666  Cmdl.append(w);
1667  }
1668  }
1669  threadscount = -4;
1670  next_command();
1671 }
1673  threadscount--;
1674  for(int i = 0; i < 12-threadscount; i++ )
1675  if(Cmdl.length()>0){
1676  WebData* wd = new WebData(Cmdl.takeLast());
1677  connect(wd,SIGNAL(finished()),this,SLOT(next_command()));
1678  qRegisterMetaType<webdatacmd>("webdatacmd");
1679  connect(wd,SIGNAL(add(webdatacmd*)),this,SLOT(add_Cmd(webdatacmd*)));
1680  threadscount++;
1681  wd->start();
1682  }
1683 }
1685  Cmdl.append(*w);
1686 }
1688  webdatacmd first;
1689  first.z = 0;
1690  first.x = 0;
1691  first.y = 0;
1692  first.mode = SplitEurope;
1693 
1694  Cmdl.append(first);
1695  threadscount = 1;
1696  next_command();
1697 }
1699  QString foldername = QFileDialog::getExistingDirectory(this,"select SRTM3 data directory");
1700  if(!foldername.isEmpty()){
1701  QDir f(foldername,"*.hgt");
1702  HeightData HD;
1704  QString text;
1705  QStringList hgt = f.entryList();
1706  int correctedPoints;
1707  for(int i = 0; i < hgt.count();i++){
1708  correctedPoints = HD.correct_hgt(f.absoluteFilePath(hgt[i]).toLocal8Bit().data());
1709  if(correctedPoints > 0)
1710  text.append(QString("%1 corrected points in %2.\n").arg(correctedPoints).arg(hgt[i]));
1711  }
1712  if(text.isEmpty())
1713  text = "no hgt files corrected.";
1714  //HD.correct_hgt("C:\\Users\\User\\Desktop\\SRTM3\\N50E013.hgt");
1715  QMessageBox(QMessageBox::NoIcon,"hgt-correction",text).exec();
1716  }
1717 }
1719  double maxlat0 = 72;
1720  double minlat0 = 36;
1721  double minlon0 = -11;
1722  double maxlon0 = 30;
1723  int z = 9;
1724  double step = 360. / pow(2.,z);
1725  int xmin = int(ceil((minlon0+180)/step));
1726  int xmax = int(floor((maxlon0+180)/step));
1727  int ymin = int(ceil((180.-lattomercator(maxlat0))/step));
1728  int ymax = int(floor((180.-lattomercator(minlat0))/step));
1729  QString folderpathsrc = "D:\\ClimbProject\\pbf-Data\\";
1730  QString folderpathdest = "D:\\ClimbProject\\btp-Data\\";
1731  for(int x = xmin; x < xmax; x++)
1732  for(int y = ymin; y < ymax; y++){
1733  webdatacmd w;
1734  w.dest = QString("%1%2-%3-%4.btp")
1735  .arg(folderpathdest)
1736  .arg(z)
1737  .arg(x)
1738  .arg(y);
1739  w.src = QString("%1%2-%3-%4.pbf")
1740  .arg(folderpathsrc)
1741  .arg(z)
1742  .arg(x)
1743  .arg(y);
1744  w.mode = ReadOSM;
1745  Cmdl.append(w);
1746  }
1747  threadscount = 1;
1748  next_command();
1749 }
1751  double maxlat0 = 72;
1752  double minlat0 = 36;
1753  double minlon0 = -11;
1754  double maxlon0 = 30;
1755  int z = 9;
1756  double step = 360. / pow(2.,z);
1757  int xmin = int(ceil((minlon0+180)/step));
1758  int xmax = int(floor((maxlon0+180)/step));
1759  int ymin = int(ceil((180.-lattomercator(maxlat0))/step));
1760  int ymax = int(floor((180.-lattomercator(minlat0))/step));
1761  QString folderpathsrc = "D:\\ClimbProject\\btp-Data\\";
1762  QString folderpathdest = "D:\\ClimbProject\\html-Data\\";
1763  for(int x = xmin; x < xmax; x++)
1764  for(int y = ymin; y < ymax; y++){
1765  webdatacmd w;
1766  w.z = 9;
1767  w.x = x;
1768  w.y = y;
1769  w.dest = QString("%1%2-%3")
1770  .arg(folderpathdest)
1771  .arg(x)
1772  .arg(y);
1773  w.src = QString("%1%2-%3-%4.btp")
1774  .arg(folderpathsrc)
1775  .arg(z)
1776  .arg(x)
1777  .arg(y);
1778  w.mode = CreateHTML;
1779  Cmdl.append(w);
1780  }
1781  threadscount = 1;
1782  next_command();
1783 
1784 }
1786  double boxes[8][4] = {{10.15,51.33,11.55,51.95},//Harz
1787  {9.44,49.85,17.8,51.5},//Rhoen-Jeseniky
1788  {12.08,48.11,15.8,49.6},//BayWa
1789  {6.5,46.95,9.4,48.92},//Aarau-Vosges-Schwarzwald
1790  {1.8,43.9,45,46.2},//MassiveCentral
1791  {18,48.55,21.3,49.9},//Slovensko
1792  {6.9,48.8,9.44,51.6},// NRW
1793  {4.4,48.9,8.35,50.8}};//Ardennen
1794  for(int b = 0; b < 8; b++){
1795  for(int z = 12; z < 15; z++){
1796  double step = 360. / pow(2.,z);
1797  int xmin = int(ceil((boxes[b][0]+180)/step));
1798  int xmax = int(floor((boxes[b][2]+180)/step));
1799  int ymin = int(ceil((180.-lattomercator(boxes[b][3]))/step));
1800  int ymax = int(floor((180.-lattomercator(boxes[b][1]))/step));
1801  for(int y = ymin; y < ymax; y++){
1802  QDir ydir(QString("D:\\ClimbProject\\ZoomedTiles")
1803  .append(QString("\\%1\\%2")
1804  .arg(z)
1805  .arg(y)));
1806  if(!ydir.exists())
1807  QDir (QString("D:\\ClimbProject\\ZoomedTiles")
1808  .append(QString("\\%1")
1809  .arg(z))).mkdir(ydir.dirName());
1810  for(int x = xmin; x < xmax; x++){
1811  QFile f(QString("%1%2\\%3\\%4.png")
1812  .arg("D:\\ClimbProject\\Tiles\\")
1813  .arg(z)
1814  .arg(y)
1815  .arg(x));
1816  f.copy(ydir.filePath(QString("%1.png").arg(x)));
1817  }
1818  }
1819 
1820  }
1821  }
1822 }
double hmperkm
hmmax=max(hmmax,radius*hmperkm)
Definition: DataTyps.h:294
double get_P()
return average power
void read_OSM()
read osm file
Definition: osm.cpp:59
void read_europe()
slot to organize multithreating task
void settings(MapSettings *MS)
assigns new settings
Definition: MAP.cpp:122
double ** get_vdata()
returns data array pointer
double ** get_Pdata()
returns data array pointer
int STRONGstate
Definition: mainwindow.h:353
QString status2
Definition: mainwindow.h:350
Neighbour * via
connection to reach this STRONG
Definition: DataTyps.h:258
void draw_line(QPainter *p, KOOlist *k, int kc)
drawing commends from outside
Definition: MAP.cpp:1151
provide all user settings
Definition: btp3setups.h:70
void load(char *filename)
load btp to dataset
Definition: osm.cpp:2049
bool html
climb analyse dialog
Definition: DataTyps.h:307
double minP
climb analyse dialog
Definition: DataTyps.h:303
KOO * anchorto
Definition: mainwindow.h:339
void correct_hgt()
slot to organize multithreating task
double mapsize
picturesize in megapixel
Definition: DataTyps.h:318
void delete_to_cross(int cc)
relation ** waterr
Definition: osm.h:79
void reset_track()
Definition: mainwindow.cpp:939
void STRONGlayer_save(char *filename, STRONGlayer *SL)
saves STRONGlayer to file
Definition: Routing.cpp:398
char start_btp[260]
osm data to load at beginning
Definition: DataTyps.h:331
Way * selected_way
Definition: mainwindow.h:349
STRONGsetting sconfig
STRONGAlgo setting, detail mode.
Definition: DataTyps.h:328
void update_profil()
Definition: mainwindow.cpp:351
void next_command()
slot to organize multithreating task
int get_datacount()
returns data array length
void accept_ct()
QPixmap * cmap
Definition: mainwindow.h:335
void toggle_showpower()
int threadscount
Definition: mainwindow.h:370
double scale()
Definition: MAP.cpp:1147
double getmaxlat()
return lsat calced bounding rect
Definition: osm.cpp:1752
int hmmax
finalization criterium absolute
Definition: DataTyps.h:293
double getminlat()
return real borders
Definition: MAP.cpp:357
float minP
defines climb: min. difficulty
Definition: DataTyps.h:297
list elements to handle multiple STRONGlayers
Definition: DataTyps.h:349
KOO * get_first_KOO()
returns root of node-AVL tree
Definition: osm.cpp:1692
KOO * kdot
Definition: mainwindow.h:338
container struct to hold data of a coordinate
Definition: DataTyps.h:82
STRONGlayer * STRONGlayer_load(char *filename)
loades STRONGlayer from file
Definition: Routing.cpp:370
bool Climblayer
climb analyse dialog
Definition: DataTyps.h:313
int y
Definition: webdata.h:29
double lat
Definition: DataTyps.h:86
short next_d(double lat, double lon, double *d)
searches for closest point on track to point (lat,lon)
Definition: track.cpp:423
double ** get_d_h_array()
returns reference
Definition: track.cpp:204
QLabel * statusLeft
Definition: mainwindow.h:366
lines ** water
Definition: osm.h:70
void get_KOO_Waysavl()
links node IDs to nodes recursivly
Definition: osm.cpp:578
void route_short()
Definition: mainwindow.cpp:801
void set_maxtype(char mt)
Track ** STRONGtracks
Definition: mainwindow.h:342
short notNULL()
is track empty or not
Definition: track.cpp:513
float downtoupmax
defines climb: allowed down Hm
Definition: DataTyps.h:296
void delete_complete()
Definition: track.cpp:501
double get_v(double d)
interpolate time in data
float get_height_meters()
Definition: track.cpp:273
short extract_KOO(KOO *k, double d)
creates KOO refering distance point d
Definition: track.cpp:358
void extract_neighbourlist(STRONG *s, STRONG *e, Neighbour ***nl, int *nc)
collects a Neighbour list from STRONG network
Definition: Routing.cpp:180
void get_brect(double *latmin, double *latmax, double *lonmin, double *lonmax)
return bounding rect of Track
Definition: track.cpp:697
short next_cross(double clickedlat, double clickedlon, KOO **kdot, float maxd)
stores cross in kdot which is closest to (clickedlat,clickedlon)
Definition: track.cpp:794
void route_STRONG_finalize(int succes)
Definition: mainwindow.cpp:862
void recalc_power()
void finish_STRONG()
resets STRONG network of a STRONGcalc to normal Dijkstra state
Definition: Routing.cpp:197
void delete_cross(int nr)
deletes last nr cross of Track
Definition: track.cpp:462
routing container struct, connects cross via Way with each other
Definition: DataTyps.h:47
int hmstep
Additional criteria for STRONGPlus defining climb.
Definition: DataTyps.h:292
label algorithm to solve multicriteria shortes path problem
Definition: strongcalc.h:28
relation ** woodr
Definition: osm.h:79
short extract_h(double d, double *h)
creates double for height refering distance point d
Definition: track.cpp:379
void calc_brect()
refresh bounding rect of dataset
Definition: osm.cpp:1644
void zoom(double zoomfactor, double dlonfactor, double dlatfactor)
handles all map modification (mooving, zooming)
Definition: mainwindow.cpp:207
void sort_peaks()
primitive sort algorithm
Definition: osm.cpp:1813
int trace_back(KOO *k)
Definition: mainwindow.cpp:725
void mousePressEvent(QMouseEvent *event)
handles all mouse inputs
Definition: mainwindow.cpp:412
RunModeWebData mode
Definition: webdata.h:17
UndoRedo * UR
Definition: mainwindow.h:345
void set_marker(double x)
draws vertical black line at x pos
Definition: plot2D.cpp:565
void toggle_preview()
int width
rendering image size
Definition: webdata.h:22
void check_lines()
delete Way with unresolved nodes
Definition: osm.cpp:2298
int x
Definition: webdata.h:29
bool drawct
draw current track
Definition: DataTyps.h:321
Definition: gpx.h:12
bool noSTRONGPlus
dont apply climb restrictions
Definition: DataTyps.h:298
int z
Definition: webdata.h:29
dotstate dstate
Definition: mainwindow.h:346
double getminlat()
return lsat calced bounding rect
Definition: osm.cpp:1746
creates data for web site
Definition: webdata.h:42
void update_map_raw()
Definition: mainwindow.cpp:296
config * c
BTP configuration to be used.
Definition: webdata.h:24
bool list
climb analyse dialog
Definition: DataTyps.h:309
double maxlon
Definition: DataTyps.h:216
void set_routingmode(inputstate ip)
sets routing mode and shows hints in statusbar
Definition: mainwindow.cpp:975
STRONG * s
memory for routing algorithms
Definition: DataTyps.h:75
qint64 id
OSM way id
Definition: DataTyps.h:123
undo and redo container class for BTP to save no longer needed tracks
Definition: UndoRedo.h:13
char SRTM3folder[260]
SRTM3 data folder.
Definition: DataTyps.h:330
char maxtype
way restrictions
Definition: DataTyps.h:326
void enter()
holds digital elevation model extracted from SRTM3 data
Definition: HeightData.h:26
official representation of Track in BTP3
Definition: track.h:14
void to_gpx(char *filename)
save to gpx file
Definition: track.cpp:860
int STRONGindex
Definition: mainwindow.h:344
char type
classification
Definition: DataTyps.h:129
void keyPressEvent(QKeyEvent *event)
handles keyboard input
Definition: mainwindow.cpp:103
double get_length()
returns Track length [km]
Definition: track.cpp:320
void reset_t(double minlat, double maxlat, double minlon, double maxlon)
generates the data grid being
Definition: HeightData.cpp:327
QString src
source file name
Definition: webdata.h:31
container for line geodata
Definition: DataTyps.h:122
Track * ct
Definition: mainwindow.h:340
void save_to_png(QString filename)
save map as picture to hard disk
Definition: MAP.cpp:1197
void resize(int width, int height)
adapts size, recalculate borders from desired borders
Definition: MAP.cpp:126
short traceback
Definition: mainwindow.h:355
void zoom_profil(double dmin, double dmax)
repaints profil with current dataset, but refreshed titel
double y_to_lat(int y)
map coordinate information
Definition: MAP.cpp:375
void add_Cmd(webdatacmd *w)
slot to organize multithreating task
void drawCross(QPainter *p)
Definition: mainwindow.cpp:386
void * from
&lt; pointer to STRONG or FibunacciHeap
Definition: DataTyps.h:257
short near_check(double lat, double lon, double limit)
check if point (lat,lon) is closer to track then limit
Definition: track.cpp:519
plotting 2D-Data sets as the height profile of a track or poweranalysis data
Definition: plot2D.h:20
int drawSTRONGlayer
create mapdialog setting
Definition: DataTyps.h:333
void set_default(PowerAnalysisSetting *s)
apply default setting to the PowerAnalysisSetting s
void STRONG_settings()
QString dest
destination file name
Definition: webdata.h:25
short readytotrace
Definition: mainwindow.h:351
void RelationstoFace(relation **l, lines **f)
collect all Way to one relation
Definition: osm.cpp:1469
void calc_peak_index_pro(HeightData *h)
summit ranking uses t-functions of heighdata
Definition: osm.cpp:1759
void update_map_MovObj(Way *w)
Definition: mainwindow.cpp:327
OSM * osm
Definition: webdata.h:26
void set_borders(double latmin0, double latmax0, double lonmin0, double lonmax0)
sets desired borders, recalculate bordes due to window size
Definition: MAP.cpp:132
short toggle_marker(KOO *k)
a KOO of the track can be marked or not, used for drag&amp;drop routing
Definition: track.cpp:718
extracts climbs from street network and provides climblayer handling
Definition: ClimbAnalyse.h:52
double minHM
climb analyse dialog
Definition: DataTyps.h:306
climblayer * CL
Climblayer.
Definition: mainwindow.h:365
void toggle_poweranalysis()
conroles communication from profil to mainwindow
QLabel * statusMiddle
Definition: mainwindow.h:367
inputstate input
current routing mode
Definition: DataTyps.h:332
KOO ** node
array KOO pointers
Definition: DataTyps.h:125
bool drawSL
draw stronglayer
Definition: DataTyps.h:320
void update_map_track()
Definition: mainwindow.cpp:313
short DijkstraFib_minHM(KOO *s, KOO *e, char max, char min, OSM *o, int Si)
see DijkstraFib(), but minimizing Hm instead of distance
Definition: Routing.cpp:77
int height
rendering image size
Definition: webdata.h:23
void CA_europe()
slot to organize multithreating task
multithreading working command, defines the task to be executed
Definition: webdata.h:16
class to perform routing routines on osm data sets
Definition: Routing.h:18
char ProjectName[260]
climb analyse dialog
Definition: DataTyps.h:311
void STRONG_europe()
slot to organize multithreating task
void resizeEvent(QResizeEvent *event)
change of main window size
Definition: mainwindow.cpp:97
void set_SRTM3_folder(char *folder)
specifies the folder where hgt-files of SRTM3 data are searched
Definition: HeightData.cpp:324
double mapsize
climb analyse dialog
Definition: DataTyps.h:312
void init()
loads settings, initialized variables
Definition: mainwindow.cpp:235
bool drawCL
draw climblayer
Definition: DataTyps.h:319
STRONGsetting cconfig
STRONGAlgo setting, climb mode.
Definition: DataTyps.h:329
void refresh_pixmap()
repaints the plot&#39;s pixmap
Definition: plot2D.cpp:214
QPixmap * get_Map()
return pixmap of the last generated map
Definition: MAP.cpp:139
void invert_Hm()
void STRONG_preview(int i)
bool map
climb analyse dialog
Definition: DataTyps.h:308
void calc_borders()
desired borders to real borders
Definition: MAP.cpp:142
void generate_tiles()
creates tiles for map server
assigns heights to Way, generates Neighbour data
Definition: WayHeight.h:33
int plotpower
Plotting power calc results.
Definition: DataTyps.h:340
void draw_map(STRONGlayer *SL, climblayer *cl, Track *ct, int fastmode)
universal high quality drawing
Definition: MAP.cpp:1410
double get_t(double d)
interpolate time in data
power calculation for height-distance datasets
Definition: poweranalysis.h:76
STRONGlayer * STRONGlayer_create(STRONGlayer *SL, int N)
creates STRONGlayer from a unfinalized STRONG network
Definition: Routing.cpp:312
void drawRoute(QPainter *p)
Definition: mainwindow.cpp:398
void set_data(double **dataxy, int count)
setting one dataset and repaint plot
Definition: plot2D.cpp:475
BTP3 database, created from OpenStreetMap data.
Definition: osm.h:34
double minS
climb analyse dialog
Definition: DataTyps.h:304
void acceptSTRONG()
Definition: mainwindow.cpp:917
lines ** wood
Definition: osm.h:70
short DijkstraFib(KOO *s, KOO *e, char max, char min, OSM *o, int Si)
this is famous Dijkstra shortes path algothim
Definition: Routing.cpp:8
void zoom14_collection()
copy high zoom level tiles for desired areas in europe
int drawClimblayer
create mapdialog setting
Definition: DataTyps.h:335
double maxlon
borders
Definition: DataTyps.h:317
char ProjectFolder[260]
climb analyse dialog
Definition: DataTyps.h:310
double getminlon()
return lsat calced bounding rect
Definition: osm.cpp:1749
void normalize_Hm(KOO *k)
removes total height differences from Neighbour relation
Definition: osm.cpp:2675
int plotspeed
Plotting power calc results.
Definition: DataTyps.h:339
void set_mintype(char mt)
void route_flat()
Definition: mainwindow.cpp:823
int isready()
returns whether data is loaded
void center_track(double d)
short dhmin
defines climb: min. Hm
Definition: DataTyps.h:295
void save(char *filename, double minlat, double maxlat, double minlon, double maxlon)
save dataset as btp
Definition: osm.cpp:1855
void route_STRONG()
Definition: mainwindow.cpp:847
double maxdwnHM
climb analyse dialog
Definition: DataTyps.h:305
main user setting container
Definition: DataTyps.h:324
void selectSTRONG(readdirection rd, short steps)
void toggle_showspeed()
void calc_track(Track *t)
calc power from P(v) distribution
int nodec
count of KOO
Definition: DataTyps.h:124
int drawRoute
create mapdialog setting
Definition: DataTyps.h:334
void invert_Hm(KOO *k)
switches descenting and ascenting vertical meters in Neighbour relation
Definition: osm.cpp:2691
int get_status()
returns current class state
Definition: osm.cpp:790
QList< webdatacmd > Cmdl
command list to calculate web content multithreated
Definition: mainwindow.h:369
STRONGsetting mconfig
STRONGAlgo setting, fast mode.
Definition: DataTyps.h:327
double getmaxlon()
return lsat calced bounding rect
Definition: osm.cpp:1755
void normalize_Hm()
generating maps
Definition: MAP.h:24
container for user settings to manually generate map
Definition: DataTyps.h:316
void split_europe_pbf()
splits europe.pbf $osm data
void generate_Map()