map-dots/run/cli.go

89 lines
2.7 KiB
Go

package run
import (
"fmt"
"image"
"os"
"git.fjla.uk/fred.boniface/map-dots/data"
"git.fjla.uk/fred.boniface/map-dots/imaging"
"git.fjla.uk/fred.boniface/map-dots/log"
)
func CLI(height, width uint64, style, format, input string) {
log.Msg.Info("CLI Mode Started")
fmt.Printf("Running CLI mode with device=%s, height=%d, width=%d, type=%s, input=%s\n", "deviceId", height, width, style, input)
fmt.Println("CLI Mode not implemented")
if input == "traccar" {
envCheck()
// Use traccar package to fetch data
// Pass fetched data to imageing package
}
// Check that `input` is a valid filepath and points to a valid file.
// Use relevent package to parse file
// Pass parsed data to imaging package
var testing []data.LocationData
var _ image.Image = imaging.Generate(1, 1, "circle", testing)
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)
}