modulepackage
0.0.0-20190728211353-227292859006
Repository: https://github.com/mercatormaps/go-mapcss.git
Documentation: pkg.go.dev
# README
go-mapcss
go-mapcss
is a Go parser for MapCSS.
Features
Rules
Selectors | Supported |
---|---|
multiple selectors | :heavy_check_mark: |
multiple attributes | :heavy_check_mark: |
negated attributes | :heavy_check_mark: |
zoom level (` | z`) |
canvas
rule properties
Properties | Supported |
---|---|
antialiasing | :heavy_check_mark: full , text , none |
fill-color | :heavy_check_mark: rgb , rgba , hex (3, 4, 6 and 8-digit) |
fill-opacity | :heavy_check_mark: 0 (transparent) — 1 (opaque) |
fill-image |
Development
The included ANTLR grammar file (MapCSS.g4
) is used to produce the parser
package. The Go target was added to ANTLR v4.6, so the command below downloads the latest version at the time of writing:
curl -O https://www.antlr.org/download/antlr-4.7.2-complete.jar
This command generates the Go target package:
java -jar /path/to/antlr-4.7.2-complete.jar -Dlanguage=Go -o internal/ MapCSS.g4
# Functions
AntialiasingString retrieves an enum value from the enum constants string name.
AntialiasingValues returns all values of the enum.
Parse a MapCSS document.
WithErrorReporter configures a reporter for error messages.
# Constants
AntialiasingFull 'full' applies to lines and text.
AntialiasingNone disables antialasing.
AntialiasingText 'text' applies to text only.
ExactZoom is a single applicable zoom level.
MinZoom is a minimum applicable zoom level.
ZoomRange is a range of applicable zoom levels.
# Structs
Attribute represents a MapCSS rule selector attribute.
Canvas represents a "canvas" rule in a MapCSS document.
Color where RGB values are 0-255, and alpha component is 0-1.
ErrorHandler is invoked when error is encounted by the parser.
Rule represents a MapCSS rule.
Selector represents a MapCSS rule selector.
Stylesheet represents a MapCSS document.
Zoom represents the zoom component of a MapCSS rule selector.
# Type aliases
Antialiasing property value.
ErrorReporter is passed an error message.
Option funcs can be passed to Parse().
ZoomType represents a method of specifying zoom level.