diff --git a/go.mod b/go.mod index 499ac4b..236c615 100644 --- a/go.mod +++ b/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 diff --git a/main.go b/main.go index 4ab7bfa..d8d710c 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,9 @@ package main import ( "flag" "fmt" - "os" - "git.fjla.uk/fred.boniface/map-dot/log" - "git.fjla.uk/fred.boniface/map-dot/run" + "git.fjla.uk/fred.boniface/map-dots/log" + "git.fjla.uk/fred.boniface/map-dots/run" ) var ( @@ -15,7 +14,7 @@ var ( func main() { 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") height := flag.Uint64("height", 600, "Output image height") width := flag.Uint64("width", 800, "Output image width") @@ -37,72 +36,14 @@ func main() { } func init() { - log.Msg.Info("Starting map-dot") + log.Msg.Info("Starting map-dots") fmt.Println("\n" + ascii) fmt.Println("Creating art from location data") } -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) -} +const ascii string = `███╗ ███╗ █████╗ ██████╗ ██████╗ ██████╗ ████████╗███████╗ +████╗ ████║██╔══██╗██╔══██╗ ██╔══██╗██╔═══██╗╚══██╔══╝██╔════╝ +██╔████╔██║███████║██████╔╝█████╗██║ ██║██║ ██║ ██║ ███████╗ +██║╚██╔╝██║██╔══██║██╔═══╝ ╚════╝██║ ██║██║ ██║ ██║ ╚════██║ +██║ ╚═╝ ██║██║ ██║██║ ██████╔╝╚██████╔╝ ██║ ███████║ +╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝` diff --git a/map-dot b/map-dot deleted file mode 100755 index 5b4e90d..0000000 Binary files a/map-dot and /dev/null differ diff --git a/run/cli.go b/run/cli.go index c7ffa22..fd6a4ce 100644 --- a/run/cli.go +++ b/run/cli.go @@ -1,6 +1,9 @@ package run -import "fmt" +import ( + "fmt" + "os" +) 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) @@ -17,3 +20,61 @@ func CLI(height, width uint64, style, format, input string) { // Pass parsed data to imaging package 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) +} diff --git a/run/common.go b/run/common.go index f333064..eb821e1 100644 --- a/run/common.go +++ b/run/common.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "git.fjla.uk/fred.boniface/map-dot/log" + "git.fjla.uk/fred.boniface/map-dots/log" ) func envCheck() { diff --git a/run/server.go b/run/server.go index 24de6a3..d03f3bd 100644 --- a/run/server.go +++ b/run/server.go @@ -40,7 +40,7 @@ func handleTraccarRequest(w http.ResponseWriter, r *http.Request) { message := map[string]string{ "status": "success", - "message": "Hello from map-dot", + "message": "Hello from map-dots", } // Marshal the JSON data