map: draw only labels present on map using rtrees
This commit is contained in:
parent
9d2318dce1
commit
22b49c1a55
5 changed files with 100 additions and 67 deletions
35
lib/map.js
35
lib/map.js
|
|
@ -1,7 +1,7 @@
|
|||
define(["map/clientlayer", "map/labelslayer",
|
||||
"d3", "leaflet", "moment", "locationmarker",
|
||||
"d3", "leaflet", "moment", "locationmarker", "rbush",
|
||||
"leaflet.label", "leaflet.providers"],
|
||||
function (ClientLayer, LabelsLayer, d3, L, moment, LocationMarker) {
|
||||
function (ClientLayer, LabelsLayer, d3, L, moment, LocationMarker, rbush) {
|
||||
var options = { worldCopyJump: true,
|
||||
zoomControl: false
|
||||
}
|
||||
|
|
@ -300,6 +300,15 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
return L.circle(barycenter, r * config.mapSigmaScale)
|
||||
}
|
||||
|
||||
function mapRTree(d) {
|
||||
var o = [ d.nodeinfo.location.latitude, d.nodeinfo.location.longitude,
|
||||
d.nodeinfo.location.latitude, d.nodeinfo.location.longitude]
|
||||
|
||||
o.node = d
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
self.setData = function (data) {
|
||||
nodeDict = {}
|
||||
linkDict = {}
|
||||
|
|
@ -349,11 +358,23 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
groupNew = L.featureGroup(markersNew).addTo(map)
|
||||
groupLost = L.featureGroup(markersLost).addTo(map)
|
||||
|
||||
clientLayer.setData(data.nodes.all.filter(online).filter(has_location))
|
||||
labelsLayer.setData({online: nodesOnline.filter(has_location),
|
||||
offline: nodesOffline.filter(has_location),
|
||||
new: data.nodes.new.filter(has_location),
|
||||
lost: data.nodes.lost.filter(has_location)
|
||||
var rtreeOnlineAll = rbush(9)
|
||||
var rtreeOnline = rbush(9)
|
||||
var rtreeOffline = rbush(9)
|
||||
var rtreeNew = rbush(9)
|
||||
var rtreeLost = rbush(9)
|
||||
|
||||
rtreeOnlineAll.load(data.nodes.all.filter(online).filter(has_location).map(mapRTree))
|
||||
rtreeOnline.load(nodesOnline.filter(has_location).map(mapRTree))
|
||||
rtreeOffline.load(nodesOffline.filter(has_location).map(mapRTree))
|
||||
rtreeNew.load(data.nodes.new.filter(has_location).map(mapRTree))
|
||||
rtreeLost.load(data.nodes.lost.filter(has_location).map(mapRTree))
|
||||
|
||||
clientLayer.setData(rtreeOnlineAll)
|
||||
labelsLayer.setData({online: rtreeOnline,
|
||||
offline: rtreeOffline,
|
||||
new: rtreeNew,
|
||||
lost: rtreeLost
|
||||
})
|
||||
|
||||
updateView(true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue