Attaching my Bash script for illustrative and inspirative purposes.

Note that I am not particularly good at Linux scripting, so it is surely possible to write in in more elegant or more powerful way. I have just written it recently, so updates are expected.

Dne 9. Ĩervna 2019 17:33:45 Poutnik Fornntp <poutnik4n...@gmail.com> napsal:
Note also if one installs termux, a very good Linux terminal emulator, one can write wget or curl based Bash scripts for direct download to the final Android placement, optionally skipping downloads if no update is available, or if local files are not older than chosen threshold.

Note that it is by default sandboxed, must be explicitly configured to have access to Android storage.

I use it for BRouter RD5 file updates and Mapsforge compatible maps for LocusMap.(OpenAndroMaps globally, or osm.paws.cz for middle Europe.), using iteration overthe script arguments, where each argument is a code for particular downloadm defined withing tge script.

E.g. argument 0 means an update of my Brouter "homegrid" 5x5deg RD5 file to be downloaded to

~/storage/shared/Brouter/segments4

--
You received this message because you are subscribed to the Google Groups 
"Osmand" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osmand+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osmand/16b3ce66ab0.2799.a291d67f9894f806060d35c996ca15e9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
#!/bin/bash

#https://stackoverflow.com/questions/255898/how-to-iterate-over-arguments-in-a-bash-script
 
##  https://www.vionblog.com/linux-delete-files-older-than-x-days/
# find /path/to/files/ -type f -name '*.jpg' -mtime +30 -exec rm {} \;


webaddr=https://osm.paws.cz
#downloadfolder=~/Downloads
downloadfolder=~/storage/shared/Locus/mapsVector

websegments=http://brouter.de/brouter/segments4
segmentdownloadfolder=~/storage/shared/Brouter/segments4

function getfile0 {
cd $downloadfolder
wget -N  $webaddr/$1
}

function getfile {
cd $downloadfolder
maxdayage=40
find $downloadfolder/  -type f -name $1 -mtime +$maxdayage -exec wget -N 
$webaddr/$1 \;

}



function getrd5file0 {
# %1 = lon  E5,E10,   %2=lat
cd $segmentdownloadfolder
wget -N --limit-rate=10M $websegments/$1_$2.rd5
}

function getrd5file {
cd $segmentdownloadfolder
rd5file=$1_$2.rd5
maxdayage=20
find $segmentdownloadfolder/  -type f -name $rd5file -mtime +$maxdayage -exec 
wget -N --limit-rate=10M $websegments/$rd5file \;
}

for var in "$@"
do

#   https://www.shellscript.sh/case.html

    case $var in
        0)
        getrd5file E15 N45
        ;;
        1)
        getrd5file E10 N45
        getrd5file E10 N50
        getrd5file E15 N50
        ;;
        2)
        getrd5file E10 N40
        getrd5file E15 N40
        getrd5file E20 N40 
        getrd5file E20 N45 
        getrd5file E20 N50 
        ;;
        3)
        getrd5file E0 N40 
        getrd5file E0 N45 
        getrd5file E0 N50
        getrd5file E5 N40 
        getrd5file E5 N45 
        getrd5file E5 N50
        ;;
        4)
        getrd5file E20 N50 
        getrd5file E20 N55
        getrd5file E25 N50
        getrd5file E25 N55 
        ;;
        cz)
        getfile czech_republic_gccz.map
        ;;
        sk)
        getfile slovakia_gccz.map
        ;;
        at)
        getfile austria_gccz.map
        ;;
        ato)
        wget -N http://download.openandromaps.org/maps/europe/Austria.zip
        unzip Austria.zip -o
        rm Austria.zip
        ;;
        at4)
        wget -N http://download.openandromaps.org/mapsV4/europe/Austria.zip
        unzip Austria.zip -o
        rm Austria.zip
        ;;
        sa)
        getfile sachsen_gccz.map
        ;;
        ba)
        getfile bayern_gccz.map
        ;;
        ine)
        getfile nord_est_gccz.map
        ;;
        inw)
        getfile nord_ovest_gccz.map
        ;;
        cr)
        getfile croatia_gccz.map
        ;;
        sl)
        getfile slovenia_gccz.map
        ;;
        hu)
        getfile hungary_gccz.map
        ;;
        sw)
        getfile switzerland_gccz.map
        ;;
        uk)
        getfile ukraine_gccz.map
        ;;
        pl)
        getfile poland_gccz.map.zip
        unzip poland_gccz.map.zip -o
        rm poland_gccz.map.zip
        ;;
        *)      echo "Unknown code"
                ;;
    esac

done

Reply via email to