Compare commits

..

2 Commits

28 changed files with 191 additions and 763 deletions

2
.gitignore vendored
View File

@ -1,3 +1 @@
htdocs/tiles/**/
scripts/geojson/*.json
scripts/geojson/**/*.json

9
.gitmodules vendored
View File

@ -1,9 +0,0 @@
[submodule "lifo-dijkstraserv"]
path = lifo-dijkstraserv
url = https://git.notsyncing.net/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 +0,0 @@
Subproject commit 4fcacdfc82ed58f0173062851a4cda713845df82

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

View File

@ -1,16 +0,0 @@
<?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.";
}
?>

View File

@ -1,19 +0,0 @@
#!/bin/bash
function fetch() {
if [[ "$3" != "" ]]; then
fn="$3"
else
fn="$1"
fi
"./fetch_$1.sh" "$2" | json_reformat -m > "$fn.json.tmp"
rm -f "$fn.json"
mv "$fn.json.tmp" "$fn.json"
}
fetch streets
fetch city_outlines
fetch trainlines "Train Lines"
fetch trainlines "Access Paths" trainlines_access
fetch bodiesofwater "Rivers" rivers
fetch bodiesofwater "Oceans, Seas, and Lakes" oceans

View File

@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>LinuxWorks Minetest Map [beta]</title>
<title>LinuxWorks Minetest Map (unofficial)</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="fa/css/all.css">
<link rel="stylesheet" href="awesomemarkers/dist/leaflet.awesome-markers.css">
<link rel="stylesheet" href="awesomemarkers/leaflet.awesome-markers.css">
<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="awesomemarkers/dist/leaflet.awesome-markers.js"></script>
<script src="awesomemarkers/leaflet.awesome-markers.js"></script>
<!-- Streets -->
<script src='leafletjs/ctxtextpath.js'></script>
<script src='leafletjs/L.LabelTextCollision.js'></script>
@ -48,7 +48,7 @@
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */
}
</style>
<script src="mapscript.js?v3"></script>
<script src="mapscript.js"></script>
<script src="streeteditor.js"></script>
</body>
</html>

View File

