Boost:...:Utils(3pm)
π Boost::Geometry::Utils β a whole manual but make it cute π
okay bestie, so this is Boost::Geometry::Utils, and it lives in the User Contributed Perl Documentation corner of your local perl man pages (so yes, Boost:...:Utils(3pm) is the whole vibe). it's Bindings for the Boost Geometry library β¨
π NAME π
Boost::Geometry::Utils β literally just Bindings for the Boost Geometry library. that's the name, that's the whole personality π
πΈ VERSION πΈ
this is version 0.07, bestie. iconic. periodt.
π¦ SYNOPSIS π¦
okay so here's the whole thing in action. copy it exactly, no cap:
use Boost::Geometry::Utils qw(polygon linestring polygon_linestring_intersection);
my $square = [ # ccw
[10, 10],
[20, 10],
[20, 20],
[10, 20],
];
my $hole_in_square = [ # cw
[14, 14],
[14, 16],
[16, 16],
[16, 14],
];
my $polygon = polygon($square, $hole_in_square);
my $linestring = linestring([ [5, 15], [30, 15] ]);
my $intersection = polygon_linestring_intersection($polygon, $linestring);
# $intersection is:
# [
# [ [10, 15], [14, 15] ],
# [ [16, 15], [20, 15] ],
# ]
and yes, the comments say # ccw and # cw because orientation matters and the module knows. π«Ά
β¨ ABSTRACT β¨
so this module gives you bindings so you can do some geometric operations using the Boost Geometry library. it is not trying to give you full bindings for that library β which is exactly why the author left the Boost::Geometry namespace free, bestie, he was being polite π.
he says he's unsure about the optimal architecture for providing full bindings, but he's interested in that kind of project β so if you have ideas, please get in touch with him. collab era π
β οΈ Warning: the API could change in the future. like, for real. don't get too attached. π
π METHODS π
polygon_linestring_intersection
does an intersection between the polygon you supplied and the linestring you supplied, and hands you back an arrayref of linestrings (each one represented as an arrayref of points). also, fun fact bestie: this kind of intersection is also called clipping. slay.
polygon_multi_linestring_intersection
same as polygon_linestring_intersection, but it accepts a multilinestring object so you can do multiple clippings in a single batch. efficiency queen π
multi_polygon_multi_linestring_intersection
same as polygon_multi_linestring_intersection, except it accepts a multipolygon object, so again: multiple clippings, one single batch. π
multi_linestring_multi_polygon_difference
performs a difference between the multilinestring you supplied and the multipolygon you supplied. returns a multilinestring object. it's giving subtraction but make it geometry π
polygon_to_wkt
converts one or more arrayref(s) of points into a WKT representation of a polygon (with holes). yes, with holes. we love a polygon with lore. π³οΈ
linestring_to_wkt
converts an arrayref of points into a WKT representation of a multilinestring.
wkt_to_multilinestring
parses a MULTILINESTRING back into a Perl data structure. the round trip is real, fr fr.
linestring_simplify
accepts an arrayref of points representing a linestring and a numeric tolerance, and returns an arrayref of points representing the simplified linestring β¨
multi_linestring_simplify
accepts an arrayref of arrayrefs of points representing a multilinestring and a numeric tolerance, and returns an arrayref of arrayrefs of points representing the simplified linestrings. nesting? we love her. πͺ
point_covered_by_polygon
accepts a point and an arrayref of points representing a polygon, and returns true or false depending on the 'cover_by' strategy.
point_covered_by_multi_polygon
same as above, but it accepts a multipolygon arrayref π«Ά
point_within_polygon
accepts a point and an arrayref of points representing a polygon, and returns true or false depending on the 'within' strategy.
point_within_multi_polygon
same as above, but it accepts a multipolygon arrayref π
linestring_length
returns the length of a linestring. measuring tape out π
polygon_centroid
returns the centroid point of a given polygon.
linestring_centroid
returns the centroid point of a given linestring.
multi_linestring_centroid
returns the centroid point of a given multi_linestring.
correct_polygon
corrects the orientation(s) of the given polygon. it's a glow-up but for winding order π
correct_multi_polygon
corrects the orientation(s) of the given multi_polygon.
polygon_area
returns the area of the given polygon. she's got range (literally, area is two-dimensional π).
π ACKNOWLEDGEMENTS π
huge thanks to mauke and mst (Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>) for their valuable help in getting this to compile under Windows (MinGW) too. and thanks to Mark Hindness for his work on data types conversion. the real ones fr fr π
π AUTHOR π
Alessandro Ranellucci <aar@cpan.org>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2013 by Alessandro Ranellucci.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so go forth and redistribute, bestie π
and that's the tea π this page came to you courtesy of perl v5.42.3, dated 2026-08-19 β and the manual name up top was Boost:...:Utils(3pm) in case you forgot where you were. mwah π
π¦ where this page comes from
- ubuntu stonking: libboost-geometry-utils-perl 0.15-4build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms