[OSGeo-Discuss] Parsing well-known text

Pierre Abbat phma at bezitopo.org
Sun Sep 6 09:52:56 PDT 2020


On Wednesday, 2 September 2020 05:41:40 EDT Even Rouault wrote:
> As far as I know, you can't create a CRS WKT with just unit information. The
> most minimal content that validates the WKT1 grammar would be something
> like:
> 
> LOCAL_CS["unspecified CRS",
>     LOCAL_DATUM["unspecified datum",2000],
>     UNIT["metre",1,
>         AUTHORITY["EPSG","9001"]],
>     AXIS["Easting",EAST],
>     AXIS["Northing",NORTH]]

That doesn't seem to have an elevation unit; should I assume that they're both 
meters?

> Yes, PROJ >= 6 has support for parsing and creating WKT in several versions
> of the WKT standard.
> 
> See proj_create_from_wkt() at
> https://proj.org/development/reference/functions.html, and all other
> proj_XXXX getters.
> 
> For creation of WKT, you might need the more advanced functions of
> https://github.com/OSGeo/PROJ/blob/master/src/proj_experimental.h , before
> exporting with proj_as_wkt()

That's overkill for what I'm doing. I don't need to make a projection, all I 
need to know is the units. I don't need to create a WKT except in the case 
that the original cloud doesn't have one and I'm adding one to specify the 
units.

The code to parse the WKT is in YACC, which I don't know how to work with, and 
I don't need all the tokens. Treating them as opaque atoms and looking for 
"UNIT" should work. Where can I find the grammar of the language of which WKT 
is an instance?

Adding any library multiplies the complexity of building and packaging on 
Windows. PROJ is 79 times as big as Wolkenbase so far and 17 times as big as 
PerfectTIN. Even Bezitopo, which handles projections, but only conformal ones, 
is only 1/7 as big as PROJ, by running du on the source trees with .git 
included.

Pierre
-- 
When a barnacle settles down, its brain disintegrates.
Já não percebe nada, já não percebe nada.





More information about the Discuss mailing list