From: Dan Scott Date: Thu, 9 Jan 2014 03:28:43 +0000 (-0500) Subject: Start adding the map infrastructure X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a3bcb7956ad69a75e05789a946b833562808a75b;p=working%2FEvergreen.git Start adding the map infrastructure Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm index d0b17a6898..496486a817 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm @@ -6,6 +6,8 @@ use OpenSRF::Utils::Logger qw/$logger/; use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; +use LWP::UserAgent; +use URL::Encode; my $U = 'OpenILS::Application::AppUtils'; my $library_cache; @@ -72,4 +74,18 @@ sub load_library { return Apache2::Const::OK; } +sub geocode_address { + # Using Google Maps API v3 we can geocode some addresses; see + # https://developers.google.com/maps/tutorials/fundamentals/adding-a-google-map + # for a basic introduction + # + # curl -G --data-urlencode address='J.N. Desmarais Library, Laurentian University, Sudbury, Ontario P3E 2C6' -d sensor=false https://maps.googleapis.com/maps/api/geocode/json + my $address = shift; + + my $base_uri = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address='; + my $agent = LWP::UserAgent->new(timeout => '1'); + my $response = $agent->get($base_uri . urlencode($address)); + my $geocode = OpenSRF::Utils::JSON->JSON2perl($response); +} + 1;