Version: v1.2.0 Latest Latest

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 15 Imported by: 1



Package mss implements a CartoCSS parser and rule generator.



This section is empty.


View Source
var InvalidZoom = ZoomRange(0)


This section is empty.


type CompOp

type CompOp int
const (
	Unknown CompOp = iota

func (CompOp) String

func (c CompOp) String() string

type Decoder

type Decoder struct {
	// contains filtered or unexported fields

Decoder decodes one or more MSS files. Parse/ParseFile can be called multiple times to decode dependent .mss files. MSS() returns the current decoded style.

func New

func New() *Decoder

New will allocate a new MSS Decoder

func (*Decoder) Evaluate

func (d *Decoder) Evaluate() (err error)

Evaluate evaluates all expressions and resolves all references to variables. Must be called after last ParseFile/ParseString call.

func (*Decoder) MSS

func (d *Decoder) MSS() *MSS

MSS returns the current decoded style.

func (*Decoder) ParseFile

func (d *Decoder) ParseFile(filename string) error

ParseFile parses the given .mss file. Can be called multiple times to parse a style split into multiple files.

func (*Decoder) ParseString

func (d *Decoder) ParseString(content string) (err error)

func (*Decoder) Vars

func (d *Decoder) Vars() *Properties

Vars returns the current set of all variables. Call Evaluate first to resolve expressions, functions and variables.

type Field

type Field string

type Filter

type Filter struct {
	Field  string
	CompOp CompOp
	Value  Value

Filter contains a single condition. A style is only applied if the Field compares to the Value. Value can be a number or string for all comparsions with one exception. Filter with modulo comparsion will have ModuloComparsion as a value, to store the division the comparsion and the value.

func (Filter) String

func (f Filter) String() string

type MSS

type MSS struct {
	// contains filtered or unexported fields

func (*MSS) LayerRules

func (m *MSS) LayerRules(layer string, classes ...string) []Rule

LayerRules returns all Rules for this layer.

func (*MSS) LayerZoomRules

func (m *MSS) LayerZoomRules(layer string, zoom ZoomRange, classes ...string) []Rule

LayerZoomRules returns all Rules for this layer within the specified ZoomRange.

func (*MSS) Layers

func (m *MSS) Layers() []string

Layers returns all layer names in order of appearance.

func (*MSS) Map

func (m *MSS) Map() *Properties

Map returns properties of the root Map{} block.

type ModuloComparsion added in v1.2.0

type ModuloComparsion struct {
	Div    int
	CompOp CompOp
	Value  int

ModuloComparsion stores the divider and the actual comparsion for a modulo filter.

func (ModuloComparsion) String added in v1.2.0

func (f ModuloComparsion) String() string

type ParseError

type ParseError struct {
	Filename string
	Line     int
	Column   int
	Err      string

func (*ParseError) Error

func (p *ParseError) Error() string

type Prefix

type Prefix struct {
	Name     string
	Instance string

func SortedPrefixes

func SortedPrefixes(p *Properties, prefixes []string) []Prefix

SortedPrefixes returns a slice of all propertry prefixes, sorted by their first occurence.

type Properties

type Properties struct {
	// contains filtered or unexported fields

Properties is a map of all defined attributes for a rule. Use prop.GetXxx() to get typed properties.

func NewProperties

func NewProperties(kv ...interface{}) *Properties

func NewPropertiesInstance

func NewPropertiesInstance(kiv ...interface{}) *Properties

func (*Properties) GetBool

func (p *Properties) GetBool(property string) (bool, bool)

func (*Properties) GetColor

func (p *Properties) GetColor(property string) (color.Color, bool)

func (*Properties) GetFieldList

func (p *Properties) GetFieldList(property string) ([]interface{}, bool)

func (*Properties) GetFloat

func (p *Properties) GetFloat(property string) (float64, bool)

func (*Properties) GetFloatList

func (p *Properties) GetFloatList(property string) ([]float64, bool)

func (*Properties) GetStopList

func (p *Properties) GetStopList(property string) ([]Stop, bool)

GetStopList returns property as a list of Stops.

func (*Properties) GetString

func (p *Properties) GetString(property string) (string, bool)

func (*Properties) GetStringList

func (p *Properties) GetStringList(property string) ([]string, bool)

GetStringList returns property as a list of strings, single string is converted to a slice.

func (*Properties) SetDefaultInstance

func (p *Properties) SetDefaultInstance(instance string)

SetDefaultInstance sets the instance name used for all following GetXXX calls.

func (*Properties) String

func (p *Properties) String() string

type Rule

type Rule struct {
	Layer      string
	Attachment string
	Class      string
	Filters    []Filter
	Zoom       ZoomRange
	Properties *Properties
	// contains filtered or unexported fields

func (*Rule) String

func (r *Rule) String() string

type Selector

type Selector struct {
	Layer      string
	Class      string
	Attachment string
	Zoom       ZoomRange
	Filters    []Filter

type Stop

type Stop struct {
	Value int
	Color color.Color

type Value

type Value interface{}

type ZoomRange

type ZoomRange int32

func NewZoomRange

func NewZoomRange(comp CompOp, zoom int64) ZoomRange

func RulesZoom

func RulesZoom(rs []Rule) ZoomRange

func (ZoomRange) First

func (z ZoomRange) First() int

func (ZoomRange) Last

func (z ZoomRange) Last() int

func (ZoomRange) Levels

func (z ZoomRange) Levels() (n int)

func (ZoomRange) String

func (z ZoomRange) String() string

Jump to

Keyboard shortcuts

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