/usr/share/perl5/Geo/Space.pm is in libgeo-point-perl 0.96-2.
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 | # Copyrights 2005-2014 by [Mark Overmeer].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.01.
use strict;
use warnings;
package Geo::Space;
use vars '$VERSION';
$VERSION = '0.96';
use base 'Geo::Shape';
use Math::Polygon::Calc qw/polygon_bbox/;
use List::Util qw/sum first/;
sub new(@)
{ my $thing = shift;
my @components;
push @components, shift while ref $_[0];
my %args = @_;
if(ref $thing) # instance method
{ $args{proj} ||= $thing->proj;
}
my $proj = $args{proj};
return () unless @components;
$thing->SUPER::new(components => \@components);
}
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{GS_comp} = $args->{components} || [];
$self;
}
sub components() { @{shift->{GS_comp}} }
sub component(@)
{ my $self = shift;
wantarray ? $self->{GS_comp}[shift] : @{$self->{GS_comp}}[@_];
}
sub nrComponents() { scalar @{shift->{GS_comp}} }
sub points() { grep $_->isa('Geo::Points'), shift->components }
sub onlyPoints() { not first {! $_->isa('Geo::Points')} shift->components }
sub lines() { grep $_->isa('Geo::Line'), shift->components }
sub onlyLines() { not first {! $_->isa('Geo::Line')} shift->components }
sub onlyRings() { not first {! $_->isa('Geo::Line') || ! $_->isRing}
shift->components }
sub in($)
{ my ($self, $projnew) = @_;
return $self if ! defined $projnew || $projnew eq $self->proj;
my @t;
foreach my $component ($self->components)
{ ($projnew, my $t) = $component->in($projnew);
push @t, $t;
}
(ref $self)->new(@t, proj => $projnew);
}
sub bbox()
{ my $self = shift;
my @bboxes = map [$_->bbox], $self->components;
polygon_bbox(map +([$_->[0], $_->[1]], [$_->[2], $_->[3]]), @bboxes);
}
sub area() { sum map $_->area, shift->components }
sub perimeter() { sum map $_->perimeter, shift->components }
sub toString(;$)
{ my ($self, $proj) = @_;
my $space;
if(defined $proj)
{ $space = $self->in($proj);
}
else
{ $proj = $self->proj;
$space = $self;
}
"space[$proj]\n ("
. join(")\n (", map {$_->string} $space->components)
. ")\n";
}
*string = \&toString;
1;
|