-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
119 lines (101 loc) · 2.61 KB
/
main.cpp
File metadata and controls
119 lines (101 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <iostream>
#include "rest/APIController.h"
#include "xml/XMLController.h"
#include "graph/GraphService.h"
#include "xml/Osm.h"
#include <fstream>
#include "graph/graph.h"
using namespace std;
void menu();
int printMenu();
void example();
void url();
/**
* starten des menus.
*
* @return -
*/
int main() {
menu();
return 0;
}
/**
* auswahl des menu punkts.
*/
void menu() {
int in = 0;
while (in != 9) {
in = printMenu();
switch (in) {
case 1:
example();
break;
case 2:
url();
break;
}
}
cout << endl << "Beendet .." << endl;
}
/**
* laden der beispiel osm datei (ALEXANDERHOEHE).
*/
void example() {
APIController controller = APIController();
XMLController xmlController = XMLController(controller.getResponse());
Osm osm = xmlController.parse();
GraphService graphService = GraphService(osm);
Graph g = graphService.getGraph();
filebuf fb;
string filename;
cout << "Geben Sie einen Dateinamen ein (*.gdi): " << endl;
cin >> filename;
if (fb.open(filename, ios::out)) {
ostream os(&fb);
SaveGraph(os, g);
fb.close();
cout << "Knotenzahl: " << g.knotenzahl << endl;
} else {
cout << "Datei konnte nicht geöffnet werden" << endl;
}
}
/**
* laden einer osm datei mittels api link.
*/
void url() {
APIController controller = APIController();
string url;
cout << "Geben Sie eine OpenStreetMap URL ein: " << endl;
cout << "Achtung! Zu grosse Bereiche werden von OpenStreetMap nicht als *.osm Datei ausgegeben." << endl;
cout << "Beispiel: [https://api.openstreetmap.org/api/0.6/map?bbox=7.6817,51.3669,7.6910,51.3723]" << endl;
cin >> url;
XMLController xmlController = XMLController(controller.getResponse(url));
Osm osm = xmlController.parse();
GraphService graphService = GraphService(osm);
Graph g = graphService.getGraph();
filebuf fb;
string filename;
cout << "Geben Sie einen Dateinamen ein (*.gdi);" << endl;
cin >> filename;
if (fb.open(filename, ios::out)) {
ostream os(&fb);
SaveGraph(os, g);
fb.close();
cout << "Knotenzahl: " << g.knotenzahl << endl;
} else {
cout << "Datei konnte nicht geöffnet werden" << endl;
}
}
/**
* ausgeben des menus.
*
* @return Menu Nummer.
*/
int printMenu() {
int in = 0;
cout << "[1] Iserlohn Alexanderhöhe (Beispiel)" << endl;
cout << "[2] OpenStreetMap URL (API)" << endl;
cout << "[9] Beenden" << endl;
cin >> in;
return in;
}