{"id":14036413,"url":"https://github.com/tangrams/terrain-demos","last_synced_at":"2025-07-27T03:31:53.563Z","repository":{"id":46183813,"uuid":"52998620","full_name":"tangrams/terrain-demos","owner":"tangrams","description":"Ways to manipulate terrain data with Tangram","archived":false,"fork":false,"pushed_at":"2021-11-08T21:14:24.000Z","size":3906,"stargazers_count":52,"open_issues_count":0,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-06T15:06:50.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tangrams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-02T21:43:50.000Z","updated_at":"2025-04-07T14:40:58.000Z","dependencies_parsed_at":"2022-09-23T06:00:50.299Z","dependency_job_id":null,"html_url":"https://github.com/tangrams/terrain-demos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tangrams/terrain-demos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangrams%2Fterrain-demos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangrams%2Fterrain-demos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangrams%2Fterrain-demos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangrams%2Fterrain-demos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tangrams","download_url":"https://codeload.github.com/tangrams/terrain-demos/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangrams%2Fterrain-demos/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267294180,"owners_count":24065343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-12T03:01:57.553Z","updated_at":"2025-07-27T03:31:53.036Z","avatar_url":"https://github.com/tangrams.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# terrain-demos\n\nWays to manipulate heightmap data in [Tangram](http://github.com/tangrams/tangram) as seen in the [Mapping Mountains](https://mapzen.com/blog/mapping-mountains/) post on the [Mapzen blog](http://mapzen.com/blog).\n\n\u003cimg width=\"664\" alt=\"terrain demo\" src=\"https://cloud.githubusercontent.com/assets/459970/14753849/e36167ae-08a5-11e6-9abb-3e219a3bc20f.png\"\u003e\n\n## Style gallery\n\n- elevation tiles: http://tangrams.github.io/terrain-demos/?url=styles/elevation-tiles.yaml\n- basic green: http://tangrams.github.io/terrain-demos/?url=styles/green.yaml\n- animated contours: http://tangrams.github.io/terrain-demos/?url=styles/contours.yaml\n- grayscale hypsometric: http://tangrams.github.io/terrain-demos/?url=styles/grayscale.yaml\n- classic hypsometric: http://tangrams.github.io/terrain-demos/?url=styles/hypsometric.yaml\n- slopemap: http://tangrams.github.io/terrain-demos/?url=styles/slope.yaml\n- heightmap: http://tangrams.github.io/terrain-demos/?url=styles/heightmap.yaml\n- manual normal derivation: http://tangrams.github.io/terrain-demos/?url=styles/normals-manual.yaml\n- normal tiles: http://tangrams.github.io/terrain-demos/?url=styles/normals-tiles.yaml\n- single light: http://tangrams.github.io/terrain-demos/?url=styles/single-light.yaml\n- two lights: http://tangrams.github.io/terrain-demos/?url=styles/two-lights.yaml\n- three lights: http://tangrams.github.io/terrain-demos/?url=styles/three-lights.yaml\n- environment map: http://tangrams.github.io/terrain-demos/?url=styles/environment-map1.yaml\n- metal spheremap: http://tangrams.github.io/terrain-demos/?url=styles/metal.yaml\n- sunrise spheremap: http://tangrams.github.io/terrain-demos/?url=styles/sunrise.yaml\n- sunset spheremap: http://tangrams.github.io/terrain-demos/?url=styles/sunset.yaml\n- swiss style: http://tangrams.github.io/terrain-demos/?url=styles/imhof.yaml\n\nCheck out the source code for these and more examples in the [styles directory](https://github.com/tangrams/terrain-demos/tree/gh-pages/styles).\n\n### Elevation tiles vs. Normal tiles alpha elevation\n\nMapzen offers two sources of elevation data: the [\"terrarium\" elevation tiles](https://mapzen.com/documentation/terrain-tiles/formats/#terrarium), and also the [alpha channel of the normal tiles](https://mapzen.com/documentation/terrain-tiles/formats/#normal). Most of the examples in this repo are based on the elevation tiles, but some of them (such as normal-alpha-elevation.yaml) use the alpha channel of the normal tiles. This source is a bit trickier to use, but if you don't need the 24-bit resolution of the elevation tiles, and are already loading the normal tiles, it will make your styles faster.\n\nThe elevation tiles use a relatively simple linear encoding, but the normal tiles alpha channel is quantized, non-linear, and 8-bit. (More information about this encoding can be found in [the documentation for our elevation datasource](https://mapzen.com/documentation/terrain-tiles/formats/#normal).)\n\nTo make this source simpler to interpret, we're using a \"[decoder ring](https://wikipedia.org/wiki/Secret_decoder_ring)\" image which maps the quantized range to the unquantized range as best it can. This image is generated with [a piece of JavaScript](decoder.js) which runs the quantize function in reverse, and creates a new image in a canvas element with the decoded output values for each input value. [You can run this script here](tangrams.github.io/terrain-demos/decoder.html). This image has also been pregenerated for your convenience, and is stored in this repo as [decoder.png](https://github.com/tangrams/terrain-demos/blob/master/img/decoder.png). It looks like this:\n\n![decoder ring image](https://github.com/tangrams/terrain-demos/blob/master/img/decoder.png)\n\nThis image can be used as a texture in a heightmap shader, for easier decoding.\n\n### To run locally:\n\nStart a web server in the repo's directory:\n\n    python -m SimpleHTTPServer 8000\n    \nIf that doesn't work, try:\n\n    python -m http.server 8000\n    \nThen navigate to, eg: [http://localhost:8000/?url=styles/contours.yaml](http://localhost:8000/?url=styles/contours.yaml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangrams%2Fterrain-demos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftangrams%2Fterrain-demos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangrams%2Fterrain-demos/lists"}