Help language development. Donate to The Perl Foundation

Geo::WellKnownText zef:kjpye last updated on 2022-09-22

ca477a0528d5958a0ef2f33399f4769859bf2adb/

Actions Status

TITLE

Geom::WellKnownText

The Geo::WellKnownText module contains a single function:

from-wkt

from-wkt takes a single Str parameter, and returns a single Geo::Geometry object corresponding to the wkt specification, or a Failure if the contents of the string cannot be interpreted as a Geometry object.

The conversion is case-insensitive, and optional whitespace may be included in various places. Thus the following strings will all produce the same object:

    PointZ(123 456 789)
    Point Z (123 456 789)
    Point Z(123 456 789)
    pointz (123 456 789)

Geo::WellKnownText::Grammar

The Geo::WellKnownText::Grammar module contains a single grammar Geo::WellKnownText::Grammar::WKT.

This is the same grammar used by the Geo::WellKnownText module, but it can be used separately to parse WKT strings.

The general usage would be

    my $results = Geo::WellKnownText::Grammar::WKT.parse($string, actions => My::Actions);

The actions used by Geo::WellKnownText::from-wkt are available in Geo::WellKnownText::WKT-Actions, but in that case you might as well use from-wkt described above.

The actions class will need to include the following methods (36 in total):

Geometry type Method Available Parameters
Point[Z][M] point[z][m] $<value> — an array containing the values for x, y, z and m as appropriate
LineString[Z][M] linestring[z][m]-text $<point[z][m]> — an array of whatever the relevant point method passed to make.
LinearRing[Z][M] linearring[z][m]-text $<point[z][m]> — and array of whatever the relevant point method passed to make.
Polygon[Z][M] polygon[z][m]-text $<linearring[z][m]-text — an array of whatever the appropriate linearring-text method passed to make.
PolyhedralSurface[Z][M] polyhedralsurface[z][m]-text $<polygon[z][m]-text — an array of whatever the appropriate polygon-text method passed to make.
MultiPoint[Z][M] multipoint[z][m]-text $<point[z][m]> — an array of whatever the relevant point method passed to make.
MultiLineString[Z][M] multilinestring[z][m]-text $<linestring[z][m]-text> — an array of whatever the relevant linestring-text method passed to make.
MultiPolygon[Z][M] multipolygon[z][m]-text $<polygon[z][m]-text — an array of whatever the appropriate polygon-text method passed to make.
GeometryCollection[Z][M] geometrycollection[z][m]-tagged-text $<geometry[z][m]-tagged-text> — an array of whatever the relevant geometry-text method passed to make.