Skip to content

Commit

Permalink
Removing experimental renderer to stay more true to the original goal…
Browse files Browse the repository at this point in the history
… of this repo
  • Loading branch information
Niels-Ole Lambertz committed Apr 11, 2024
1 parent fa03893 commit 9d0fec4
Show file tree
Hide file tree
Showing 15 changed files with 8 additions and 922 deletions.
25 changes: 1 addition & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ go build .
If you prefer to run the binary directly you have the following options:

```
Usage of ./go_tile:
Usage of go_tile:
-data string
Path to directory containing tiles (default "./data")
-host string
HTTP Listening host (default "0.0.0.0")
-map string
Name of map. This value is also used to determine the metatile subdirectory (default "ajt")
-osm_path string
Path to osm_path to use for direct rendering. (experimental)
-port int
HTTP Listening port (default 8080)
-renderd-timeout duration
Expand Down Expand Up @@ -138,24 +136,3 @@ Percentage of the requests served within a certain time (ms)

This benchmark doesn't access the disk, as the tile has obviously been cached in memory.
Anyways it should give you an indication of whether this is fast enough for your use-case.

# Experimental renderer

This repo also contains an experimental rudimentary renderer. Its goal is to be able to render some sort of map with little operational overhead.

Experimental renderer (this will not be updated on every release, so ymmv) compared with osm.org:

![black lines only](assets/5295.png)
![osm.org](assets/5295-compare.png)

Images [OpenStreetMap](https://www.openstreetmap.org/) contributors, [CC-BY-SA](https://creativecommons.org/licenses/by-sa/2.0/)

To use this, pass an oms.pbf file via `-osm_path`.

Currently osm.pbf files have to be prepared like so
```
osmium add-locations-to-ways ~/Downloads/hamburg-latest.osm.pbf -o prepared.osm.pbf -f
```

This creates a temporary file on startup, which might take some time.
Testing so far was only done for individual cities.
Binary file removed assets/5295-compare.png
Binary file not shown.
Binary file removed assets/5295.png
Binary file not shown.
17 changes: 0 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
module github.com/nielsole/go_tile

go 1.20

require (
git.sr.ht/~sbinet/gg v0.5.0
github.com/paulmach/osm v0.7.1
)

require (
github.com/campoy/embedmd v1.0.0 // indirect
github.com/datadog/czlib v0.0.0-20160811164712-4bc9a24e37f2 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/paulmach/orb v0.1.3 // indirect
github.com/paulmach/protoscan v0.2.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/image v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
60 changes: 0 additions & 60 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,60 +0,0 @@
git.sr.ht/~sbinet/gg v0.5.0 h1:6V43j30HM623V329xA9Ntq+WJrMjDxRjuAB1LFWF5m8=
git.sr.ht/~sbinet/gg v0.5.0/go.mod h1:G2C0eRESqlKhS7ErsNey6HHrqU1PwsnCQlekFi9Q2Oo=
github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY=
github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8=
github.com/datadog/czlib v0.0.0-20160811164712-4bc9a24e37f2 h1:ISaMhBq2dagaoptFGUyywT5SzpysCbHofX3sCNw1djo=
github.com/datadog/czlib v0.0.0-20160811164712-4bc9a24e37f2/go.mod h1:2yDaWzisHKoQoxm+EU4YgKBaD7g1M0pxy7THWG44Lro=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/paulmach/orb v0.1.3 h1:Wa1nzU269Zv7V9paVEY1COWW8FCqv4PC/KJRbJSimpM=
github.com/paulmach/orb v0.1.3/go.mod h1:VFlX/8C+IQ1p6FTRRKzKoOPJnvEtA5G0Veuqwbu//Vk=
github.com/paulmach/osm v0.7.1 h1:dc84gLa4S/zCCqpBxb6jXTkN5dCI7VK7edt/tZTFG50=
github.com/paulmach/osm v0.7.1/go.mod h1:v0vZa0rKnCsO8ovx0Z+hR9BWVD+vO4ogLOXcV18/0yk=
github.com/paulmach/protoscan v0.2.1 h1:rM0FpcTjUMvPUNk2BhPJrreDKetq43ChnL+x1sRg8O8=
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw=
golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
69 changes: 7 additions & 62 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/nielsole/go_tile/renderer"
"github.com/nielsole/go_tile/utils"
)

Expand Down Expand Up @@ -174,7 +172,6 @@ func main() {
data_dir := flag.String("data", "./data", "Path to directory containing tiles")
static_dir := flag.String("static", "./static/", "Path to static file directory")
renderd_socket := flag.String("socket", "", "Unix domain socket path or hostname:port for contacting renderd. Rendering disabled by default.")
osm_path := flag.String("osm_path", "", "Path to osm_path to use for direct rendering. (experimental)")
renderd_timeout_duration := flag.Duration("renderd-timeout", (time.Duration(60) * time.Second), "Timeout duration after which renderd returns an error to the client (I.E. '30s' for thirty seconds). Set negative to disable")
map_name := flag.String("map", "ajt", "Name of map. This value is also used to determine the metatile subdirectory")
tls_cert_path := flag.String("tls_cert_path", "", "Path to TLS certificate")
Expand All @@ -184,10 +181,6 @@ func main() {

flag.Parse()

if len(*osm_path) > 0 && len(*renderd_socket) > 0 {
logFatalf("osm_path and renderd_socket are mutually exclusive")
}

// Renderd expects at most 64 bytes.
// 64 - (5 * 4 bytes - 1 zero byte of null-terminated string) = 43
if len(*map_name) > 43 {
Expand All @@ -212,63 +205,15 @@ func main() {
logInfof("renderd backend is disabled")
}

var requestHandler func(http.ResponseWriter, *http.Request)

if len(*osm_path) > 0 {
// Create a temp file.
var err error
tempFile, err := ioutil.TempFile("", "example")
if err != nil {
fmt.Println("Cannot create temp file:", err)
os.Exit(1)
}

data, err := renderer.LoadData(*osm_path, 15, tempFile)
if err != nil {
logFatalf("There was an error loading data: %v", err)
}
tempFileName := tempFile.Name()
tempFile.Close()

// Memory-map the file
mmapData, mmapFile, err := renderer.Mmap(tempFileName)
if err != nil {
logFatalf("There was an error memory-mapping temp file: %v", err)
}
defer renderer.Munmap(mmapData)
defer mmapFile.Close()
requestHandler = func(w http.ResponseWriter, r *http.Request) {
if *verbose {
logDebugf("%s request received: %s", r.Method, r.RequestURI)
}
if r.Method != "GET" {
http.Error(w, "Only GET requests allowed", http.StatusMethodNotAllowed)
return
}
renderer.HandleRenderRequest(w, r, *renderd_timeout_duration, data, 15, mmapData)
//handleRequest(w, r, *data_dir, *map_name, *renderd_socket, *renderd_timeout_duration, *tile_expiration_duration)
requestHandler := func(w http.ResponseWriter, r *http.Request) {
if *verbose {
logDebugf("%s request received: %s", r.Method, r.RequestURI)
}
defer func() {
// Cleanup the temp file.
if err := os.Remove(tempFile.Name()); err != nil {
fmt.Println("Failed to remove temp file:", err)
} else {
fmt.Println("Temp file removed.")
}

}()
} else {

requestHandler = func(w http.ResponseWriter, r *http.Request) {
if *verbose {
logDebugf("%s request received: %s", r.Method, r.RequestURI)
}
if r.Method != "GET" {
http.Error(w, "Only GET requests allowed", http.StatusMethodNotAllowed)
return
}
handleRequest(w, r, *data_dir, *map_name, *renderd_socket, *renderd_timeout_duration, *tile_expiration_duration)
if r.Method != "GET" {
http.Error(w, "Only GET requests allowed", http.StatusMethodNotAllowed)
return
}
handleRequest(w, r, *data_dir, *map_name, *renderd_socket, *renderd_timeout_duration, *tile_expiration_duration)
}
// HTTP request multiplexer
httpServeMux := http.NewServeMux()
Expand Down
3 changes: 0 additions & 3 deletions renderer/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions renderer/experimental-renderer-windows.go

This file was deleted.

Loading

0 comments on commit 9d0fec4

Please sign in to comment.