Bug 37537

Summary: Add bounding box variant to geo-search
Product: Koha Reporter: HKS3 Tadeusz Sośnierz <tadeusz>
Component: Searching - ElasticsearchAssignee: HKS3 Tadeusz Sośnierz <tadeusz>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: phil
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Patch implementing 37537

Description HKS3 Tadeusz Sośnierz 2024-07-31 14:14:15 UTC
Following up on https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31652, it would be useful to be able to search for records falling within a (rectangular, axis-aligned) bounding box.

The current solution allows looking up records within a specified distance from a given point. geo_bounding_box searches would allow for things like "given this map fragment, overlay all records that would be visible on it".
Comment 1 HKS3 Tadeusz Sośnierz 2024-07-31 14:18:32 UTC
Created attachment 169893 [details] [review]
Patch implementing 37537

Test plan to follow soon; will likely require https://github.com/HKS3/HKS3GeoSearch to be tested properly.
Comment 2 HKS3 Tadeusz Sośnierz 2024-08-02 14:45:25 UTC
Test plan:

1. Install the GeoSearch plugin https://github.com/HKS3/HKS3GeoSearch/releases/tag/v0.4
2. Either add visibility of 034s  and 034t in framework manually or issue the following commands in the database:

``` 
update marc_subfield_structure set hidden = 0 where tagfield = '034' and tagsubfield = 's' and frameworkcode = 'BKS';
update marc_subfield_structure set hidden = 0 where tagfield = '034' and tagsubfield = 't' and frameworkcode = 'BKS';
```

3. Add some location information using https://github.com/HKS3/HKS3GeoSearch/blob/main/scripts/insert_geo_data.pl
4. restart_all for a good measure
5. Go to Advanced OPAC search at /cgi-bin/koha/opac-search.pl; a Geographic Search should be visible at the bottom
6. Position the map at [48, 13] without changing the zoom level; the circle should just about be covering Munchen on the left and Linz on the right, with Wien being outside of it on the right
7. Perform the search, no results should come up. The query string should be along the lines of `lat:48 lng:13 distance:120km`
8. Go back to search, and back to [48, 13]. This time toggle the "Search visible area" to switch to bounding-box searches.
9. Perform the search. This time, 3 books should come up around the Vienna area. The query string should be along the lines of `boundingbox:53.54030739150022,0.9228515625000001,41.77131167976407,25.0927734375` (the exact numbers may very).
10. Celebrate the great success