Geo::WKT::Simple(3pm) | User Contributed Perl Documentation | Geo::WKT::Simple(3pm) |
Geo::WKT::Simple - Simple utils to parse/build Well Known Text(WKT) format string.
use Geo::WKT::Simple; # Export all or use Geo::WKT::Simple ':parse'; # Only WKT parser functions or use Geo::WKT::Simple ':make'; # Only WKT builder functions # WKT POINT wkt_parse_point('POINT(10 20)'); #=> (10 20) wkt_make_point(10, 20); #=> POINT(10 20) # WKT LINESTRING wkt_parse_linestring('LINESTRING(1 2, 3 4)'); #=> ([ 1, 2 ], [ 3, 4 ]) wkt_make_linestring([ 1, 2 ], [ 3, 4 ]); #=> LINESTRING(1 2, 3 4) # WKT POLYGON wkt_parse_polygon('POLYGON((1 2, 3 4, 5 6, 1 2), (1 2, 3 4, 5 6, 1 2))'); #=> ( # [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 1, 2 ] ], # [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 1, 2 ] ], # ) wkt_make_polygon( [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 1, 2 ] ], [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 1, 2 ] ], ); #=> 'POLYGON((1 2, 3 4, 5 6, 1 2), (1 2, 3 4, 5 6, 1 2))' # And like so on for (MULTI)LINESTRING|POLYGON # WKT GEOMETRYCOLLECTION wkt_parse_geometrycollection( 'GEOMETRYCOLLECTION(POINT(10 20), LINESTRING(10 20, 30 40))' ); #=> ([ POINT => [ 10, 20 ] ], [ LINESTRING => [ [ 10, 20 ], [ 30, 40 ] ] ]) wkt_make_geometrycollection( [ POINT => [ 10, 20 ] ], [ LINESTRING => [ [ 10, 20 ], [ 30, 40 ] ] ] ); #=> 'GEOMETRYCOLLECTION(POINT(10 20), LINESTRING(10 20, 30 40))' # If you don't like too many exported symbols: use Geo::WKT::Simple qw/ wkt_parse wkt_make /; wkt_parse(POINT => 'POINT(10 20)'); wkt_make(POINT => [ 10, 20 ]);
Geo::WKT::Simple is a module to provide simple parser/builder for Well Known Text(WKT) format string.
This module can parse/build WKT format string into/from pure perl data structure.
There is few reasons.
See SYNOPSIS section for usages.
Parse WKT Point string.
Parse WKT Linestring string.
Parse WKT MultiLinestring string.
Parse WKT Polygon string.
Parse WKT MultiPolygon string.
Parse WKT GeometryCollection string.
Dispatch to parser which specified in first argument.
wkt_parse(POINT => 'POINT(10 20)') is equivalent to wkt_parse_point('POINT(10 20)')
Build WKT Point string.
Build WKT Linestring string.
Build WKT MultiLinestring string.
Build WKT Polygon string.
Build WKT MultiPolygon string.
Build WKT GeometryCollection string.
Dispatch to builder function which specified in first argument.
wkt_make(POINT => [ 10, 20 ]) is equivalent to wkt_make_point(10, 20)
Yuto KAWAMURA(kawamuray) <kawamuray.dadada {at} gmail.com>
Geo::WKT: As same as this module except few things.
Well-known text: http://en.wikipedia.org/wiki/Well-known_text
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2024-01-14 | perl v5.38.2 |