All Projects → heremaps → Tin Terrain

heremaps / Tin Terrain

Licence: mit
A command-line tool for converting heightmaps in GeoTIFF format into tiled optimized meshes.

Projects that are alternatives of or similar to Tin Terrain

Ol Cesium
OpenLayers - Cesium integration
Stars: ✭ 660 (+68.37%)
Mutual labels:  3d, cesium
Dc Sdk
DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。🌎
Stars: ✭ 206 (-47.45%)
Mutual labels:  3d, cesium
Cesium
An open-source JavaScript library for world-class 3D globes and maps 🌎
Stars: ✭ 8,095 (+1965.05%)
Mutual labels:  3d, cesium
reearth
Free, open, highly extensible WebGIS platform
Stars: ✭ 121 (-69.13%)
Mutual labels:  cesium, 3d
Py3dtiles
⚠️ Project migrated to : https://gitlab.com/Oslandia/py3dtiles ⚠️
Stars: ✭ 152 (-61.22%)
Mutual labels:  3d, cesium
Xbsjearthui
XbsjEarthUI是基于Cesium和EarthSDK的三维GIS/BIM的UI模板,可以基于此定制自己的三维App
Stars: ✭ 373 (-4.85%)
Mutual labels:  3d, cesium
Webgl2examples
Rendering algorithms implemented in raw WebGL 2.
Stars: ✭ 353 (-9.95%)
Mutual labels:  3d
Blendergis
Blender addons to make the bridge between Blender and geographic data
Stars: ✭ 4,642 (+1084.18%)
Mutual labels:  3d
Mesh mesh align plus
Precisely align, move, and measure+match objects and mesh parts in your 3D scenes.
Stars: ✭ 350 (-10.71%)
Mutual labels:  3d
Dotscad
Reduce the burden of mathematics when playing OpenSCAD
Stars: ✭ 344 (-12.24%)
Mutual labels:  3d
Exengine
A C99 3D game engine
Stars: ✭ 391 (-0.26%)
Mutual labels:  3d
Tinyraytracer
A brief computer graphics / rendering course
Stars: ✭ 3,971 (+913.01%)
Mutual labels:  3d
Software
DeepValueNetwork is a peer-to-peer database network managed and hosted by its community. It contains a browser to render 2D/3D content and allow the creation of scripted applications built on top of the p2p database network and managed by its creators, without intermediary platform.
Stars: ✭ 357 (-8.93%)
Mutual labels:  3d
Taro
A lightweight 3D game engine for the web.
Stars: ✭ 345 (-11.99%)
Mutual labels:  3d
Home Platform
HoME: a Household Multimodal Environment is a platform for artificial agents to learn from vision, audio, semantics, physics, and interaction with objects and other agents, all within a realistic context.
Stars: ✭ 370 (-5.61%)
Mutual labels:  3d
Examplesforcesium
My personal examples for Cesium, hopefully may it help you to build this beautiful world~
Stars: ✭ 350 (-10.71%)
Mutual labels:  cesium
Libgdx
Desktop/Android/HTML5/iOS Java game development framework
Stars: ✭ 19,420 (+4854.08%)
Mutual labels:  3d
Universalviewer
A community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
Stars: ✭ 343 (-12.5%)
Mutual labels:  3d
Resium
React components for 🌏 Cesium
Stars: ✭ 356 (-9.18%)
Mutual labels:  cesium
Curated List Of Awesome 3d Morphable Model Software And Data
The idea of this list is to collect shared data and algorithms around 3D Morphable Models. You are invited to contribute to this list by adding a pull request. The original list arised from the Dagstuhl seminar on 3D Morphable Models https://www.dagstuhl.de/19102 in March 2019.
Stars: ✭ 375 (-4.34%)
Mutual labels:  3d

TIN Terrain

Build Status

TIN Terrain is a command-line tool for converting heightmaps presented in GeoTIFF format into tiled optimized meshes (Triangulated Irregular Network) with different levels of details.

Check out heremaps/quantized-mesh-viewer for examples of rendering output in Cesium.js and Three.js.

Note: This is experimental code, expect changes.

dem2tin GeoTIFF to mesh on USGS craterlake DEM

Features

  • Takes GeoTIFF with heightmap as an input
  • Transforms heightmap into a TIN mesh with a given max-error parameter and outputs into .obj format
  • Transforms heightmap into tiled TIN mesh for a given zoom range and outputs tiled pyramid into quantized-mesh-1.0 terrain format

Let us know what you think!

You can help us a lot to prioritize issues in tin-terrain if you submit a short anonymous survey

Installation

You can build and run this tool either with Docker or directly on your system. Building with Docker is easier and works on macOS, Linux, and Windows.

Detailed instructions for each platform are provided below.

Building with Docker

The provided Dockerfile builds the TIN Terrain executable on Ubuntu Linux.

