Geo-Point
view release on metacpan or search on metacpan
lib/Geo/Space.pm view on Meta::CPAN
# Copyrights 2005-2021 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.02.
# This code is part of distribution Geo-Point. Meta-POD processed with
# OODoc into POD and HTML manual-pages. See README.md
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
package Geo::Space;
use vars '$VERSION';
$VERSION = '0.99';
use base 'Geo::Shape';
use strict;
use warnings;
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;
( run in 0.855 second using v1.01-cache-2.11-cpan-39bf76dae61 )