Patrick Brosi 4 years ago
parent
commit
13a9174c85
5 changed files with 31 additions and 24 deletions
  1. 19 5
      src/osmfixer/CMakeLists.txt
  2. 0 13
      src/osmfixer/_config.h.in
  3. 7 1
      src/osmfixer/server/StatServer.cpp
  4. 2 3
      web/index.html
  5. 3 2
      web/script.js

+ 19 - 5
src/osmfixer/CMakeLists.txt

@@ -8,12 +8,26 @@ include_directories(
8
 	${OSMFIXER_INCLUDE_DIR}
8
 	${OSMFIXER_INCLUDE_DIR}
9
 )
9
 )
10
 
10
 
11
-configure_file (
12
-  "_config.h.in"
13
-  "_config.h"
14
-)
15
-
16
 add_executable(osmfixer ${osmfixer_main})
11
 add_executable(osmfixer ${osmfixer_main})
17
 add_library(osmfixer_dep ${osmfixer_SRC})
12
 add_library(osmfixer_dep ${osmfixer_SRC})
18
 
13
 
14
+add_custom_command(
15
+	OUTPUT index.h
16
+	COMMAND cd ${PROJECT_BINARY_DIR}/../web/ && xxd -i index.html > ${CMAKE_CURRENT_BINARY_DIR}/index.h
17
+	DEPENDS "${PROJECT_BINARY_DIR}/../web/index.html"
18
+	VERBATIM
19
+)
20
+
21
+add_custom_command(
22
+	OUTPUT build.h
23
+	COMMAND cd ${PROJECT_BINARY_DIR}/../web/ && cat leaflet-heat.js script.js > build.js && xxd -i build.js > ${CMAKE_CURRENT_BINARY_DIR}/build.h && rm build.js
24
+	DEPENDS "${PROJECT_BINARY_DIR}/../web/script.js"
25
+	DEPENDS "${PROJECT_BINARY_DIR}/../web/leaflet-heat.js"
26
+	VERBATIM
27
+)
28
+
29
+add_custom_target(htmlfiles DEPENDS index.h build.h)
30
+
31
+add_dependencies(osmfixer_dep htmlfiles)
32
+
19
 target_link_libraries(osmfixer osmfixer_dep util ${Boost_LIBRARIES} -lpthread)
33
 target_link_libraries(osmfixer osmfixer_dep util ${Boost_LIBRARIES} -lpthread)

+ 0 - 13
src/osmfixer/_config.h.in

@@ -1,13 +0,0 @@
1
-// Copyright 2017
2
-// Author: Patrick Brosi
3
-
4
-#ifndef SRC_PFAEDLE_CONFIG_H_
5
-#define SRC_PFAEDLE_CONFIG_H_
6
-
7
-// version number from cmake version module
8
-#define VERSION_FULL "@VERSION_GIT_FULL@"
9
-
10
-// version number from cmake version module
11
-#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
12
-
13
-#endif  // SRC_PFAEDLE_CONFIG_H_N

+ 7 - 1
src/osmfixer/server/StatServer.cpp

@@ -8,6 +8,8 @@
8
 #include "util/String.h"
8
 #include "util/String.h"
9
 #include "util/geo/Geo.h"
9
 #include "util/geo/Geo.h"
10
 #include "util/log/Log.h"
10
 #include "util/log/Log.h"
11
+#include "osmfixer/index.h"
12
+#include "osmfixer/build.h"
11
 
13
 
12
 using osmfixer::Params;
14
 using osmfixer::Params;
13
 using osmfixer::StatServer;
15
 using osmfixer::StatServer;
@@ -22,7 +24,11 @@ util::http::Answer StatServer::handle(const util::http::Req& req,
22
     auto cmd = parseUrl(req.url, req.payload, &params);
24
     auto cmd = parseUrl(req.url, req.payload, &params);
23
 
25
 
24
     if (cmd == "/") {
26
     if (cmd == "/") {
25
-      a = util::http::Answer("200 OK", "osmfixer");
27
+      a = util::http::Answer("200 OK", reinterpret_cast<const char*>(index_html));
28
+      a.params["Content-Type"] = "text/html; charset=utf-8";
29
+    } else if (cmd == "/build.js") {
30
+      a = util::http::Answer("200 OK", reinterpret_cast<const char*>(build_js));
31
+      a.params["Content-Type"] = "application/javascript; charset=utf-8";
26
     } else if (cmd == "/map") {
32
     } else if (cmd == "/map") {
27
       a = handleMapReq(params);
33
       a = handleMapReq(params);
28
     } else if (cmd == "/heatmap") {
34
     } else if (cmd == "/heatmap") {

+ 2 - 3
web/index.html

@@ -9,7 +9,6 @@
9
 
9
 
10
     <link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
10
     <link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
11
     <script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin=""></script>
11
     <script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin=""></script>
12
-    <script src="leaflet-heat.js"></script>
13
 
12
 
14
     <link href="https://fonts.googleapis.com/css?family=Nunito:600&display=swap" rel="stylesheet">
13
     <link href="https://fonts.googleapis.com/css?family=Nunito:600&display=swap" rel="stylesheet">
15
     <link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
14
     <link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
@@ -22,7 +21,7 @@
22
 <body>
21
 <body>
23
     <a id="logo" class="noselect"href="/">staty</a>
22
     <a id="logo" class="noselect"href="/">staty</a>
24
     <div id="map" style="width: 100%;height: 100%;"></div>
23
     <div id="map" style="width: 100%;height: 100%;"></div>
25
-    <script src="script.js">
24
+    <script src="build.js">
26
     </script>
25
     </script>
27
 </body>
26
 </body>
28
-</html>
27
+</html>

+ 3 - 2
web/script.js

@@ -2,7 +2,8 @@ widths = [12, 13, 13, 13, 13, 13, 13, 13];
2
 opas = [0.8, 0.6, 0.5, 0.5, 0.4];
2
 opas = [0.8, 0.6, 0.5, 0.5, 0.4];
3
 mwidths = [1, 1, 1, 1.5, 2, 3, 5, 6, 6, 4, 3, 2];
3
 mwidths = [1, 1, 1, 1.5, 2, 3, 5, 6, 6, 4, 3, 2];
4
 
4
 
5
-backend = "http://staty.cs.uni-freiburg.de/backend/";
5
+//backend = "http://staty.cs.uni-freiburg.de/backend/";
6
+backend = "http://localhost:9090";
6
 
7
 
7
 function marker(stat, z) {
8
 function marker(stat, z) {
8
     if (z > 15) {
9
     if (z > 15) {
@@ -410,4 +411,4 @@ function render() {
410
     }
411
     }
411
 }
412
 }
412
 
413
 
413
-render();
414
+render();