Start adding the map infrastructure user/dbs/google_maps
authorDan Scott <dscott@laurentian.ca>
Thu, 9 Jan 2014 03:28:43 +0000 (22:28 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 9 Dec 2014 19:10:56 +0000 (14:10 -0500)
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm

index d0b17a6..496486a 100644 (file)
@@ -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;