First mini-patch that adds the Bounding Box Argument to views based on search_api.

TODO: when you set a limit on the view (say, 2 points) it apparently FIRST fetches 2 points from the backend (i tested with solr) and THEN filters them trough the bounding box.

So, out of the 4 points i tested with, i always saw the same 2 (but the whole AJAX and boundingbox thing did work on these 2)

Best way to test tip: add the same data to a map twice, once as geojson and once as a normal openlayers layer. (both with a different style, obviously)

If this needs to go in a separate module, that is also fine, its just ment as a small headstart.

Comments

dasjo’s picture

interesting. i just tried this and it fails due to some methods that the search_api views query implementation is missing (add_table, add_where, set_where_group)

Debug Error: Call to undefined method SearchApiViewsQuery::add_table() in .../views_geojson/views/views_geojson_bbox_argument.inc on line 147

here's the source
http://drupalcode.org/project/views_geojson.git/blob/refs/heads/7.x-1.x:...

batje’s picture

I am pretty sure that we will have to implement the bounding box query for search_api & facetapi using a bbox facetapi Filter.

dasjo’s picture

sounds good to me. i'm not an expert in the api's - batje do you think you could provide some code of how this could look like? i'd be happy to test, iterate on it.

edit:
search_api_location has a radius-based filter implementation: http://drupalcode.org/project/search_api_location.git/blob/refs/heads/7....
maybe there was some bbox functionality planned, at least it seems to be removed since #1398862: Cleanup (patch included)

dasjo’s picture

Title: Search_API views compatability » Bounding Box support with Search API views
batje’s picture

search_api is too complex for me too to quickly whip out some code :-)

randallknutson’s picture

I believe I've got this working to a certain extent. Here is what I used:

Modules/Patches

search_api
search_api_views
search_api_solr
search_api_location
Patch #1 from #2061639: Add views argument for geojson bbox
views_geojson
Patch #11 from #1839554: BBox argument handler fixes
leaflet_geojson
Patch #1 from #2061629: Allow other views arguments to provide BBOX

How to set it up:

  1. Set up an index and index the geofield
  2. Create a view based on the search api index
  3. Add a page to the view and set the format to GeoJSON Feed
  4. Add a contextual filter to the view of type "Custom: XXX LatLong Pair (indexed) bbox"
  5. Set the default value for the contextual filter to "Bounding box from query string"
  6. Create a leaflet bean block and set the source to that view page
das-peter’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new8.52 KB

The following patch introduces Search API bbox support - if following related issue is solved: #2368399: Support for "proper" bbox location searches
We use the already available Search API query option search_api_location to provide the bbox data to the search service which is then responsible to handle the data according to the backend.
I also did some cleanup as the class seemed quite a bit untended.

I actually would prefer to see this functionality in Search API Location itself, however I'm not sure if this will happen as of the feedback here #2061639-3: Add views argument for geojson bbox
Further this implementation will work seamlessly with Leaflet Geojson - even thought it could use some love: #2367459: Search for "feed" displays in hook_leaflet_geojson_source_info

das-peter’s picture

das-peter’s picture

StatusFileSize
new7.01 KB

Updated the patch according to the ongoing discussion about how to handle bbox in search api.

das-peter’s picture

StatusFileSize
new6.92 KB

Oh, I forgot to cleanup some part.

das-peter’s picture

StatusFileSize
new8.1 KB

Overhauled the used approach.
No extra configuration for Search API Views necessary.
Means it should work seamlessly.

pol’s picture

Is it good to go in ?

das-peter’s picture

@Pol I appreciate your pro-active spirit :) But give it another day or two. Maybe we can leave this up to #2061639: Add views argument for geojson bbox
Thomas is aware of it and told me he will do a review. I it goes in I would need to adjust leaflet geojson - but there's a change pending anyway.
And I'm still in early testing phase, I just reviewed the code again and thought I could solve this smoother ;)
Right now I try to add geocluster to the party.

pol’s picture

Any update on this ?

das-peter’s picture

Seems to work quite well with the latest Search API Location.
However, the patch also contains quite some cleanup - shall I strip the Search API sepcific part and post somewhere else an "cleanup" patch?
Also if we keep this in one could use bbox filtering without having Search API Location installed - you just need a Search API backend that supports the search_api_location handling.

Exploratus’s picture

What's the status of this?

basvredeling’s picture

Status: Needs review » Needs work

The patch currently doesn't work. It requires search_api_location (which is not included in the .info).
Also once you enable search_api_location (both recommended and latest dev) you run into an error: Call to undefined method SearchApiViewsQuery::ensure_table()

das-peter’s picture

As statet in #15. This patch isn't required anymore to make bbox and search api location working:

However, the patch also contains quite some cleanup - shall I strip the Search API sepcific part and post somewhere else an "cleanup" patch?

So if the cleanup makes sense we could adapt it, otherwise I guess we can close this issue.

basvredeling’s picture

Cleanup looks good, but unaware of this patch I've done something similar: #2396781: Clean up the views_geojson module

das-peter’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2396781: Clean up the views_geojson module

So if there's a already an issue solely for cleaning up let's got with it instead this one.
Closed in favour of #2396781: Clean up the views_geojson module

basvredeling’s picture

Status: Closed (duplicate) » Needs work

I've merge all cleanup code into #2396781: Clean up the views_geojson module comment #11

basvredeling’s picture

Status: Needs work » Closed (duplicate)

Sorry

monstrfolk’s picture

Confused on the status of bbox support with search api.

@basvredeling

I've merge all cleanup code into #2396781: Clean up the views_geojson module comment #11

Patch from https://www.drupal.org/node/2396781 contains

if ((empty($this->argument)) || ($this->view->base_field == 'search_api_id')) {
  return;
}

Does not look like bbox support works.

basvredeling’s picture

@monstrfolk it doesn't work... see: #2747493: Search API bbox support