Compare commits

...

6 Commits

7 changed files with 75 additions and 8 deletions

6
.gitmodules vendored
View File

@ -1,3 +1,9 @@
[submodule "lifo-dijkstraserv"] [submodule "lifo-dijkstraserv"]
path = lifo-dijkstraserv path = lifo-dijkstraserv
url = https://notsyncing.net:8080/markus/lifo-dijkstraserv.git url = https://notsyncing.net:8080/markus/lifo-dijkstraserv.git
[submodule "htdocs/fa"]
path = htdocs/fa
url = https://github.com/FortAwesome/Font-Awesome
[submodule "htdocs/awesomemarkers"]
path = htdocs/awesomemarkers
url = https://github.com/lvoogdt/Leaflet.awesome-markers

1
htdocs/awesomemarkers Submodule

@ -0,0 +1 @@
Subproject commit 4fcacdfc82ed58f0173062851a4cda713845df82

1
htdocs/fa Submodule

@ -0,0 +1 @@
Subproject commit fcec2d1b01ff069ac10500ac42e4478d20d21f4c

16
htdocs/geojson/update.php Normal file
View File

@ -0,0 +1,16 @@
<?php
$fn = "/tmp/lifo_update_ts";
$ctime = time();
$ltime = (int)(file_get_contents($fn));
$ntime = $ltime + 60*1 * 30;
if (isset($_GET['force']))
$ntime = 0;
if ($ctime > $ntime) {
file_put_contents($fn, $ctime);
echo "Downloading... ";
flush();
system("cd /srv/http/maps.linux-forks.de/geojson/; ./update_all.sh");
} else {
echo "Next update in " . intval(($ntime - $ctime) / 60) . " minutes.";
}
?>

12
htdocs/geojson/update_all.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
function fetch() {
"./fetch_$1.sh" | json_reformat -m > "$1.json.tmp"
rm -f "$1.json"
mv "$1.json.tmp" "$1.json"
}
fetch streets
fetch city_outlines
echo "OK."

View File

@ -1,14 +1,14 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>LinuxWorks Minetest Map</title> <title>LinuxWorks Minetest Map [beta]</title>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="fa/css/all.css"> <link rel="stylesheet" href="fa/css/all.css">
<link rel="stylesheet" href="awesomemarkers/leaflet.awesome-markers.css"> <link rel="stylesheet" href="awesomemarkers/dist/leaflet.awesome-markers.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script> <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
<script src="awesomemarkers/leaflet.awesome-markers.js"></script> <script src="awesomemarkers/dist/leaflet.awesome-markers.js"></script>
<!-- Streets --> <!-- Streets -->
<script src='leafletjs/ctxtextpath.js'></script> <script src='leafletjs/ctxtextpath.js'></script>
<script src='leafletjs/L.LabelTextCollision.js'></script> <script src='leafletjs/L.LabelTextCollision.js'></script>
@ -48,7 +48,7 @@
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */ -ms-interpolation-mode: nearest-neighbor; /* IE8+ */
} }
</style> </style>
<script src="mapscript.js"></script> <script src="mapscript.js?v3"></script>
<script src="streeteditor.js"></script> <script src="streeteditor.js"></script>
</body> </body>
</html> </html>

View File

