wkt-crs-go
Parser for Well Known Text (WKT) Coordinate Reference System (CRS) for golang.
It supports v1 of the language specification.
Grammar is available at ANTLR grammars repo;
The parser is generated by ANTLR for go target.
There are no ANTLR visitor nor listener generated, as I find them rather useless from code point of view.
Grammar is basically having two main entry rules:
propsFile
is accepting properties file
wkt
is accepting single definition WKT text
The parser can be used to read WKT and provide AST.
Instead there are few other visitors, which can be used as basis for whatever else is required:
to_text
is simple identity print of AST i.e. it prints content as-is, white space removed.
to_map
is converting AST to array of objects and properties (represented as map[string]interface{}). this can used to directly write it as json
.
to_pretty_text
is converting AST into text indented format.
Usage
The library offers a compiled
V1 support
WKT CRS V1 reference: Specification
The grammar tries to adhere to the spec but have not made extensive tests.
This grammar is extended with ability to parse properties file, containing EPSG=WKTCRS type of definitions.
For example one can parse GeoTools epsg.properties directly.
If the input is properties file, use propsFile
starting rule.
If the input is pure WKT, use wkt
starting rule.