diff --git a/ws30/ws30-vbp-generator-docker/.gitignore b/ws30/ws30-vbp-generator-docker/.gitignore new file mode 100644 index 0000000..e6f9700 --- /dev/null +++ b/ws30/ws30-vbp-generator-docker/.gitignore @@ -0,0 +1,16 @@ +# Data files +*.zip +*.hdr +*.tfw +*.tif + +## Corine +data/u2018_clc2018_v2020_20u1_raster100m/ +## SRTM +data/readme.txt + +# macOS +*.DS_Store + +# Output folder +output \ No newline at end of file diff --git a/ws30/ws30-vbp-generator-docker/Dockerfile b/ws30/ws30-vbp-generator-docker/Dockerfile new file mode 100644 index 0000000..3371c60 --- /dev/null +++ b/ws30/ws30-vbp-generator-docker/Dockerfile @@ -0,0 +1,44 @@ +FROM ubuntu:focal + +WORKDIR /home/flightgear/build/ + +# Set timezone: +RUN ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone + +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + cmake \ + git \ + libnvtt-dev + +RUN git clone --branch release/2.4 https://github.com/OSGeo/gdal.git +WORKDIR /home/flightgear/build/gdal/gdal +RUN ./configure +RUN make -j $(nproc) +RUN make install + +WORKDIR /home/flightgear/build/ +RUN git clone --branch OpenSceneGraph-3.6.5 https://github.com/openscenegraph/OpenSceneGraph.git +RUN mkdir OpenSceneGraph/build/ +RUN cat /etc/apt/sources.list +RUN sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list +RUN cat /etc/apt/sources.list +RUN apt-get update && apt-get build-dep -y openscenegraph +WORKDIR OpenSceneGraph/build +RUN cmake -D CMAKE_BUILD_TYPE="Release" -D CMAKE_CXX_FLAGS_RELEASE="-O3 -pipe" -D CMAKE_C_FLAGS_RELEASE="-O3 -pipe" -D CMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOLEAN="true" -G "Unix Makefiles" .. +RUN make -j $(nproc) +RUN make install + +WORKDIR /home/flightgear/build/ +RUN git clone https://github.com/openscenegraph/VirtualPlanetBuilder.git && cd VirtualPlanetBuilder && git checkout VirtualPlanetBuilder-1.0 +RUN mkdir VirtualPlanetBuilder/build/ +WORKDIR /home/flightgear/build/VirtualPlanetBuilder/build/ +RUN cmake .. +RUN make -j $(nproc) +RUN make install + +WORKDIR /home/flightgear/ +ENV LD_LIBRARY_PATH /usr/local/lib64:/usr/local/lib + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/ws30/ws30-vbp-generator-docker/README.md b/ws30/ws30-vbp-generator-docker/README.md new file mode 100644 index 0000000..5786cd7 --- /dev/null +++ b/ws30/ws30-vbp-generator-docker/README.md @@ -0,0 +1,29 @@ +# VirtualPlanetBuilder Terrain Generation for FlightGear + +This repository provides a DockerFile that can generate an image to build VPB terrain. It is currently based on the following versions: + +* Ubuntu 20.04 (LTS) +* GDAL 2.4 +* OpenSceneGraph 3.6.5 +* VirtualPlanetBuilder 1.0 + +To build the image, run `build_image.sh`. This will build and tag the image with the name `flightgear/ws30-vbp-generator:v1`. + +## Building terrain +The provided `run_image.sh` will launch a container and present a `bash` prompt with the environment for building all set up: + +* GDAL and VPB executables will be available to run +* The `data` directory will be mounted at `/home/flightgear/data/` inside the container (readonly) +* The `output` directory will be mounted at `/home/flightgear/output` inside the container with write access + +A sample script in `data/run.sh` is provided to automatically build a small area around Edinburgh. To build the terrain: +1. First download SRTM heightmap and CORINE landclass data (see the wiki for details: [https://wiki.flightgear.org/Virtual_Planet_Builder](https://wiki.flightgear.org/Virtual_Planet_Builder) and `data/run.sh` for links) +2. Extract the files to `./data` +3. Launch the container with `./run_image.sh` +4. Run `./data/run.sh` at the prompt. The script will saves all output to the mounted `./output` folder, so its accessible outside the container. + +A shorthand for steps 3-4 is also available: + +```bash +./run_image.sh ./data/run.sh +``` diff --git a/ws30/ws30-vbp-generator-docker/build_image.sh b/ws30/ws30-vbp-generator-docker/build_image.sh new file mode 100755 index 0000000..ded524e --- /dev/null +++ b/ws30/ws30-vbp-generator-docker/build_image.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build . -t flightgear/ws30-vbp-generator:v1 \ No newline at end of file diff --git a/ws30/ws30-vbp-generator-docker/data/run.sh b/ws30/ws30-vbp-generator-docker/data/run.sh new file mode 100755 index 0000000..1fba0b0 --- /dev/null +++ b/ws30/ws30-vbp-generator-docker/data/run.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Sample script to build a small ws30 tile + +# This script assumes the data is already present (in the same directory as this script). +# SRTM data from: +# https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_34_02.zip +# https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_35_01.zip +# https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_35_02.zip +# https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_36_01.zip +# https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_36_02.zip +# +# CORINE landcover from: +# https://land.copernicus.eu/pan-european/corine-land-cover/clc2018?tab=download +# (behind registration wall - Corine Land Cover - 100 meter Raster) + +osgdem \ + --TERRAIN \ + --compressor-nvtt \ + --compression-quality-highest \ + --no-interpolate-imagery \ + --disable-error-diffusion \ + --geocentric \ + -t /home/flightgear/data/u2018_clc2018_v2020_20u1_raster100m/DATA/U2018_CLC2018_V2020_20u1.tif \ + -d /home/flightgear/data/srtm_34_02.tif \ + -d /home/flightgear/data/srtm_35_01.tif \ + -d /home/flightgear/data/srtm_35_02.tif \ + -d /home/flightgear/data/srtm_36_01.tif \ + -d /home/flightgear/data/srtm_36_02.tif \ + -b -4 50 -3 51 \ + --PagedLOD \ + -l 7 \ + --radius-to-max-visible-distance-ratio 3 \ + -o /home/flightgear/output/vpb/w010n50/w004n50/ws_w004n50.osgb \ No newline at end of file diff --git a/ws30/ws30-vbp-generator-docker/run_image.sh b/ws30/ws30-vbp-generator-docker/run_image.sh new file mode 100755 index 0000000..7515562 --- /dev/null +++ b/ws30/ws30-vbp-generator-docker/run_image.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +BASE_DIR="/home/flightgear" + +mkdir -p output +docker run \ + --rm \ + --mount "type=bind,source=`pwd`/data,target=${BASE_DIR}/data,readonly" \ + --mount "type=bind,source=`pwd`/output,target=${BASE_DIR}/output" \ + -it \ + flightgear/ws30-vbp-generator:v1 /bin/bash $1 \ No newline at end of file