mirror of
https://github.com/est31/leaftest.git
synced 2024-12-23 01:10:38 +01:00
Allow set most params in .sh via env. Allow change tilesize and tiles dir.
This commit is contained in:
parent
a470106c84
commit
0d15c3a66c
29
mapper.sh
29
mapper.sh
@ -3,12 +3,11 @@
|
|||||||
MAPDIR=$1
|
MAPDIR=$1
|
||||||
SPAWNPOS=$2
|
SPAWNPOS=$2
|
||||||
DIMENSIONS=$3
|
DIMENSIONS=$3
|
||||||
|
DIMENSIONS=${DIMENSIONS=6144}
|
||||||
|
|
||||||
if [ -z $MAPPERDIR ]; then
|
MAPPERDIR=${MAPPERDIR=.}
|
||||||
MAPPERDIR=.
|
|
||||||
fi
|
|
||||||
|
|
||||||
mapperpath=$MAPPERDIR/minetestmapper
|
mapperpath=${mapperpath=$MAPPERDIR/minetestmapper}
|
||||||
|
|
||||||
if [ ! -f $mapperpath ]; then
|
if [ ! -f $mapperpath ]; then
|
||||||
echo "Error, "$mapperpath" doesn't exist."
|
echo "Error, "$mapperpath" doesn't exist."
|
||||||
@ -35,9 +34,7 @@ else
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$JOBNUM" ]; then
|
JOBNUM=${JOBNUM=1}
|
||||||
JOBNUM=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$JOBNUM" in
|
case "$JOBNUM" in
|
||||||
''|*[!0-9]*) echo "Bad number of jobs '$JOBNUM'. Please specify a positive integer." ; exit 1 ;;
|
''|*[!0-9]*) echo "Bad number of jobs '$JOBNUM'. Please specify a positive integer." ; exit 1 ;;
|
||||||
@ -66,16 +63,20 @@ eval $prefix_func
|
|||||||
#bash -c "$prefix_pipefail ; (echo -e 'a\nb\nc\n' ; false) | prefix 'PREF '" || echo "ERR"
|
#bash -c "$prefix_pipefail ; (echo -e 'a\nb\nc\n' ; false) | prefix 'PREF '" || echo "ERR"
|
||||||
#exit 1
|
#exit 1
|
||||||
|
|
||||||
scriptdir=`readlink -f $0`
|
if [ -z "$scriptdir" ]; then
|
||||||
scriptdir=`dirname $scriptdir`
|
scriptdir=`readlink -f $0`
|
||||||
|
scriptdir=`dirname $scriptdir`
|
||||||
|
fi
|
||||||
|
|
||||||
tiledir=$scriptdir/www/tiles
|
tiledir=${tiledir=$scriptdir/www/tiles}
|
||||||
|
|
||||||
spawnx=${SPAWNPOS%%,*}
|
spawnx=${SPAWNPOS%%,*}
|
||||||
|
spawnx=${spawnx=0}
|
||||||
spawny=${SPAWNPOS##*,}
|
spawny=${SPAWNPOS##*,}
|
||||||
|
spawny=${spawny=0}
|
||||||
#echo "spawn position: $spawnx $spawny"
|
#echo "spawn position: $spawnx $spawny"
|
||||||
tilesize=256
|
tilesize=${tilesize=256}
|
||||||
zoomlevelnum=3
|
zoomlevelnum=${zoomlevelnum=3}
|
||||||
|
|
||||||
tilenum=$(($DIMENSIONS/$tilesize))
|
tilenum=$(($DIMENSIONS/$tilesize))
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ do
|
|||||||
dir=$tiledir/$zoomlevel
|
dir=$tiledir/$zoomlevel
|
||||||
dirb=$tiledir/$zoomlevelbefore
|
dirb=$tiledir/$zoomlevelbefore
|
||||||
mkdir -p $dir
|
mkdir -p $dir
|
||||||
rm -f ${dir}/20/*
|
rm -f ${dir}/*
|
||||||
for x in $(seq 0 $tnum)
|
for x in $(seq 0 $tnum)
|
||||||
do
|
do
|
||||||
for y in $(seq 0 $tnum)
|
for y in $(seq 0 $tnum)
|
||||||
@ -144,4 +145,4 @@ done
|
|||||||
|
|
||||||
zoommin=$((20-$zoomlevelnum))
|
zoommin=$((20-$zoomlevelnum))
|
||||||
#write the resulting config into a json file
|
#write the resulting config into a json file
|
||||||
echo "{\"mapsize\":$DIMENSIONS, \"spawn\":{\"x\":$spawnx,\"y\":$spawny}, \"zoommin\":$zoommin}" > $scriptdir/www/conf.json
|
echo "{\"mapsize\":$DIMENSIONS, \"spawn\":{\"x\":$spawnx,\"y\":$spawny}, \"zoommin\":$zoommin, \"tilesize\":$tilesize}" > ${conffile=$tiledir/conf.json}
|
||||||
|
10
www/map.js
10
www/map.js
@ -1,3 +1,4 @@
|
|||||||
|
var tilesdir = 'tiles/';
|
||||||
var xmlhttp = new XMLHttpRequest();
|
var xmlhttp = new XMLHttpRequest();
|
||||||
xmlhttp.onreadystatechange = function() {
|
xmlhttp.onreadystatechange = function() {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
@ -5,7 +6,7 @@ xmlhttp.onreadystatechange = function() {
|
|||||||
loadmap(config);
|
loadmap(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xmlhttp.open("GET", "conf.json", true);
|
xmlhttp.open("GET", tilesdir + "conf.json", true);
|
||||||
xmlhttp.overrideMimeType("application/json"); //to silence browser warnings when started without a server
|
xmlhttp.overrideMimeType("application/json"); //to silence browser warnings when started without a server
|
||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
|
|
||||||
@ -13,8 +14,9 @@ function loadmap(config) {
|
|||||||
var mapsize = config.mapsize;
|
var mapsize = config.mapsize;
|
||||||
var spawn = config.spawn;
|
var spawn = config.spawn;
|
||||||
var zoommin = config.zoommin;
|
var zoommin = config.zoommin;
|
||||||
|
var tilesize = config.tilesize;
|
||||||
var xb= 0-spawn.x+mapsize/2;
|
var xb= 0-spawn.x+mapsize/2;
|
||||||
var yb= 0-spawn.y-mapsize/2-256;
|
var yb= 0-spawn.y-mapsize/2-tilesize;
|
||||||
var bnd = new L.LatLngBounds();
|
var bnd = new L.LatLngBounds();
|
||||||
bnd.extend(L.latLng([spawn.x-mapsize/2, spawn.y-mapsize/2]));
|
bnd.extend(L.latLng([spawn.x-mapsize/2, spawn.y-mapsize/2]));
|
||||||
bnd.extend(L.latLng([spawn.x+mapsize/2, spawn.y+mapsize/2]));
|
bnd.extend(L.latLng([spawn.x+mapsize/2, spawn.y+mapsize/2]));
|
||||||
@ -41,10 +43,10 @@ function loadmap(config) {
|
|||||||
})
|
})
|
||||||
}).setView([0,0], 22);
|
}).setView([0,0], 22);
|
||||||
map.setView([spawn.x,spawn.y]);
|
map.setView([spawn.x,spawn.y]);
|
||||||
L.tileLayer('tiles/{z}/map_{x}_{y}.png', {
|
L.tileLayer(tilesdir + '{z}/map_{x}_{y}.png', {
|
||||||
maxZoom: 26,
|
maxZoom: 26,
|
||||||
maxNativeZoom: 20,
|
maxNativeZoom: 20,
|
||||||
tileSize: 256,
|
tileSize: tilesize,
|
||||||
continuousWorld: true
|
continuousWorld: true
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
map.on('mousemove click', function(e) {
|
map.on('mousemove click', function(e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user