/usr/lib/perl5/Boost/Geometry/Utils.pm is in libboost-geometry-utils-perl 0.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | package Boost::Geometry::Utils;
{
$Boost::Geometry::Utils::VERSION = '0.15';
}
# ABSTRACT: Bindings for the Boost Geometry library
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
use XSLoader;
XSLoader::load('Boost::Geometry::Utils', $Boost::Geometry::Utils::VERSION);
our @EXPORT_OK = qw(polygon_to_wkt linestring_to_wkt wkt_to_multilinestring
polygon linestring polygon_linestring_intersection
polygon_multi_linestring_intersection multi_polygon_multi_linestring_intersection
point_within_polygon point_covered_by_polygon
point_within_multi_polygon point_covered_by_multi_polygon
linestring_simplify
multi_linestring_simplify linestring_length polygon_centroid
linestring_centroid multi_linestring_centroid multi_polygon
correct_polygon correct_multi_polygon multi_linestring_multi_polygon_difference
polygon_medial_axis polygon_area);
sub polygon_to_wkt {
sprintf 'POLYGON(%s)', join ',', map { sprintf '(%s)', join ',', map { join ' ', @$_ } @$_ } @_;
}
sub linestring_to_wkt {
sprintf "MULTILINESTRING(%s)", join ',', map { sprintf '(%s)', join ',', map { join ' ', @$_ } @$_ } @_;
}
sub wkt_to_multilinestring {
return [] if $_[0] eq 'MULTILINESTRING()';
$_[0] =~ s/^MULTILINESTRING\(\(//;
$_[0] =~ s/\)\)$//;
[ map [ map [ split / / ], split /,/ ], split /\),\(/, $_[0] ];
}
sub polygon {
_polygon(\@_);
}
sub multi_polygon {
_multi_polygon(\@_);
}
sub linestring {
_multi_linestring(\@_)
}
sub multi_linestring {
_multi_linestring(\@_)
}
1;
__END__
=pod
=head1 NAME
Boost::Geometry::Utils - Bindings for the Boost Geometry library
=head1 VERSION
version 0.07
=head1 SYNOPSIS
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] ],
# ]
=head1 ABSTRACT
This module provides bindings to perform some geometric operations using
the Boost Geometry library. It does not aim at providing full bindings
for such library, and that's why I left the I<Boost::Geometry> namespace
free. I'm unsure about the optimal architectural for providing full
bindings, but I'm interested in such a project -- so, if you have ideas
please get in touch with me.
B<Warning:> the API could change in the future.
=head1 METHODS
=head2 polygon_linestring_intersection
Performs an intersection between the supplied polygon and linestring,
and returns an arrayref of linestrings (represented as arrayrefs of
points).
Note that such an intersection is also called I<clipping>.
=head2 polygon_multi_linestring_intersection
Same as I<polygon_linestring_intersection> but it accepts a multilinestring
object to perform multiple clippings in a single batch.
=head2 multi_polygon_multi_linestring_intersection
Same as I<polygon_multi_linestring_intersection> but it accepts a multipolygon
object to perform multiple clippings in a single batch.
=head2 multi_linestring_multi_polygon_difference
Performs a difference between the supplied multilinestring and the supplied
multipolygon. It returns a multilinestring object.
=head2 polygon_to_wkt
Converts one or more arrayref(s) of points to a WKT representation of
a polygon (with holes).
=head2 linestring_to_wkt
Converts an arrayref of points to a WKT representation of a multilinestring.
=head2 wkt_to_multilinestring
Parses a MULTILINESTRING back to a Perl data structure.
=head2 linestring_simplify
Accepts an arrayref of points representing a linestring and a numeric tolerance
and returns an arrayref of points representing the simplified linestring.
=head2 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.
=head2 point_covered_by_polygon
Accepts a point and an arrayref of points representing a polygon and returns true
or false according to the 'cover_by' strategy.
=head2 point_covered_by_multi_polygon
Same as above but accepts a multipolygon arrayref.
=head2 point_within_polygon
Accepts a point and an arrayref of points representing a polygon and returns true
or false according to the 'within' strategy.
=head2 point_within_multi_polygon
Same as above but accepts a multipolygon arrayref.
=head2 linestring_length
Returns length of a linestring.
=head2 polygon_centroid
Returns the centroid point of a given polygon.
=head2 linestring_centroid
Returns the centroid point of a given linestring.
=head2 multi_linestring_centroid
Returns the centroid point of a given multi_linestring.
=head2 correct_polygon
Corrects the orientation(s) of the given polygon.
=head2 correct_multi_polygon
Corrects the orientation(s) of the given multi_polygon.
=head2 polygon_area
Returns the area of the given polygon.
=for Pod::Coverage linestring multi_linestring multi_polygon polygon
=head1 ACKNOWLEDGEMENTS
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.
Thanks to Mark Hindness for his work on data types conversion.
=head1 AUTHOR
Alessandro Ranellucci <aar@cpan.org>
=head1 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.
=cut
|