To build the container, execute:

./build-docker.sh

To run TIN Terrain from Docker, type e.g.

docker run -v [local data directory]:/data:cached --name tin-terrain --rm -i -t tin-terrain tin-terrain ...

where [local data directory] is the folder that contains your DEM files and will receive the output files. This will be mapped to /data in the Docker instance, so you should use:

docker run -v [local data directory]:/data:cached --name tin-terrain --rm -i -t tin-terrain tin-terrain dem2tin --input /data/... --output /data/... 

Alternatively, use

docker run -v [local data directory]:/data:cached --name tin-terrain --rm -i -t tin-terrain bash 

to open an interactive shell which lets you execute tin-terrain and access /data. Any files not stored in /data will be lost when closing the session.

Prerequisites & Dependencies

If you choose to compile and run "TIN Terrain" directly on your system, please note that the following packages must be installed on your system:

  • The C++ standard library from the compiler (tested with clang 9.1.0 and gcc 7.3.0)
  • Boost (BSL-1.0) program_options, filesystem, system (tested with version 1.67)
  • GDAL (MIT) gdal, gdal_priv, cpl_conv (tested with version 2.3)

TIN Terrain also downloads some source code of 3rd party libraries during the CMake configure phase:

You can disable this behaviour by passing the -DTNTN_DOWNLOAD_DEPS=OFF option to CMake when generating the project/makefiles. If you do so, you have to download dependencies yourself and also pass the TNTN_LIBGLM_SOURCE_DIR and TNTN_LIBFMT_SOURCE_DIR variables to CMake as well as TNTN_CATCH2_SOURCE_DIR if you want to run the tests.

See download-deps.cmake for detailed version info.

Building on macOS

  1. Install dependencies, preferably with homebrew:
    brew install boost
    brew install cmake
    brew install gdal
    
  2. Create an XCode project:
    mkdir build-cmake-xcode
    cd build-cmake-xcode
    cmake -GXcode path/to/sourcecode/
    open tin-terrain.xcodeproj
    
  3. Build the TIN Terrain target.

The resulting binaries will be in the Debug/Release subdirectory.

To run the tests, build and run the tntn-tests target.

Possible linking issues with GDAL

If another version of GDAL is present on your machine, the FindGDAL.cmake provided with cmake might not be able to properly detect the newest version of GDAL you installed through homebrew (or any other prefered method).

Whether this is the case, can be easily detected, if the linking step in the compilation errors on linking GDAL.

Therefore you might need to guide cmake to the right location of the GDAL:

cmake -GXcode -DGDAL_LIBRARY=PATH/TO/GDAL/LIB path/to/sourcecode/

e.g

cmake -GXcode -DGDAL_LIBRARY=/usr/local/Cellar/gdal/2.3.1_2/lib/libgdal.dylib path/to/sourcecode/

Building on Linux

  1. Install dependencies, e.g. on Ubuntu:
    apt-get install build-essential cmake libboost-all-dev libgdal-dev
    
  2. Create Makefile:
    mkdir build-cmake-release
    cd build-cmake-release
    cmake -DCMAKE_BUILD_TYPE=Release path/to/sourcecode/
    
  3. Build the tin-terrain target
    VERBOSE=1 make tin-terrain
    

The resulting binary should then be ready. To run the tests, build and run the tntn-tests target:

  1. Recreate Makefile (and set TNTN_TEST=ON):
    cd build-cmake-release
    cmake -DTNTN_TEST=ON -DCMAKE_BUILD_TYPE=Debug path/to/sourcecode/
    
  2. Build the tntn-tests target
    VERBOSE=1 make tntn-tests
    

Usage

The tin-terrain command-line tool has a few subcommands. You can run tin-terrain --help to see all available subcommands.

$ tin-terrain --help
usage:
  tin-terrain [OPTION]... <subcommand> ...

Global Options:
  -h [ --help ]               print this help message
  --log arg (=stdout)         diagnostics output/log target, can be stdout,
                              stderr, or none
  -v [ --verbose ] [=arg(=1)] be more verbose
  --subcommand arg            command to execute
  --subargs arg               arguments for command

available subcommands:
  dem2tin - convert a DEM into a mesh/tin
  dem2tintiles - convert a DEM into mesh/tin tiles
  benchmark - run all available meshing methods on a given set of input files and produce statistics (performance, error rate)
  version - print version information

Projections

The tin-terrain tool requires your datasets to be in the Web Mercator projection (EPSG:3857). If your datasets are not in this projection, you can quite easily reproject your datasets with gdalwarp, e.g.:

gdalwarp -t_srs EPSG:3857 ned19_n37x75_w122x50_ca_goldengate_2010.img ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif

Creating a single mesh/TIN

You can use the dem2tin subcommand to convert a raster heightmap into a single big mesh/TIN in the OBJ format.

You can see all available options by running tin-terrain dem2tin --help.

