/usr/share/perl5/Geo/Surface.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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # 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::Surface;
use vars '$VERSION';
$VERSION = '0.96';
use base 'Geo::Shape';
use Math::Polygon::Surface ();
use Math::Polygon::Calc qw/polygon_bbox/;
use List::Util qw/sum first/;
use Carp;
sub new(@)
{ my $thing = shift;
my @lines;
push @lines, shift while ref $_[0];
@lines or return ();
my %args = @_;
my $class;
if(ref $thing) # instance method
{ $args{proj} ||= $thing->proj;
$class = ref $thing;
}
else
{ $class = $thing;
}
my $proj = $args{proj};
unless($proj)
{ my $s = first { UNIVERSAL::isa($_, 'Geo::Shape') } @lines;
$args{proj} = $proj = $s->proj if $s;
}
my $mps;
if(@lines==1 && UNIVERSAL::isa($_, 'Math::Polygon::Surface'))
{ $mps = shift @lines;
}
else
{ my @polys;
foreach (@lines)
{ push @polys
, UNIVERSAL::isa($_, 'Geo::Line' ) ? [$_->in($proj)->points]
: UNIVERSAL::isa($_, 'Math::Polygon') ? $_
: UNIVERSAL::isa($_, 'ARRAY' ) ? Math::Polygon->new(@$_)
: croak "ERROR: Do not known what to do with $_";
}
$mps = Math::Polygon::Surface->new(@polys);
}
$args{_mps} = $mps;
$thing->SUPER::new(%args);
}
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{GS_mps} = $args->{_mps};
$self;
}
sub outer() { shift->{GS_mps}->outer }
sub inner() { shift->{GS_mps}->inner }
sub geoOuter()
{ my $self = shift;
Geo::Line->new(points => [$self->outer->points], proj => $self->proj);
}
sub geoInner()
{ my $self = shift;
my $proj = $self->proj;
map { Geo::Line->new(points => [$_->points], proj => $proj) } $self->inner;
}
*geo_outer = \&geoOuter;
*geo_inner = \&geoInner;
#--------------
sub in($)
{ my ($self, $projnew) = @_;
return $self if ! defined $projnew || $projnew eq $self->proj;
my @newrings;
foreach my $ring ($self->outer, $self->inner)
{ (undef, my @points) = $self->projectOn($projnew, $ring->points);
push @newrings, \@points;
}
my $mp = Math::Polygon::Surface->new(@newrings);
(ref $self)->new($mp, proj => $projnew);
}
sub bbox() { polygon_bbox shift->outer->points }
sub area()
{ my $self = shift;
my $area = $self->outer->area;
$area -= $_->area for $self->inner;
$area;
}
sub perimeter() { shift->outer->perimeter }
sub toString(;$)
{ my ($self, $proj) = @_;
my $surface;
if(defined $proj)
{ $surface = $self->in($proj);
}
else
{ $proj = $self->proj;
$surface = $self;
}
my $mps = $self->{GS_mps}->string;
$mps =~ s/\n-/)\n -(/;
"surface[$proj]\n ($mps)\n";
}
*string = \&toString;
1;
|