Correct name from map-dot to map-dots
This commit is contained in:
parent
f98e2d3a7a
commit
1018afe598
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module git.fjla.uk/fred.boniface/map-dot
|
module git.fjla.uk/fred.boniface/map-dots
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
79
main.go
79
main.go
@ -3,10 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
"git.fjla.uk/fred.boniface/map-dot/log"
|
"git.fjla.uk/fred.boniface/map-dots/log"
|
||||||
"git.fjla.uk/fred.boniface/map-dot/run"
|
"git.fjla.uk/fred.boniface/map-dots/run"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -15,7 +14,7 @@ var (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.BoolVar(&showHelp, "help", false, "Show extended help")
|
flag.BoolVar(&showHelp, "help", false, "Show extended help")
|
||||||
flag.Usage = customUsage
|
flag.Usage = run.HelpText
|
||||||
serverMode := flag.Bool("server", false, "Run as an API server - Omit all other flags if running as server")
|
serverMode := flag.Bool("server", false, "Run as an API server - Omit all other flags if running as server")
|
||||||
height := flag.Uint64("height", 600, "Output image height")
|
height := flag.Uint64("height", 600, "Output image height")
|
||||||
width := flag.Uint64("width", 800, "Output image width")
|
width := flag.Uint64("width", 800, "Output image width")
|
||||||
@ -37,72 +36,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.Msg.Info("Starting map-dot")
|
log.Msg.Info("Starting map-dots")
|
||||||
fmt.Println("\n" + ascii)
|
fmt.Println("\n" + ascii)
|
||||||
fmt.Println("Creating art from location data")
|
fmt.Println("Creating art from location data")
|
||||||
}
|
}
|
||||||
|
|
||||||
const ascii string = `███╗ ███╗ █████╗ ██████╗ ██████╗ ██████╗ ████████╗
|
const ascii string = `███╗ ███╗ █████╗ ██████╗ ██████╗ ██████╗ ████████╗███████╗
|
||||||
████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔═══██╗╚══██╔══╝
|
████╗ ████║██╔══██╗██╔══██╗ ██╔══██╗██╔═══██╗╚══██╔══╝██╔════╝
|
||||||
██╔████╔██║███████║██████╔╝██║ ██║██║ ██║ ██║
|
██╔████╔██║███████║██████╔╝█████╗██║ ██║██║ ██║ ██║ ███████╗
|
||||||
██║╚██╔╝██║██╔══██║██╔═══╝ ██║ ██║██║ ██║ ██║
|
██║╚██╔╝██║██╔══██║██╔═══╝ ╚════╝██║ ██║██║ ██║ ██║ ╚════██║
|
||||||
██║ ╚═╝ ██║██║ ██║██║ ██████╔╝╚██████╔╝ ██║
|
██║ ╚═╝ ██║██║ ██║██║ ██████╔╝╚██████╔╝ ██║ ███████║
|
||||||
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ `
|
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝`
|
||||||
|
|
||||||
func customUsage() {
|
|
||||||
extendedHelp := `
|
|
||||||
map-dot - Transform location data into artistic heat-map style images
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
map-dot [--server] [--height=HEIGHT] [--width=WIDTH] [--style=STYLE] [--format=FORMAT] [--input=INPUT] [--id=ID]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--server Run in server mode
|
|
||||||
--height=HEIGHT Output image height
|
|
||||||
--width=WIDTH Output image width
|
|
||||||
--style=STYLE Output image style
|
|
||||||
--format=FORMAT Output image format
|
|
||||||
--input=INPUT Input source
|
|
||||||
--id=ID Traccar device ID
|
|
||||||
|
|
||||||
More detailed help information:
|
|
||||||
-- server (Omit to run in CLI Mode):
|
|
||||||
Runs a web API on localhost:8198
|
|
||||||
Note that there is no authentication built in and the service could expose
|
|
||||||
personal location data if access is allowed from the internet.
|
|
||||||
|
|
||||||
-- height (Only in CLI Mode): DEFAULT: 1080
|
|
||||||
The height of the output image in pixels (Max: 7680)
|
|
||||||
|
|
||||||
-- width (Only in CLI Mode): DEFAULT: 1920
|
|
||||||
The width of the output image in pixels (Max: 4320)
|
|
||||||
|
|
||||||
-- style (Only in CLI Mode): DEFAULT: circles
|
|
||||||
The style of the output image - currently only 'circles' is available
|
|
||||||
|
|
||||||
-- format (Only in CLI Mode): DEFAULT: png
|
|
||||||
The image format of the output image. Options are:
|
|
||||||
png, jpeg, gif, bmp, tiff, webp
|
|
||||||
|
|
||||||
-- input (Only in CLI Mode): DEFAULT: traccar
|
|
||||||
The input source for data. Options are:
|
|
||||||
traccar, a valid file path in a supported format (See below for formats)
|
|
||||||
|
|
||||||
-- id (Only in CLI Mode): REQUIRED for CLI in 'traccar' mode
|
|
||||||
The Traccar device ID to fetch data for
|
|
||||||
|
|
||||||
If you want to fetch data from Traccar, you must ensure the following environment variables are set
|
|
||||||
This applies to Server and CLI modes:
|
|
||||||
TRACCAR_USER : Traccar Username
|
|
||||||
TRACCAR_PASS : Traccar Password
|
|
||||||
TRACCAR_URL : Traccar URL (Including port if not 80/443)
|
|
||||||
|
|
||||||
Input Formats:
|
|
||||||
Supported input file formats are:
|
|
||||||
xml+gpx, xml+kml, traccar-Api-JSON
|
|
||||||
|
|
||||||
For Web API usage information start the server and go to localhost:8198/help
|
|
||||||
`
|
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", extendedHelp)
|
|
||||||
}
|
|
||||||
|
63
run/cli.go
63
run/cli.go
@ -1,6 +1,9 @@
|
|||||||
package run
|
package run
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
func CLI(height, width uint64, style, format, input string) {
|
func CLI(height, width uint64, style, format, input string) {
|
||||||
fmt.Printf("Running CLI mode with height=%d, width=%d, type=%s, input=%s\n", height, width, style, input)
|
fmt.Printf("Running CLI mode with height=%d, width=%d, type=%s, input=%s\n", height, width, style, input)
|
||||||
@ -17,3 +20,61 @@ func CLI(height, width uint64, style, format, input string) {
|
|||||||
// Pass parsed data to imaging package
|
// Pass parsed data to imaging package
|
||||||
fmt.Println("End of implementation")
|
fmt.Println("End of implementation")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HelpText() {
|
||||||
|
extendedHelp := `
|
||||||
|
map-dots - Transform location data into artistic heat-map style images
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
map-dots [--server] [--height=HEIGHT] [--width=WIDTH] [--style=STYLE] [--format=FORMAT] [--input=INPUT] [--id=ID]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--server Run in server mode
|
||||||
|
--height=HEIGHT Output image height
|
||||||
|
--width=WIDTH Output image width
|
||||||
|
--style=STYLE Output image style
|
||||||
|
--format=FORMAT Output image format
|
||||||
|
--input=INPUT Input source
|
||||||
|
--id=ID Traccar device ID
|
||||||
|
|
||||||
|
More detailed help information:
|
||||||
|
-- server (Omit to run in CLI Mode):
|
||||||
|
Runs a web API on localhost:8198
|
||||||
|
Note that there is no authentication built in and the service could expose
|
||||||
|
personal location data if access is allowed from the internet.
|
||||||
|
|
||||||
|
-- height (Only in CLI Mode): DEFAULT: 1080
|
||||||
|
The height of the output image in pixels (Max: 7680)
|
||||||
|
|
||||||
|
-- width (Only in CLI Mode): DEFAULT: 1920
|
||||||
|
The width of the output image in pixels (Max: 4320)
|
||||||
|
|
||||||
|
-- style (Only in CLI Mode): DEFAULT: circles
|
||||||
|
The style of the output image - currently only 'circles' is available
|
||||||
|
|
||||||
|
-- format (Only in CLI Mode): DEFAULT: png
|
||||||
|
The image format of the output image. Options are:
|
||||||
|
png, jpeg, gif, bmp, tiff, webp
|
||||||
|
|
||||||
|
-- input (Only in CLI Mode): DEFAULT: traccar
|
||||||
|
The input source for data. Options are:
|
||||||
|
traccar, a valid file path in a supported format (See below for formats)
|
||||||
|
|
||||||
|
-- id (Only in CLI Mode): REQUIRED for CLI in 'traccar' mode
|
||||||
|
The Traccar device ID to fetch data for
|
||||||
|
|
||||||
|
If you want to fetch data from Traccar, you must ensure the following environment variables are set
|
||||||
|
This applies to Server and CLI modes:
|
||||||
|
TRACCAR_USER : Traccar Username
|
||||||
|
TRACCAR_PASS : Traccar Password
|
||||||
|
TRACCAR_URL : Traccar URL (Including port if not 80/443)
|
||||||
|
|
||||||
|
Input Formats:
|
||||||
|
Supported input file formats are:
|
||||||
|
xml+gpx, xml+kml, traccar-Api-JSON
|
||||||
|
|
||||||
|
For Web API usage information start the server and go to localhost:8198/help
|
||||||
|
`
|
||||||
|
|
||||||
|
fmt.Fprintf(os.Stderr, "%s\n", extendedHelp)
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.fjla.uk/fred.boniface/map-dot/log"
|
"git.fjla.uk/fred.boniface/map-dots/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func envCheck() {
|
func envCheck() {
|
||||||
|
@ -40,7 +40,7 @@ func handleTraccarRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
message := map[string]string{
|
message := map[string]string{
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"message": "Hello from map-dot",
|
"message": "Hello from map-dots",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal the JSON data
|
// Marshal the JSON data
|
||||||
|
Loading…
Reference in New Issue
Block a user