1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
6 MainWindow::MainWindow(QWidget *parent) :
12 centralWidget()->setLayout(ui->verticalLayout);
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()));
86 MainWindow::~MainWindow(){
87 if(autosave) autosave_setting();
93 void MainWindow::closeEvent(QCloseEvent *){
98 QSize sold =
event->oldSize();
99 if(sold.width()>0 && sold.height() > 0)
104 switch(event->key()){
106 zoom(1. , 0.5, 0);
break;
108 zoom(1. ,-0.5, 0);
break;
110 zoom(1. , 0, 0.5);
break;
112 zoom(1. , 0,-0.5);
break;
114 zoom(0.5, 0, 0);
break;
116 zoom(2. , 0, 0);
break;
118 if(c.
input == routeshort ||
119 c.
input == routeflat)
133 case Qt::Key_Backspace:
134 if(QApplication::keyboardModifiers() == Qt::ControlModifier)
140 if(QApplication::keyboardModifiers() == Qt::ControlModifier)
146 if(QApplication::keyboardModifiers() == Qt::ControlModifier)
152 if(QApplication::keyboardModifiers() == Qt::ControlModifier)
158 if(QApplication::keyboardModifiers() == Qt::ControlModifier)
164 if(QApplication::keyboardModifiers() == Qt::ControlModifier)
170 if(QApplication::keyboardModifiers() && Qt::ControlModifier)
176 if(QApplication::keyboardModifiers() && Qt::ControlModifier)
181 case Qt::Key_PageDown:
182 if(QApplication::keyboardModifiers() && Qt::ControlModifier)
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;
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();
229 c.MS.minlat = mlat-dlat;
230 c.MS.maxlat = mlat+dlat;
231 c.MS.minlon = mlon-dlon;
250 map =
new MAP(hd,osm);
257 statusLeft->setFrameStyle(QFrame::Panel | QFrame::Sunken);
259 statusMiddle->setFrameStyle(QFrame::Panel | QFrame::Sunken);
261 void MainWindow::autoload_setting(){
262 QString filename = QCoreApplication::applicationDirPath();
263 filename.append(
"/settings.stg");
264 FILE* f = fopen(filename.toLocal8Bit().data(),
"rb");
266 fread(&c,
sizeof(
config),1,f);
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);
279 void MainWindow::init_config(){
288 c.
input = routeshort;
298 status2 =
"Map is rendering...";
301 map->
resize(ui->MapLabel->width(),ui->MapLabel->height());
320 if(c.
input == editdata
322 p.setPen(QPen(Qt::red,5));
325 ui->MapLabel->setPixmap(*
cmap);
328 if(w != NULL ||
dstate != nonedot){
329 QPixmap cmapt(*
cmap);
332 p.setPen(QPen(Qt::red,5));
338 p.setBrush(QBrush(Qt::red));
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);
345 ui->MapLabel->setPixmap(cmapt);
348 ui->MapLabel->setPixmap(*
cmap);
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")
360 .arg(PA->
get_v(),0,
'f',1)
361 .arg(PA->
get_P(),0,
'f',0),
366 ui->profil->set_labels(QString(
"%1 km %2 Hm %3 Hm/km")
371 double **dt = NULL,**dt1 = NULL,**dt2 = NULL;
372 int tc=0,tc1=0,tc2=0;
374 tc =
ct->get_array_length();
383 ui->profil->
set_data(dt,tc,dt1,tc1,dt2,tc2);
387 p->setPen(Qt::NoPen);
388 p->setBrush(QBrush(Qt::green));
390 p->drawEllipse(map->lon_to_x(kold->lon)-5,
391 map->lat_to_y(kold->
lat)-5,
394 p->drawEllipse(map->lon_to_x(knew->lon)-5,
395 map->lat_to_y(knew->
lat)-5,
401 p->setPen(QPen(Qt::green,5));
402 p->setBrush(QBrush(Qt::black));
406 void MainWindow::set_SRTM3_folder(){
407 QString filename = QFileDialog::getExistingDirectory(
this,
"select SRTM3 data directory");
408 strcpy(c.
SRTM3folder,filename.toLocal8Bit().data());
413 if(event->button()==Qt::LeftButton && !
traceback){
414 xold =
event->x()-centralWidget()->x();
415 yold =
event->y()-centralWidget()->y();
417 if( (c.
input == routeshort || c.
input == routeflat)
421 if(c.
input == routeshort){
422 if(anchorfrom != NULL)
427 if(c.
input == routeflat){
428 if(anchorfrom != NULL)
437 void MainWindow::mouseReleaseEvent(QMouseEvent *event){
438 x =
event->x()-centralWidget()->x();
439 y =
event->y()-centralWidget()->y();
440 if(event->button()==Qt::LeftButton){
444 if(x == xold ||
y ==
yold){
445 if(c.
input == editdata){
451 status2 = QString(
"Way %1 selected, typ: %2")
471 status2 =
"STRONG calculation still running. ESC to quit.";
480 osm->select_cross(map->
y_to_lat(
y),map->x_to_lon(x),&k,&d,k);
483 if(kold != NULL && knew != NULL && kold != knew){
487 if(c.
input == routeSTRONG
488 ||c.
input == routeclimb
489 ||c.
input == routemountain)
500 if(event->modifiers()==Qt::ControlModifier){
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());
508 zoom(1.,1.*(xold-x)/map->getwidth(),1.*(
y-
yold)/map->getheight());
514 void MainWindow::mouseDoubleClickEvent(QMouseEvent *event){
517 void MainWindow::mouseMoveEvent(QMouseEvent *event){
519 x =
event->x()-centralWidget()->x();
520 y =
event->y()-centralWidget()->y();
522 KOO* k;
float d = 1e15;
523 osm->select_cross(map->
y_to_lat(
y),map->x_to_lon(x),
525 status1 = QString(
"%1°N %2 °E %3 m")
527 .arg(map->x_to_lon(x),10,
'f',6)
528 .arg(map->xy_to_height(x,
y),7,
'f',1);
532 if(event->buttons()==Qt::LeftButton){
533 if(event->modifiers()==Qt::ControlModifier){
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)));
540 ui->MapLabel->setPixmap(prev);
541 ui->MapLabel->repaint();
542 status1 = QString(
"%1°N %2°E %3 m")
544 .arg(map->x_to_lon(x),10,
'f',6)
545 .arg(map->xy_to_height(x,
y),7,
'f',1);
549 QPixmap prev(ui->MapLabel->size());
550 QPainter painter(&prev);
552 ui->MapLabel->setPixmap(prev);
553 ui->MapLabel->repaint();
558 status1 = QString(
"%1°N %2°E %3 m")
560 .arg(map->x_to_lon(x),10,
'f',6)
561 .arg(map->xy_to_height(x,
y),7,
'f',1);
564 if(c.
input == editdata){
565 w = osm->select_Way(map->
y_to_lat(
y),map->x_to_lon(x));
567 status2 = QString(
"way id: %1").arg(w->
id);
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());
585 zoom(0.5,1.*(x-xmiddle)/map->getwidth(),
586 1.*(ymiddle-
y)/map->getheight());
588 void MainWindow::update_statusbar(){
591 ui->statusBar->update();
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);
601 void MainWindow::load_btp(QString filename){
603 osm->
load(filename.toLocal8Bit().data());
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);
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);
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);
629 save_btp(filename,map->
getminlat(),map->getmaxlat(), map->getminlon(),
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);
639 void MainWindow::read_osm(){
640 QString filename = QFileDialog().getOpenFileName(
this,
"read OSM data",
"",
"OpenStreetMap data (*.osm)");
641 if(!filename.isEmpty()){
646 void MainWindow::read_osm(QString filename){
647 status2 =
"Data is processed. This may last several minutes.";
649 osm->setfilename(filename.toLocal8Bit().data());
651 status2 =
"Data read. Continue with generating relational data base.";
655 status2 =
"Data base ready. Processing OSM-Relationdata.";
659 status2 =
"Relations processed. Loading heightdata server.";
668 status2 =
"Heightdata ready. Ranking summits.";
672 status2 =
"Summits ranked. Generating streets height data.";
675 status2 =
"OSM Processing has finished. First save data as *.btp an restart programm.";
684 void MainWindow::set_start_btp(){
685 QString filename = QFileDialog().getOpenFileName(
this,
"select BTP file",
"",
"BergTourenPlaner data (*btp)");
686 if(filename.isEmpty()){
688 status2 = QString(
"Loading no btp data at programm start.");
691 strcpy(c.
start_btp,filename.toLocal8Bit().data());
692 status2 = QString(
"Loading %1 at program start.").arg(filename);
696 void MainWindow::profilinfo(
double 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]")
707 .arg(map->xy_to_height(xpx,ypx),7,
'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()));
718 xdot = map->lon_to_x(k.lon);
719 ydot = map->lat_to_y(k.
lat);
727 if(
anchorto != NULL || anchorfrom != NULL){
728 Track *tfrom,*tto, start(lrt),end(lrt);
730 if(anchorfrom != NULL){
732 start.trim_right(anchorfrom);
733 if(k->cd->
s[0].
from != NULL){
738 tfrom =
new Track(nl,nc);
745 start.delete_complete();
752 if(k->cd->
s[1].
from != NULL){
757 tto =
new Track(nl,nc);
785 Track ttemp(&(nl[1]),nc-1);
802 status2 =
"Shortest track is routing ...";
824 status2 =
"Least vertical meter track is routing ...";
852 if(c.
input == routeclimb){ s = &(c.
cconfig); hmonly =
false;}
856 connect(sc,SIGNAL(refresh_progress(
int)),
this,SLOT(
STRONG_preview(
int)));
858 connect(
this,SIGNAL(stop_STRONG()),sc,SLOT(stop_calculations()));
866 if(c.
input == routemountain){
868 double minQu = 0, Qut = -1;
869 for(
int i = 0; i <
sN; i++){
888 status2 = QString(
"STRONG %1/%2, select with page up/down, ENTER to accept, 'm' to select any crossroad as end point")
897 status2 =
"Found no way. Free Memory ...";
908 void MainWindow::delete_STRONG_tracks(){
910 for(
int i = 0; i <
sN; i++)
918 if( c.
input == routeSTRONG
919 || c.
input == routemountain
920 || c.
input == routeclimb){
933 knew =
ct->get_last_KOO();
982 status2 = QString(
"[mint: %1, maxt: %2] Routet kuerzesten Weg; z fuer rueckgaengig, entf zum loeschen").arg(
int(c.mintype)).arg(
int(c.
maxtype));
985 status2 = QString(
"[mint: %1, maxt: %2] Routet hoehenmeteraermsten Weg; z fuer rueckgaengig, entf zum loeschen").arg(
int(c.mintype)).arg(
int(c.
maxtype));
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")
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")
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")
1011 .arg(
int(c.mintype))
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")
1018 .arg(
int(c.mintype))
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")
1030 .arg(
int(c.mintype))
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")
1037 .arg(
int(c.mintype))
1045 status2 = QString(
"Waehlen sie einen Weg durch Klicken zum Editieren aus; entf zum entfernen, Zahlen 0 bis 5 zum einstellen des Typ");
1049 status2 = QString(
"STRONGlayer %1 von %2 wird angezeigt; mit Bild auf/ab Layer auswaehlen").arg(SLc).arg(SLN);
1053 status2 = QString(
"Kein STRONGlayer geladen");
1066 knew =
ct->get_last_KOO();
1075 c.mintype = qMin(mt,
char(5));
1081 status2 = QString(
"Weg %i geaendert\nneuer Typ: %i ")
1099 knew =
ct->get_last_KOO();
1110 lrt =
ct =
UR->redo();
1113 knew =
ct->get_last_KOO();
1133 status2 = QString(
"STRONG %1/%2, select with page up/down, ENTER to accept, 'm' to select any crossroad as end point")
1139 if(c.
input == selectlayer && SL != NULL){
1144 status2 = QString(
"STRONGlayer %1 von %2 is shown. Select layer with page up/down").arg(SLc).arg(SLN);
1149 void MainWindow::MouseToTrack(){
1159 ydot = map->lat_to_y(
kdot->
lat);
1164 ydot = map->lat_to_y(
kdot->
lat);
1169 (map->getmaxlat()-map->
getminlat())*0.1))
1175 xdot = map->lon_to_x(ktt.lon);
1176 ydot = map->lat_to_y(ktt.
lat);
1180 status1.append(QString(
" [%1 km %2 m]")
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()));
1194 ui->profil->
set_marker(ui->profil->get_xmin());
1201 status2 =
"STRONG calculation still running. ESC to quit.";
1205 if( c.
input == routeSTRONG
1206 ||c.
input == routeclimb
1207 ||c.
input == routemountain){
1216 if( c.
input == routeflat && knew != NULL){
1217 status2 =
"Hoehenmeteraermster Weg mit offenem Ende wird geroutet ...";
1222 status2 =
"Hoehenmeterarme Wege bereit ...";
1225 if( c.
input == routeshort && knew != NULL){
1226 status2 =
"Kuerzester Weg mit offenem Ende wird geroutet ...";
1231 status2 =
"Kurze Wege bereit ...";
1248 knew =
ct->get_last_KOO();
1263 status2 = QString(
"STRONG calculation: %1/%2 steps done").arg(i).arg(sN);
1278 void MainWindow::create_STRONGlayer(){
1285 status2 =
"There is no finished STRONG calculation to operate upon.";
1289 void MainWindow::save_STRONGlayer(){
1290 QString filename = QFileDialog().getSaveFileName(
this,
"save STRONGlayer",
"",
"BTP STRONGlayer (*.bsl)");
1291 if(SL != NULL && !filename.isEmpty()){
1293 status2 = QString(
"saved STRONGlayer as %1").arg(filename);
1297 void MainWindow::load_STRONGlayer(){
1298 QString filename = QFileDialog().getOpenFileName(
this,
"load STRONGlayer",
"",
"BTP STRONGlayer (*.bsl)");
1299 if(!filename.isEmpty()){
1305 void MainWindow::toggle_STRONGlayer(){
1312 void MainWindow::AnalyseClimbs(){
1315 status2 =
"Analysing climbs ...";
1323 status2 =
"Creating Climblayer ...";
1327 CL = CA.get_ClimbLayer();
1335 status2 =
"Generating map ...";
1338 mt.settings(&(c.MS));
1342 int height = int(sqrt(c.CA.
mapsize*1000000/widthtoheight));
1343 int width= int(height*widthtoheight);
1344 mt.resize(width,height);
1349 mt.draw_map(NULL,clt,NULL,0);
1352 mt.save_to_png(filename);
1355 status2 =
"Generating html data ...";
1364 void MainWindow::load_Climblayer(){
1365 QString filename = QFileDialog().getOpenFileName(
this,
"load climblayer",
"",
"BTP climblayer (*.bbl)");
1366 if(!filename.isEmpty()){
1369 CL = CA.load_ClimbLayer(filename.toLocal8Bit().data());
1373 void MainWindow::toggle_Climblayer(){
1382 ems.maxlat = map->getmaxlat();
1384 ems.
maxlon = map->getmaxlon();
1385 ems.minlon = map->getminlon();
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);
1409 QString filename = QFileDialog().getSaveFileName(
this,
"save Map",
"",
"portable network graphic (*.png)");
1410 if(!filename.isEmpty())
1416 status2 =
"Routing Height data is normalized.";
1421 status2 =
"Routing Height data is inverted.";
1424 void MainWindow::save_profile(){
1425 QString filename = QFileDialog().getSaveFileName(
this,
"save Profil",
"",
"portable network graphic (*.png)");
1426 if(
ct != NULL && !filename.isEmpty()){
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);
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);
1442 void MainWindow::profil_settings(){
1446 void MainWindow::map_settings(){
1468 (k.lon-map->getmaxlon())/(map->getmaxlon()-map->getminlon())+0.5,
1469 (k.
lat-map->getmaxlat())/(map->getmaxlat()-map->
getminlat())+0.5);
1475 float d = dmax-dmin;
1476 ui->profil->set_labels(QString(
"%1 km %2 Hm %3 Hm/km %4 km/h %5 W")
1480 .arg(PA->
get_v(dmin,dmax),0,
'f',1)
1481 .arg(PA->
get_P(dmin,dmax),0,
'f',0),
1501 void MainWindow::analyse_gpx(QString filename){
1502 if(!filename.isEmpty()){
1503 gpx g(filename.toLocal8Bit().data());
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)){
1513 WayHeight(hd,data[2],data[3],length,&nb);
1517 ct =
new Track(data[0],data[1],data[2],data[3],length);
1520 for(
long i = 0; i < 5; i++)
1525 &(c.MS.minlon),&(c.MS.
maxlon));
1531 void MainWindow::analyse_gpx(){
1532 QString filename = QFileDialog().getOpenFileName(
this,
"analyse gpx",
"",
"GPS exchange format (*.gpx)");
1533 analyse_gpx(filename);
1535 void MainWindow::load_STRONGcalc(){
1536 QString filename = QFileDialog().getOpenFileName(
this,
"open STRONG calculation ",
"",
"STRONG calculation(*.sca)");
1542 connect(sc,SIGNAL(status(QString)),
this,SLOT(show_STRONG_status(QString)));
1548 void MainWindow::save_STRONGcalc(){
1550 QString filename = QFileDialog().getSaveFileName(
this,
"save STRONG calculation ",
"",
"STRONG calculation(*.sca)");
1559 status2 =
"There is no finished STRONG calculation to operate upon.";
1564 double maxlat0 = 52;
1565 double minlat0 = 36;
1566 double minlon0 = -11;
1567 double maxlon0 = 30;
1575 int xmin, xmax, ymin, ymax;
1579 QString folderpath =
"D:\\ClimbProject\\Tiles\\";
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--)
1590 for(
int y = ymin;
y <= ymax;
y++){
1595 w.
dest = folderpath;
1597 w.
mode = CreateTilesBTP;
1630 double maxlat0 = 52;
1631 double minlat0 = 36;
1632 double minlon0 = -11;
1633 double maxlon0 = 30;
1640 int xmin, xmax, ymin, ymax;
1644 QString folderpath =
"D:\\ClimbProject\\STRONGLayers\\";
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++){
1659 w.
dest = folderpath;
1661 w.
mode = CreateSTRONGLayers;
1675 if(
Cmdl.length()>0){
1677 connect(wd,SIGNAL(finished()),
this,SLOT(
next_command()));
1678 qRegisterMetaType<webdatacmd>(
"webdatacmd");
1692 first.
mode = SplitEurope;
1699 QString foldername = QFileDialog::getExistingDirectory(
this,
"select SRTM3 data directory");
1700 if(!foldername.isEmpty()){
1701 QDir f(foldername,
"*.hgt");
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]));
1713 text =
"no hgt files corrected.";
1715 QMessageBox(QMessageBox::NoIcon,
"hgt-correction",text).exec();
1719 double maxlat0 = 72;
1720 double minlat0 = 36;
1721 double minlon0 = -11;
1722 double maxlon0 = 30;
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++){
1734 w.
dest = QString(
"%1%2-%3-%4.btp")
1735 .arg(folderpathdest)
1739 w.
src = QString(
"%1%2-%3-%4.pbf")
1751 double maxlat0 = 72;
1752 double minlat0 = 36;
1753 double minlon0 = -11;
1754 double maxlon0 = 30;
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++){
1769 w.
dest = QString(
"%1%2-%3")
1770 .arg(folderpathdest)
1773 w.
src = QString(
"%1%2-%3-%4.btp")
1778 w.
mode = CreateHTML;
1786 double boxes[8][4] = {{10.15,51.33,11.55,51.95},
1787 {9.44,49.85,17.8,51.5},
1788 {12.08,48.11,15.8,49.6},
1789 {6.5,46.95,9.4,48.92},
1791 {18,48.55,21.3,49.9},
1792 {6.9,48.8,9.44,51.6},
1793 {4.4,48.9,8.35,50.8}};
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")
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\\")
1816 f.copy(ydir.filePath(QString(
"%1.png").arg(x)));
double hmperkm
hmmax=max(hmmax,radius*hmperkm)
double get_P()
return average power
void read_OSM()
read osm file
void read_europe()
slot to organize multithreating task
void settings(MapSettings *MS)
assigns new settings
double ** get_vdata()
returns data array pointer
double ** get_Pdata()
returns data array pointer
Neighbour * via
connection to reach this STRONG
void draw_line(QPainter *p, KOOlist *k, int kc)
drawing commends from outside
provide all user settings
void load(char *filename)
load btp to dataset
bool html
climb analyse dialog
double minP
climb analyse dialog
void correct_hgt()
slot to organize multithreating task
double mapsize
picturesize in megapixel
void delete_to_cross(int cc)
void STRONGlayer_save(char *filename, STRONGlayer *SL)
saves STRONGlayer to file
char start_btp[260]
osm data to load at beginning
STRONGsetting sconfig
STRONGAlgo setting, detail mode.
void next_command()
slot to organize multithreating task
int get_datacount()
returns data array length
double getmaxlat()
return lsat calced bounding rect
int hmmax
finalization criterium absolute
double getminlat()
return real borders
float minP
defines climb: min. difficulty
list elements to handle multiple STRONGlayers
KOO * get_first_KOO()
returns root of node-AVL tree
container struct to hold data of a coordinate
STRONGlayer * STRONGlayer_load(char *filename)
loades STRONGlayer from file
bool Climblayer
climb analyse dialog
short next_d(double lat, double lon, double *d)
searches for closest point on track to point (lat,lon)
double ** get_d_h_array()
returns reference
void get_KOO_Waysavl()
links node IDs to nodes recursivly
void set_maxtype(char mt)
short notNULL()
is track empty or not
float downtoupmax
defines climb: allowed down Hm
double get_v(double d)
interpolate time in data
float get_height_meters()
short extract_KOO(KOO *k, double d)
creates KOO refering distance point d
void extract_neighbourlist(STRONG *s, STRONG *e, Neighbour ***nl, int *nc)
collects a Neighbour list from STRONG network
void get_brect(double *latmin, double *latmax, double *lonmin, double *lonmax)
return bounding rect of Track
short next_cross(double clickedlat, double clickedlon, KOO **kdot, float maxd)
stores cross in kdot which is closest to (clickedlat,clickedlon)
void route_STRONG_finalize(int succes)
void finish_STRONG()
resets STRONG network of a STRONGcalc to normal Dijkstra state
void delete_cross(int nr)
deletes last nr cross of Track
routing container struct, connects cross via Way with each other
int hmstep
Additional criteria for STRONGPlus defining climb.
label algorithm to solve multicriteria shortes path problem
short extract_h(double d, double *h)
creates double for height refering distance point d
void calc_brect()
refresh bounding rect of dataset
void zoom(double zoomfactor, double dlonfactor, double dlatfactor)
handles all map modification (mooving, zooming)
void sort_peaks()
primitive sort algorithm
void mousePressEvent(QMouseEvent *event)
handles all mouse inputs
void set_marker(double x)
draws vertical black line at x pos
int width
rendering image size
void check_lines()
delete Way with unresolved nodes
bool drawct
draw current track
bool noSTRONGPlus
dont apply climb restrictions
double getminlat()
return lsat calced bounding rect
creates data for web site
config * c
BTP configuration to be used.
bool list
climb analyse dialog
void set_routingmode(inputstate ip)
sets routing mode and shows hints in statusbar
STRONG * s
memory for routing algorithms
undo and redo container class for BTP to save no longer needed tracks
char SRTM3folder[260]
SRTM3 data folder.
char maxtype
way restrictions
holds digital elevation model extracted from SRTM3 data
official representation of Track in BTP3
void to_gpx(char *filename)
save to gpx file
void keyPressEvent(QKeyEvent *event)
handles keyboard input
double get_length()
returns Track length [km]
void reset_t(double minlat, double maxlat, double minlon, double maxlon)
generates the data grid being
QString src
source file name
container for line geodata
void save_to_png(QString filename)
save map as picture to hard disk
void resize(int width, int height)
adapts size, recalculate borders from desired borders
void zoom_profil(double dmin, double dmax)
repaints profil with current dataset, but refreshed titel
double y_to_lat(int y)
map coordinate information
void add_Cmd(webdatacmd *w)
slot to organize multithreating task
void drawCross(QPainter *p)
void * from
< pointer to STRONG or FibunacciHeap
short near_check(double lat, double lon, double limit)
check if point (lat,lon) is closer to track then limit
plotting 2D-Data sets as the height profile of a track or poweranalysis data
int drawSTRONGlayer
create mapdialog setting
void set_default(PowerAnalysisSetting *s)
apply default setting to the PowerAnalysisSetting s
QString dest
destination file name
void RelationstoFace(relation **l, lines **f)
collect all Way to one relation
void calc_peak_index_pro(HeightData *h)
summit ranking uses t-functions of heighdata
void update_map_MovObj(Way *w)
void set_borders(double latmin0, double latmax0, double lonmin0, double lonmax0)
sets desired borders, recalculate bordes due to window size
short toggle_marker(KOO *k)
a KOO of the track can be marked or not, used for drag&drop routing
extracts climbs from street network and provides climblayer handling
double minHM
climb analyse dialog
climblayer * CL
Climblayer.
void toggle_poweranalysis()
conroles communication from profil to mainwindow
inputstate input
current routing mode
KOO ** node
array KOO pointers
bool drawSL
draw stronglayer
short DijkstraFib_minHM(KOO *s, KOO *e, char max, char min, OSM *o, int Si)
see DijkstraFib(), but minimizing Hm instead of distance
int height
rendering image size
void CA_europe()
slot to organize multithreating task
multithreading working command, defines the task to be executed
class to perform routing routines on osm data sets
char ProjectName[260]
climb analyse dialog
void STRONG_europe()
slot to organize multithreating task
void resizeEvent(QResizeEvent *event)
change of main window size
void set_SRTM3_folder(char *folder)
specifies the folder where hgt-files of SRTM3 data are searched
double mapsize
climb analyse dialog
void init()
loads settings, initialized variables
bool drawCL
draw climblayer
STRONGsetting cconfig
STRONGAlgo setting, climb mode.
void refresh_pixmap()
repaints the plot's pixmap
QPixmap * get_Map()
return pixmap of the last generated map
void STRONG_preview(int i)
bool map
climb analyse dialog
void calc_borders()
desired borders to real borders
void generate_tiles()
creates tiles for map server
assigns heights to Way, generates Neighbour data
int plotpower
Plotting power calc results.
void draw_map(STRONGlayer *SL, climblayer *cl, Track *ct, int fastmode)
universal high quality drawing
double get_t(double d)
interpolate time in data
power calculation for height-distance datasets
STRONGlayer * STRONGlayer_create(STRONGlayer *SL, int N)
creates STRONGlayer from a unfinalized STRONG network
void drawRoute(QPainter *p)
void set_data(double **dataxy, int count)
setting one dataset and repaint plot
BTP3 database, created from OpenStreetMap data.
double minS
climb analyse dialog
short DijkstraFib(KOO *s, KOO *e, char max, char min, OSM *o, int Si)
this is famous Dijkstra shortes path algothim
void zoom14_collection()
copy high zoom level tiles for desired areas in europe
int drawClimblayer
create mapdialog setting
char ProjectFolder[260]
climb analyse dialog
double getminlon()
return lsat calced bounding rect
void normalize_Hm(KOO *k)
removes total height differences from Neighbour relation
int plotspeed
Plotting power calc results.
void set_mintype(char mt)
int isready()
returns whether data is loaded
void center_track(double d)
short dhmin
defines climb: min. Hm
void save(char *filename, double minlat, double maxlat, double minlon, double maxlon)
save dataset as btp
double maxdwnHM
climb analyse dialog
main user setting container
void selectSTRONG(readdirection rd, short steps)
void calc_track(Track *t)
calc power from P(v) distribution
int drawRoute
create mapdialog setting
void invert_Hm(KOO *k)
switches descenting and ascenting vertical meters in Neighbour relation
int get_status()
returns current class state
QList< webdatacmd > Cmdl
command list to calculate web content multithreated
STRONGsetting mconfig
STRONGAlgo setting, fast mode.
double getmaxlon()
return lsat calced bounding rect
container for user settings to manually generate map
void split_europe_pbf()
splits europe.pbf $osm data