Skip to content

Commit

Permalink
make solr geometry field used for bbox configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Feb 13, 2015
1 parent c877f7c commit 44d0486
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/views/catalog/_index_split_default.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% # header bar for doc items in index view -%>
<%= content_tag :div, class: 'documentHeader row', data: { layer_id: document[:uuid], bbox: document[:solr_bbox], geom: document[:solr_geom] } do %>
<%= content_tag :div, class: 'documentHeader row', data: { layer_id: document[:uuid], bbox: document.bounding_box_as_wsen } do %>
<div class='status-icons'>
<%= geoblacklight_icon(document['layer_geom_type_s']) %>
<%= geoblacklight_icon(document['dct_provenance_s']) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_show_default_viewer_container.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% document ||= @document %>
<div id='viewer-container' class="col-md-8">
<%= content_tag :div, id: 'map', data: { map: 'item', protocol: document.viewer_protocol, url: document.viewer_endpoint, 'layer-id' => document[:layer_id_s], 'map-bbox' => document[:solr_bbox], 'catalog-path'=> catalog_index_path, available: document_available? } do %>
<%= content_tag :div, id: 'map', data: { map: 'item', protocol: document.viewer_protocol, url: document.viewer_endpoint, 'layer-id' => document[:layer_id_s], 'map-bbox' => document.bounding_box_as_wsen, 'catalog-path'=> catalog_index_path, available: document_available? } do %>
<% end %>
</div>
3 changes: 3 additions & 0 deletions lib/generators/geoblacklight/templates/settings.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#Main Solr geometry field used for spatial search and bounding box. Should be type 'rpt'
GEOMETRY_FIELD: 'solr_bbox'

# Institution deployed at
INSTITUTION: 'Stanford'

Expand Down
4 changes: 2 additions & 2 deletions lib/geoblacklight/controller_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ module ControllerOverride
def add_spatial_params(solr_params, req_params)
if req_params[:bbox]
solr_params[:bq] ||= []
solr_params[:bq] = ["solr_bbox:\"IsWithin(#{req_params[:bbox]})\"^10"]
solr_params[:bq] = ["#{Settings.GEOMETRY_FIELD}:\"IsWithin(#{req_params[:bbox]})\"^10"]
solr_params[:fq] ||= []
solr_params[:fq] << "solr_bbox:\"Intersects(#{req_params[:bbox]})\""
solr_params[:fq] << "#{Settings.GEOMETRY_FIELD}:\"Intersects(#{req_params[:bbox]})\""
end
solr_params
end
Expand Down
2 changes: 1 addition & 1 deletion lib/geoblacklight/download/kmz_download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class KmzDownload < Download
KMZ_DOWNLOAD_PARAMS = { service: 'wms', version: '1.1.0', request: 'GetMap', srsName: 'EPSG:900913', format: 'application/vnd.google-earth.kmz', width: 2000, height: 2000 }

def initialize(document)
request_params = KMZ_DOWNLOAD_PARAMS.merge(layers: document[:layer_id_s], bbox: document[:solr_bbox].split(' ').join(', '))
request_params = KMZ_DOWNLOAD_PARAMS.merge(layers: document[:layer_id_s], bbox: document.bounding_box_as_wsen.split(' ').join(', '))
super(document, {
type: 'kmz',
extension: 'kmz',
Expand Down
1 change: 0 additions & 1 deletion lib/geoblacklight/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Engine < ::Rails::Engine

Blacklight::Configuration.default_values[:view].split.partials = ['index']
Blacklight::Configuration.default_values[:view].delete_field('list')

# GeoblacklightHelper is needed by all helpers, so we inject it
# into action view base here.
initializer 'geoblacklight.helpers' do |app|
Expand Down
3 changes: 3 additions & 0 deletions lib/geoblacklight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def itemtype
"http://schema.org/Dataset"
end

def bounding_box_as_wsen
get(Settings.GEOMETRY_FIELD.to_sym)
end
##
# Provides a convenience method to access a SolrDocument's References
# endpoint url without having to check and see if it is available
Expand Down

0 comments on commit 44d0486

Please sign in to comment.