Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompileError ¶
type CompileError struct { Cause error // reported by the Compile{Expression|Condition} funcs // The parsed yaml that was used as input Input interface{} }
CompileError represents an errors during the compiling of conditions orr expressions.
func (*CompileError) Error ¶
func (e *CompileError) Error() string
Error returns a summary of the error.
func (*CompileError) YAML ¶
func (e *CompileError) YAML() string
YAML returns the input yaml that caused the error.
type Condition ¶
A Condition is something that evaluates to a boolean.
func CompileCondition ¶
CompileCondition will take the parsed YAML condition and return a compiled condition interface.
type Context ¶
type Context struct { Debug bool Verbose bool FeatureID osm.FeatureID Geometry orb.Geometry // To compute ways and/or relations if needed OSM *osm.OSM Tags map[string]string // OSMTags are used during post processing we need access // the original osm tags as well as the new filter outputs. OSMTags map[string]string WayMembership map[osm.NodeID]osm.Ways RelationMembership map[osm.FeatureID]osm.Relations // contains filtered or unexported fields }
Context is the evaluation context which is a bag of data. Also used as a data cache.
func NewContext ¶
NewContext creates a new filter.Context from an osmgeojson feature.
func NewContextFromProperties ¶
func NewContextFromProperties(ctx *Context, props geojson.Properties) *Context
NewContextFromProperties will create a context using a set of properties. This limits the queries one can do since not all the geometry is present.
func (*Context) Area ¶
Area computes the area of the element. This is used many places so it's computed/cached on the context.
func (*Context) Length ¶
Length computes the length of the element. This is used many places so it's computed/cached on the context.
func (*Context) MinZoom ¶
MinZoom computes the min zoom that the attributes should be displayed at. https://github.com/tilezen/vector-datasource/blob/e01d363c7279ba23c2e61c26b3562dccb7f33e60/data/functions.sql#L166-L187
type Expression ¶
type Expression interface {
Eval(*Context) interface{}
}
An Expression is something that evaluates to a boolean, number or string, depending on context.
func CompileExpression ¶
func CompileExpression(expr interface{}) (Expression, error)
CompileExpression will compile the parsed YAML into an Expression that can be evaluated into a bool, float64 or string.
type Filter ¶
type Filter struct { Skip bool RawFilter interface{} `yaml:"filter"` RawOutput map[string]interface{} `yaml:"output"` RawMinZoom interface{} `yaml:"min_zoom"` Table string `yaml:"table"` MinZoom NumExpression `yaml:"-"` Filter Condition `yaml:"-"` // Output map[string]Expression `yaml:"-"` Output []OutputExpression `yaml:"-"` }
A Filter is a set of matchers and the resulting tag transformation to add to the element properties if the matcher matches.
func (*Filter) Compile ¶
Compile will compile the parsed yaml into the expressions and conditions. This should be called once before matching. Returns a *CompileError with details about what exactly went wrong.
func (*Filter) Match ¶
Match will return true/false if the ctx/element matches the feature. Must call Compile() first to initialize the filters.
func (*Filter) Properties ¶
Properties of the element mapped to the given filter outputs. Must call Compile() first to initialize the output expressions.
type NumExpression ¶
NumExpression is something to evaluates to a number.
func CompileNumExpression ¶
func CompileNumExpression(expr interface{}) (NumExpression, error)
CompileNumExpression will compile the parsed YAML into a NumExpression that can be evaluated.
type OutputExpression ¶ added in v1.5.1
type OutputExpression struct { Key string Expr Expression }
OutputExpression has the key and expression value for the outputs. Using a slice vs a key value map was much cleaner.