blacklight_heatmaps 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/app/assets/javascripts/blacklight_heatmaps/default.esm.js +2000 -0
- data/app/assets/javascripts/blacklight_heatmaps/default.esm.js.map +1 -0
- data/app/assets/javascripts/blacklight_heatmaps/default.js +2006 -8
- data/app/assets/javascripts/blacklight_heatmaps/default.js.map +1 -0
- data/app/{assets/javascripts/blacklight_heatmaps → javascript}/basemaps.js +4 -2
- data/app/javascript/blacklight_heatmaps.js +42 -0
- data/app/javascript/icons.js +5 -0
- data/app/javascript/viewers/index.js +76 -0
- data/app/javascript/viewers/show.js +24 -0
- data/lib/blacklight_heatmaps/version.rb +1 -1
- data/lib/generators/blacklight_heatmaps/install_generator.rb +2 -0
- data/spec/examples.txt +31 -0
- data/spec/features/configurable_basemap_spec.rb +1 -2
- data/spec/features/index_page_map_spec.rb +1 -1
- data/spec/features/show_page_map_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- data/vendor/assets/javascripts/geostats.js +511 -284
- data/vendor/assets/javascripts/leaflet_solr_heatmap.js +6 -4
- metadata +13 -9
- data/app/assets/javascripts/blacklight_heatmaps/blacklight_heatmaps.js +0 -18
- data/app/assets/javascripts/blacklight_heatmaps/icons.js +0 -3
- data/app/assets/javascripts/blacklight_heatmaps/viewers/index.js +0 -91
- data/app/assets/javascripts/blacklight_heatmaps/viewers/show.js +0 -39
- data/app/assets/javascripts/index.js +0 -8
@@ -1,3 +1,5 @@
|
|
1
|
+
import geostats from './geostats'
|
2
|
+
|
1
3
|
L.SolrHeatmap = L.GeoJSON.extend({
|
2
4
|
options: {
|
3
5
|
solrRequestHandler: 'select',
|
@@ -136,7 +138,7 @@ L.SolrHeatmap = L.GeoJSON.extend({
|
|
136
138
|
_getGradient: function (classifications) {
|
137
139
|
var gradient = {};
|
138
140
|
var maxValue = classifications[classifications.length - 1];
|
139
|
-
var colors = _this.options.colors;
|
141
|
+
var colors = _this.options.colors;
|
140
142
|
// skip first lower bound, assumed to be 0 from Jenks
|
141
143
|
for (var i = 1; i < classifications.length; i++)
|
142
144
|
gradient[classifications[i] / maxValue] = colors[i];
|
@@ -145,7 +147,7 @@ L.SolrHeatmap = L.GeoJSON.extend({
|
|
145
147
|
|
146
148
|
// compute size of heatmap cells in pixels
|
147
149
|
_getCellSize: function () {
|
148
|
-
_this = this;
|
150
|
+
const _this = this;
|
149
151
|
var mapSize = _this._map.getSize(); // should't we use solr returned map extent?
|
150
152
|
var widthInPixels = mapSize.x;
|
151
153
|
var heightInPixels = mapSize.y;
|
@@ -261,7 +263,7 @@ L.SolrHeatmap = L.GeoJSON.extend({
|
|
261
263
|
// Jenks classification can be slow so we optionally sample the data
|
262
264
|
// typically any big sample of counts are much the same, don't need to classify on all of them
|
263
265
|
_sampleCounts: function (passedArray) {
|
264
|
-
_this = this;
|
266
|
+
const _this = this;
|
265
267
|
if (passedArray.length <= _this.options.maxSampleSize) {
|
266
268
|
return passedArray; // array too small to sample
|
267
269
|
}
|
@@ -269,7 +271,7 @@ L.SolrHeatmap = L.GeoJSON.extend({
|
|
269
271
|
var maxValue = Math.max.apply(Math, passedArray);
|
270
272
|
var sampledArray = [];
|
271
273
|
var period = Math.ceil(passedArray.length / _this.options.maxSampleSize);
|
272
|
-
for (i = 0; i < passedArray.length; i = i + period) {
|
274
|
+
for (let i = 0; i < passedArray.length; i = i + period) {
|
273
275
|
sampledArray.push(passedArray[i]);
|
274
276
|
}
|
275
277
|
|
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: 1.
|
4
|
+
version: 1.4.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:
|
11
|
+
date: 2025-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -173,17 +173,19 @@ files:
|
|
173
173
|
- README.md
|
174
174
|
- Rakefile
|
175
175
|
- app/assets/images/blacklight/heatmaps.svg
|
176
|
-
- app/assets/javascripts/blacklight_heatmaps/
|
177
|
-
- app/assets/javascripts/blacklight_heatmaps/
|
176
|
+
- app/assets/javascripts/blacklight_heatmaps/default.esm.js
|
177
|
+
- app/assets/javascripts/blacklight_heatmaps/default.esm.js.map
|
178
178
|
- app/assets/javascripts/blacklight_heatmaps/default.js
|
179
|
-
- app/assets/javascripts/blacklight_heatmaps/
|
180
|
-
- app/assets/javascripts/blacklight_heatmaps/viewers/index.js
|
181
|
-
- app/assets/javascripts/blacklight_heatmaps/viewers/show.js
|
182
|
-
- app/assets/javascripts/index.js
|
179
|
+
- app/assets/javascripts/blacklight_heatmaps/default.js.map
|
183
180
|
- app/assets/stylesheets/blacklight_heatmaps/default.scss
|
184
181
|
- app/components/blacklight_heatmaps/icons/heatmaps_component.rb
|
185
182
|
- app/controllers/blacklight_heatmaps/application_controller.rb
|
186
183
|
- app/helpers/blacklight/maps_helper.rb
|
184
|
+
- app/javascript/basemaps.js
|
185
|
+
- app/javascript/blacklight_heatmaps.js
|
186
|
+
- app/javascript/icons.js
|
187
|
+
- app/javascript/viewers/index.js
|
188
|
+
- app/javascript/viewers/show.js
|
187
189
|
- app/models/concerns/blacklight_heatmaps/bounding_box.rb
|
188
190
|
- app/models/concerns/blacklight_heatmaps/exceptions.rb
|
189
191
|
- app/models/concerns/blacklight_heatmaps/geometry_parser.rb
|
@@ -206,6 +208,7 @@ files:
|
|
206
208
|
- lib/generators/blacklight_heatmaps/templates/blacklight_heatmaps.js
|
207
209
|
- lib/generators/blacklight_heatmaps/templates/blacklight_heatmaps.scss
|
208
210
|
- lib/tasks/blacklight_heatmaps_tasks.rake
|
211
|
+
- spec/examples.txt
|
209
212
|
- spec/features/configurable_basemap_spec.rb
|
210
213
|
- spec/features/index_page_map_spec.rb
|
211
214
|
- spec/features/show_page_map_spec.rb
|
@@ -243,11 +246,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
246
|
- !ruby/object:Gem::Version
|
244
247
|
version: '0'
|
245
248
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
249
|
+
rubygems_version: 3.5.23
|
247
250
|
signing_key:
|
248
251
|
specification_version: 4
|
249
252
|
summary: Search and view Blacklight resources on a map.
|
250
253
|
test_files:
|
254
|
+
- spec/examples.txt
|
251
255
|
- spec/features/configurable_basemap_spec.rb
|
252
256
|
- spec/features/index_page_map_spec.rb
|
253
257
|
- spec/features/show_page_map_spec.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
!(function (global) {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
var BlacklightHeatmaps = L.Class.extend({
|
5
|
-
statics: {
|
6
|
-
__version__: '0.0.3',
|
7
|
-
|
8
|
-
selectBasemap: function (basemap) {
|
9
|
-
if (basemap && basemap !== undefined) {
|
10
|
-
return BlacklightHeatmaps.Basemaps[basemap];
|
11
|
-
} else {
|
12
|
-
return BlacklightHeatmaps.Basemaps.positron;
|
13
|
-
}
|
14
|
-
},
|
15
|
-
},
|
16
|
-
});
|
17
|
-
global.BlacklightHeatmaps = BlacklightHeatmaps;
|
18
|
-
}(this));
|
@@ -1,91 +0,0 @@
|
|
1
|
-
Blacklight.onLoad(function () {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
document.querySelectorAll('[data-index-map]').forEach(function (el) {
|
5
|
-
BlacklightHeatmaps.indexView(el, {});
|
6
|
-
});
|
7
|
-
});
|
8
|
-
|
9
|
-
!(function (global) {
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var IndexView = L.Class.extend({
|
13
|
-
options: {},
|
14
|
-
|
15
|
-
initialize: function (el, options) {
|
16
|
-
var requestUrl = el.dataset.searchUrl + '&format=heatmaps';
|
17
|
-
var geometryField = el.dataset.geometryField;
|
18
|
-
var template = el.dataset.sidebarTemplate;
|
19
|
-
var colorRamp = JSON.parse(el.dataset.colorRamp);
|
20
|
-
|
21
|
-
// Blank out page link content first and disable pagination
|
22
|
-
document.querySelectorAll('#sortAndPerPage .page-links').forEach(function (links) {
|
23
|
-
links.innerHTML = '';
|
24
|
-
});
|
25
|
-
document.querySelectorAll('ul.pagination').forEach(function (links) {
|
26
|
-
links.classList.add('d-none');
|
27
|
-
});
|
28
|
-
|
29
|
-
var map = L.map(el.id).setView([0, 0], 1);
|
30
|
-
var basemap = BlacklightHeatmaps.selectBasemap(
|
31
|
-
el.dataset.basemapProvider
|
32
|
-
).addTo(map);
|
33
|
-
|
34
|
-
var solrLayer = L.solrHeatmap(requestUrl, {
|
35
|
-
field: geometryField,
|
36
|
-
maxSampleSize: 50,
|
37
|
-
colors: colorRamp,
|
38
|
-
}).addTo(map);
|
39
|
-
|
40
|
-
var sidebar = L.control.sidebar('index-map-sidebar', {
|
41
|
-
position: 'right',
|
42
|
-
});
|
43
|
-
|
44
|
-
map.addControl(sidebar);
|
45
|
-
|
46
|
-
solrLayer.on('click', function (e) {
|
47
|
-
if (!sidebar.isVisible()) {
|
48
|
-
map.setView(e.latlng);
|
49
|
-
} else {
|
50
|
-
var point = map.project(e.latlng);
|
51
|
-
var offset = sidebar.getOffset();
|
52
|
-
var newPoint = L.point(point.x - (offset / 2), point.y);
|
53
|
-
map.setView(map.unproject(newPoint));
|
54
|
-
}
|
55
|
-
|
56
|
-
sidebar.show();
|
57
|
-
});
|
58
|
-
|
59
|
-
solrLayer.on('dataAdded', function (e) {
|
60
|
-
if (e.response && e.response.docs) {
|
61
|
-
var html = '';
|
62
|
-
e.response.docs.forEach(function (value) {
|
63
|
-
html += L.Util.template(template, value);
|
64
|
-
});
|
65
|
-
|
66
|
-
sidebar.setContent(html);
|
67
|
-
|
68
|
-
var docCount = e.response.pages.total_count;
|
69
|
-
|
70
|
-
document.querySelectorAll('#sortAndPerPage .page-links').forEach(function (links) {
|
71
|
-
links.innerHTML = parseInt(docCount).toLocaleString() + ' ' + (docCount == 1 ? 'item' : 'items') + ' found';
|
72
|
-
});
|
73
|
-
}
|
74
|
-
});
|
75
|
-
},
|
76
|
-
|
77
|
-
pluralize: function (count, word) {
|
78
|
-
switch (count) {
|
79
|
-
case 1:
|
80
|
-
return word;
|
81
|
-
default:
|
82
|
-
return word + 's';
|
83
|
-
}
|
84
|
-
},
|
85
|
-
});
|
86
|
-
|
87
|
-
global.BlacklightHeatmaps.IndexView = IndexView;
|
88
|
-
global.BlacklightHeatmaps.indexView = function (el, options) {
|
89
|
-
return new IndexView(el, options);
|
90
|
-
};
|
91
|
-
})(this);
|
@@ -1,39 +0,0 @@
|
|
1
|
-
Blacklight.onLoad(function () {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
document.querySelectorAll('[data-show-map]').forEach(function (el) {
|
5
|
-
BlacklightHeatmaps.showView(el);
|
6
|
-
});
|
7
|
-
});
|
8
|
-
|
9
|
-
!(function (global) {
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var ShowView = L.Class.extend({
|
13
|
-
options: {},
|
14
|
-
|
15
|
-
initialize: function (el, options) {
|
16
|
-
var json = JSON.parse(el.dataset.features);
|
17
|
-
|
18
|
-
var map = L.map(el.id).setView([0, 0], 1);
|
19
|
-
var basemap = BlacklightHeatmaps.selectBasemap(
|
20
|
-
el.dataset.basemapProvider
|
21
|
-
).addTo(map);
|
22
|
-
|
23
|
-
var features = L.geoJson(json, {
|
24
|
-
pointToLayer: function(feature, latlng) {
|
25
|
-
return L.marker(latlng, {
|
26
|
-
icon: BlacklightHeatmaps.Icons.default
|
27
|
-
})
|
28
|
-
}
|
29
|
-
}).addTo(map);
|
30
|
-
|
31
|
-
map.fitBounds(features.getBounds());
|
32
|
-
},
|
33
|
-
});
|
34
|
-
|
35
|
-
global.BlacklightHeatmaps.ShowView = ShowView;
|
36
|
-
global.BlacklightHeatmaps.showView = function (el, options) {
|
37
|
-
return new ShowView(el, options);
|
38
|
-
};
|
39
|
-
})(this);
|