Skip to content

Commit

Permalink
enabled multivalued bbox support fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Mar 21, 2014
1 parent ea5acdb commit 8179173
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -27,7 +27,7 @@ Blacklight-Maps adds a map view capability for a results set that contains geosp

For now, Blacklight-Maps requires that your Solr index include one of the following two types of fields:

1. A `location_rpt` field that contains a bounding box for the document. For more on `location_rpt` see [Solr help](https://cwiki.apache.org/confluence/display/solr/Spatial+Search)
1. A `location_rpt` field that contains a bounding box for the document. For more on `location_rpt` see [Solr help](https://cwiki.apache.org/confluence/display/solr/Spatial+Search). This field can be multivalued.
```
place_bbox: 44.0318907 25.0594286 63.3333366 39.7816755
# minX minY maxX maxY
Expand Down
10 changes: 6 additions & 4 deletions lib/blacklight/maps/export.rb
Expand Up @@ -73,10 +73,12 @@ def build_bbox_features
features = []
@response_docs.each do |doc|
next if doc[bbox_field].nil?
lnglat = Geometry::BoundingBox.from_lon_lat_string(doc[bbox_field]).find_center
features.push(
build_point_feature(lnglat[0], lnglat[1],
html: render_leaflet_sidebar_partial(doc)))
doc[bbox_field].uniq.each do |loc|
lnglat = Geometry::BoundingBox.from_lon_lat_string(loc).find_center
features.push(
build_point_feature(lnglat[0], lnglat[1],
html: render_leaflet_sidebar_partial(doc)))
end
end
features
end
Expand Down
2 changes: 1 addition & 1 deletion solr_conf/conf/schema.xml
Expand Up @@ -579,7 +579,7 @@
<dynamicField name="*spell" type="textSpell" indexed="true" stored="false" multiValued="true" />

<dynamicField name="*_pt" type="location" stored="true" indexed="true"/>
<dynamicField name="*_bbox" type="location_rpt" stored="true" indexed="true"/>
<dynamicField name="*_bbox" type="location_rpt" stored="true" indexed="true" multiValued="true"/>

<!-- uncomment the following to ignore any fields that don't already match an existing
field name or dynamic field, rather than reporting them as an error.
Expand Down
6 changes: 3 additions & 3 deletions spec/features/maps_spec.rb
Expand Up @@ -91,10 +91,10 @@
end
end

before { visit catalog_index_path :q => 'tibet', :view => 'maps' }
before { visit catalog_index_path :q => 'korea', :view => 'maps' }

it "should have 2 markers" do
expect(find("div.marker-cluster")).to have_content(2)
it "should have 4 markers" do
expect(find("div.marker-cluster")).to have_content(4)
end

describe "click marker cluster" do
Expand Down
4 changes: 3 additions & 1 deletion spec/fixtures/sample_solr_documents.yml
Expand Up @@ -1372,7 +1372,9 @@
placename_coords:
- Seoul (Korea)-|-37.566535-|-126.9779692
- Korea (South)-|-35.907757-|-127.766922
place_bbox: 124.608139 33.1061096 130.9232178 38.6169312
place_bbox:
- 126.7645827 37.4259627 127.18359 37.7017495
- 124.608139 33.1061096 130.9232178 38.6169312
- subtitle_display: dar khiradvarzī-i siyāsī va huvīyat-i mā Īrānīyān
author_vern_display: "‏رجايى، فرهنگ ."
subject_addl_t:
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/blacklight/maps/export_spec.rb
Expand Up @@ -19,7 +19,7 @@ class BlacklightMaps::GeojsonExport
@request = ActionDispatch::TestRequest.new
@controller.request = @request
@response = ActionDispatch::TestResponse.new
@response.stub(:docs) {[{ "published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "subject_geo_facet"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "placename_coords"=>["China-|-35.86166-|-104.195397", "Tibet-|-29.646923-|-91.117212", "India-|-20.593684-|-78.96288"], "place_bbox"=>"68.162386 6.7535159 97.395555 35.5044752", "score"=>0.0026767207 }]}
@response.stub(:docs) {[{ "published_display"=>["Dharamsala, Distt. Kangra, H.P."], "pub_date"=>["2007"], "format"=>"Book", "title_display"=>"Ses yon", "material_type_display"=>["xii, 419 p."], "id"=>"2008308478", "subject_geo_facet"=>["China", "Tibet", "India"], "subject_topic_facet"=>["Education and state", "Tibetans", "Tibetan language", "Teaching"], "language_facet"=>["Tibetan"], "placename_coords"=>["China-|-35.86166-|-104.195397", "Tibet-|-29.646923-|-91.117212", "India-|-20.593684-|-78.96288"], "place_bbox"=>["68.162386 6.7535159 97.395555 35.5044752"], "score"=>0.0026767207 }]}
end

subject {BlacklightMaps::GeojsonExport.new(@controller, @response.docs)}
Expand Down

0 comments on commit 8179173

Please sign in to comment.