@ -42,7 +42,8 @@ L.StreetLabels = L.LabelTextCollision
_text: function (ctx, layer) {
if (layer && layer.feature && layer.feature.properties && layer.feature.properties[this.options.propertyName] !== undefined) {
if (layer && layer.feature && layer.feature.properties && layer.feature.properties[this.options.propertyName] !== 'undefined') {
if (this.options.showLabelIf) {
if (this.options.showLabelIf.call(this, layer.feature) === false) {
return;
@ -79,8 +80,10 @@ L.StreetLabels = L.LabelTextCollision
ctx.lineWidth = this.options.fontStyle.lineWidth;
var fontSize = this.options.fontStyle.fontSize;
if (this._map && this.options.fontStyle.dynamicFontSize === true) {
fontSize = this._getDynamicFontSize(layer.feature);
fontSize = this._getDynamicFontSize();
}
ctx.font = fontSize + this.options.fontStyle.fontSizeUnit + " 'Helvetica Neue',Helvetica,Arial,sans-serif";
@ -94,7 +97,8 @@ L.StreetLabels = L.LabelTextCollision
L.point(p.x + offsetX, p.y + offsetY), L.point(
textWidth, textHeight));
if (this._getCollisionFlag(layer)) {
if (this.options.collisionFlg) {
for (var index in this._textList) {
var pointBounds = this._textList[index];
if (pointBounds.intersects(bounds)) {
@ -105,6 +109,7 @@ L.StreetLabels = L.LabelTextCollision
this._textList.push(bounds);
ctx.fillStyle = this.options.fontStyle.fillStyle;
ctx.strokeStyle = this.options.fontStyle.strokeStyle;
@ -112,7 +117,8 @@ L.StreetLabels = L.LabelTextCollision
var textLength = ctx.measureText(layerText).width;
ctx.strokeText(layerText, p.x + offsetX - textLength / 2, p.y + offsetY);
ctx.fillText(layerText, p.x + offsetX - textLength / 2, p.y + offsetY);
} else if (layer instanceof L.Polyline) {
}
if (layer instanceof L.Polyline) {
/**
* Render text alongside the polyline
* **/
@ -125,7 +131,7 @@ L.StreetLabels = L.LabelTextCollision
if (layer._parts) {
ctx.textAlign = "center";
ctx.textBaseline = "middle";
//ctx.lineWidth = 3;
ctx.lineWidth = 3;
layer._parts.forEach(function (part) {
//Build the points list for the first part
var pathPoints = [];
@ -142,10 +148,6 @@ L.StreetLabels = L.LabelTextCollision
}
},
_getCollisionFlag: function (layer) {
return this.options.collisionFlg;
},
/***
* Returns the bearing in degrees clockwise from north (0 degrees)
from the first L.LatLng to the second, at the first LatLng
@ -183,7 +185,7 @@ L.StreetLabels = L.LabelTextCollision
return polyline;
},
_getDynamicFontSize: function (layer) {
_getDynamicFontSize: function () {
return parseInt(this._map.getZoom());
},

View File

@ -1,136 +1,21 @@
var editor_mode = 0;
var mymap;
var polyconf_show_street_names = 5; // Zoom level for when to start showing street names
var polyconf_show_cities = 5; /* City outlines will be filled on this level and further away */
var polyconf_show_districts = 4; /* Shown from polyconf_show_cities until this*/
var polyconf_show_oceans = 5; // Show ocean labels from zoom level
var dijkstraserv_base = "https://notsyncing.net/dijkstra/";
var wikiurl_base = "https://wiki.linux-forks.de/mediawiki/index.php/"
var tiles_base = "https://notsyncing.net/maps.linux-forks.de/tiles/"
var streetLabelsRenderer = new L.StreetLabels({
collisionFlg: true,
propertyName: 'name',
showLabelIf: function (layer) {
switch (layer.feature.geometry.type) {
case "LineString":
if (mymap.getZoom() <= polyconf_show_street_names)
return false;
break;
case "Polygon":
if (layer.myName == "Oceans")
return (mymap.getZoom() > polyconf_show_oceans);
if (mymap.getZoom() > polyconf_show_street_names)
return false;
break;
default:
return false;
}
return true;
return layer.geometry.type == "LineString";
},
fontStyle: {
dynamicFontSize: true,
dynamicFontSize: false,
fontSize: 10,
fontSizeUnit: "px",
lineWidth: 3.0,
lineWidth: 4.0,
fillStyle: "black",
strokeStyle: "white"
strokeStyle: "white",
},
});
streetLabelsRenderer._getCollisionFlag = function (layer) {
if (!(layer instanceof L.Polygon)) // Always check collision for streets
return true;
zoom = mymap.getZoom();
return (zoom < 5);
}
streetLabelsRenderer._getDynamicFontSize = function (layer) {
zoom = mymap.getZoom();
switch (layer.myName) {
case "Oceans":
return size *= 2.0/3;;
break;
default:
switch (layer.feature.geometry.type) {
case "LineString":
if (zoom <= 8)
return 11;
else
return 2**(zoom - 9) * 11;
break;
case "Polygon":
var size;
if (zoom >= 4)
size = 30;
else
size = 20;
switch (layer.feature.properties.type) {
case "city":
break;
case "town":
size *= 2.0/3.0;
break;
case "village":
size *= 1.5/3;
break;
case "district":
size *= 2.0/3;
break;
default:
size *= 0.5/3;
break;
}
return size;
default:
break;
}
}
return 10;
}
var style_outlines = {
radius: 8,
fillColor: "#ff7800",
color: "black",
opacity: 1.0,
fillOpacity: 0.5
};
var style_streets = {
};
var style_trains = {
color: "yellow"
};
var style_tech = {
color: "red"
};
var style_rivers = {
color: "blue",
fillColor: "#00999955",
};
var style_oceans = {
color: "#00556655",
fillColor: "#00999955",
};
var style_route = {
radius: 8,
fillColor: "#00ff00",
color: "red",
opacity: 1.0,
fillOpacity: 0.5
};
// Projection fix from: https://gis.stackexchange.com/questions/200865/leaflet-crs-simple-custom-scale
var factorx = 1 / 256 * 4;
var factory = factorx;
@ -164,7 +49,7 @@ mymap = L.map('mapid', {
renderer: streetLabelsRenderer,
editable: true,
crs: L.CRS.pr
}).setView([0, 0], 5);
}).setView([0, 0], 6);
var mapheight = 16384;
var mapwidth = mapheight;
@ -200,17 +85,13 @@ function load_svg(name, url, active=1) {
}
function load_tiles(name, id) {
var url = "";
if (name != "") {
url = tiles_base + '{id}/{z}/{y}/{x}.png';
}
var satellite = new L.TileLayer(url, {
var satellite = L.tileLayer('https://notsyncing.net/maps.linux-forks.de/tiles/?id={id}&z={z}&x={x}&y={y}', {
maxZoom: 14 /*8*/,
maxNativeZoom: 6,
minNativeZoom: 0,
minZoom: 0,
noWrap: true,
attribution: 'Map data &copy; <a href="' + wikiurl_base + 'Maps">Linux-Forks</a>',
attribution: 'Map data &copy; <a href="https://wiki.linux-forks.de/mediawiki/index.php/Maps">Linux-Forks</a>, ' + 'All rights reserved, ',
id: id,
tileSize: 256,
zoomOffset: 0,
@ -221,46 +102,20 @@ function load_tiles(name, id) {
return satellite;
}
var current_location = "";
var current_feature = null;
var current_layer = null;
function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
function load_geojson(name, url, iconname, iconcolor, active=1, style={}) {
var xhttp_ps = new XMLHttpRequest();
xhttp_ps.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
onEachFeature = null;
pointToLayer = null;
filter = null;
switch (geotype) {
switch (iconname) {
case "street":
case "train":
onEachFeature = function(feature, layer) {
layer.myTag = geotype;
layer.myName = name;
if (geotype == "train")
layer.no_search = true
layer.on("click", function (e) {
current_layer = layer;
current_feature = feature;
});
};
break;
case "outline":
onEachFeature = function(feature, layer) {
layer.myTag = geotype;
layer.myName = name;
layer.on("click", function (e) {
current_location = feature.properties.name;
});
}
onEachFeature = null;
pointToLayer = null;
break;
default: /* else it is a marker with the specified icon */
onEachFeature = function(feature, layer) {
layer.myName = name;
label = String(feature.properties.name)
layer.bindPopup('<h1><a target="_blank" href="' + wikiurl_base + feature.properties.name + '">' + feature.properties.name + '</a> (' + feature.geometry.coordinates + ')</h1>' + '<p><img style="width:100%" src="' + feature.properties.image + '"></p>' + '<p>' + feature.properties.description + '</p>');
layer.bindPopup('<h1><a href="https://wiki.linux-forks.de/mediawiki/index.php/' + feature.properties.name + '">' + feature.properties.name + '</a> (' + feature.geometry.coordinates + ')</h1>' + '<p><img style="width:100%" src="' + feature.properties.image + '"></p>' + '<p>' + feature.properties.description + '</p>');
layer.bindTooltip(label, {
permanent: true,
direction: "center",
@ -269,59 +124,7 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
};
pointToLayer = function(feature, latlng) {
label = String(feature.properties.name)
if (geotype == "auto") {
iconname = "star"; // default icon
iconcolor = "orange";
for (var i = 0; i < feature.properties.categories.length; i++) {
category = feature.properties.categories[i].toLowerCase();
switch (category) {
case "stations":
iconname = "train";
iconcolor = "blue";
break;
case "shops":
iconname = "shopping-cart";
iconcolor = "green";
break;
case "city":
case "village":
case "town":
case "settlements":
iconname = "city";
iconcolor = "red";
break;
case "parks":
iconname = "tree";
iconcolor = "green";
break;
case "courts":
iconname = "balance-scale";
iconcolor = "black";
break;
case "train depots":
iconname = "wrench";
iconcolor = "violet";
break;
case "hotels":
iconname = "hotel";
iconcolor = "gray";
break;
case "beaches":
iconname = "umbrella-beach";
iconcolor = "orange";
break;
case "waterway":
iconname = "water";
iconcolor = "blue";
break;
}
if (iconname != "star")
break;
}
} else {
iconname = geotype;
}
marker = new L.marker(latlng,{
return new L.marker(latlng,{
icon: L.AwesomeMarkers.icon({
icon: iconname,
markerColor: iconcolor
@ -331,19 +134,16 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
direction: "center",
opacity: 0.7
}).openTooltip();
return marker;
};
break;
}
var json = JSON.parse(xhttp_ps.responseText);
geojson = L.geoJSON(json, {
var geojson = L.geoJSON(json, {
style: style,
onEachFeature: onEachFeature,
pointToLayer: pointToLayer,
filter: filter
pointToLayer: pointToLayer
});
layers.addOverlay(geojson, name);
if (active)
geojson.addTo(mymap);
return geojson;
@ -357,53 +157,36 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
xhttp_ps.send();
}
load_tiles("Satellite (2020-12-13)", 'world-2020-12-13').addTo(mymap);
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("Satellite (2020-04-09)", 'world-2020-04-09').addTo(mymap);
load_tiles("Satellite (2019-05-04, wrong coords)", 'world-2019-05-04');
load_geojson("All", "./geojson/all.json", "auto", "auto", 0);
load_geojson("Streets", "./geojson/streets.json", "street", "auto", 1, style_streets);
load_geojson("Trainlines (beta)", "./geojson/trainlines.json", "train", "auto", 1, style_trains);
load_geojson("TL Access (tech layer)", "./geojson/trainlines_access.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("Rivers", "./geojson/rivers.json", "street", "auto", 1, style_rivers);
load_geojson("Oceans", "./geojson/oceans.json", "outline", "auto", 1, style_oceans);
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();
//load_svg("Test", "./overlay.svg", 0);
load_geojson("Cities", "./geojson/cities.json", "city", "red");
load_geojson("Stations", "./geojson/stations.json", "train", "blue");
load_geojson("Shops", "./geojson/shops.json", "shopping-cart", "green");
load_geojson("Parks", "./geojson/parks.json", "tree", "darkgreen");
load_geojson("Libraries", "./geojson/libraries.json", "book-open", "darkblue");
load_geojson("CW Complexes", "./geojson/cw_complexes.json", "border-all", "black");
load_geojson("Courts", "./geojson/courts.json", "balance-scale", "black");
load_geojson("Waterway", "./geojson/waterway.json", "water", "darkblue");
load_geojson("Train Depots", "./geojson/depots.json", "wrench", "violet");
load_geojson("Streets", "./geojson/streets.json", "street", "blue", 0);
L.control.scale().addTo(mymap);
function resolve_latlng(latlng, recenter = 0) {
latlng.lng = Math.round(latlng.lng);
latlng.lat = Math.round(latlng.lat);
return latlng;
}
function get_current_location_str() {
var latlng = resolve_latlng(mymap.getCenter());
return latlng.lng + "," + latlng.lat + "," + mymap.getZoom();
var latlng = mymap.getCenter();
return Math.round(latlng.lng) + "," + Math.round(latlng.lat) + "," + mymap.getZoom();
}
/* Important: Do not use mymap.setView, use this function instead */
function jump_to(latlng, zoom = -1) {
if (zoom == -1)
zoom = mymap.getZoom();
if (!editor_mode) {
pos = resolve_latlng(latlng);
document.location.hash = "#" + pos.lng + "," + pos.lat + "," + zoom;
} else {
if (!editor_mode)
document.location.hash = "#" + Math.round(latlng.lng) + "," + Math.round(latlng.lat) + "," + zoom;
else
mymap.setView(latlng, zoom);
}
}
function jump_to_marker(e) {
@ -422,57 +205,28 @@ function prompt_location() {
}
var search_element;
var route_element;
function build_sidebar() {
function toggle_search() {
if (el = document.getElementById('searchbar')) {
el.parentNode.removeChild(el);
return;
}
if (!search_element) {
search_element = document.createElement("div");
search_element.style.overflow = "scroll";
search_element.style.padding = "6px";
search_element.style.height = "100%";
search_element.innerHTML = '<input style="width:100%;" id="search_query" name="lifo_map_search" type="search" placeholder="Start typing to search..." oninput="search(event)"><div id="search_results"></div>';
}
if (!route_element) {
route_element = document.createElement("div");
route_element.style.overflow = "scroll";
route_element.style.padding = "6px";
route_element.style.height = "100%";
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>';
}
}
var current_sidebar = "search";
function toggle_search(type = current_sidebar, force_act = 0) {
if (el = document.getElementById('sidebar')) {
el.parentNode.removeChild(el);
if (force_act == 0 && type == current_sidebar)
return;
search_element.innerHTML = '<input style="width:100%;" id="search_query" name="lifo_map_search" type="search" placeholder="Start typing to search..." onkeypress="search(event)"><div id="search_results"></div>' ;
}
td = document.getElementById('windowtr').insertCell(0);
td.style.width = "400px";
td.style.borderRight = "1px solid black";
td.style.verticalAlign = "top";
td.id = "sidebar";
td.id = "searchbar";
td.appendChild(search_element);
switch (type) {
case "search":
td.appendChild(search_element);
document.getElementById('search_query').select();
break;
case "route":
td.appendChild(route_element);
break;
default:
alert("JS error: sidebar");
break;
}
current_sidebar = type;
document.getElementById('search_query').focus();
}
function htmlEntities(str) {
@ -488,16 +242,10 @@ function polyline_get_middle_coords(coords) {
var highlighted_line;
var default_street_color = "#3388ff";
function search(e) {
var query = document.getElementById("search_query").value;
var real_query = true;
var query = htmlEntities(document.getElementById("search_query").value);
document.getElementById('search_results').innerHTML = "";
if (true) {
if (query.length == 0) {
real_query = false;
query = "!@#$%^&"; // Cheap workaround to (hopefully) match nothing
}
if (query.length > 0 || e.key == "Enter") {
results = document.createElement("ul");
for (var i = 0; i < layers._layers.length; i++) {
if (!layers._layers[i].layer._layers)
@ -505,21 +253,13 @@ function search(e) {
for (key in layers._layers[i].layer._layers) {
item = layers._layers[i].layer._layers[key];
if (item.hasOwnProperty("no_search"))
break;
switch (item.feature.geometry.type) {
case "Point":
regex = new RegExp(query, 'i');
if (item.feature.properties.name.match(regex)) {
el = document.createElement("li");
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="layers._layers[' + i + '].layer._layers[' + item._leaflet_id + '].fire(\'click\'); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="layers._layers[' + i + '].layer._layers[' + item._leaflet_id + '].fire(\'click\'); return false;">' + item.feature.properties.name + "</a>";
results.appendChild(el);
item.setOpacity(1.0); // TODO: setOpacity does not disable hover and click events
} else {
if (real_query)
item.setOpacity(0.0); // TODO
else
item.setOpacity(1.0); // TODO
}
break;
case "LineString":
@ -530,21 +270,12 @@ function search(e) {
regex = new RegExp(query, 'i');
if (item.feature.properties.name.match(regex)) {
console.log(item.options.color);
item.options.color = "#FF0000";
item.redraw();
el = document.createElement("li");
zpos = polyline_get_middle_coords(item.feature.geometry.coordinates);
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos[1] + ',' + zpos[0] + '); jump_to(latLng2); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
results.appendChild(el);
}
break;
case "Polygon":
regex = new RegExp(query, 'i');
if (item.feature.properties.name.match(regex)) {
el = document.createElement("li");
zpos = resolve_latlng(layers._layers[i].layer._layers[item._leaflet_id].getCenter());
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos.lat + ',' + zpos.lng + '); jump_to(latLng2, ' + polyconf_show_cities + '); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos[1] + ',' + zpos[0] + '); jump_to(latLng2); return false;">' + item.feature.properties.name + "</a>";
results.appendChild(el);
}
break;
@ -558,67 +289,6 @@ function search(e) {
return false;
}
var route_layer;
function route(e) // BOOKMARK
{
if (route_layer) {
mymap.removeLayer(route_layer);
}
start = document.getElementById('route_start').value;
destination = document.getElementById('route_destination').value;
if ((start == "") || (destination == "")) {
document.getElementById('route_results').innerHTML = "";
return;
}
document.getElementById('route_submit').disabled = true;
document.getElementById('route_results').innerHTML = "Loading...";
var xhttp_ps = new XMLHttpRequest();
xhttp_ps.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
var json = JSON.parse(xhttp_ps.responseText);
geojson = L.geoJSON(json, {
style: style_route
});
route_layer = geojson.addTo(mymap);
str = "<ol>";
last_through = "";
geojson.eachLayer( function(layer) {
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).replace('[T]', '🚆️') + "</a></li>";
last_through = layer.feature.properties.through;
}
});
str += "</ol>";
document.getElementById('route_results').innerHTML = str;
} else {
document.getElementById('route_results').innerHTML = "No results.";
}
document.getElementById('route_submit').disabled = false;
}
};
coordstr = start + ';' + destination;
xhttp_ps.open("GET", dijkstraserv_base + coordstr, true);
xhttp_ps.send();
}
function set_route_start(latlng) {
toggle_search("route", 1);
document.getElementById('route_start').value = latlng.lat + ',' + latlng.lng;
route();
}
function set_route_destination(latlng) {
toggle_search("route", 1);
document.getElementById('route_destination').value = latlng.lat + ',' + latlng.lng;
route();
}
L.MyControl = L.Control.extend({
options: {
position: 'topleft',
@ -633,13 +303,11 @@ L.MyControl = L.Control.extend({
link.href = '#';
link.title = this.options.title;
link.innerHTML = this.options.html;
L.DomEvent.on(link, 'mousedown', L.DomEvent.stop);
L.DomEvent.on(link, 'mouseup', L.DomEvent.stop);
L.DomEvent.on(link, 'click', L.DomEvent.stop)
.on(link, 'click', function () {
window.LAYER = this.options.callback.call();
}, this);
return container;
.on(link, 'click', function () {
window.LAYER = this.options.callback.call();
}, this);
return container;
}
});
@ -662,31 +330,6 @@ L.GotoControl = L.MyControl.extend({
mymap.addControl(new L.SearchControl());
mymap.addControl(new L.GotoControl());
L.CurrentPosControl = L.Control.extend({
options: {
position : 'bottomleft',
callback: null,
kind: "",
html: ''
},
onAdd: function (map) {
container = L.DomUtil.create('div', 'leaflet-control-scale leaflet-bar');
container.style.visibility = "hidden";
div = L.DomUtil.create('div', '', container);
div.style.backgroundColor = "white";
div.style.paddingLeft = "4px";
div.style.paddingRight = "4px";
div.style.borderRadius = "2px";
div.style.margin = "2px";
div.style.opacity = "0.6";
div.style.fontWeight = "bold";
div.innerHTML = "";
div.id = "current_position_label";
return container;
}
});
mymap.addControl(new L.CurrentPosControl());
var popup = L.popup();
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
@ -695,30 +338,8 @@ var baseballIcon = L.AwesomeMarkers.icon({
markerColor: 'red'
});
function escapeHtml(text) {
return text
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
function onMapClick(e) {
var addinfo = "";
pos = resolve_latlng(e.latlng);
route_links = '<br><a href="#" onclick="latLng2 = L.latLng(' + pos.lng + ',' + pos.lat + '); set_route_start(latLng2); return false;">[route from here]</a>';
route_links += ' <a href="#" onclick="latLng2 = L.latLng(' + pos.lng + ',' + pos.lat + '); set_route_destination(latLng2); return false;">[route to here]</a>';
if (current_location != "")
addinfo = " (part of <a target=\"_blank\" href=\"" + wikiurl_base + encodeURIComponent(current_location) + "\">" + escapeHtml(current_location) + "</a>)";
if (current_feature) {
popup.setLatLng(e.latlng).setContent("This is <a target=\"_blank\" href=\"" + wikiurl_base + current_layer.myName + ":" + encodeURIComponent(current_feature.properties.name) + "\">" + escapeHtml(current_feature.properties.name) + "</a>" + addinfo + route_links).openOn(mymap);
} else {
popup.setLatLng(e.latlng).setContent("You clicked the map at " + pos.lng + "," + pos.lat + addinfo + route_links).openOn(mymap);
}
current_feature = null;
current_layer = null;
current_location = "";
popup.setLatLng(e.latlng).setContent("You clicked the map at " + e.latlng.toString()).openOn(mymap);
}
mymap.on('click', onMapClick);
@ -745,81 +366,25 @@ function update_aa_status() {
document.getElementById('mapid').classList.remove("no-aa");
}
function update_street_width() {
zoom = mymap.getZoom();
var w;
if (zoom <= 6) {
w = 2;
} else {
w = 2**zoom * 0.016 * 2;
}
var myStyle = {weight: w, opacity: 0.7};
mymap.eachLayer( function(layer) {
if ( layer.myTag && layer.myTag === "street") {
layer.setStyle(myStyle);
}
});
}
function update_outline_visibility() {
zoom = mymap.getZoom();
mymap.eachLayer( function(layer) {
if ( layer.myTag && layer.myTag === "outline") {
var fillOpacity;
if (zoom <= polyconf_show_cities)
fillOpacity = 0.5;
//else if (zoom == polyconf_show_cities + 1)
// opacity = 0.2;
else
fillOpacity = 0.0;
layer.setStyle({fillOpacity: fillOpacity});
}
});
}
function update_current_mouse_position(e) {
var lbl = document.getElementById('current_position_label');
if (e.type == "mouseout") {
lbl.parentElement.style.visibility = "hidden";
return;
}
lbl.parentElement.style.visibility = "visible";
pos = resolve_latlng(e.latlng);
lbl.innerHTML = pos.lng + "," + pos.lat;
}
mymap.on('zoomend', function () {is_user_drag = 1; update_hash_from_position();});
mymap.on('zoomend', update_aa_status);
mymap.on('zoomend', update_street_width);
mymap.on('zoomend', update_outline_visibility);
mymap.on('moveend', update_hash_from_position);
mymap.on('dragstart', function () { is_user_drag = 1;});
mymap.on('keydown', function (e) { if (e.originalEvent.code.match(/Arrow.*/)) is_user_drag = 1;});
mymap.on('overlayadd', function (e) { update_street_width(); update_outline_visibility(); });
mymap.on('mousemove', update_current_mouse_position);
mymap.on('mouseout', update_current_mouse_position);
function onHashChange(e, hash=null) {
if (!hash)
hash = document.location.hash;
if (hash == "")
return;
if (hash == "#" + get_current_location_str())
return; // We're already there
coordstr = decodeURIComponent(hash.slice(1)).split(",");
coordstr = hash.slice(1).replace(/%20/g, "").split(",");
if (coordstr.length < 2)
coordstr.push(0); // Default y
if (coordstr.length < 3)
coordstr.push(mymap.getZoom()); // Default zoom
var latlng = L.latLng(parseFloat(coordstr[1]), parseFloat(coordstr[0]));
mymap.setView(latlng, parseInt(coordstr[2]));
if (coordstr.length > 3) { /* Drop named marker */
foo = L.marker(latlng).bindPopup(htmlEntities(coordstr[3])).addTo(mymap).openPopup();
}
}
build_sidebar();
window.addEventListener("hashchange", onHashChange, false);
onHashChange(null);

View File

@ -3,20 +3,16 @@ const urlParams = new URLSearchParams(queryString);
editor_mode = urlParams.has('editor');
if (editor_mode) {
var editor_mode_polygon = urlParams.has('polygon');
var draw_layer;
var polyline;
var edit_active = 0;
var editor_style = {
radius: 8,
fillColor: "#00ff00",
color: "red",
opacity: 1.0,
fillOpacity: 0.5
};
function resolve_latlng(latlng, recenter = 0) {
latlng.lng = Math.round(latlng.lng);
latlng.lat = Math.round(latlng.lat);
return latlng;
}
function start_editing(dir = 1) {
// TODO: Check whether we already are in edit mode
@ -27,10 +23,7 @@ if (editor_mode) {
else
polyline.editor.continueBackward();
} else {
if (editor_mode_polygon)
polyline = mymap.editTools.startPolygon();
else
polyline = mymap.editTools.startPolyline();
polyline = mymap.editTools.startPolyline();
}
}
@ -60,11 +53,11 @@ if (editor_mode) {
if (interactive) {
str = prompt("Instructions: \n" +
"* Click the scribble-icon in the top left to start or continue drawing.\n" +
"* Click last waypoint to stop drawing.\n" +
"* Click a waypoint to delete it.\n" +
"* Double click last waypoint to stop.\n" +
"* Double click a waypoint to delete it.\n" +
"* Click save in the top right to get the new string.\n\n" +
"Enter existing waypoints in the following format: [x,y],[x,y]:", window.location.hash.slice(1));
if (str == undefined)
if (!str)
return;
} else {
str = window.location.hash.slice(1);
@ -80,10 +73,7 @@ if (editor_mode) {
for (var i = 0; i < coords.length; i++) {
coords[i] = [coords[i][1], coords[i][0]];
}
if (editor_mode_polygon)
polyline = L.polygon([coords], editor_style).addTo(mymap);
else
polyline = L.polyline(coords, editor_style).addTo(mymap);
polyline = L.polyline(coords).addTo(mymap);
// polyline.on('dragend', onDragEnd); // TODO: Doesn't work, see "workaround" below
polyline.enableEdit();
if (interactive) {
@ -103,24 +93,12 @@ if (editor_mode) {
window.addEventListener("hashchange", editor_onHashChange, false);
window.addEventListener("mouseup", onDragEnd, false); // Workaround as polyline.on(dragend, ) doesn't seem to work
function onMapKeydown(e) {
if (e.originalEvent.key == "Escape") {
if (polyline)
polyline.editor.cancelDrawing();
}
}
// Configure map for better editing
mymap.setMaxZoom(14);
mymap.off('click', onMapClick);
mymap.on('keydown', onMapKeydown);
function get_location_string() {
var latlngs;
if (editor_mode_polygon)
latlngs = polyline.getLatLngs()[0];
else
latlngs = polyline.getLatLngs();
var latlngs = polyline.getLatLngs();
var str = "";
for (var i = 0; i < latlngs.length; i++) {
@ -134,8 +112,6 @@ if (editor_mode) {
}
function show_location_string(e) {
if (polyline)
polyline.editor.cancelDrawing();
prompt("Copy this string back into the Wiki and wait for the server to refresh the maps:", get_location_string());
}
@ -157,12 +133,10 @@ if (editor_mode) {
link.href = '#';
link.title = this.options.title;
link.innerHTML = this.options.html;
L.DomEvent.on(link, 'mousedown', L.DomEvent.stop);
L.DomEvent.on(link, 'mouseup', L.DomEvent.stop);
L.DomEvent.on(link, 'click', L.DomEvent.stop)
.on(link, 'click', function (e) {
window.LAYER = this.options.callback.call(map.editTools);
}, this);
.on(link, 'click', function () {
window.LAYER = this.options.callback.call(map.editTools);
}, this);
return container;
}
});

3
htdocs/tiles/index.php Normal file
View File

@ -0,0 +1,3 @@
<?php
?>

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

View File

@ -1,62 +0,0 @@
#!/bin/bash
OUTDIR=`pwd`/tiles
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
mode="$1"
if [ "$mode" == "legacy" ]; then
MAPSERVER='http://old-maps.li-fo.de/'
FILES=`curl "$MAPSERVER" | sed -n 's/.*<a href="\([^\.]\+\.png\).*/\1/p'`
else
MAPSERVER='https://lifomaps.de'
FILES=`curl "$MAPSERVER" | sed -n 's/.*>\(world-[0-9\-]\+\.png\).*/\1/p'`
fi
if [[ "$FILES" == "" ]]; then
echo "ERROR: Could not detect latest map file."
exit
fi
for FILE in $FILES; do
REMOTE_URL="$MAPSERVER/$FILE"
LOCAL_FILE="`echo $FILE | sed 's#.*/##'`"
LOCAL_URL="$OUTDIR/$LOCAL_FILE"
MAPNAME=`echo $LOCAL_URL | sed 's/.*\/\([^\.]\+\).*/\1/g'`
echo "# Downloading and converting $MAPNAME."
mkdir -p $OUTDIR
cd $OUTDIR
if [ ! -d "$OUTDIR/$MAPNAME" ]; then
echo "Downloading latest map file..."
curl -C - "$REMOTE_URL" -o "$LOCAL_URL"
if [ "$mode" == "legacy" ]; then
echo "Patching map (for map exports prior to 2019-07-09)..."
OSIZE=`file $LOCAL_URL | sed -n 's/.*PNG image data, \([0-9]\+\).*/\1/p'`
NSIZE=$(($OSIZE+1008))
RESIZED_URL="$LOCAL_URL-temp.png"
convert $LOCAL_URL -gravity SouthEast -extent ${NSIZE}x${NSIZE} $RESIZED_URL
rm $LOCAL_URL
mv $RESIZED_URL $LOCAL_URL
fi
echo "Resizing map..."
OSIZE=`file $LOCAL_URL | sed -n 's/.*PNG image data, \([0-9]\+\).*/\1/p'`
NSIZE=$((2**6 * 256))
RESIZED_URL="$LOCAL_URL-resized.png"
convert $LOCAL_URL -extent ${NSIZE}x${NSIZE} -gravity NorthWest $RESIZED_URL
echo "Converting map..."
$SCRIPT_DIR/convert_maps.sh $MAPNAME $RESIZED_URL
echo "Cleaning up..."
rm $RESIZED_URL
rm $LOCAL_URL
else
echo "Skipping $MAPNAME."
fi
done

View File

@ -11,8 +11,8 @@
# `convert $MAPFILE -extent ${crop}x${crop} -gravity NorthWest $MAPFILE.scaled.png`
TILESIZE=256
MAPNAME="$1"
MAPFILE="$2"
MAPNAME="world-2020-04-09"
MAPFILE="../$MAPNAME.png"
width=`file "$MAPFILE" | sed -n "s/.* \([0-9]\+\) x \([0-9]\+\).*/\1/p"`
crop=$TILESIZE
@ -41,7 +41,7 @@ while true; do
fi
echo " Generating tiles..."
convert $tempfile -crop ${TILESIZE}x${TILESIZE} +adjoin $out/%d.png
convert $tempfile -crop ${TILESIZE}x${TILESIZE} +adjoin $out/%05d.png
rm $tempfile
@ -51,16 +51,3 @@ while true; do
crop=$(($crop * 2))
zoom=$(($zoom + 1))
done;
echo "Renaming files..."
for (( z=0; z<=$zoom; z++ )) {
echo "Zoom level $z"
fac=$((2**$z))
for (( y=0; y<$fac; y++ )) {
outdir="$MAPNAME/$z/$y"
mkdir $outdir
for (( x=0; x<$fac; x++ )) {
mv $MAPNAME/$z/$(($fac * y + $x)).png $outdir/$x.png
}
}
}

4
scripts/geojson/common.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
LIFO_SERVER="https://wiki.linux-forks.de"
CURLOPTS=( '-b' "/path/to/auth-cookies.txt" )

30
scripts/geojson/fetch.sh Executable file
View File

@ -0,0 +1,30 @@
fetch_category () {
echo "Fetching $1" > /dev/stderr
json=`curl "https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:$1&cmlimit=max" 2>/dev/null`
cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '`
num=`echo $cities | tr ' ' '\n' | wc -l`
i=0
echo "["
for city in $cities; do
let i++
echo -n -e "\rFetched $i/$num" > /dev/stderr
./fetch_single.sh "$city"
done
echo > /dev/stderr
echo "{}]"
}
JSONDIR=../../htdocs/geojson
mkdir -p $JSONDIR
fetch_category Shops > $JSONDIR/shops.json
fetch_category City > $JSONDIR/cities.json
fetch_category Stations > $JSONDIR/stations.json
fetch_category Parks > $JSONDIR/parks.json
fetch_category Libraries > $JSONDIR/libraries.json
fetch_category "CW_Complexes" > $JSONDIR/cw_complexes.json
fetch_category Courts > $JSONDIR/courts.json
fetch_category Waterway > $JSONDIR/waterway.json
fetch_category Train_Depots > $JSONDIR/depots.json

View File

@ -1,35 +0,0 @@
#!/bin/bash
json=`curl -s 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=search&redirects=1&converttitles=1&srsearch=%7B%7BCo%7C&srlimit=max&srwhat=text&srprop=snippet'`
data=`echo "$json" | json_reformat`;
echo "[";
IFS=$'\n';
for line in $data; do
temp=`echo "$line" | sed -n 's/^\s*{\s*$/END/p'`
if [[ "$temp" == "END" ]]; then
title="";
coords="";
fi
temp=`echo "$line" | sed -n 's/\s*"title": "*\([^"]\+\).*/\1/p'`
if [[ "$temp" != "" ]]; then
title="$temp";
fi
temp=`echo "$line" | sed -n 's#.*<span class=.searchmatch.>Co<\/span>|\([0-9\-]\+\)|\([0-9\-]\+\)|\([0-9\-]\+\).*#\1,\3#p'`
if [[ "$temp" != "" ]]; then
coords="$temp";
fi
if [[ "$title" != "" && "$coords" != "" ]]; then
echo "{\"type\": \"Feature\", \"properties\": {\"name\": \"$title\","
urltitle=`echo "$title" | sed 's/ /_/g'`
./get_rendered_meta.sh "https://wiki.linux-forks.de/mediawiki/index.php/$urltitle"
echo "},";
echo "\"geometry\": {\"type\": \"Point\", \"coordinates\": [$coords]}},";
title="";
coords="";
fi
done
IFS=" ";
echo "{}]";

View File

@ -2,7 +2,7 @@
source common.sh
json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:BodiesOfWater'`
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:BodiesOfWater'`
data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
section=""

10
scripts/geojson/fetch_cities.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:City&cmlimit=100'`
cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '`
echo "["
for city in $cities; do
./fetch_single.sh "$city"
done
echo "{}]"

View File

@ -2,7 +2,7 @@
source common.sh
json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'`
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'`
data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
echo "["

10
scripts/geojson/fetch_shops.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:Shops&cmlimit=1000' 2>/dev/null`
cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '`
echo "["
for city in $cities; do
./fetch_single.sh "$city"
done
echo "{}]"

31
scripts/geojson/fetch_single.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
json=`curl "https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=$1&rvsection=0&rvslots=main" 2>/dev/null | sed -s "s/\\\\\\\\n//g"`
title=`echo $json | sed -n 's/.*"title":\s*"\([^"]\+\).*/\1/p'`
img=$(curl "https://wiki.linux-forks.de/mediawiki/index.php/$1" 2>/dev/null | sed s/\"/\\n/g | grep /thumb/ | head -n 1)
image="https://wiki.linux-forks.de$img"
coords=`echo "$json" | sed -n "s/.*coordinates = {{Co|\([^}]*\).*/\1/p"`
coord_x=`echo "$coords" | sed -n "s/\([^|]\+\).*/\1/p"`
coord_y=`echo "$coords" | sed -n "s/.*|\([^|]\+\).*/\1/p"`
description=`curl "https://wiki.linux-forks.de/mediawiki/api.php?action=parse&page=$1&section=0&prop=text&format=json" 2>/dev/null | sed -z -n "s/<\/p><p>//g;s/.*<p>\(.*\)<\/p>.*/\1/p" | sed s,\"/mediawiki/index.php,\"https://wiki.linux-forks.de/mediawiki/index.php,g`
if [[ "$coord_x" != "" && "$coord_y" != "" ]]; then
echo "{\
\"type\": \"Feature\",\
\"properties\": {\
\"name\": \"$title\",\
\"amenity\": \"City\",\
\"description\": \"$description\",\
\"image\": \"$image\"\
},\
\"geometry\": {\
\"type\": \"Point\",\
\"coordinates\": [$coord_x, $coord_y]\
}\
},"
fi

View File

@ -0,0 +1,10 @@
#!/bin/bash
json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:Stations&cmlimit=1000' 2>/dev/null`
cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '`
echo "["
for city in $cities; do
./fetch_single.sh "$city"
done
echo "{}]"

View File

@ -4,7 +4,7 @@
source common.sh
json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Streets'`
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Streets'`
data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
echo "["

View File

@ -2,7 +2,7 @@
source common.sh
json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Trainlines'`
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Trainlines'`
data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
section=""

View File

@ -1,49 +0,0 @@
#!/bin/bash
BASE="https://wiki.linux-forks.de"
mode="find_description"
thumbnail=""
categories=""
data=`curl -s "$1"`
temp=`echo "$data" | sed -n 's/<p>\(.\+\).*/\1/p' | grep -v -e '^<br />$' | sed 's#^</p>##' | head -n1`
if [ "$temp" != "" ]; then
temp=`echo "$temp" | sed "s#href=\"#href=\"$BASE#g" | sed 's/"/\\\\"/g' | sed 's/\t//g'`
description="$temp"
mode="find_infobox";
fi
IFS=$'>';
for line in $data; do
if [ "$mode" == "find_infobox" ]; then
if [ "`echo \"$line\" | grep 'infobox'`" != "" ]; then
mode="image";
fi
elif [ "$mode" == "image" ]; then
temp=`echo "$line" | sed -n 's/.*img.*src="\([^"]\+\).*/\1/p'`;
if [ "$temp" != "" ]; then
thumbnail="$BASE$temp"
mode="find_cat"
fi
elif [ "$mode" == "find_cat" ]; then
if [ "`echo \"$line\" | grep 'mw-normal-catlinks'`" != "" ]; then
mode="cat";
fi
elif [ "$mode" == "cat" ]; then
temp=`echo "$line" | sed -n 's/.*title="Category:\([^"]\+\).*/\1/pg' | grep -v 'page does not exist'`
if [ "$temp" != "" ]; then
if [ "$categories" != "" ]; then
categories="$categories,"
fi
categories="$categories\"$temp\""
fi
fi
done
IFS=" ";
echo "\"categories\": [$categories],"
echo "\"image\": \"$thumbnail\","
echo "\"description\": \"$description\""

View File

@ -1,3 +0,0 @@
#!/bin/bash
CURLOPTS=( '-b' "/etc/lifomapserver/cookies.txt" )