1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
# NAME
Geo::WKT::Simple - Simple utils to parse/build Well Known Text(WKT) format string.
# SYNOPSIS
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 ]);
# DESCRIPTION
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.
## Why not [Geo::WKT](http://search.cpan.org/perldoc?Geo::WKT) ?
There is few reasons.
- \- I just need simple return value represented by pure perl data structure.
Geo::WKT returns results as a Geo::\* instances which represents each type of geodetic components.
- \- [Geo::Proj4](http://search.cpan.org/perldoc?Geo::Proj4) dependencies. [Geo::Proj4](http://search.cpan.org/perldoc?Geo::Proj4) depends to libproj4
- \- I need to support MULTI(LINESTRING|POLYGON).
# FUNCTIONS
See SYNOPSIS section for usages.
## wkt\_parse\_point()
Parse WKT Point string.
## wkt\_parse\_linestring()
Parse WKT Linestring string.
## wkt\_parse\_multilinestring()
Parse WKT MultiLinestring string.
## wkt\_parse\_polygon()
Parse WKT Polygon string.
## wkt\_parse\_multipolygon()
Parse WKT MultiPolygon string.
## wkt\_parse\_geometrycollection()
Parse WKT GeometryCollection string.
## wkt\_parse()
Dispatch to parser which specified in first argument.
wkt_parse(POINT => 'POINT(10 20)') is equivalent to wkt_parse_point('POINT(10 20)')
## wkt\_make\_point()
Build WKT Point string.
## wkt\_make\_linestring()
Build WKT Linestring string.
## wkt\_make\_multilinestring()
Build WKT MultiLinestring string.
## wkt\_make\_polygon()
Build WKT Polygon string.
## wkt\_make\_multipolygon()
Build WKT MultiPolygon string.
## wkt\_make\_geometrycollection()
Build WKT GeometryCollection string.
## wkt\_make()
Dispatch to builder function which specified in first argument.
wkt_make(POINT => [ 10, 20 ]) is equivalent to wkt_make_point(10, 20)
# AUTHOR
Yuto KAWAMURA(kawamuray) <kawamuray.dadada {at} gmail.com>
# SEE ALSO
[Geo::WKT](http://search.cpan.org/perldoc?Geo::WKT): As same as this module except few things.
Well-known text: http://en.wikipedia.org/wiki/Well-known\_text
# LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
|