Geo-Location-TimeZone
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
b/build-data.pl view on Meta::CPAN
#!/usr/bin/perl
$|=1;
use strict;
use Geo::ShapeFile;
use Math::Polygon;
use Data::Dumper;
use lib "../lib";
use lib "lib";
use Geo::Location::TimeZone;
# This is a hacky script to generate the data used by Geo::Location::TimeZone.
# It essentially uses brute force. It is run by the package maintainer, and
# not as part of unpacking the package.
# The steps taken are:
# 1) Read in list of centroid points and matching names.
# 2) read the ESRI Timezone boundary DB.
# 3) Iterate through above:
# 3a) Get the bounding box of the polygon.
# 3b) Work through each 15x15 box within the boundary, seeing if
# anything is within.
# 3b1) Check to see if any known centroids are within
# this 15x15 square.
# 3b2) else, check to see if the timezone matches the
# calculated zone. Skip if so (save memory)
# 3b3) If a name different to the calculated one is
# found, write out this polygon.
# 3b4) If multiple polygons are found, work out the one
# with the largest area and use that one as the
# default.
#
# Note: Everything found is kept in memory, so it can be output in one hit.
# Master data store.
my %data = ();
my $outdir = "../lib/Geo/Location/TimeZone/";
my $basezone = "Geo::Location::TimeZone";
my $geotzobj = $basezone->new();
my $totpack = 0;
my $totunpack = 0;
# Fun, ESRI did decimal hour offsets.
my %offcountries = ( "3.50" => "Asia/Tehran",
"4.50" => "Asia/Kabul",
"5.75" => "Asia/Katmandu",
"-3.50" => "Canada/Newfoundland",
"-9.50" => "Pacific/Marquesas",
"9.50" => "Australia/Darwin",
"6.50" => "Indian/Cocos",
"-8.50" => "Pacific/Marquesas",
"11.50" => "Pacific/Norfolk",
"10.50" => "Australia/Adelaide",
"12.75" => "Pacific/Chatham",
"5.50" => "Asia/Calcutta",
);
sub close15 {
my $arg = shift;
my $retval = int(( abs( $arg ) + 7.5 ) /15 );
if( $arg < 7.5 ){
$retval = 0 - $retval;
}
return( $retval );
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.320 second using v1.00-cache-2.02-grep-82fe00e-cpan-3b7f77b76a6c )