blacklight_heatmaps 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77506e7f719dfe48668fff1eee85870869345e18
4
- data.tar.gz: 10b18e63457595f3b494571ac85b14bf52072cb2
3
+ metadata.gz: a3ccce3da873d326189a04751821096659975b08
4
+ data.tar.gz: 4bdd563cab7c22e9788d528bac24ee1521722879
5
5
  SHA512:
6
- metadata.gz: e127e89b873b508bcc2d574f926da8437c183f31d6fe1b1401489ef4e14a959302527fc27b1c47fa2f7e5014b3a392fb18fa73557232b8de54d31cb8869c977f
7
- data.tar.gz: c78589f392100861feb56966042431bd4037a1ddcfa2ea0fae68acde4ecf0206a95bb71575b12943503e14205610b16486e390d7185747cbbcf70cdd26fe6844
6
+ metadata.gz: acc8026a66f6ff89f5a945c69b0712ba1039a69d72a3e743d87b4031bd1df93ed1e9f2f12bdc60ca4840217996fddc66944439c5904b99c92d410a0cf2c3c5bb
7
+ data.tar.gz: 85681826d5992b5d02ea40566f27140530f17feaa81da8e5c6ef7c8e8320310b0ae9381d663acb2ced69cf83033c70ec04ceffdc463c9d9e68c6e38146ac4fb0
data/README.md CHANGED
@@ -40,6 +40,20 @@ BlacklightHeatmaps expects your data to be indexed as a [Spatial Recursive Prefi
40
40
  - `x y` Syntax. example: "-121.631609 36.688128"
41
41
  - CQL ENVELOPE Syntax (`minX, maxX, maxY, minY`). example: "ENVELOPE(122.934585571, 153.987060547, 45.522888184, 20.422889709)"
42
42
 
43
+ BlacklightHeatmaps also works with multivalued Spatial Recursive Prefix Tree types.
44
+
45
+ ```json
46
+ {
47
+ "id": 1,
48
+ "name": "Null Island",
49
+ "geo_srpt": [
50
+ "ENVELOPE(-0.0005, 0.000379, 0.000309, -0.000282)", "0 0"
51
+ ]
52
+ }
53
+ ```
54
+
55
+ Solr does not seem to be able to handle multivalued points without an accompanying geometry.
56
+
43
57
  Additional formats could be added by extending `BlacklightHeatmaps::GeometryParser`
44
58
 
45
59
  ### Customizing the basemap
@@ -4,8 +4,18 @@ module BlacklightHeatmaps
4
4
  module GeometrySolrDocument
5
5
  def to_geojson(blacklight_config = nil)
6
6
  return unless blacklight_config.try(:geometry_field) && fetch(blacklight_config.geometry_field, nil)
7
- BlacklightHeatmaps::GeometryParser
8
- .parse(fetch(blacklight_config.geometry_field)).to_geojson
7
+ {
8
+ type: 'FeatureCollection',
9
+ features: Array(fetch(blacklight_config.geometry_field)).map do |geometry|
10
+ {
11
+ type: 'Feature',
12
+ geometry: JSON.parse(
13
+ BlacklightHeatmaps::GeometryParser.parse(geometry).to_geojson
14
+ ),
15
+ properties: {}
16
+ }
17
+ end
18
+ }.to_json
9
19
  end
10
20
  end
11
21
  end
@@ -1,3 +1,3 @@
1
1
  module BlacklightHeatmaps
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -12,7 +12,7 @@ feature 'Index page map', js: true do
12
12
  expect(page).to have_css 'ul.pagination li.disabled', count: 6
13
13
 
14
14
  # Document counts
15
- expect(page).to have_css '.page_links', text: '17 items found'
15
+ expect(page).to have_css '.page_links', text: '18 items found'
16
16
 
17
17
  expect(page).to have_css '#index-map-sidebar', visible: false
18
18
  page.first('svg g path').click
@@ -8,8 +8,11 @@ feature 'Show map map', js: true do
8
8
  expect(page).to have_css 'img[src*="light_all/4/11/5.png"]'
9
9
  expect(page).to have_css 'svg g path'
10
10
  end
11
- it 'renders a point type' do
11
+ it 'renders a point type and a polygon' do
12
12
  visit solr_document_path '34860108'
13
- expect(page).to have_css '.leaflet-marker-icon'
13
+ within '.leaflet-container' do
14
+ expect(page).to have_css 'svg g path'
15
+ expect(page).to have_css '.leaflet-marker-icon'
16
+ end
14
17
  end
15
18
  end
@@ -0,0 +1,36 @@
1
+ {
2
+ "type": "FeatureCollection",
3
+ "features": [
4
+ {
5
+ "type": "Feature",
6
+ "geometry": {
7
+ "type": "Polygon",
8
+ "coordinates": [
9
+ [
10
+ [
11
+ -0.0005,
12
+ -0.000282
13
+ ],
14
+ [
15
+ -0.0005,
16
+ 0.000309
17
+ ],
18
+ [
19
+ 0.000379,
20
+ 0.000309
21
+ ],
22
+ [
23
+ 0.000379,
24
+ -0.000282
25
+ ],
26
+ [
27
+ -0.0005,
28
+ -0.000282
29
+ ]
30
+ ]
31
+ ]
32
+ },
33
+ "properties": {}
34
+ }
35
+ ]
36
+ }
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BlacklightHeatmaps::GeometrySolrDocument do
3
+ describe BlacklightHeatmaps::GeometrySolrDocument, :include_fixtures do
4
4
  subject { SolrDocument.new(fields).to_geojson(blacklight_config) }
5
5
 
6
6
  context 'when configured' do
7
- let(:fields) { { some_field: 'ENVELOPE(1,2,4,3)' } }
7
+ let(:fields) { { some_field: 'ENVELOPE(-0.0005, 0.000379, 0.000309, -0.000282)' } }
8
8
  let(:blacklight_config) { double('BlacklightConfig', geometry_field: :some_field) }
9
- it 'returns the data from the document as geoJSON' do
10
- expect(subject).to eq '{"type":"Polygon","coordinates":[[[1.0,3.0],[1.0,4.0],[2.0,4.0],[2.0,3.0],[1.0,3.0]]]}'
9
+ it 'returns the data from the document as GeoJson FeatureCollection' do
10
+ expect(subject).to eq null_island.gsub(/\s/, '')
11
11
  end
12
12
  end
13
13
  context 'when not configured' do
@@ -18,10 +18,10 @@ describe BlacklightHeatmaps::GeometrySolrDocument do
18
18
  end
19
19
  end
20
20
  context 'when the document has the field' do
21
- let(:fields) { { some_field: 'ENVELOPE(1,2,4,3)' } }
21
+ let(:fields) { { some_field: 'ENVELOPE(-0.0005, 0.000379, 0.000309, -0.000282)' } }
22
22
  let(:blacklight_config) { double('BlacklightConfig', geometry_field: :some_field) }
23
- it 'returns the data from the document as geoJSON' do
24
- expect(subject).to eq '{"type":"Polygon","coordinates":[[[1.0,3.0],[1.0,4.0],[2.0,4.0],[2.0,3.0],[1.0,3.0]]]}'
23
+ it 'returns the data from the document as GeoJson FeatureCollection' do
24
+ expect(subject).to eq null_island.gsub(/\s/, '')
25
25
  end
26
26
  end
27
27
  context 'when the document does not have the field' do
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,8 @@ EngineCart.load_application!
15
15
 
16
16
  require 'rspec/rails'
17
17
 
18
+ Dir[Pathname.new(File.expand_path("../support/**/*.rb", __FILE__))].each { |f| require f }
19
+
18
20
  require 'capybara/poltergeist'
19
21
  Capybara.javascript_driver = :poltergeist
20
22
 
@@ -0,0 +1,9 @@
1
+ module FixtureData
2
+ def null_island
3
+ File.read(Pathname.new(File.expand_path('../../fixtures/null_island.geojson', __FILE__)))
4
+ end
5
+ end
6
+
7
+ RSpec.configure do |config|
8
+ config.include FixtureData, :include_fixtures
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_heatmaps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Reed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -195,6 +195,7 @@ files:
195
195
  - spec/features/configurable_basemap_spec.rb
196
196
  - spec/features/index_page_map_spec.rb
197
197
  - spec/features/show_page_map_spec.rb
198
+ - spec/fixtures/null_island.geojson
198
199
  - spec/helpers/blacklight/maps_helper_spec.rb
199
200
  - spec/models/concerns/blacklight_heatmaps/bounding_box_spec.rb
200
201
  - spec/models/concerns/blacklight_heatmaps/geometry_parser_spec.rb
@@ -202,6 +203,7 @@ files:
202
203
  - spec/models/concerns/blacklight_heatmaps/point_spec.rb
203
204
  - spec/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior_spec.rb
204
205
  - spec/spec_helper.rb
206
+ - spec/support/fixture_data.rb
205
207
  - spec/test_app_templates/lib/generators/test_app_generator.rb
206
208
  - spec/views/catalog/_document_heatmaps.html.erb_spec.rb
207
209
  - spec/views/catalog/_show_leaflet_map_default.html.erb_spec.rb
@@ -235,6 +237,7 @@ test_files:
235
237
  - spec/features/configurable_basemap_spec.rb
236
238
  - spec/features/index_page_map_spec.rb
237
239
  - spec/features/show_page_map_spec.rb
240
+ - spec/fixtures/null_island.geojson
238
241
  - spec/helpers/blacklight/maps_helper_spec.rb
239
242
  - spec/models/concerns/blacklight_heatmaps/bounding_box_spec.rb
240
243
  - spec/models/concerns/blacklight_heatmaps/geometry_parser_spec.rb
@@ -242,6 +245,7 @@ test_files:
242
245
  - spec/models/concerns/blacklight_heatmaps/point_spec.rb
243
246
  - spec/models/concerns/blacklight_heatmaps/solr_facet_heatmap_behavior_spec.rb
244
247
  - spec/spec_helper.rb
248
+ - spec/support/fixture_data.rb
245
249
  - spec/test_app_templates/lib/generators/test_app_generator.rb
246
250
  - spec/views/catalog/_document_heatmaps.html.erb_spec.rb
247
251
  - spec/views/catalog/_show_leaflet_map_default.html.erb_spec.rb