@ -95,6 +95,14 @@ var style_outlines = {
var style_streets = { var style_streets = {
}; };
var style_trains = {
color: "yellow"
};
var style_tech = {
color: "red"
};
var style_route = { var style_route = {
radius: 8, radius: 8,
fillColor: "#00ff00", fillColor: "#00ff00",
@ -206,9 +214,12 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
switch (geotype) { switch (geotype) {
case "street": case "street":
case "train":
onEachFeature = function(feature, layer) { onEachFeature = function(feature, layer) {
layer.myTag = geotype; layer.myTag = geotype;
layer.myName = name; layer.myName = name;
if (geotype == "train")
layer.no_search = true
layer.on("click", function (e) { layer.on("click", function (e) {
current_feature = feature; current_feature = feature;
}); });
@ -323,14 +334,28 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
xhttp_ps.send(); xhttp_ps.send();
} }
load_tiles("Satellite (2020-04-09)", 'world-2020-04-09').addTo(mymap); load_tiles("Satellite (2020-12-13)", 'world-2020-12-13').addTo(mymap);
load_tiles("Satellite (2019-05-04, wrong coords)", 'world-2019-05-04'); load_tiles("Satellite (2020-11-20)", 'world-2020-11-20');
load_tiles("Satellite (2020-08-30)", 'world-2020-08-30');
load_tiles("Satellite (2020-06-04)", 'world-2020-06-04');
load_tiles("Satellite (2020-04-26)", 'world-2020-04-26');
load_tiles("Satellite (2020-04-09)", 'world-2020-04-09');
load_tiles("None", ''); load_tiles("None", '');
load_geojson("All", "./geojson/all.json", "auto", "auto", 0); load_geojson("All", "./geojson/all.json", "auto", "auto", 0);
load_geojson("Streets", "./geojson/streets.json", "street", "auto", 1, style_streets); load_geojson("Streets", "./geojson/streets.json", "street", "auto", 1, style_streets);
load_geojson("Trainlines (beta)", "./geojson/trainlines_beta.json", "train", "auto", 1, style_trains);
load_geojson("TL Access (tech layer)", "./geojson/trainlines_access_beta.json", "train", "auto", 0, style_tech);
load_geojson("Railroad Tracks", "./geojson/trains.json", "train", "auto", 0, style_trains);
load_geojson("Cities", "./geojson/city_outlines.json", "outline", "auto", 1, style_outlines); load_geojson("Cities", "./geojson/city_outlines.json", "outline", "auto", 1, style_outlines);
function update_geojson() {
var xhttp_ps = new XMLHttpRequest();
xhttp_ps.open("GET", "https://notsyncing.net/maps.linux-forks.de/geojson/update.php", true);
xhttp_ps.send();
}
update_geojson();
L.control.scale().addTo(mymap); L.control.scale().addTo(mymap);
function resolve_latlng(latlng, recenter = 0) { function resolve_latlng(latlng, recenter = 0) {
@ -387,7 +412,11 @@ function build_sidebar() {
route_element.style.overflow = "scroll"; route_element.style.overflow = "scroll";
route_element.style.padding = "6px"; route_element.style.padding = "6px";
route_element.style.height = "100%"; route_element.style.height = "100%";
route_element.innerHTML = '<a href="#" onclick="toggle_search(\'search\',1);return false;">&lt;-- Return to search<br></a><input style="width:100%;" id="route_start" name="lifo_route_loc" type="search" placeholder="Start at x,y"><br><input style="width:100%;" id="route_destination" name="lifo_route_loc" type="search" placeholder="Go to x,y"><br><input id="route_submit" type="button" style="width:100%;" value="Go!" onclick="route(event)"><div id="route_results"></div>'; route_element.innerHTML = '<a href="#" onclick="toggle_search(\'search\',1);return false;">&lt;-- Return to search<br><br></a>\
<input style="width:100%;" id="route_start" name="lifo_route_loc" type="search" placeholder="Start at x,y"><br>\
<input style="width:100%;" id="route_destination" name="lifo_route_loc" type="search" placeholder="Go to x,y"><br>\
<input type="checkbox" name="use_trains" id="use_trains" value="trains" checked disabled=true><label for="use_trains"> Use trains (only S12)</label><br>\
<input id="route_submit" type="button" style="width:100%;" value="Go!" onclick="route(event)"><div id="route_results"></div>';
} }
} }
@ -451,6 +480,8 @@ function search(e) {
for (key in layers._layers[i].layer._layers) { for (key in layers._layers[i].layer._layers) {
item = layers._layers[i].layer._layers[key]; item = layers._layers[i].layer._layers[key];
if (item.hasOwnProperty("no_search"))
break;
switch (item.feature.geometry.type) { switch (item.feature.geometry.type) {
case "Point": case "Point":
regex = new RegExp(query, 'i'); regex = new RegExp(query, 'i');
@ -533,7 +564,7 @@ function route(e) // BOOKMARK
last_through = ""; last_through = "";
geojson.eachLayer( function(layer) { geojson.eachLayer( function(layer) {
if (last_through != layer.feature.properties.through) { if (last_through != layer.feature.properties.through) {
str += '<li><a href="#" onclick="latLng2 = L.latLng(' + layer.feature.geometry.coordinates[0][1] + ',' + layer.feature.geometry.coordinates[0][0] + '); jump_to(latLng2); return false;">' + htmlEntities(layer.feature.properties.description) + "</a></li>"; str += '<li><a href="#" onclick="latLng2 = L.latLng(' + layer.feature.geometry.coordinates[0][1] + ',' + layer.feature.geometry.coordinates[0][0] + '); jump_to(latLng2); return false;">' + htmlEntities(layer.feature.properties.description).replace('[T]', '🚆️') + "</a></li>";
last_through = layer.feature.properties.through; last_through = layer.feature.properties.through;
} }
}); });