Module: Geoblacklight::SpatialSearchBehavior
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/geoblacklight/spatial_search_behavior.rb
Instance Method Summary collapse
-
#add_spatial_params(solr_params) ⇒ Blacklight::Solr::Request
Adds spatial parameters to a Solr query if :bbox is present.
-
#boost ⇒ String
Allow bq boost to be configured, default 10 for backwards compatibility.
-
#bounding_box ⇒ Geoblacklight::BoundingBox
Returns a Geoblacklight::BoundingBox built from the blacklight_params.
- #envelope_bounds ⇒ String
Instance Method Details
#add_spatial_params(solr_params) ⇒ Blacklight::Solr::Request
Adds spatial parameters to a Solr query if :bbox is present. :bbox should be passed in using Solr lat-lon rectangle format e.g. “minX minY maxX maxY”
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 15 def add_spatial_params(solr_params) if blacklight_params[:bbox] solr_params[:bq] ||= [] solr_params[:bq] << "#{Settings.FIELDS.GEOMETRY}:\"IsWithin(#{envelope_bounds})\"#{boost}" solr_params[:fq] ||= [] solr_params[:fq] << "#{Settings.FIELDS.GEOMETRY}:\"Intersects(#{envelope_bounds})\"" end solr_params rescue Geoblacklight::Exceptions::WrongBoundingBoxFormat # TODO: Potentially delete bbox params here so that its not rendered as search param solr_params end |
#boost ⇒ String
Allow bq boost to be configured, default 10 for backwards compatibility
36 37 38 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 36 def boost "^#{Settings.BBOX_WITHIN_BOOST || '10'}" end |
#bounding_box ⇒ Geoblacklight::BoundingBox
Returns a Geoblacklight::BoundingBox built from the blacklight_params
43 44 45 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 43 def bounding_box Geoblacklight::BoundingBox.from_rectangle(blacklight_params[:bbox]) end |
#envelope_bounds ⇒ String
30 31 32 |
# File 'app/models/concerns/geoblacklight/spatial_search_behavior.rb', line 30 def envelope_bounds bounding_box.to_envelope end |