Skip to content

Commit

Permalink
Add heatmap to the narrative web.
Browse files Browse the repository at this point in the history
  • Loading branch information
SNoiraud committed Mar 13, 2024
1 parent 8361567 commit 8e54aa3
Show file tree
Hide file tree
Showing 7 changed files with 1,482 additions and 9 deletions.
19 changes: 19 additions & 0 deletions gramps/plugins/webreport/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@ def display_nav_links(self, currentsection, cal=0):
("families", self._("Families"), self.report.inc_families),
("events", self._("Events"), self.report.inc_events),
("places", self._("Places"), self.report.inc_places),
("heatmaps", self._("Heatmaps"), self.report.inc_heatmaps),
("sources", self._("Sources"), self.report.inc_sources),
("repositories", self._("Repositories"), inc_repos),
(
Expand Down Expand Up @@ -1964,6 +1965,9 @@ def display_nav_links(self, currentsection, cal=0):
elif nav_text == self._("Places"):
if "plc" in self.report.cur_fname:
check_cs = True
elif nav_text == self._("Heatmap"):
if "heat" in self.report.cur_fname:
check_cs = True
elif nav_text == self._("Events"):
if "evt" in self.report.cur_fname:
check_cs = True
Expand Down Expand Up @@ -3130,6 +3134,21 @@ def doc_link(self, handle, name, uplink=False, usedescr=True):
thumbnail += document_link
return thumbnail

def heatmap_link(self, name, uplink=False):
"""
Returns a hyperlink for heatmap link
@param: name -- repository title
@param: uplink -- If True, then "../../../" is inserted in front of
the result.
"""
url = self.report.build_url_fname_html(name, "heat", uplink)

hyper = Html("a", html_escape(self._(name)), href=url.replace(" ", ""), title=html_escape(self._(name)))

# return hyperlink to its callers
return hyper

def place_link(self, handle, name, gid=None, uplink=False):
"""
Returns a hyperlink for place link
Expand Down
33 changes: 26 additions & 7 deletions gramps/plugins/webreport/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
OSM_MARKERS = """
window.addEventListener("load", function() {
var map;
var heat = '%s';
var tracelife = %s;
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
Expand All @@ -241,6 +242,10 @@
});
var markerSource = new ol.source.Vector({
});
var centerCoord = new ol.proj.transform([%s, %s], 'EPSG:4326', 'EPSG:3857');
var zoom = %d;
var radius = %d;
var blur = %d;
for (var i = 0; i < tracelife.length; i++) {
var loc = tracelife[i];
var iconFeature = new ol.Feature({
Expand All @@ -260,13 +265,27 @@
source: markerSource,
style: iconStyle
});
var centerCoord = new ol.proj.transform([%s, %s], 'EPSG:4326', 'EPSG:3857');
map = new ol.Map({
target: 'map_canvas',
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }),
markerLayer, tooltip],
view: new ol.View({ center: centerCoord, zoom: %d })
});
heatmap = new ol.layer.Heatmap({
source: markerSource,
radius: radius,
blur: blur,
style: iconStyle
});
if (heat == "heatmap") {
map = new ol.Map({
target: 'map_canvas',
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }),
heatmap],
view: new ol.View({ center: centerCoord, zoom: zoom })
});
} else {
map = new ol.Map({
target: 'map_canvas',
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }),
markerLayer, tooltip],
view: new ol.View({ center: centerCoord, zoom: zoom })
});
};
"""

STAMEN_MARKERS = """
Expand Down
Loading

0 comments on commit 8e54aa3

Please sign in to comment.