# SPDX-License-Identifier: AGPL-3.0-or-later

# done for battlemesh v15 presentation for guifi sax 2022 on 2022-11-4
#   by guifipedro in a lavapies hotel in Madrid

library(leaflet)
library(data.table)

# https://stackoverflow.com/questions/37376398/how-to-create-an-empty-datatable-with-columns-names-and-then-append-datatables-t

dt <- data.table(edition=numeric(),lat=numeric(), long=numeric())
# calafou -> https://battlemesh.org/BattleMeshV15
dt <- rbind(dt, list(15, 41.51118847925773, 1.7028579145321114))
# fusolab -> https://battlemesh.org/BattleMeshV14
dt <- rbind(dt, list(14, 41.8720435, 12.5822329))
# point it to the sea -> src https://battlemesh.org/BattleMeshV13
#dt <- rbind(dt, list(13, 46.832150, -9.069017))
# le 6b -> src https://battlemesh.org/BattleMeshV12
dt <- rbind(dt, list(12, 48.93810677428581, 2.342786597620561))
# c-base -> src https://battlemesh.org/BattleMeshV11 -> src https://wireless-meshup.org
dt <- rbind(dt, list(11, 52.512979591701196, 13.42010285544062))
# Volkskundemuseum -> src https://battlemesh.org/BattleMeshV10
dt <- rbind(dt, list(10, 48.21298, 16.35052))
# Faculty of Engineering, University of Porto -> src https://battlemesh.org/BattleMeshV9
dt <- rbind(dt, list(9, 41.1782, -8.5958))
# Dom Obrambe Pekre -> src https://battlemesh.org/BattleMeshV8
dt <- rbind(dt, list(8, 46.5348607,15.5841888))
# sublab -> src https://battlemesh.org/BattleMeshV7
dt <- rbind(dt, list(7, 51.33027747540477, 12.330840668159015))
# Aalborg University -> src https://battlemesh.org/BattleMeshV6
dt <- rbind(dt, list(6, 57.0134, 9.9893))
# National Technical University of Athens (NTUA) -> src https://battlemesh.org/BattleMeshV5
dt <- rbind(dt, list(5.2, 37.9878421,23.7307094))
# Sarantaporo -> src https://battlemesh.org/BattleMeshV5_Warmup
dt <- rbind(dt, list(5.1, 40.01732095079183, 22.071475061427538))
# ? -> src https://battlemesh.org/BattleMeshV4.01
# FIXME this gave me 404
# Can Roca Sant Bartomeu del Grau -> src https://battlemesh.org/BattleMeshV4
dt <- rbind(dt, list(4, 41.969587068961374, 2.1691728856638686))
# camp in Godarville -> src https://battlemesh.org/BattleMeshV3.3
dt <- rbind(dt, list(3.3, 50.501992,4.284022))
# the Ghent hackerspace, 0x20 (aka whitespace) -> src https://battlemesh.org/BattleMeshV3.1416
dt <- rbind(dt, list(3.1, 51.059737375192924, 3.7323995787093787))
# bracciano camping -> src https://battlemesh.org/BattleMeshV3
dt <- rbind(dt, list(3, 42.10605,12.18743))
# hasselt -> src https://wiki.hsbxl.be/Wireless_Battle_Mesh_v_2.7182
dt <- rbind(dt, list(2.7, 50.92567356913028, 5.319454261398706))
# okno -> src https://wiki.hsbxl.be/Wireless_Battle_Mesh_v2
dt <- rbind(dt, list(2, 50.85478277588161, 4.342007724407652))
# /tmp/lab -> src https://www.tmplab.org/2009/02/16/first-tmplab-wireless-battle-mesh-april-11-12th-2009-tmplab/
dt <- rbind(dt, list(1, 48.755009244613184, 2.411218359572519))

# thaanks https://stackoverflow.com/questions/31745525/leaflet-with-r-add-text-labels
#leaflet(data = dt) %>% addTiles() %>%
#  addLabelOnlyMarkers(~long, ~lat, label = ~as.character(edition),
#                      labelOptions = labelOptions(noHide = T, direction = 'center', textOnly = T, textsize = "30px")) %>%
#  addProviderTiles(providers$CartoDB.Positron)

leaflet(data = dt) %>% addTiles() %>%
  addMarkers(~long, ~lat, label = ~as.character(edition)) %>%
  addProviderTiles(providers$CartoDB.Positron)
