Skip to content

Commit

Permalink
Merge pull request #1 from tits4net/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
tits4net authored Mar 8, 2024
2 parents 313feb0 + f46f178 commit fad7b4c
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 114,148 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/deploy_aci.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Docker build and push

on:
workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
Expand Down
35 changes: 30 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
# Use the small IBM java JRE
FROM ibmjava:sfj

# Load our application
COPY mkgmap /motomap/mkgmap
COPY splitter /motomap/splitter
# Set configuration, default to some basic (light) examples
ENV MAPS_LIST "antarctica;europe/andorra;europe/france/guyane"
ENV MKGMAP_VERSION="r4918"
ENV SPLITTER_VERSION="r653"

# Prepare helper software in image
RUN apt-get update ; apt-get -y install curl unzip

# Download needed software in image and extract them
# mkgmap
RUN mkdir -p /motomap/mkgmap && \
curl --output /motomap/mkgmap/mkgmap.zip https://www.mkgmap.org.uk/download/mkgmap-${MKGMAP_VERSION}.zip && \
unzip -d /motomap/mkgmap/ /motomap/mkgmap/mkgmap.zip

# splitter
RUN mkdir -p /motomap/splitter && \
curl --output /motomap/splitter/splitter.zip https://www.mkgmap.org.uk/download/splitter-${SPLITTER_VERSION}.zip && \
unzip -d /motomap/splitter/ /motomap/splitter/splitter.zip

# Download global usefull dataset
# precomp-sea
RUN mkdir -p /motomap/precomp-sea && \
curl --output /motomap/precomp-sea/sea-latest.zip https://www.thkukuk.de/osm/data/sea-latest.zip

# bounds
RUN mkdir -p /motomap/bounds && \
curl --output /motomap/bounds/bounds-latest.zip https://www.thkukuk.de/osm/data/bounds-latest.zip

# Add our scripts
COPY motomap /motomap/motomap
COPY precomp-sea /motomap/precomp-sea

# run motomap
# Run script
CMD ["/bin/bash", "/motomap/motomap/motomap.sh"]
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: help build push all

build:
docker build -t motomap .

run:
docker run motomap

debug:
docker run --rm -it --entrypoint bash motomap
7 changes: 7 additions & 0 deletions examples/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
motomap:
image: "docker.io/library/motomap"
volumes:
- ./data/output/:/motomap/output/
environment:
MAPS_LIST: "antarctica;europe/andorra;europe/france/guyane"
77 changes: 27 additions & 50 deletions motomap/motomap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,36 @@ fi
startDatetime=$(date)
echo "INFO: Motomap Processing - Started"

# we need two variables, the base directory for the motomap code
# and the path to the configuration file for motomap.sh
# get switches from the command line
# otherwise get the environment variables

if [[ -z "${MOTOMAP_BASEDIR}" && -z "${MOTOMAP_CONFIG}" ]]; then
echo "INFO: getting options from getopts"
while getopts ":b:c:" opt; do
case "${opt}" in
b)
echo "INFO: basedir is ${OPTARG}"
basedir=${OPTARG}
;;
c)
echo "INFO: config is ${OPTARG}"
config=${OPTARG}
;;
esac
done
else
echo "INFO: using environment variables"
basedir=$MOTOMAP_BASEDIR
config=$MOTOMAP_CONFIG
fi

if [[ -z "${basedir}" || -z "${config}" ]]; then
echo "ERROR: Variables basedir:$basedir and config:$config not set"
exit 1
fi

# jump into the motomap base dir so we can find all our stuff
cd $basedir
mkdir -p working
source motomap/parse_yaml.sh
eval $(parse_yaml $config)

echo "INFO: Motomap Processing - Config for map: input_file=$inputfile output_file=$outputfile, familyid=$familyid, mapname=$mapname, mapdesc=$mapdesc"

echo "INFO: Motomap Processing - Splitting Map"
# split each pbf file into segments so we don't run out of memory
# allocating max of 4G heap space - create the container with 5G memory
java -Xms$memmin -Xmx$memmax -jar splitter/splitter.jar --output-dir="working/" $inputfile

echo "INFO: Motomap Processing - Generating Map"
# gen the .img file from the split files
java -Xms$memmin -Xmx$memmax -jar mkgmap/mkgmap.jar --mapname="$mapname" --family-id="$familyid" --family-name="Motomap - $mapdesc" --description="Motomap - $mapdesc" --output-dir=working/ --precomp-sea=precomp-sea/sea-latest.zip --generate-sea --route --housenumbers -c motomap/motomap.cfg working/6324*.osm.pbf motomap/typ/motomap_typ.txt
mv working/gmapsupp.img $outputfile

# clean up
rm -rf working
cd /motomap/
mkdir -p output

IFS=';' read -r -a map_array <<< "${MAPS_LIST}"
echo "INFO: Motomap Processing - Get "${#map_array[@]}" maps to process ..."
for element in "${map_array[@]}"
do
final_name=$(basename "$element")
mkdir -p workdir
echo "INFO: Motomap Processing - Processing $element (name : ${final_name^})"
echo "INFO: Motomap Processing - Download OSM map"
curl --output /motomap/workdir/map.osm.pbf https://download.geofabrik.de/"$element"-latest.osm.pbf

echo "INFO: Motomap Processing - Splitting Map"
# split each pbf file into segments so we don't run out of memory
# allocating max of 4G heap space - create the container with 5G memory
java -Xms4G -Xmx4G -jar /motomap/splitter/splitter-r653/splitter.jar --output-dir="/motomap/workdir/" /motomap/workdir/map.osm.pbf

echo "INFO: Motomap Processing - Generating Map"
# gen the .img file from the split files
java -Xms4G -Xmx4G -jar /motomap/mkgmap/mkgmap-r4918/mkgmap.jar --mapname="63241601" --family-id="17001" --family-name="Motomap - ${final_name^}" --description="Motomap - ${final_name^}" --output-dir=/motomap/workdir/ --precomp-sea=/motomap/precomp-sea/sea-latest.zip --generate-sea --route --housenumbers -c /motomap/motomap/motomap.cfg /motomap/workdir/6324*.osm.pbf motomap/typ/motomap_typ.txt
mv workdir/gmapsupp.img /motomap/output/"$final_name".img

# clean up
rm -rf workdir
done

# log end of processing
endDatetime=$(date)
diffSeconds="$(($(date -d "${endDatetime}" +%s)-$(date -d "${startDatetime}" +%s)))"
diffTime=$(date -d @${diffSeconds} +"%Hh %Mm %Ss" -u)
echo "INFO: Motomap Processing - Complete in $diffTime, output file $outputfile"
echo "INFO: Motomap Processing - Complete in $diffTime"
163 changes: 0 additions & 163 deletions motomap/parse_yaml.sh

This file was deleted.

Binary file removed screenshots/85 and 400 2.png
Binary file not shown.
Binary file removed screenshots/85 and 400.png
Binary file not shown.
Binary file removed screenshots/chatahoochee nf 2.png
Binary file not shown.
Binary file removed screenshots/chattahoochee nf.png
Binary file not shown.
Binary file removed screenshots/old dial road 2.png
Binary file not shown.
Binary file removed screenshots/old dial road zoomed 2.png
Binary file not shown.
Binary file removed screenshots/old dial road zoomed.png
Binary file not shown.
Binary file removed screenshots/old dial road.png
Binary file not shown.
5 changes: 0 additions & 5 deletions test/map001-test.sh

This file was deleted.

16 changes: 0 additions & 16 deletions test/map001-tiny-docker.yml

This file was deleted.

Loading

0 comments on commit fad7b4c

Please sign in to comment.