# having assigned the job title to a category, now try to lookup the # lat and long of the job position so we can plot in on a map. # turns out the Google API has a limit of 10 geocodes per second so we # need a loop to throttle the request rate. otherwise google throws an error # and I am not sure how to trap it. if ($loop < 10) { $geocoder = Geo::Coder::Google->new(apiver => 3); eval{ $latlong = $geocoder->geocode(location => $location); if ($1){ print "!!! !!! !!! --- Couldn't get location : $location --- !!! !!! !!!\n"; }else{ $map_coords = $latlong->{geometry}{location}{lat} . " " . $latlong->{geometry}{location}{lng}; print ( " job no.\: $job_count $job_title \=\=\> $department $location $map_coords \n" ); $loop++; } } } else { print ( " job no.\: $job_count $job_title \=\=\> $department $location $map_coords \n" ); $loop = 0; sleep 1; } # count up the jobs by category # if the category already exists in the hash table then increment it if (exists $categories{$department} ) { $categories{$department}++; } # otherwise add it and initialize the counter to '1'. else { $categories{$department} = 1; } # count up the jobs by city # if the location already exists in the hash table then increment it if (exists $offices{$map_coords} ) { $offices{$map_coords}++; } # otherwise add it and initialize the counter to '1'. else { $offices{$map_coords} = 1; $cities{$map_coords} = $location; } # need to loop through the offices hash and scale out the size of the dot print ($out_fh "$map_coords \"\" color=red symbolsize=", "$offices{$map_coords}", "\n"); print ($out_fh "$map_coords \"\" color=red symbolsize=", "$offices{$map_coords}" * "2", "\n \n"); } p %categories; p %offices; p %cities; close ($out_fh);