gpxcharts

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutputSVG = ".svg"
	OutputPNG = ".png"
)
View Source
const (
	DEFAULT_LEFT_PADDING_PIXELS   = 40
	DEFAULT_BOTTOM_PADDING_PIXELS = 20
)
View Source
const (
	ONE_FEET          = 0.3048
	ONE_YARD          = 0.9144
	ONE_MILE          = 1.609344 * 1000
	ONE_NAUTICAL_MILE = 1852
)

Variables

View Source
var (
	SPEED_MPS  = 1.
	SPEED_KMH  = 1000. / math.Pow(60., 2)
	SPEED_MPH  = 1.609344 * 1000. / math.Pow(60., 2)
	SPEED_KNOT = 1852. / math.Pow(60., 2)
)
View Source
var (
	Units       = map[string]float64{}
	SPEED_UNITS = map[string]float64{
		"mps":  SPEED_MPS,
		"kmh":  SPEED_KMH,
		"mph":  SPEED_MPH,
		"knot": SPEED_KNOT,
	}
)

Functions

func ConvertFromM

func ConvertFromM(n float64, toUnit string) float64

Convert from meters (or m/s if speed) into...

func FormatAltitude

func FormatAltitude(altitude_m float64, unit_type UnitType) string

func FormatFloat

func FormatFloat(f float64, digits int) string

func FormatLength

func FormatLength(lengthM float64, ut UnitType) string

func FormatSpeed

func FormatSpeed(meters_per_seconds float64, unit_type UnitType, round bool) string

func IsNanOrOnf

func IsNanOrOnf(f float64) bool

func RGBAToBytes

func RGBAToBytes(m *image.RGBA) ([]byte, error)

func SVGToBytes

func SVGToBytes(svg *draw2dsvg.Svg) ([]byte, error)

Types

type Axis

type Axis struct {
	Show      bool
	Grid      float64
	Labels    float64
	FontSize  float64
	Formatter func(float64) string
}

type ChartParams

type ChartParams struct {
	Width, Height int
	XAxis, YAxis  Axis
	Points        []Point
	FillColor     color.RGBA
	Unit          UnitType
	LineWidth     float64

	ChartMargin  Padding
	ChartPadding Padding

	MinX, MaxX float64
	MinY, MaxY float64
	// contains filtered or unexported fields
}

func (ChartParams) UnitTypeOrMetric

func (cp ChartParams) UnitTypeOrMetric() UnitType

type ChartService

type ChartService struct {
	FontDirs []string

	Log ErrorLogger
	// contains filtered or unexported fields
}

func NewChartService

func NewChartService(fontDirs []string) (*ChartService, error)

func (ChartService) ElevationChart

func (cs ChartService) ElevationChart(c context.Context, params ChartParams, g gpx.GPX, output OutputExtension) ([]byte, error)

func (*ChartService) Errorf

func (cs *ChartService) Errorf(c context.Context, msg string, params ...interface{})

func (ChartService) SpeedChart

func (cs ChartService) SpeedChart(c context.Context, params ChartParams, g gpx.GPX, output OutputExtension) ([]byte, error)

func (ChartService) SteepnessChart

func (cs ChartService) SteepnessChart(c context.Context, params ChartParams, g gpx.GPX, output OutputExtension) ([]byte, error)

type ErrorLogger

type ErrorLogger interface {
	Errorf(c context.Context, msg string, params ...interface{})
}

type OutputExtension

type OutputExtension string

type Padding

type Padding struct {
	Top, Right, Bottom, Left float64
}

type Point

type Point struct {
	X, Y float64
}

type UnitType

type UnitType string
const (
	UnitTypeMetric   UnitType = "m"
	UnitTypeImperial UnitType = "i"
	UnitTypeNautical UnitType = "n"
)

func AllUnitTypes

func AllUnitTypes() []UnitType

func (UnitType) Name

func (ut UnitType) Name() string

func (UnitType) Units

func (ut UnitType) Units() map[string]float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL