Politics-AU-Geo
view release on metacpan or search on metacpan
lib/Politics/AU/Geo.pm view on Meta::CPAN
TO BE COMPLETED
=head1 METHODS
=cut
use 5.006;
use strict;
use warnings;
use Storable 2.20 ();
use Math::Polygon 1.01 ();
use Params::Util 0.38 ();
use ORLite::Mirror 1.15 ();
our $VERSION = '0.01';
use Politics::AU::Geo::Electorates;
use Politics::AU::Geo::Polygons;
# Set up the ORLite::Mirror integration for the dataset
sub import {
lib/Politics/AU/Geo/Polygons.pm view on Meta::CPAN
package Politics::AU::Geo::Polygons;
use strict;
use Storable ();
use Params::Util qw{_INSTANCE};
use Math::Polygon ();
our $VERSION = '0.01';
sub point_in_polygon {
my $self = shift;
my $latitude = shift;
my $longitude = shift;
# Inflate
my $polygon = Storable::thaw($self->points);
unless ( _INSTANCE($polygon, 'Math::Polygon') ) {
die("Failed to deserialize the Math::Polygon object");
}
# Check
if ( $polygon->contains([ $longitude, $latitude ]) ) {
return 1;
} else {
return '';
}
}
( run in 0.390 second using v1.01-cache-2.11-cpan-0a6323c29d9 )