| 1 | package Politics::AU::Geo::Electorates; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use Politics::AU::Geo::Polygons; | ||
| 5 | |||
| 6 | our $VERSION = '0.01'; | ||
| 7 | |||
| 8 | sub house_id { | ||
| 9 | my $self = shift; | ||
| 10 | join( '.', $self->state, $self->level, $self->house ); | ||
| 11 | } | ||
| 12 | |||
| 13 | sub point_in_polygon { | ||
| 14 | my $self = shift; | ||
| 15 | my $latitude = shift; | ||
| 16 | my $longitude = shift; | ||
| 17 | |||
| 18 | # Load the polygon | ||
| 19 | my @polygon = Politics::AU::Geo::Polygons->select( | ||
| 20 | 'where eid = ?', $self->eid, | ||
| 21 | ); | ||
| 22 | unless ( @polygon ) { | ||
| 23 | die("Failed to find polygon for electorate"); | ||
| 24 | } | ||
| 25 | |||
| 26 | $polygon[0]->point_in_polygon( $latitude, $longitude ); | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |