From d6492b31c6b7dfdc30cafc9062fb570ac73ed65a Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 12 Oct 2017 15:22:09 -0400
Subject: [PATCH] Allow WorldCat lat/lon configuration.

---
 config/vufind/WorldCat.ini                                    | 4 ++++
 .../src/VuFindSearch/Backend/WorldCat/Connector.php           | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/config/vufind/WorldCat.ini b/config/vufind/WorldCat.ini
index d78e36b365b..e3b303c0d35 100644
--- a/config/vufind/WorldCat.ini
+++ b/config/vufind/WorldCat.ini
@@ -73,6 +73,10 @@ view=full
 ; This section contains additional settings to pass to the WorldCat connector
 ; code.
 [Connector]
+; Set this to the latitude,longitude position of your library to ensure that
+; custom holding locations are retrieved from your region first.
+;latLon = "40.0373881,-75.3442107"
+
 ; When looking up holdings at other libraries, should we retrieve holdings for
 ; any record matching the FRBR group (true) or only for exact matches (false)?
 ;useFrbrGroupingForHoldings = false
\ No newline at end of file
diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php
index 056dfe3f8de..b280d16b41c 100644
--- a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php
+++ b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php
@@ -89,6 +89,10 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector
         }
         $uri = "http://www.worldcat.org/webservices/catalog/content/libraries/{$id}"
             . "?wskey={$this->wskey}&servicelevel=full&frbrGrouping=$grouping";
+        if (isset($this->options['latLon'])) {
+            list($lat, $lon) = explode(',', $this->options['latLon']);
+            $uri .= '&lat=' . urlencode($lat) . '&lon=' . urlencode($lon);
+        }
         $this->client->setUri($uri);
         $this->debug('Connect: ' . $uri);
         $result = $this->client->setMethod('POST')->send();
-- 
GitLab