view release on metacpan or search on metacpan
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"GIS::Distance" : "0.14",
"Geo::Proj4" : "1.01",
"Math::Polygon" : "1.01",
"Math::Trig" : "1",
"Test::More" : "0.47"
}
}
},
"release_status" : "stable",
"resources" : {
"homepage" : "http://perl.overmeer.net/CPAN/",
"license" : [
"http://dev.perl.org/licenses/"
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Geo-Point
no_index:
directory:
- t
- inc
requires:
GIS::Distance: '0.14'
Geo::Proj4: '1.01'
Math::Polygon: '1.01'
Math::Trig: '1'
Test::More: '0.47'
resources:
homepage: http://perl.overmeer.net/CPAN/
license: http://dev.perl.org/licenses/
repository: https://github.com/markov2/perl5-Geo-Point.git
version: '0.99'
x_serialization_backend: 'CPAN::Meta::YAML version 0.011'
Makefile.PL view on Meta::CPAN
require 5.008;
WriteMakefile
( NAME => 'Geo::Point'
, VERSION => '0.99'
, PREREQ_PM =>
{ Test::More => 0.47
, GIS::Distance => 0.14
, Geo::Proj4 => 1.01
, Math::Polygon => 1.01
, Math::Trig => 1.00
}
, AUTHOR => 'Mark Overmeer'
, ABSTRACT => 'Geographical structures'
, LICENSE => 'perl_5'
, META_MERGE =>
{ 'meta-spec' => { version => 2 }
, resources =>
{ repository =>
lib/Geo/Line.pm view on Meta::CPAN
# 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::Line;
use vars '$VERSION';
$VERSION = '0.99';
use base qw/Geo::Shape Math::Polygon/;
use strict;
use warnings;
use Carp;
use List::Util qw/min max/;
use Scalar::Util qw/refaddr/;
sub new(@)
lib/Geo/Line.pm view on Meta::CPAN
my $proj = $args{proj};
foreach my $p (@$points)
{ next unless UNIVERSAL::isa($p, 'Geo::Point');
$proj ||= $p->proj;
$p = [ $p->xy($proj) ]; # replace
}
$args{proj} = $proj;
}
ref $thing
or return shift->Math::Polygon::new(%args);
# instance method: clone!
$thing->Math::Polygon::new
( ring => $thing->{GL_ring}
, filled => $thing->{GL_fill}
, proj => $thing->proj
, %args
);
}
sub init($)
{ my ($self, $args) = @_;
$self->Geo::Shape::init($args);
$self->Math::Polygon::init($args);
$self->{GL_ring} = $args->{ring} || $args->{filled};
$self->{GL_fill} = $args->{filled};
$self->{GL_bbox} = $args->{bbox};
$self;
}
sub line(@)
{ my $thing = shift;
lib/Geo/Line.pm view on Meta::CPAN
}
#----------------
sub equal($;$)
{ my $self = shift;
my $other = shift;
return 0 if $self->nrPoints != $other->nrPoints;
$self->Math::Polygon::equal($other->in($self->proj), @_);
}
sub bbox() { shift->Math::Polygon::bbox }
sub area()
{ my $self = shift;
croak "ERROR: area requires a ring of points"
unless $self->isRing;
$self->Math::Polygon::area;
}
sub perimeter()
{ my $self = shift;
croak "ERROR: perimeter requires a ring of points."
unless $self->isRing;
$self->Math::Polygon::perimeter;
}
sub length() { shift->Math::Polygon::perimeter }
sub clip(@)
{ my $self = shift;
my $proj = $self->proj;
my @bbox = @_==1 ? $_[0]->bbox : @_;
$self->isFilled ? $self->fillClip1(@bbox) : $self->lineClip(@bbox);
}
#----------------
lib/Geo/Line.pm view on Meta::CPAN
}
else
{ $proj = $self->proj;
$line = $self;
}
my $type = $line->isFilled ? 'filled'
: $line->isRing ? 'ring'
: 'line';
"$type\[$proj](".$line->Math::Polygon::string.')';
}
*string = \&toString;
1;
lib/Geo/Line.pod view on Meta::CPAN
=head1 NAME
Geo::Line - a sequence of connected points
=head1 INHERITANCE
Geo::Line
is a Geo::Shape
Geo::Line
is a Math::Polygon
=head1 SYNOPSIS
my $line = Geo::Line->new(points => [$p1, $p2]);
my $line = Geo::Line->line($p1, $p2);
my $ring = Geo::Line->ring($p1, $p2, $p3, $p1);
my $ring = Geo::Line->ring($p1, $p2, $p3);
my $plane = Geo::Line->filled($p1, $p2, $p3, $p1);
my $plane = Geo::Line->filled($p1, $p2, $p3);
=head1 DESCRIPTION
A 2-dimensional sequence of connected points. The points will be forced
to use the same projection.
Extends L<"DESCRIPTION" in Math::Polygon|Math::Polygon/"DESCRIPTION">.
Extends L<"DESCRIPTION" in Geo::Shape|Geo::Shape/"DESCRIPTION">.
=head1 METHODS
Extends L<"METHODS" in Math::Polygon|Math::Polygon/"METHODS">.
Extends L<"METHODS" in Geo::Shape|Geo::Shape/"METHODS">.
=head2 Constructors
Extends L<"Constructors" in Math::Polygon|Math::Polygon/"Constructors">.
Extends L<"Constructors" in Geo::Shape|Geo::Shape/"Constructors">.
=over 4
=item Geo::Line-E<gt>B<bboxFromString>( $string, [$projection] )
Create a square from the $string. The coordinates can be separated by
a comma (preferably), or blanks. When the coordinates end on NSEW, the
order does not matter, otherwise lat-long or xy order is presumed.
lib/Geo/Line.pod view on Meta::CPAN
are passed to L<new()|Geo::Line/"Constructors"> as well.
=item $obj-E<gt>B<new>( [%options] )
=item Geo::Line-E<gt>B<new>( [%options] )
When called as instance method, the projection, ring, and filled attributes
are taken from the initiator, like a clone with modification.
-Option --Defined in --Default
bbox Math::Polygon undef
clockwise Math::Polygon undef
filled <false>
points <data>
proj Geo::Shape see Geo::Proj::defaultProjection()
ring <false>
=over 2
=item bbox => [$xmin,$ymin, $xmax,$ymax]
=item clockwise => BOOLEAN
lib/Geo/Line.pod view on Meta::CPAN
=item Geo::Line-E<gt>B<ringFromString>( $string, [$projection] )
Calls L<bboxFromString()|Geo::Line/"Constructors"> and then produces a ring object from than.
Don't forget the C<eval> when you call this method.
=back
=head2 Attributes
Extends L<"Attributes" in Math::Polygon|Math::Polygon/"Attributes">.
Extends L<"Attributes" in Geo::Shape|Geo::Shape/"Attributes">.
=over 4
=item $obj-E<gt>B<geopoint>( $index, [$index, ..] )
Returns the L<Geo::Point|Geo::Point> for the point with the specified $index or
indices.
=item $obj-E<gt>B<geopoints>()
In LIST context, this returns all points as separate scalars: each is a
L<Geo::Point|Geo::Point> with projection information. In SCALAR context, a
reference to the coordinates is returned.
With L<points()|Math::Polygon/"Attributes">, you get arrays with XY coordinates returned, but
without the projection information. That will be much faster, but
not sufficient for some uses.
=item $obj-E<gt>B<isFilled>()
Returns a true value is the internals of the ring of points are declared
to belong to the shape.
=item $obj-E<gt>B<isRing>()
Returns a true value if the sequence of points are a ring or filled: the
first point is the last.
=item $obj-E<gt>B<nrPoints>()
Inherited, see L<Math::Polygon/"Attributes">
=item $obj-E<gt>B<order>()
Inherited, see L<Math::Polygon/"Attributes">
=item $obj-E<gt>B<point>( $index, [$index,...] )
Inherited, see L<Math::Polygon/"Attributes">
=item $obj-E<gt>B<points>( [FORMAT] )
Inherited, see L<Math::Polygon/"Attributes">
=item $obj-E<gt>B<proj>()
Inherited, see L<Geo::Shape/"Attributes">
=item $obj-E<gt>B<proj4>()
Inherited, see L<Geo::Shape/"Attributes">
=back
lib/Geo/Line.pod view on Meta::CPAN
Inherited, see L<Geo::Shape/"Projections">
=item $obj-E<gt>B<projectOn>($nick, @points)
Inherited, see L<Geo::Shape/"Projections">
=back
=head2 Geometry
Extends L<"Geometry" in Math::Polygon|Math::Polygon/"Geometry">.
Extends L<"Geometry" in Geo::Shape|Geo::Shape/"Geometry">.
=over 4
=item $obj-E<gt>B<area>()
Returns the area enclosed by the polygon. Only useful when the points
are in some orthogonal projection.
lib/Geo/Line.pod view on Meta::CPAN
Inherited, see L<Geo::Shape/"Geometry">
=item $obj-E<gt>B<bboxRing>( [$xmin, $ymin, $xmax, $ymax, [$proj]] )
=item Geo::Line-E<gt>B<bboxRing>( [$xmin, $ymin, $xmax, $ymax, [$proj]] )
Inherited, see L<Geo::Shape/"Geometry">
=item $obj-E<gt>B<beautify>(%options)
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<centroid>()
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<clip>( <$xmin,$xmax,$ymin,$ymax>|$object )
Clip the shape to the bounding box of $object, or the boxing parameters
specified. A list of L<Geo::Line|Geo::Line> objects is returned if anything is
inside the object.
On the moment L<Math::Polygon::lineClip()|Math::Polygon/"Clipping"> and
L<Math::Polygon::fillClip1()|Math::Polygon/"Clipping"> are used to do the job. In the future,
that may change.
=item $obj-E<gt>B<clockwise>()
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<contains>($point)
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<counterClockwise>()
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<distance>($point)
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<distance>( $object, [$unit] )
Inherited, see L<Geo::Shape/"Geometry">
=item $obj-E<gt>B<equal>( <$other | \@points,[$tolerance]> | $points )
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<isClockwise>()
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<isClosed>()
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<length>()
The length of the line, only useful in a orthogonal coordinate system
(projection). See also L<perimeter()|Geo::Line/"Geometry">.
=item $obj-E<gt>B<perimeter>()
The length of the line on the ring. A check is performed that the ring
is closed, but further this returns the result of L<length()|Geo::Line/"Geometry">
=item $obj-E<gt>B<same>( <$other_polygon | \@points, [$tolerance]> | @points )
Inherited, see L<Math::Polygon/"Geometry">
=item $obj-E<gt>B<startMinXY>()
Inherited, see L<Math::Polygon/"Geometry">
=back
=head2 Transformations
Extends L<"Transformations" in Math::Polygon|Math::Polygon/"Transformations">.
=over 4
=item $obj-E<gt>B<grid>(%options)
Inherited, see L<Math::Polygon/"Transformations">
=item $obj-E<gt>B<mirror>(%options)
Inherited, see L<Math::Polygon/"Transformations">
=item $obj-E<gt>B<move>(%options)
Inherited, see L<Math::Polygon/"Transformations">
=item $obj-E<gt>B<resize>(%options)
Inherited, see L<Math::Polygon/"Transformations">
=item $obj-E<gt>B<rotate>(%options)
Inherited, see L<Math::Polygon/"Transformations">
=item $obj-E<gt>B<simplify>(%options)
Inherited, see L<Math::Polygon/"Transformations">
=back
=head2 Clipping
Extends L<"Clipping" in Math::Polygon|Math::Polygon/"Clipping">.
=over 4
=item $obj-E<gt>B<fillClip1>($box)
Inherited, see L<Math::Polygon/"Clipping">
=item $obj-E<gt>B<lineClip>($box)
Inherited, see L<Math::Polygon/"Clipping">
=back
=head2 Display
Extends L<"Display" in Math::Polygon|Math::Polygon/"Display">.
Extends L<"Display" in Geo::Shape|Geo::Shape/"Display">.
=over 4
=item $obj-E<gt>B<deg2dm>($degrees, $pos, $neg)
=item Geo::Line-E<gt>B<deg2dm>($degrees, $pos, $neg)
Inherited, see L<Geo::Shape/"Display">
lib/Geo/Line.pod view on Meta::CPAN
Inherited, see L<Geo::Shape/"Display">
=item $obj-E<gt>B<dms2deg>($dms)
=item Geo::Line-E<gt>B<dms2deg>($dms)
Inherited, see L<Geo::Shape/"Display">
=item $obj-E<gt>B<string>( [FORMAT] )
Inherited, see L<Math::Polygon/"Display">
=item $obj-E<gt>B<toString>( [$projection] )
Returns a string representation of the line, which is also used for
stringification. The old method named C<string> is deprecated.
=back
=head1 OVERLOAD
lib/Geo/Space.pm view on Meta::CPAN
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
lib/Geo/Space.pod view on Meta::CPAN
=over 4
=item $obj-E<gt>B<new>( [$components], %options )
=item Geo::Space-E<gt>B<new>( [$components], %options )
When called as instance method, some defaults are copied from the
object where the call is made upon. Usually called as class method.
$components are L<Math::Polygon|Math::Polygon>, L<Math::Polygon::Surface|Math::Polygon::Surface>,
L<Geo::Point|Geo::Point>, L<Geo::Line|Geo::Line>, L<Geo::Surface|Geo::Surface>, L<Geo::Space|Geo::Space> objects.
-Option--Defined in--Default
proj Geo::Shape see Geo::Proj::defaultProjection()
=over 2
=item proj => LABEL
=back
lib/Geo/Surface.pm view on Meta::CPAN
package Geo::Surface;
use vars '$VERSION';
$VERSION = '0.99';
use base 'Geo::Shape';
use strict;
use warnings;
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 ();
lib/Geo/Surface.pm view on Meta::CPAN
{ $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};
lib/Geo/Surface.pm view on Meta::CPAN
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;
lib/Geo/Surface.pod view on Meta::CPAN
=over 4
=item $obj-E<gt>B<new>( <$surface | <$outer,$inner,...> >, %options )
=item Geo::Surface-E<gt>B<new>( <$surface | <$outer,$inner,...> >, %options )
When called as instance method, some defaults are copied from the
object where the call is made upon.
You may either provide a L<Math::Polygon::Surface|Math::Polygon::Surface> $surface, or a LIST
of lines. In the latter case, the first line is the $outer polygon of
the surface, and the other are all $inner enclosures: lakes. Lines
are and L<Geo::Line|Geo::Line>, L<Math::Polygon|Math::Polygon> objects, or ARRAY of points.
If no projection is specified, then the projection of the first
Geo-encoded line will be used.
-Option--Defined in--Default
proj Geo::Shape see Geo::Proj::defaultProjection()
=over 2
=item proj => LABEL
lib/Geo/Surface.pod view on Meta::CPAN
=item $obj-E<gt>B<geoInner>()
Returns a LIST of enclosed polygons, converted to L<Geo::Line|Geo::Line> objects.
=item $obj-E<gt>B<geoOuter>()
Returns the outer polygon as L<Geo::Line|Geo::Line> object.
=item $obj-E<gt>B<inner>()
Returns a LIST of enclosed L<Math::Polygon|Math::Polygon> objects.
=item $obj-E<gt>B<outer>()
Returns the outer L<Math::Polygon|Math::Polygon>.
=item $obj-E<gt>B<proj>()
Inherited, see L<Geo::Shape/"Attributes">
=item $obj-E<gt>B<proj4>()
Inherited, see L<Geo::Shape/"Attributes">
=back
t/12surface.t view on Meta::CPAN
my $s1 = Geo::Surface->new([[1,2],[3,4],[5,6],[1,2]], proj => 'wgs84');
ok(defined $s1, 'simple outer');
isa_ok($s1, 'Geo::Surface');
is($s1->toString, <<_S);
surface[wgs84]
([[1,2], [3,4], [5,6], [1,2]])
_S
my $o1 = $s1->outer;
isa_ok($o1, 'Math::Polygon');
my @p1 = $o1->points;
cmp_ok(scalar @p1, '==', 4);
is($o1->string, '[1,2], [3,4], [5,6], [1,2]');
my @i1 = $s1->inner;
cmp_ok(scalar @i1, '==', 0);
my $go1 = $s1->geo_outer;
isa_ok($go1, 'Geo::Line');
is($go1->toString, 'line[wgs84]([1,2], [3,4], [5,6], [1,2])');