Skip to content

Commit 2e3d21d

Browse files
committed
finalized project
1 parent c2ef19c commit 2e3d21d

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

src/backend/helpers/fmiFormat.go

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func CreateFileFromGraph(graph datastructures.Graph, pathToFile string) {
8585
if err != nil {
8686
log.Fatalf("Got error while flushing a filewriter. Err: %s", err.Error())
8787
}
88+
log.Printf("Writing graph.fmi file to %s\n", pathToFile)
8889
}
8990

9091
func createNodesFromFile(nodeCount int, graph datastructures.Graph, idToIdx map[int]int, fileScanner *bufio.Scanner) {

src/main.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ package main
22

33
import (
44
"OSM/src/backend/helpers"
5-
pre2 "OSM/src/backend/pre"
5+
"OSM/src/backend/pre"
6+
"log"
67
"os"
8+
"path"
79
)
810

9-
const N = 1e6
11+
const N = 1e3
1012

1113
func main() {
12-
path := os.Getenv("PBF")
13-
14-
wayNodes := pre2.GenerateCoastlines(path)
15-
points := pre2.GenerateSpherePoints(N)
16-
classification := pre2.TopLevel(wayNodes, points)
17-
graph := pre2.GenerateGraphFromPoints(N, points, classification)
18-
helpers.CreateFileFromGraph(graph, "./out/graph.fmi")
19-
14+
pathToPBF := os.Args[1]
15+
pathToFmi := path.Dir(pathToPBF)
16+
pathToFmi = pathToFmi + "/graph.fmi"
17+
log.Println(pathToFmi)
18+
wayNodes := pre.GenerateCoastlines(pathToPBF)
19+
points := pre.GenerateSpherePoints(N)
20+
classification := pre.TopLevel(wayNodes, points)
21+
graph := pre.GenerateGraphFromPoints(N, points, classification)
22+
helpers.CreateFileFromGraph(graph, pathToFmi)
2023
}

src/mainWeb.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
import (
4+
"OSM/src/web"
5+
"os"
6+
)
7+
8+
func main() {
9+
pathToFmi := os.Args[1]
10+
port := os.Args[2]
11+
web.Main(pathToFmi, port)
12+
}

src/web/server.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ import (
44
"OSM/src/backend/datastructures"
55
helpers2 "OSM/src/backend/helpers"
66
"OSM/src/backend/shortestPath"
7+
"fmt"
78
"log"
89
"math"
910
"net/http"
1011
"strconv"
1112
)
1213

13-
func Main(pathToFmiFile string) {
14+
func Main(pathToFmiFile string, port string) {
1415
graph := helpers2.CreateGraphFromFile(pathToFmiFile)
1516

1617
fileServer := http.FileServer(http.Dir("web/static"))
1718
http.Handle("/", fileServer)
1819
http.HandleFunc("/route", routeHandler(graph))
1920
http.HandleFunc("/point", pointHandler(graph))
2021

21-
log.Printf("Starting server at port 8080\n")
22-
if err := http.ListenAndServe(":8080", nil); err != nil {
22+
log.Printf("Starting server at port %s\n", port)
23+
if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil {
2324
log.Fatal(err)
2425
}
2526
}

0 commit comments

Comments
 (0)