$ tin-terrain dem2tin --help
usage:
  tin-terrain dem2tin [OPTIONS]...

dem2tin options:
  --input arg                 input filename
  --input-format arg (=auto)  input file format, can be any of: auto, asc, xyz,
                              tiff
  --output arg                output filename
  --output-format arg (=auto) output file format, can be any of: auto, obj,
                              off, terrain (quantized mesh), json/geojson
  --method arg (=terra)       meshing method, valid values are: terra, zemlya and dense
  --max-error arg             (terra & zemlya) maximum geometric error
  --step arg (=1)		      (dense) grid spacing in pixels


methods:
  terra     - implements a delaunay based triangulation with point selection using a fast greedy insert mechnism
    reference: Garland, Michael, and Paul S. Heckbert. "Fast polygonal approximation of terrains and height fields." (1995).
    paper: https://mgarland.org/papers/scape.pdf
    and http://mgarland.org/archive/cmu/scape/terra.html
  zemlya    - hierarchical greedy insertion
    reference: Zheng, Xianwei, et al. "A VIRTUAL GLOBE-BASED MULTI-RESOLUTION TIN SURFACE MODELING AND VISUALIZETION METHOD." International Archives of the Photogrammetry, Remote Sensing & Spatial Information Sciences 41 (2016).
    paper: https://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XLI-B2/459/2016/isprs-archives-XLI-B2-459-2016.pdf
  dense     - generates a simple mesh grid from the raster input by placing one vertex per pixel

For example, you can run the following command to convert "ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif" to a single big mesh, using a max-error parameter of 2.0 meters:

tin-terrain dem2tin --input /data/ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif --output /data/terrain.obj --max-error 2.0

After running this command, you should see a "terrain.obj" output file in the same directory. This OBJ file contains the generated mesh.

The max-error parameter specifies the vertical error allowance in meters, so a smaller max-error parameter results in more triangles in the output mesh, better mesh quality, and longer running time.

Creating a pyramid of mesh/TIN tiles

The dem2tintiles subcommand takes a raster heightmap as the input, and creates tiled TIN mesh for a given zoom range. The output tiles can be either in the OBJ format or in the quantized-mesh-1.0 terrain format.

You can see all available options by running tin-terrain dem2tintiles --help.

$ tin-terrain dem2tintiles --help
usage:
  tin-terrain dem2tintiles [OPTION]...

dem2tintiles options:
  --input arg                    input filename
  --output-dir arg (=./output)
  --max-zoom arg (=-1)           maximum zoom level to generate tiles for. will
                                 guesstimate from resolution if not provided.
  --min-zoom arg (=-1)           minimum zoom level to generate tiles for will
                                 guesstimate from resolution if not provided.
  --max-error arg                (terra or zemlya) max error when using
  --step arg (=1)            	 (dense) grid spacing in pixels
  --output-format arg (=terrain) output tiles in terrain (quantized mesh) or
                                 obj
  --method arg (=terra)          meshing algorithm. one of: terra, zemlya or dense

For example, you can run the following command to convert "ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif" to a pyramid of mesh tiles.

tin-terrain dem2tintiles --input /data/ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif --output-dir /data/output --min-zoom 5 --max-zoom 14 --output-format=terrain --max-error 2.0

When this command finishes running, you should see an output folder containing all the mesh tiles, organized into a pyramid of subfolders.

├── 10
│   ├── 163
│   │   ├── 627.terrain
│   │   └── 628.terrain
│   └── 164
│       ├── 627.terrain
│       └── 628.terrain
...

The folder structure follows the map tile convention: Z/X/Y.terrain.

These mesh tiles can then be easily served from a webserver and be consumed by frontend applications for purposes such as terrain visualization.

Sample Datasets

When you enable the TNTN_TEST and TNTN_DOWNLOAD_DEPS options in the CMake configuration, a few sample datasets will be downloaded into the ${CMAKE_SOURCE_DIR}/3rdparty/ folder.

For example, you will find the crater lake dataset in the ${CMAKE_SOURCE_DIR}/3rdparty/craterlake folder. This dataset is created and maintained by the U.S. Geological Survey (USGS) and can be downloaded from http://oe.oregonexplorer.info/craterlake/.

To generate a mesh from this dataset, you need to reproject it to the Web Mercator projection first, using the gdalwarp command-line tool which comes with your GDAL installation:

gdalwarp -t_srs EPSG:3857 -r cubic -of GTiff -ot Float32 dems_10m.dem dems_10m.tif

Then you can run tin-terrain on this reprojected GeoTIFF file to create a mesh:

./tin-terrain dem2tin --input dems_10m.tif --output terrain.obj --max-error 2.0 --method terra

License

Copyright (C) 2018 HERE Europe B.V.

See the LICENSE file in the root of this project for license details.

Papers

Some algorithms are based on ideas from:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].