config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Zoom6Max = 64
	Zoom5Max = 32
	Zoom4Max = 16
	Zoom3Max = 8
	Zoom2Max = 4
)
View Source
const (
	FlagBaseURL     = "base-url"
	FlagInsecure    = "insecure"
	FlagYear        = "year"
	FlagFullImage   = "full-image"
	FlagCropLeft    = "crop-left"
	FlagCropRight   = "crop-right"
	FlagCropTop     = "crop-top"
	FlagCropBottom  = "crop-bottom"
	FlagZoom        = "zoom"
	FlagParallelism = "parallelism"
	FlagFormat      = "format"
	FlagCompression = "compression"
	FlagNoProgress  = "no-progress"
)

Variables

View Source
var (
	ErrBoundsTooSmall = errors.New("bounds too small")
	ErrBoundsTooLarge = errors.New("bounds too large")
)
View Source
var (
	ErrNoFormat           = errors.New("could not discover file format")
	ErrUnexpectedResponse = errors.New("unexpected response")
)
View Source
var ErrInvalidZoom = errors.New("invalid zoom")
View Source
var ErrMissingConfig = errors.New("command missing config")
View Source
var ErrMissingYear = errors.New("map is not available for year")

Functions

func CompressionLevelStrings

func CompressionLevelStrings() []string

CompressionLevelStrings returns a slice of all String values of the enum

func InitLog

func InitLog()

func NewContext

func NewContext(ctx context.Context, conf *Config) context.Context

Types

type CompressionLevel

type CompressionLevel int
const (
	CompressionDefault CompressionLevel = iota
	CompressionNone
	CompressionFast
	CompressionBest
)

func CompressionLevelString

func CompressionLevelString(s string) (CompressionLevel, error)

CompressionLevelString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func CompressionLevelValues

func CompressionLevelValues() []CompressionLevel

CompressionLevelValues returns all values of the enum

func (CompressionLevel) IsACompressionLevel

func (i CompressionLevel) IsACompressionLevel() bool

IsACompressionLevel returns "true" if the value is listed in the enum definition. "false" otherwise

func (CompressionLevel) MarshalText

func (i CompressionLevel) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for CompressionLevel

func (*CompressionLevel) Set

func (c *CompressionLevel) Set(s string) error

func (CompressionLevel) String

func (i CompressionLevel) String() string

func (*CompressionLevel) ToPNG

func (*CompressionLevel) Type

func (c *CompressionLevel) Type() string

func (*CompressionLevel) UnmarshalText

func (i *CompressionLevel) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for CompressionLevel

type Config

type Config struct {
	Completion  string
	BaseURL     pflagx.URL
	Insecure    bool
	Client      *http.Client
	Year        int
	TileSize    int
	FullImage   bool
	Crop        image.Rectangle
	Bounds      image.Rectangle
	Zoom        int
	Parallelism int
	Format      string
	Compression CompressionLevel
	NoProgress  bool
}

func FromContext

func FromContext(ctx context.Context) (*Config, bool)

func Load

func Load(ctx context.Context, cmd *cobra.Command) (*Config, error)

func New

func New() *Config

func (*Config) BuildURL added in v0.2.0

func (c *Config) BuildURL(year, zoom int, pt image.Point, format string) *url.URL

func (*Config) CheckYear

func (c *Config) CheckYear(ctx context.Context) error

func (*Config) FindFormat

func (c *Config) FindFormat(ctx context.Context) error

func (*Config) GetYearBounds added in v0.3.0

func (c *Config) GetYearBounds() (image.Rectangle, error)

func (*Config) MaxForZoom

func (c *Config) MaxForZoom() (image.Point, error)

func (*Config) RegisterCompletions

func (c *Config) RegisterCompletions(cmd *cobra.Command)

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(cmd *cobra.Command)

func (*Config) TileCount

func (c *Config) TileCount() int

func (*Config) TilesHorizontal added in v0.3.0

func (c *Config) TilesHorizontal() int

func (*Config) TilesVertical added in v0.3.0

func (c *Config) TilesVertical() int

func (*Config) UpdateBounds added in v0.3.0

func (c *Config) UpdateBounds() error

Jump to

Keyboard shortcuts

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