diff --git a/.gitignore b/.gitignore index 8e63281ca..5cf9666f5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.xcodeproj *.o *.actual.png +*.diff.png /node_modules /mapnik-packaging /macosx/build diff --git a/.travis.yml b/.travis.yml index dddd096c8..ec877eb68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ env: global: - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" + - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" before_install: - ./scripts/setup_travis.sh @@ -29,6 +30,7 @@ script: - make linux -j4 BUILDTYPE=${BUILDTYPE} - make test -j4 BUILDTYPE=${BUILDTYPE} - ./scripts/run_tests.sh +- ./scripts/compare_images.js after_script: - ./scripts/deploy_results.sh @@ -38,7 +40,7 @@ notifications: rooms: secure: "SgMjGDp8MP+UTAY/aWJwSQH2hv1Q0vhEc1BdIde59+lEL3u6gNMSexUTSJoVxRlIQTFXDJBU7v58ISdgJX8cPa+UvIC8hhLsayM+cbm+J3jgy7V9E9wllq3RpmXN33TxY7nwKgWdIms2t9YKZco3y4dKKAUyHXrtMvw8NNPQM+4=" template: - - 'Build #%{build_number}: %{author} tested %{commit} in branch %{branch} of %{repository_name}: %{commit_message}
%{message} (%{duration})' + - 'Build #%{build_number}: %{author} tested %{commit} in branch %{branch} of %{repository_name}: %{commit_message}
%{message} (%{duration}) - Compare: 1 2 3 4' format: html git: diff --git a/Makefile b/Makefile index 217132150..70d706afa 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,11 @@ build/test/Makefile: src common config.gypi test/test.gyp deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make test: build/test/Makefile - $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test + $(MAKE) -C build/test BUILDTYPE=Testing V=$(V) test test/%: build/test/Makefile - $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) $* - (cd build/$(BUILDTYPE) && exec ./test_$*) + $(MAKE) -C build/test BUILDTYPE=Testing V=$(V) $* + (cd build/Testing && exec ./test_$*) # build Mac OS X project for Xcode xtest: config.gypi clear_xcode_cache node @@ -42,7 +42,7 @@ xtest: config.gypi clear_xcode_cache node # Builds the linux app with make. This is also used by Travis CI linux: config.gypi linux/llmr-app.gyp node deps/run_gyp linux/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make - $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp + $(MAKE) -C build/linux BUILDTYPE=Testing V=$(V) linuxapp # Executes the Linux binary run-linux: linux @@ -78,9 +78,9 @@ xproj: config.gypi macosx/llmr-app.gyp clear_xcode_cache node open ./build/macosx/llmr-app.xcodeproj # build iOS project for Xcode -iproj: config.gypi ios/llmr-app.gyp clear_xcode_cache node - deps/run_gyp ios/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/ios/llmr-app.xcodeproj +iproj: config.gypi ios/mapbox-gl-cocoa/app/llmr-app.gyp clear_xcode_cache node + deps/run_gyp ios/mapbox-gl-cocoa/app/llmr-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/ios/mapbox-gl-cocoa/app/llmr-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) lproj: config.gypi linux/llmr-app.gyp clear_xcode_cache node diff --git a/README.md b/README.md index 4ca8960be..e642468a3 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,18 @@ First off: if you hit problems during development try: This will clear cached build data and update to the latest versions of dependencies. +### Mapbox API access tokens + +The demo applications use Mapbox vector tiles, which **require a Mapbox account and API access token**. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/). + ## OS X -First run: +in the Xcode project, click on the Target icon next to the Run/Stop button, and then "Edit Scheme". In the screen, add an environment variable with the name `MAPBOX_ACCESS_TOKEN` to the targets you want to run. + +![Setting the access token](https://cloud.githubusercontent.com/assets/52399/3543326/9e7cfbb8-0860-11e4-8def-3684a9028b61.png) + + +Run: make setup @@ -52,6 +61,8 @@ First, pull down the submodule(s): git submodule init git submodule update +Insert your access token into `MBXViewController.h`. + Then run: make setup @@ -64,6 +75,8 @@ Target devices: iPhone 4 and above (4S, 5, 5c, 5s) and iPad 2 and above (3, 4, m ## Ubuntu +Set the environment variable `MAPBOX_ACCESS_TOKEN` to your token. + Ensure you have git and other build essentials: sudo apt-get update diff --git a/bin/style.js b/bin/style.js index 21cca2af3..44ff878b5 100644 --- a/bin/style.js +++ b/bin/style.js @@ -3,12 +3,11 @@ module.exports = { "version": 3, "sprite": "https://www.mapbox.com/mapbox-gl-styles/sprites/outdoors", - "glyphs": "https://mapbox.s3.amazonaws.com/gl-glyphs-256/{{fontstack}}/{{range}}.pbf", + "glyphs": "https://mapbox.s3.amazonaws.com/gl-glyphs-256/{fontstack}/{range}.pbf", "sources": { "mapbox": { "type": "vector", "url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5", - "tileSize": 512, "maxZoom": 14 } }, @@ -68,133 +67,131 @@ module.exports = { "@contour_night": "#ffff80", "@river_canal_width": { "fn": "stops", - "stops": [[11, 0.5], [12, 1], [14, 2], [16, 3]] + "stops": [[10, 0.5], [11, 1], [13, 2], [15, 3]] }, "@stream_width": { "fn": "stops", - "stops": [[13, 0.25], [14, 0.5], [16, 1.5], [18, 2]] + "stops": [[12, 0.25], [13, 0.5], [15, 1.5], [17, 2]] }, "@motorway_width": { "fn": "stops", - "stops": [[5, 0], [6, 0.5], [8, 0.8], [10, 1], [11, 1.2], [12, 2], [13, 3], [14, 4], [15, 6], [16, 9], [17, 12], [18, 14]] + "stops": [[4, 0], [5, 0.5], [7, 0.8], [9, 1], [10, 1.2], [11, 2], [12, 3], [13, 4], [14, 6], [15, 9], [16, 12], [17, 14]] }, "@motorway_casing_width": { "fn": "stops", - "stops": [[7.5, 0.6], [8, 0.8], [10, 2.8], [11, 3], [12, 4], [13, 5], [14, 6.5], [15, 9], [16, 12], [17, 15], [18, 17]] + "stops": [[6.5, 0.6], [7, 0.8], [9, 2.8], [10, 3], [11, 4], [12, 5], [13, 6.5], [14, 9], [15, 12], [16, 15], [17, 17]] }, "@motorway_link_width": { "fn": "stops", - "stops": [[12, 1.2], [14, 2], [16, 3], [18, 4]] + "stops": [[11, 1.2], [13, 2], [15, 3], [17, 4]] }, "@motorway_link_casing_width": { "fn": "stops", - "stops": [[12, 2.8], [14, 3.5], [16, 5], [18, 6]] + "stops": [[11, 2.8], [13, 3.5], [15, 5], [17, 6]] }, "@main_width": { "fn": "stops", - "stops": [[5, 1], [12, 1], [13, 1.5], [14, 2], [15, 3], [16, 6], [17, 10], [18, 12]] + "stops": [[4, 1], [11, 1], [12, 1.5], [13, 2], [14, 3], [15, 6], [16, 10], [17, 12]] }, "@main_casing_width": { "fn": "stops", - "stops": [[9, 2.9], [12, 2.9], [13, 3.5], [14, 4], [15, 5.5], [16, 9], [17, 12], [18, 14]] + "stops": [[8, 2.9], [11, 2.9], [12, 3.5], [13, 4], [14, 5.5], [15, 9], [16, 12], [17, 14]] }, "@street_width": { "fn": "stops", - "stops": [[14.5, 0], [15, 1.5], [16, 3], [17, 8]] + "stops": [[13.5, 0], [14, 1.5], [15, 3], [16, 8]] }, "@street_casing_width": { "fn": "stops", - "stops": [[13, 0.4], [14, 1], [15, 2.5], [16, 4], [17, 10]] + "stops": [[12, 0.4], [13, 1], [14, 2.5], [15, 4], [16, 10]] }, "@street_casing_opacity": { "fn": "stops", - "stops": [[14, 0], [14.5, 1]] + "stops": [[13, 0], [13.5, 1]] }, "@service_casing_width": { "fn": "stops", - "stops": [[14, 0.5], [15, 3], [16, 3.5], [17, 4], [18, 5], [19, 6]] + "stops": [[13, 0.5], [14, 3], [15, 3.5], [16, 4], [17, 5], [18, 6]] }, "@runway_width": { "fn": "stops", - "stops": [[10, 1], [11, 2], [12, 3], [13, 5], [14, 7], [15, 11], [16, 15], [17, 19], [18, 23]] + "stops": [[9, 1], [10, 2], [11, 3], [12, 5], [13, 7], [14, 11], [15, 15], [16, 19], [17, 23]] }, "@taxiway_width": { "fn": "stops", - "stops": [[10, 0.2], [12, 0.2], [13, 1], [14, 1.5], [15, 2], [16, 3], [17, 4], [18, 5]] + "stops": [[9, 0.2], [11, 0.2], [12, 1], [13, 1.5], [14, 2], [15, 3], [16, 4], [17, 5]] }, "@aerialway_width": { "fn": "stops", - "stops": [[13.5, 0.8], [14, 1.4], [15, 1.6], [16, 2], [17, 2.4], [18, 3]] + "stops": [[12.5, 0.8], [13, 1.4], [14, 1.6], [15, 2], [16, 2.4], [17, 3]] }, "@aerialway_casing_width": { "fn": "stops", - "stops": [[13.5, 2], [14, 2.5], [15, 3], [16, 3.5], [17, 4], [22, 5]] + "stops": [[12.5, 2], [13, 2.5], [14, 3], [15, 3.5], [16, 4], [21, 5]] }, "@path_width": { "fn": "stops", - "stops": [[14, 1.2], [15, 1.5], [16, 1.8]] + "stops": [[13, 1.2], [14, 1.5], [15, 1.8]] }, "@admin_l2_width": { "fn": "stops", - "stops": [[2, 0.5], [3, 0.7], [4, 0.7], [5, 0.8], [6, 1], [8, 2], [10, 3]] + "stops": [[1, 0.5], [2, 0.7], [3, 0.7], [4, 0.8], [5, 1], [7, 2], [9, 3]] }, "@admin_l3_width": { "fn": "stops", - "stops": [[6, 0.6], [8, 1], [12, 2]] + "stops": [[5, 0.6], [7, 1], [11, 2]] }, "@road_label_1_size": { "fn": "stops", - "stops": [[13, 11], [14, 12], [15, 13], [16, 14], [17, 16], [18, 18]] + "stops": [[12, 11], [13, 12], [14, 13], [15, 14], [16, 16], [17, 18]] }, "@road_label_2_size": { "fn": "stops", - "stops": [[13, 11], [14, 12], [16, 14], [18, 16]] + "stops": [[12, 11], [13, 12], [15, 14], [17, 16]] }, "@road_label_3_size": { "fn": "stops", - "stops": [[15, 10], [16, 12], [18, 14]] + "stops": [[14, 10], [15, 12], [17, 14]] }, "@fence_width": { "fn": "stops", - "stops": [[17, 0.6], [19, 1]] + "stops": [[16, 0.6], [18, 1]] }, "@hedge_width": { "fn": "stops", - "stops": [[16, 0.6], [17, 1.2], [19, 1.6]] + "stops": [[15, 0.6], [16, 1.2], [18, 1.6]] }, "@barrier_line_land_width": { "fn": "stops", - "stops": [[14, 0.4], [15, 0.75], [16, 1.5], [17, 3], [18, 6], [19, 12], [20, 24], [21, 48]] + "stops": [[13, 0.4], [14, 0.75], [15, 1.5], [16, 3], [17, 6], [18, 12], [19, 24], [20, 48]] }, "@country_label_size": { "fn": "stops", - "stops": [[1, 14], [12, 24]] + "stops": [[0, 14], [11, 24]] }, "@poi_label_1-2_size": { "fn": "stops", - "stops": [[15, 10], [16, 11], [17, 12]] + "stops": [[14, 10], [15, 11], [16, 12]] }, "@poi_label_3_size": { "fn": "stops", - "stops": [[16, 10], [17, 11]] + "stops": [[15, 10], [16, 11]] }, "@hillshade_rasterize": { "enabled": { "fn": "stops", - "stops": [[11, false], [12, true]] + "stops": [[10, false], [11, true]] }, "size": { "fn": "stops", - "stops": [[11, 1024], [12, 512], [13, 256]] + "stops": [[10, 1024], [11, 512], [12, 256]] }, "blur": 1 } }, "layers": [{ "id": "background", - "render": { - "type": "background" - }, + "type": "background", "style": { "background-color": "@land" }, @@ -206,9 +203,7 @@ module.exports = { "source": "mapbox", "source-layer": "landcover", "filter": { "class": "snow" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@snow" }, @@ -220,9 +215,7 @@ module.exports = { "source": "mapbox", "source-layer": "landcover", "filter": { "class": "crop" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@crop" }, @@ -234,21 +227,19 @@ module.exports = { "source": "mapbox", "source-layer": "landcover", "filter": { "class": "grass" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@grass", "fill-opacity": { "fn": "stops", - "stops": [[13, 1], [14, 0.8], [17, 0.2]] + "stops": [[12, 1], [13, 0.8], [16, 0.2]] } }, "style.night": { "fill-color": "@grass_night", "fill-opacity": { "fn": "stops", - "stops": [[13, 1], [14, 0.8], [17, 0.2]] + "stops": [[12, 1], [13, 0.8], [16, 0.2]] } } }, { @@ -256,21 +247,19 @@ module.exports = { "source": "mapbox", "source-layer": "landcover", "filter": { "class": "scrub" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@scrub", "fill-opacity": { "fn": "stops", - "stops": [[13, 1], [14, 0.8], [17, 0.2]] + "stops": [[12, 1], [13, 0.8], [16, 0.2]] } }, "style.night": { "fill-color": "@scrub_night", "fill-opacity": { "fn": "stops", - "stops": [[13, 1], [14, 0.8], [17, 0.2]] + "stops": [[12, 1], [13, 0.8], [16, 0.2]] } } }, { @@ -278,21 +267,19 @@ module.exports = { "source": "mapbox", "source-layer": "landcover", "filter": { "class": "wood" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@wood", "fill-opacity": { "fn": "stops", - "stops": [[13, 1], [14, 0.8], [17, 0.2]] + "stops": [[12, 1], [13, 0.8], [16, 0.2]] } }, "style.night": { "fill-color": "@wood_night", "fill-opacity": { "fn": "stops", - "stops": [[13, 1], [14, 0.8], [17, 0.2]] + "stops": [[12, 1], [13, 0.8], [16, 0.2]] } } }, { @@ -300,9 +287,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "wood" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@wood" }, @@ -315,9 +300,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "school" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@school" }, @@ -329,9 +312,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "sand" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@sand" }, @@ -344,9 +325,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "pitch" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "rgba(255,255,255,0.5)", "fill-outline-color": "@pitch" @@ -360,9 +339,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "park" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@park" }, @@ -374,9 +351,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "industrial" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "rgba(246,250,255,0.5)" }, @@ -388,9 +363,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "scrub" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@scrub" }, @@ -403,9 +376,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "grass" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@grass" }, @@ -418,9 +389,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "crop" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@crop" }, @@ -433,9 +402,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "rock" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@rock" }, @@ -448,9 +415,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "snow" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@snow" }, @@ -463,9 +428,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "hospital" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@hospital" }, @@ -477,9 +440,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse", "filter": { "class": "cemetery" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@cemetery" }, @@ -491,9 +452,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse_overlay", "filter": { "class": ["wetland", "wetland_noveg"] }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "rgba(210,225,225,0.2)", "fill-image": "wetland_noveg_64" @@ -507,9 +466,7 @@ module.exports = { "source": "mapbox", "source-layer": "landuse_overlay", "filter": { "class": ["breakwater", "pier"] }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@land" }, @@ -521,8 +478,8 @@ module.exports = { "source": "mapbox", "source-layer": "waterway", "filter": { "type": ["river", "canal"] }, + "type": "line", "render": { - "type": "line", "line-cap": "round" }, "style": { @@ -538,8 +495,8 @@ module.exports = { "source": "mapbox", "source-layer": "waterway", "filter": { "type": "stream" }, + "type": "line", "render": { - "type": "line", "line-cap": "round" }, "style": { @@ -554,15 +511,13 @@ module.exports = { "id": "building_shadow", "source": "mapbox", "source-layer": "building", - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "#d5d1c6", "fill-translate": [1, 1], "fill-opacity": { "fn": "stops", - "stops": [[16.5, 0], [17, 1]] + "stops": [[15.5, 0], [16, 1]] }, "fill-outline-color": "#d5d1c6" }, @@ -571,7 +526,7 @@ module.exports = { "fill-translate": [1, 1], "fill-opacity": { "fn": "stops", - "stops": [[16.5, 0], [17, 1]] + "stops": [[15.5, 0], [16, 1]] }, "fill-outline-color": "#026688" } @@ -591,7 +546,7 @@ module.exports = { "fill-color": "#ebe7db", "fill-opacity": { "fn": "stops", - "stops": [[16.5, 0], [17, 0.7]] + "stops": [[15.5, 0], [16, 0.7]] }, "fill-outline-color": "#d5d1c6" }, @@ -599,7 +554,7 @@ module.exports = { "fill-color": "#027797", "fill-opacity": { "fn": "stops", - "stops": [[16.5, 0], [17, 0.7]] + "stops": [[15.5, 0], [16, 0.7]] }, "fill-outline-color": "#026688" } @@ -608,16 +563,14 @@ module.exports = { "source": "mapbox", "source-layer": "hillshade", "filter": { "class": "full_highlight" }, - "render": { - "type": "fill" - }, + "type": "fill", "rasterize": "@hillshade_rasterize", "style": { "fill-color": "#fffff3", "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[15, 0.3], [16, 0.3], [17, 0.2], [18, 0.2], [19, 0.1]] + "stops": [[14, 0.3], [15, 0.3], [16, 0.2], [17, 0.2], [18, 0.1]] } }, "style.night": { @@ -625,7 +578,7 @@ module.exports = { "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[14, 0.4], [15, 0.3], [17, 0.2], [18, 0.1], [19, 0.05]] + "stops": [[13, 0.4], [14, 0.3], [16, 0.2], [17, 0.1], [18, 0.05]] } } }, { @@ -633,16 +586,14 @@ module.exports = { "source": "mapbox", "source-layer": "hillshade", "filter": { "class": "medium_highlight" }, - "render": { - "type": "fill" - }, + "type": "fill", "rasterize": "@hillshade_rasterize", "style": { "fill-color": "#ffd", "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[15, 0.3], [16, 0.3], [17, 0.2], [18, 0.2], [19, 0.1]] + "stops": [[14, 0.3], [15, 0.3], [16, 0.2], [17, 0.2], [18, 0.1]] } }, "style.night": { @@ -650,7 +601,7 @@ module.exports = { "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[15, 0.3], [17, 0.2], [18, 0.15], [19, 0.05]] + "stops": [[14, 0.3], [16, 0.2], [17, 0.15], [18, 0.05]] } } }, { @@ -658,16 +609,14 @@ module.exports = { "source": "mapbox", "source-layer": "hillshade", "filter": { "class": "medium_shadow" }, - "render": { - "type": "fill" - }, + "type": "fill", "rasterize": "@hillshade_rasterize", "style": { "fill-color": "#206", "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[15, 0.08], [16, 0.075], [17, 0.05], [18, 0.05], [19, 0.025]] + "stops": [[14, 0.08], [15, 0.075], [16, 0.05], [17, 0.05], [18, 0.025]] } }, "style.night": { @@ -675,7 +624,7 @@ module.exports = { "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[16, 0.3], [17, 0.2], [18, 0.1], [19, 0.05]] + "stops": [[15, 0.3], [16, 0.2], [17, 0.1], [18, 0.05]] } } }, { @@ -683,16 +632,14 @@ module.exports = { "source": "mapbox", "source-layer": "hillshade", "filter": { "class": "full_shadow" }, - "render": { - "type": "fill" - }, + "type": "fill", "rasterize": "@hillshade_rasterize", "style": { "fill-color": "#103", "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[15, 0.08], [16, 0.075], [17, 0.05], [18, 0.05], [19, 0.025]] + "stops": [[14, 0.08], [15, 0.075], [16, 0.05], [17, 0.05], [18, 0.025]] } }, "style.night": { @@ -700,7 +647,7 @@ module.exports = { "fill-antialias": false, "fill-opacity": { "fn": "stops", - "stops": [[16, 0.3], [17, 0.2], [18, 0.1], [19, 0.05]] + "stops": [[15, 0.3], [16, 0.2], [17, 0.1], [18, 0.05]] } } }, { @@ -708,8 +655,8 @@ module.exports = { "source": "mapbox", "source-layer": "contour", "filter": { "index": 5 }, + "type": "line", "render": { - "type": "line", "line-join": "round" }, "style": { @@ -717,7 +664,7 @@ module.exports = { "line-width": 0.9, "line-opacity": { "fn": "stops", - "stops": [[12, 0.05], [13, 0.11]] + "stops": [[11, 0.05], [12, 0.11]] } }, "style.night": { @@ -725,15 +672,15 @@ module.exports = { "line-width": 0.9, "line-opacity": { "fn": "stops", - "stops": [[12, 0.1], [13, 0.2]] + "stops": [[11, 0.1], [12, 0.2]] } } }, { "id": "contour_line_regular", "source": "mapbox", "source-layer": "contour", + "type": "line", "render": { - "type": "line", "line-join": "round" }, "style": { @@ -741,7 +688,7 @@ module.exports = { "line-width": 0.5, "line-opacity": { "fn": "stops", - "stops": [[12, 0.05], [13, 0.11]] + "stops": [[11, 0.05], [12, 0.11]] } }, "style.night": { @@ -749,7 +696,7 @@ module.exports = { "line-width": 0.5, "line-opacity": { "fn": "stops", - "stops": [[12, 0.1], [13, 0.4]] + "stops": [[11, 0.1], [12, 0.4]] } } }, { @@ -757,9 +704,7 @@ module.exports = { "source": "mapbox", "source-layer": "barrier_line", "filter": { "class": "gate" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-width": 2.5, "line-color": "#aab" @@ -773,9 +718,7 @@ module.exports = { "source": "mapbox", "source-layer": "barrier_line", "filter": { "class": "fence" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#aeada3", "line-width": "@fence_width" @@ -789,9 +732,7 @@ module.exports = { "source": "mapbox", "source-layer": "barrier_line", "filter": { "class": "hedge" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#8de99b", "line-width": "@hedge_width" @@ -805,9 +746,7 @@ module.exports = { "source": "mapbox", "source-layer": "barrier_line", "filter": { "class": "land" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@land", "line-width": "@barrier_line_land_width" @@ -821,9 +760,7 @@ module.exports = { "source": "mapbox", "source-layer": "barrier_line", "filter": { "class": "land" }, - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@land" }, @@ -835,9 +772,7 @@ module.exports = { "source": "mapbox", "source-layer": "barrier_line", "filter": { "class": "cliff" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#987", "line-width": 4 @@ -850,9 +785,7 @@ module.exports = { "id": "water", "source": "mapbox", "source-layer": "water", - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "@water", "fill-outline-color": "#a2bdc0" @@ -865,9 +798,7 @@ module.exports = { "id": "aeroway_fill", "source": "mapbox", "source-layer": "aeroway", - "render": { - "type": "fill" - }, + "type": "fill", "style": { "fill-color": "#ddd" }, @@ -879,9 +810,7 @@ module.exports = { "source": "mapbox", "source-layer": "aeroway", "filter": { "type": "runway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#ddd", "line-width": "@runway_width" @@ -895,9 +824,7 @@ module.exports = { "source": "mapbox", "source-layer": "aeroway", "filter": { "type": "taxiway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#ddd", "line-width": "@taxiway_width" @@ -911,9 +838,7 @@ module.exports = { "source": "mapbox", "source-layer": "tunnel", "filter": { "class": "motorway_link" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@case", "line-dasharray": [6, 6], @@ -929,9 +854,7 @@ module.exports = { "source": "mapbox", "source-layer": "tunnel", "filter": { "class": "service" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#000", "line-opacity": 0.04, @@ -949,16 +872,14 @@ module.exports = { "source": "mapbox", "source-layer": "tunnel", "filter": { "class": "main" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@case", "line-dasharray": [6, 6], "line-width": "@main_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9, 0], [10, 1]] + "stops": [[8, 0], [9, 1]] } }, "style.night": { @@ -967,7 +888,7 @@ module.exports = { "line-width": "@main_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9, 0], [10, 1]] + "stops": [[8, 0], [9, 1]] } } }, { @@ -975,9 +896,7 @@ module.exports = { "source": "mapbox", "source-layer": "tunnel", "filter": { "class": ["street", "street_limited"] }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#d9d5c6", "line-width": "@street_casing_width", @@ -1029,7 +948,7 @@ module.exports = { "line-width": "@main_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } }, "style.night": { @@ -1037,7 +956,7 @@ module.exports = { "line-width": "@main_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } } }, { @@ -1045,16 +964,14 @@ module.exports = { "source": "mapbox", "source-layer": "tunnel", "filter": { "class": "motorway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@case", "line-dasharray": [6, 6], "line-width": "@motorway_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9.5, 0], [10, 1]] + "stops": [[8.5, 0], [9, 1]] } }, "style.night": { @@ -1063,7 +980,7 @@ module.exports = { "line-width": "@motorway_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9.5, 0], [10, 1]] + "stops": [[8.5, 0], [9, 1]] } } }, { @@ -1074,7 +991,7 @@ module.exports = { "line-width": "@motorway_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } }, "style.night": { @@ -1082,7 +999,7 @@ module.exports = { "line-width": "@motorway_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } } }, { @@ -1090,15 +1007,13 @@ module.exports = { "source": "mapbox", "source-layer": "road", "filter": { "class": "path" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#ffd", "line-opacity": 0.4, "line-width": { "fn": "stops", - "stops": [[15, 3], [16, 4]] + "stops": [[14, 3], [15, 4]] } }, "style.night": { @@ -1110,9 +1025,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "type": "footway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#bba", "line-dasharray": [10, 4], @@ -1128,16 +1041,14 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "type": "path" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#987", "line-dasharray": [10, 4], "line-opacity": 0.8, "line-width": { "fn": "stops", - "stops": [[14, 0.8], [15, 0.9], [16, 1.2]] + "stops": [[13, 0.8], [14, 0.9], [15, 1.2]] } }, "style.night": { @@ -1146,7 +1057,7 @@ module.exports = { "line-opacity": 0.8, "line-width": { "fn": "stops", - "stops": [[14, 0.8], [15, 0.9], [16, 1.2]] + "stops": [[13, 0.8], [14, 0.9], [15, 1.2]] } } }, { @@ -1154,9 +1065,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "type": "cycleway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#488", "line-dasharray": [10, 4], @@ -1172,9 +1081,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "type": "mtb" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#488", "line-dasharray": [12, 4], @@ -1190,9 +1097,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "type": "piste" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#87b", "line-dasharray": [8, 4], @@ -1208,9 +1113,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "type": "steps" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#bba", "line-dasharray": [10, 4], @@ -1227,9 +1130,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": "major_rail" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#c8c4c0", "line-width": 0.8 @@ -1243,8 +1144,8 @@ module.exports = { "source": "mapbox", "source-layer": "road", "filter": { "class": "motorway_link" }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1261,8 +1162,8 @@ module.exports = { "source": "mapbox", "source-layer": "road", "filter": { "class": "service" }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1281,8 +1182,8 @@ module.exports = { "source": "mapbox", "source-layer": "road", "filter": { "class": "main" }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1291,7 +1192,7 @@ module.exports = { "line-width": "@main_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9, 0], [10, 1]] + "stops": [[8, 0], [9, 1]] } }, "style.night": { @@ -1299,7 +1200,7 @@ module.exports = { "line-width": "@main_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9, 0], [10, 1]] + "stops": [[8, 0], [9, 1]] } } }, { @@ -1307,8 +1208,8 @@ module.exports = { "source": "mapbox", "source-layer": "road", "filter": { "class": ["street", "street_limited"] }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1363,7 +1264,7 @@ module.exports = { "line-width": "@main_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } }, "style.night": { @@ -1371,7 +1272,7 @@ module.exports = { "line-width": "@main_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } } }, { @@ -1379,8 +1280,8 @@ module.exports = { "source": "mapbox", "source-layer": "road", "filter": { "class": "motorway" }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1389,7 +1290,7 @@ module.exports = { "line-width": "@motorway_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9.5, 0], [10, 1]] + "stops": [[8.5, 0], [9, 1]] } }, "style.night": { @@ -1397,7 +1298,7 @@ module.exports = { "line-width": "@motorway_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9.5, 0], [10, 1]] + "stops": [[8.5, 0], [9, 1]] } } }, { @@ -1408,7 +1309,7 @@ module.exports = { "line-width": "@motorway_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } }, "style.night": { @@ -1416,7 +1317,7 @@ module.exports = { "line-width": "@motorway_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } } }, { @@ -1437,9 +1338,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": "motorway_link" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@case", "line-width": "@motorway_link_casing_width" @@ -1453,9 +1352,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": "service" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#000", "line-opacity": 0.04, @@ -1471,15 +1368,13 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": "main" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@case", "line-width": "@main_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9, 0], [10, 1]] + "stops": [[8, 0], [9, 1]] } }, "style.night": { @@ -1487,7 +1382,7 @@ module.exports = { "line-width": "@main_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9, 0], [10, 1]] + "stops": [[8, 0], [9, 1]] } } }, { @@ -1495,9 +1390,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": ["street", "street_limited"] }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "#d9d5c6", "line-width": "@street_casing_width", @@ -1549,7 +1442,7 @@ module.exports = { "line-width": "@main_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } }, "style.night": { @@ -1557,7 +1450,7 @@ module.exports = { "line-width": "@main_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } } }, { @@ -1565,15 +1458,13 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": "motorway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "@case", "line-width": "@motorway_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9.5, 0], [10, 1]] + "stops": [[8.5, 0], [9, 1]] } }, "style.night": { @@ -1581,7 +1472,7 @@ module.exports = { "line-width": "@motorway_casing_width", "line-opacity": { "fn": "stops", - "stops": [[9.5, 0], [10, 1]] + "stops": [[8.5, 0], [9, 1]] } } }, { @@ -1592,7 +1483,7 @@ module.exports = { "line-width": "@motorway_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } }, "style.night": { @@ -1600,7 +1491,7 @@ module.exports = { "line-width": "@motorway_width", "line-opacity": { "fn": "stops", - "stops": [[6.5, 0], [7, 1]] + "stops": [[5.5, 0], [6, 1]] } } }, { @@ -1608,9 +1499,7 @@ module.exports = { "source": "mapbox", "source-layer": "bridge", "filter": { "class": "aerialway" }, - "render": { - "type": "line" - }, + "type": "line", "style": { "line-color": "white", "line-opacity": 0.5, @@ -1639,8 +1528,8 @@ module.exports = { "source": "mapbox", "source-layer": "admin", "filter": { "admin_level": [3, 4, 5] }, + "type": "line", "render": { - "type": "line", "line-join": "round" }, "style": { @@ -1648,7 +1537,7 @@ module.exports = { "line-dasharray": [60, 20], "line-opacity": { "fn": "stops", - "stops": [[4, 0], [6, 1]] + "stops": [[3, 0], [5, 1]] }, "line-width": "@admin_l3_width" }, @@ -1657,7 +1546,7 @@ module.exports = { "line-dasharray": [60, 20], "line-opacity": { "fn": "stops", - "stops": [[4, 0], [6, 1]] + "stops": [[3, 0], [5, 1]] }, "line-width": "@admin_l3_width" } @@ -1666,8 +1555,8 @@ module.exports = { "source": "mapbox", "source-layer": "admin", "filter": { "admin_level": 2 }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1684,8 +1573,8 @@ module.exports = { "source": "mapbox", "source-layer": "admin", "filter": { "maritime": 1 }, + "type": "line", "render": { - "type": "line", "line-join": "round", "line-cap": "round" }, @@ -1704,23 +1593,23 @@ module.exports = { "line-color": "#c0d6d6", "line-width": { "fn": "stops", - "stops": [[6, 1], [8, 2], [12, 3]] + "stops": [[5, 1], [7, 2], [11, 3]] } }, "style.night": { "line-color": "#0a1347", "line-width": { "fn": "stops", - "stops": [[6, 1], [8, 2], [12, 3]] + "stops": [[5, 1], [7, 2], [11, 3]] } } }, { "id": "country_label_line", "source": "mapbox", "source-layer": "country_label_line", + "type": "line", "render": { - "text-max-width": 5, - "type": "line" + "text-max-width": 5 }, "style": { "line-color": "@country_text", @@ -1736,10 +1625,10 @@ module.exports = { "id": "country_label", "source": "mapbox", "source-layer": "country_label", - "filter": { "$type": "point" }, + "filter": { "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 24, @@ -1761,10 +1650,10 @@ module.exports = { "id": "marine_label_line_1", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": 1 }, + "filter": { "$type": "LineString", "labelrank": 1 }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 30, @@ -1775,7 +1664,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[3, 20], [4, 25], [5, 30], [22, 30]] + "stops": [[2, 20], [3, 25], [4, 30], [21, 30]] }, "text-halo-color": "@water" }, @@ -1783,7 +1672,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[3, 20], [4, 25], [5, 30], [22, 30]] + "stops": [[2, 20], [3, 25], [4, 30], [21, 30]] }, "text-halo-color": "@water_night" } @@ -1791,10 +1680,10 @@ module.exports = { "id": "marine_label_line_2", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": 2 }, + "filter": { "$type": "LineString", "labelrank": 2 }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 24, @@ -1804,7 +1693,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[3, 13], [4, 14], [5, 20], [6, 24], [22, 24]] + "stops": [[2, 13], [3, 14], [4, 20], [5, 24], [21, 24]] }, "text-halo-color": "@water" }, @@ -1812,7 +1701,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[3, 13], [4, 14], [5, 20], [6, 24], [22, 24]] + "stops": [[2, 13], [3, 14], [4, 20], [5, 24], [21, 24]] }, "text-halo-color": "@water_night" } @@ -1820,10 +1709,10 @@ module.exports = { "id": "marine_label_line_3", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": 3 }, + "filter": { "$type": "LineString", "labelrank": 3 }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 18, @@ -1833,7 +1722,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[3, 12], [4, 13], [5, 15], [6, 18], [22, 18]] + "stops": [[2, 12], [3, 13], [4, 15], [5, 18], [21, 18]] }, "text-halo-color": "@water" }, @@ -1841,7 +1730,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[3, 12], [4, 13], [5, 15], [6, 18], [22, 18]] + "stops": [[2, 12], [3, 13], [4, 15], [5, 18], [21, 18]] }, "text-halo-color": "@water_night" } @@ -1849,10 +1738,10 @@ module.exports = { "id": "marine_label_line_other", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": [4, 5, 6] }, + "filter": { "$type": "LineString", "labelrank": [4, 5, 6] }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 16, @@ -1862,7 +1751,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[4, 12], [5, 14], [6, 16], [22, 16]] + "stops": [[3, 12], [4, 14], [5, 16], [21, 16]] }, "text-halo-color": "@water" }, @@ -1870,7 +1759,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[4, 12], [5, 14], [6, 16], [22, 16]] + "stops": [[3, 12], [4, 14], [5, 16], [21, 16]] }, "text-halo-color": "@water_night" } @@ -1878,10 +1767,10 @@ module.exports = { "id": "marine_label_point_1", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": 1 }, + "filter": { "$type": "Point", "labelrank": 1 }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 30, @@ -1893,7 +1782,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[3, 20], [4, 25], [5, 30], [22, 30]] + "stops": [[2, 20], [3, 25], [4, 30], [21, 30]] }, "text-halo-color": "@water" }, @@ -1901,7 +1790,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[3, 20], [4, 25], [5, 30], [22, 30]] + "stops": [[2, 20], [3, 25], [4, 30], [21, 30]] }, "text-halo-color": "@water_night" } @@ -1909,10 +1798,10 @@ module.exports = { "id": "marine_label_point_2", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": 2 }, + "filter": { "$type": "Point", "labelrank": 2 }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 24, @@ -1924,7 +1813,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[3, 13], [4, 14], [5, 20], [6, 24], [22, 24]] + "stops": [[2, 13], [3, 14], [4, 20], [5, 24], [21, 24]] }, "text-halo-color": "@water" }, @@ -1932,7 +1821,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[3, 13], [4, 14], [5, 20], [6, 24], [22, 24]] + "stops": [[2, 13], [3, 14], [4, 20], [5, 24], [21, 24]] }, "text-halo-color": "@water_night" } @@ -1940,10 +1829,10 @@ module.exports = { "id": "marine_label_point_3", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": 3 }, + "filter": { "$type": "Point", "labelrank": 3 }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 18, @@ -1955,7 +1844,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[3, 12], [4, 13], [5, 15], [6, 18], [22, 18]] + "stops": [[2, 12], [3, 13], [4, 15], [5, 18], [21, 18]] }, "text-halo-color": "@water" }, @@ -1963,7 +1852,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[3, 12], [4, 13], [5, 15], [6, 18], [22, 18]] + "stops": [[2, 12], [3, 13], [4, 15], [5, 18], [21, 18]] }, "text-halo-color": "@water_night" } @@ -1971,10 +1860,10 @@ module.exports = { "id": "marine_label_point_other", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": [4, 5, 6] }, + "filter": { "$type": "Point", "labelrank": [4, 5, 6] }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 16, @@ -1986,7 +1875,7 @@ module.exports = { "text-color": "@marine_text", "text-size": { "fn": "stops", - "stops": [[4, 12], [5, 14], [6, 16], [22, 16]] + "stops": [[3, 12], [4, 14], [5, 16], [21, 16]] }, "text-halo-color": "@water" }, @@ -1994,7 +1883,7 @@ module.exports = { "text-color": "@water_dark_night", "text-size": { "fn": "stops", - "stops": [[4, 12], [5, 14], [6, 16], [22, 16]] + "stops": [[3, 12], [4, 14], [5, 16], [21, 16]] }, "text-halo-color": "@water_night" } @@ -2002,10 +1891,10 @@ module.exports = { "id": "state_label", "source": "mapbox", "source-layer": "state_label", - "filter": { "$type": "point" }, + "filter": { "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Regular, Arial Unicode MS Regular", "text-max-size": 16, @@ -2017,7 +1906,7 @@ module.exports = { "text-halo-color": "rgba(244,239,225,0.8)", "text-size": { "fn": "stops", - "stops": [[3.99, 0], [4, 10], [9.99, 16], [10, 0]] + "stops": [[2.99, 0], [3, 10], [8.99, 16], [9, 0]] } }, "style.night": { @@ -2026,17 +1915,17 @@ module.exports = { "text-halo-color": "@land_night", "text-size": { "fn": "stops", - "stops": [[3.99, 0], [4, 10], [9.99, 16], [10, 0]] + "stops": [[2.99, 0], [3, 10], [8.99, 16], [9, 0]] } } }, { "id": "place_label_city", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": "city", "$type": "point" }, + "filter": { "type": "city", "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 20, @@ -2048,7 +1937,7 @@ module.exports = { "text-halo-color": "@text_stroke", "text-size": { "fn": "stops", - "stops": [[3.99, 0], [4, 10], [7, 14], [14.99, 20], [15, 0]] + "stops": [[2.99, 0], [3, 10], [6, 14], [13.99, 20], [14, 0]] } }, "style.night": { @@ -2057,17 +1946,17 @@ module.exports = { "text-halo-color": "@text2_stroke_night", "text-size": { "fn": "stops", - "stops": [[3.99, 0], [4, 10], [7, 14], [14.99, 20], [15, 0]] + "stops": [[2.99, 0], [3, 10], [6, 14], [13.99, 20], [14, 0]] } } }, { "id": "place_label_town", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": "town", "$type": "point" }, + "filter": { "type": "town", "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 24, @@ -2079,7 +1968,7 @@ module.exports = { "text-halo-color": "@text_stroke", "text-size": { "fn": "stops", - "stops": [[9, 10], [12, 13], [14, 17], [16, 22]] + "stops": [[8, 10], [11, 13], [13, 17], [15, 22]] } }, "style.night": { @@ -2088,17 +1977,17 @@ module.exports = { "text-halo-color": "@text2_stroke_night", "text-size": { "fn": "stops", - "stops": [[9, 10], [12, 13], [14, 17], [16, 22]] + "stops": [[8, 10], [11, 13], [13, 17], [15, 22]] } } }, { "id": "place_label_village", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": "village", "$type": "point" }, + "filter": { "type": "village", "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 22, @@ -2110,7 +1999,7 @@ module.exports = { "text-halo-color": "@text_stroke", "text-size": { "fn": "stops", - "stops": [[9, 8], [12, 10], [14, 14], [16, 16], [17, 20]] + "stops": [[8, 8], [11, 10], [13, 14], [15, 16], [16, 20]] } }, "style.night": { @@ -2119,17 +2008,17 @@ module.exports = { "text-halo-color": "@text2_stroke_night", "text-size": { "fn": "stops", - "stops": [[9, 8], [12, 10], [14, 14], [16, 16], [17, 20]] + "stops": [[8, 8], [11, 10], [13, 14], [15, 16], [16, 20]] } } }, { "id": "place_label_other", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": ["hamlet", "suburb", "neighbourhood"], "$type": "point" }, + "filter": { "type": ["hamlet", "suburb", "neighbourhood"], "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 18, @@ -2140,7 +2029,7 @@ module.exports = { "text-halo-color": "@text_stroke", "text-size": { "fn": "stops", - "stops": [[13, 11], [14, 12], [16, 14], [18, 18]] + "stops": [[12, 11], [13, 12], [15, 14], [17, 18]] } }, "style.night": { @@ -2149,17 +2038,17 @@ module.exports = { "text-halo-width": 0.3, "text-size": { "fn": "stops", - "stops": [[13, 11], [14, 12], [16, 14], [18, 18]] + "stops": [[12, 11], [13, 12], [15, 14], [17, 18]] } } }, { "id": "road_label_1", "source": "mapbox", "source-layer": "road_label", - "filter": { "class": ["motorway", "main"], "$type": "line" }, + "filter": { "class": ["motorway", "main"], "$type": "LineString" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-padding": 2, "text-font": "Open Sans Regular, Arial Unicode MS Regular", @@ -2182,10 +2071,10 @@ module.exports = { "id": "road_label_2", "source": "mapbox", "source-layer": "road_label", - "filter": { "class": ["street", "street_limited"], "$type": "line" }, + "filter": { "class": ["street", "street_limited"], "$type": "LineString" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-padding": 2, "text-font": "Open Sans Regular, Arial Unicode MS Regular", @@ -2208,10 +2097,10 @@ module.exports = { "id": "road_label_3", "source": "mapbox", "source-layer": "road_label", - "filter": { "class": ["service", "driveway", "path"], "$type": "line" }, + "filter": { "class": ["service", "driveway", "path"], "$type": "LineString" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-padding": 2, "text-font": "Open Sans Regular, Arial Unicode MS Regular", @@ -2234,11 +2123,11 @@ module.exports = { "id": "contour_label", "source": "mapbox", "source-layer": "contour", - "filter": { "index": [5, 10], "$type": "line" }, + "filter": { "index": [5, 10], "$type": "LineString" }, + "type": "text", "render": { - "type": "text", "text-path": "curve", - "text-field": "{{ele}} m", + "text-field": "{ele} m", "text-font": "Open Sans Regular, Arial Unicode MS Regular", "text-max-size": 10, "text-max-angle": 0.5 @@ -2259,10 +2148,10 @@ module.exports = { "id": "water_label", "source": "mapbox", "source-layer": "water_label", - "filter": { "$type": "point" }, + "filter": { "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 12, @@ -2280,10 +2169,10 @@ module.exports = { "id": "waterway_label", "source": "mapbox", "source-layer": "waterway_label", - "filter": { "$type": "line" }, + "filter": { "$type": "LineString" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 12, @@ -2303,9 +2192,9 @@ module.exports = { "source": "mapbox", "source-layer": "poi_label", "filter": { "scalerank": [1, 2] }, + "type": "icon", "render": { - "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style.night": {} @@ -2313,10 +2202,10 @@ module.exports = { "id": "poi_label_1-2", "source": "mapbox", "source-layer": "poi_label", - "filter": { "scalerank": [1, 2], "$type": "point" }, + "filter": { "scalerank": [1, 2], "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-padding": 2, "text-font": "Open Sans Semibold, Arial Unicode MS Bold", @@ -2341,31 +2230,31 @@ module.exports = { "source": "mapbox", "source-layer": "poi_label", "filter": { "scalerank": 3 }, + "type": "icon", "render": { - "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style": { "icon-opacity": { "fn": "stops", - "stops": [[16.5, 0], [16.75, 1]] + "stops": [[15.5, 0], [15.75, 1]] } }, "style.night": { "icon-opacity": { "fn": "stops", - "stops": [[16.5, 0], [16.75, 1]] + "stops": [[15.5, 0], [15.75, 1]] } } }, { "id": "poi_label_3", "source": "mapbox", "source-layer": "poi_label", - "filter": { "scalerank": 3, "$type": "point" }, + "filter": { "scalerank": 3, "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-padding": 2, "text-font": "Open Sans Semibold, Arial Unicode MS Bold", @@ -2380,7 +2269,7 @@ module.exports = { "text-halo-width": 0.3, "text-opacity": { "fn": "stops", - "stops": [[16.5, 0], [16.75, 1]] + "stops": [[15.5, 0], [15.75, 1]] } }, "style.night": { @@ -2390,7 +2279,7 @@ module.exports = { "text-halo-width": 0.3, "text-opacity": { "fn": "stops", - "stops": [[16.5, 0], [16.75, 1]] + "stops": [[15.5, 0], [15.75, 1]] } } }, { @@ -2398,31 +2287,31 @@ module.exports = { "source": "mapbox", "source-layer": "poi_label", "filter": { "scalerank": 4 }, + "type": "icon", "render": { - "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style": { "icon-opacity": { "fn": "stops", - "stops": [[18.5, 0], [18.75, 1]] + "stops": [[17.5, 0], [17.75, 1]] } }, "style.night": { "icon-opacity": { "fn": "stops", - "stops": [[18.5, 0], [18.75, 1]] + "stops": [[17.5, 0], [17.75, 1]] } } }, { "id": "poi_label_4", "source": "mapbox", "source-layer": "poi_label", - "filter": { "scalerank": 4, "$type": "point" }, + "filter": { "scalerank": 4, "$type": "Point" }, + "type": "text", "render": { - "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-padding": 2, "text-font": "Open Sans Semibold, Arial Unicode MS Bold", @@ -2435,7 +2324,7 @@ module.exports = { "text-size": 10, "text-opacity": { "fn": "stops", - "stops": [[18.5, 0], [18.75, 1]] + "stops": [[17.5, 0], [17.75, 1]] }, "text-halo-color": "@land", "text-halo-width": 0.3 @@ -2445,7 +2334,7 @@ module.exports = { "text-size": 10, "text-opacity": { "fn": "stops", - "stops": [[18.5, 0], [18.75, 1]] + "stops": [[17.5, 0], [17.75, 1]] }, "text-halo-color": "@text2_stroke_night", "text-halo-width": 0.3 @@ -2455,21 +2344,21 @@ module.exports = { "source": "mapbox", "source-layer": "poi_label", "filter": { "maki": "airport" }, + "type": "icon", "render": { - "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style": { "icon-opacity": { "fn": "stops", - "stops": [[13, 0], [13.25, 1]] + "stops": [[12, 0], [12.25, 1]] } }, "style.night": { "icon-opacity": { "fn": "stops", - "stops": [[13, 0], [13.25, 1]] + "stops": [[12, 0], [12.25, 1]] } } }] diff --git a/common.gypi b/common.gypi index a9567d4d3..a38a279ef 100644 --- a/common.gypi +++ b/common.gypi @@ -33,6 +33,16 @@ 'DEAD_CODE_STRIPPING': 'YES', 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' } + }, + 'Testing': { + 'cflags_cc': [ '-O3' ], + 'defines': [ 'NDEBUG', 'TESTING' ], + 'xcode_settings': { + 'GCC_OPTIMIZATION_LEVEL': '3', + 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO', + 'DEAD_CODE_STRIPPING': 'YES', + 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' + } } } } diff --git a/common/nslog_log.hpp b/common/nslog_log.hpp new file mode 100644 index 000000000..9f2f3aee7 --- /dev/null +++ b/common/nslog_log.hpp @@ -0,0 +1,21 @@ +#ifndef LLMR_COMMON_NSLOG_LOG +#define LLMR_COMMON_NSLOG_LOG + +#include + +namespace llmr { + +class NSLogBackend : public LogBackend { +public: + inline ~NSLogBackend() = default; + + void record(EventSeverity severity, Event event, const std::string &msg); + void record(EventSeverity severity, Event event, const char* format, ...); + void record(EventSeverity severity, Event event, int64_t code); + void record(EventSeverity severity, Event event, int64_t code, const std::string &msg); +}; + + +} + +#endif diff --git a/common/nslog_log.mm b/common/nslog_log.mm new file mode 100644 index 000000000..ad685ea8d --- /dev/null +++ b/common/nslog_log.mm @@ -0,0 +1,37 @@ +#include "nslog_log.hpp" + +#import + +namespace llmr { + +void NSLogBackend::record(EventSeverity severity, Event event, const std::string &msg) { + NSLog(@"[%s] %s: %@", stringifyEventSeverity(severity), stringifyEvent(event), + [[NSString alloc] initWithBytes:msg.data() + length:msg.size() + encoding:NSUTF8StringEncoding]); +} + + +void NSLogBackend::record(EventSeverity severity, Event event, const char* format, ...) { + va_list args; + va_start(args, format); + const int len = vsnprintf(NULL, 0, format, args); + va_end(args); + std::unique_ptr buffer(new char[len + 1]); + va_start(args, format); + vsnprintf(buffer.get(), len + 1, format, args); + va_end(args); + NSLog(@"[%s] %s: %s", stringifyEventSeverity(severity), stringifyEvent(event), buffer.get()); +} + +void NSLogBackend::record(EventSeverity severity, Event event, int64_t code) { + NSLog(@"[%s] %s: (%lld)", stringifyEventSeverity(severity), stringifyEvent(event), code); +} + +void NSLogBackend::record(EventSeverity severity, Event event, int64_t code, const std::string &msg) { + NSLog(@"[%s] %s: (%lld) %@", stringifyEventSeverity(severity), stringifyEvent(event), code, + [[NSString alloc] initWithBytes:msg.data() + length:msg.size() + encoding:NSUTF8StringEncoding]); +} +} diff --git a/common/stderr_log.cpp b/common/stderr_log.cpp new file mode 100644 index 000000000..18ad9b3f1 --- /dev/null +++ b/common/stderr_log.cpp @@ -0,0 +1,29 @@ +#include "stderr_log.hpp" + +#include + +namespace llmr { + +void StderrLogBackend::record(EventSeverity severity, Event event, const std::string &msg) { + std::cerr << "[" << severity << "] " << event << ": " << msg << std::endl; +} + +void StderrLogBackend::record(EventSeverity severity, Event event, const char* format, ...) { + std::cerr << "[" << severity << "] " << event << ": "; + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + std::cerr << std::endl; +} + +void StderrLogBackend::record(EventSeverity severity, Event event, int64_t code) { + std::cerr << "[" << severity << "] " << event << ": (" << code << ")" << std::endl; +} + +void StderrLogBackend::record(EventSeverity severity, Event event, int64_t code, const std::string &msg) { + std::cerr << "[" << severity << "] " << event << ": (" << code << ") " << msg << std::endl; + +} + +} diff --git a/common/stderr_log.hpp b/common/stderr_log.hpp new file mode 100644 index 000000000..e2492d3af --- /dev/null +++ b/common/stderr_log.hpp @@ -0,0 +1,21 @@ +#ifndef LLMR_COMMON_STDERR_LOG +#define LLMR_COMMON_STDERR_LOG + +#include + +namespace llmr { + +class StderrLogBackend : public LogBackend { +public: + inline ~StderrLogBackend() = default; + + void record(EventSeverity severity, Event event, const std::string &msg); + void record(EventSeverity severity, Event event, const char* format, ...); + void record(EventSeverity severity, Event event, int64_t code); + void record(EventSeverity severity, Event event, int64_t code, const std::string &msg); +}; + + +} + +#endif diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 1af6b3c54..5968e6b16 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -55,10 +55,11 @@ public: void setAppliedClasses(const std::vector &classes); void toggleClass(const std::string &name); const std::vector &getAppliedClasses() const; - void setAppliedClasses(std::vector &class_names); void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); void setStyleJSON(std::string newStyleJSON); std::string getStyleJSON() const; + void setAccessToken(std::string access_token); + std::string getAccessToken() const; // Transition void cancelTransitions(); @@ -166,6 +167,7 @@ private: Painter painter; std::string styleJSON = ""; + std::string accessToken = ""; bool debug = false; timestamp animationTime = 0; diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp index 2937a8f69..f74624925 100644 --- a/include/llmr/map/source.hpp +++ b/include/llmr/map/source.hpp @@ -23,7 +23,8 @@ class Texturepool; class Source : public std::enable_shared_from_this, private util::noncopyable { public: Source(SourceType type = SourceType::Vector, const std::string &url = "", - uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 22); + uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 22, + const std::string &access_token = ""); bool update(Map &map); void updateMatrices(const mat4 &projMatrix, const TransformState &transform); @@ -35,7 +36,7 @@ public: std::forward_list getIDs() const; void updateClipIDs(const std::map &mapping); - static std::string normalizeSourceURL(const std::string &url); + static std::string normalizeSourceURL(const std::string &url, const std::string &access_token); public: const SourceType type; diff --git a/include/llmr/platform/event.hpp b/include/llmr/platform/event.hpp new file mode 100644 index 000000000..c1552b1c6 --- /dev/null +++ b/include/llmr/platform/event.hpp @@ -0,0 +1,63 @@ +#ifndef LLMR_PLATFORM_EVENT +#define LLMR_PLATFORM_EVENT + +#include +#include + +namespace llmr { + +enum class EventSeverity : uint8_t { + Debug, + Info, + Test, + Warning, + Error, +}; + +EventSeverity parseEventSeverity(const char *name); +const char *stringifyEventSeverity(EventSeverity eventSeverity); +::std::ostream& operator<<(::std::ostream& os, EventSeverity eventSeverity); + +enum class Event : uint8_t { + General, + Setup, + Shader, + ParseStyle, + ParseTile, + Render, + HttpRequest, +}; + +Event parseEvent(const char *name); +const char *stringifyEvent(Event event); +::std::ostream& operator<<(::std::ostream& os, Event event); + +struct EventPermutation { + const EventSeverity severity; + const Event event; + + constexpr bool operator==(const EventPermutation &rhs) const { + return severity == rhs.severity && event == rhs.event; + } +}; + +constexpr EventSeverity disabledEventSeverities[] = { +#if !DEBUG + EventSeverity::Debug, +#endif +#if !TESTING + EventSeverity::Test, +#endif +}; + + +constexpr Event disabledEvents[] = { +}; + +constexpr EventPermutation disabledEventPermutations[] = { + { EventSeverity::Debug, Event::Shader } +}; + +} + +#endif diff --git a/include/llmr/platform/log.hpp b/include/llmr/platform/log.hpp new file mode 100644 index 000000000..7b3937004 --- /dev/null +++ b/include/llmr/platform/log.hpp @@ -0,0 +1,71 @@ +#ifndef LLMR_PLATFORM_LOG +#define LLMR_PLATFORM_LOG + +#include "event.hpp" + +#include +#include + +namespace llmr { + +class LogBackend { +public: + virtual inline ~LogBackend() = default; + virtual void record(EventSeverity severity, Event event, const std::string &msg) = 0; + virtual void record(EventSeverity severity, Event event, const char* format, ...) = 0; + virtual void record(EventSeverity severity, Event event, int64_t code) = 0; + virtual void record(EventSeverity severity, Event event, int64_t code, const std::string &msg) = 0; +}; + +class Log { +private: + template + constexpr static bool includes(const T e, T const *l, const size_t i = 0) { + return i >= sizeof l ? false : *(l + i) == e ? true : includes(e, l, i + 1); + } + +public: + template + static inline void Debug(Event event, Args&& ...args) { + Record(EventSeverity::Debug, event, ::std::forward(args)...); + } + + template + static inline void Info(Event event, Args&& ...args) { + Record(EventSeverity::Info, event, ::std::forward(args)...); + } + + template + static inline void Warning(Event event, Args&& ...args) { + Record(EventSeverity::Warning, event, ::std::forward(args)...); + } + + template + static inline void Error(Event event, Args&& ...args) { + Record(EventSeverity::Error, event, ::std::forward(args)...); + } + + template + static inline void Record(EventSeverity severity, Event event, Args&& ...args) { + if (!includes(severity, disabledEventSeverities) && + !includes(event, disabledEvents) && + !includes({ severity, event }, disabledEventPermutations)) { + if (Backend) { + Backend->record(severity, event, ::std::forward(args)...); + } + } + } + + template + static inline const T &Set(Args&& ...args) { + Backend = ::std::unique_ptr(new T(::std::forward(args)...)); + return *dynamic_cast(Backend.get()); + } + +private: + static std::unique_ptr Backend; +}; + +} + +#endif diff --git a/include/llmr/style/filter_expression.hpp b/include/llmr/style/filter_expression.hpp index 696aa04ae..5c7a400d8 100644 --- a/include/llmr/style/filter_expression.hpp +++ b/include/llmr/style/filter_expression.hpp @@ -85,7 +85,7 @@ public: enum class GeometryType : uint8_t { Any, Point, - Line, + LineString, Polygon }; diff --git a/include/llmr/style/function_properties.hpp b/include/llmr/style/function_properties.hpp index 75714d119..e72ced0b0 100644 --- a/include/llmr/style/function_properties.hpp +++ b/include/llmr/style/function_properties.hpp @@ -29,14 +29,14 @@ private: template struct ExponentialFunction { - inline ExponentialFunction(const T &value, float z_base, float slope, const T &min, + inline ExponentialFunction(const T &value, float z_base, float exp_base, float slope, const T &min, const T &max) - : value(value), min(min), max(max), z_base(z_base), slope(slope) {} + : value(value), min(min), max(max), z_base(z_base), exp_base(exp_base), slope(slope) {} T evaluate(float z) const; private: const T value, min, max; - const float z_base, slope; + const float z_base, exp_base, slope; }; template diff --git a/include/llmr/style/property_key.hpp b/include/llmr/style/property_key.hpp index 47d0d2b78..e52c33ad1 100644 --- a/include/llmr/style/property_key.hpp +++ b/include/llmr/style/property_key.hpp @@ -4,7 +4,6 @@ namespace llmr { enum class PropertyKey { - FillEnabled, FillAntialias, FillOpacity, FillColor, @@ -15,7 +14,6 @@ enum class PropertyKey { FillTranslateAnchor, FillImage, - LineEnabled, LineOpacity, LineColor, LineTranslate, // for transitions only @@ -30,12 +28,10 @@ enum class PropertyKey { LineDashGap, LineImage, - IconEnabled, IconOpacity, IconRotate, IconRotateAnchor, - TextEnabled, TextOpacity, TextSize, TextColor, @@ -43,10 +39,8 @@ enum class PropertyKey { TextHaloWidth, TextHaloBlur, - CompositeEnabled, CompositeOpacity, - RasterEnabled, RasterOpacity, RasterSpin, RasterBrightnessLow, diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index 37a50485b..cfaba1898 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -16,6 +16,7 @@ namespace llmr { +class Map; class Sprite; class Source; class StyleLayer; @@ -27,7 +28,7 @@ public: struct exception : std::runtime_error { exception(const char *msg) : std::runtime_error(msg) {} }; public: - Style(); + Style(Map &map); void loadJSON(const uint8_t *const data); @@ -63,6 +64,7 @@ private: private: + Map ↦ std::set> activeSources; PropertyTransition defaultTransition; bool initial_render_complete = false; diff --git a/include/llmr/style/style_bucket.hpp b/include/llmr/style/style_bucket.hpp index b963caba8..55ffeeb18 100644 --- a/include/llmr/style/style_bucket.hpp +++ b/include/llmr/style/style_bucket.hpp @@ -71,7 +71,8 @@ class StyleBucket { public: typedef std::shared_ptr Ptr; - BucketType type = BucketType::None; + StyleBucket(StyleLayerType type); + std::string name; std::shared_ptr source; std::string source_layer; diff --git a/include/llmr/style/style_layer.hpp b/include/llmr/style/style_layer.hpp index 5d8215cf0..4d6b8d1fa 100644 --- a/include/llmr/style/style_layer.hpp +++ b/include/llmr/style/style_layer.hpp @@ -61,6 +61,8 @@ public: // The name of this layer. const std::string id; + StyleLayerType type = StyleLayerType::Unknown; + // Bucket information, telling the renderer how to generate the geometries // for this layer (feature property filters, tessellation instructions, ...). std::shared_ptr bucket; diff --git a/include/llmr/style/style_parser.hpp b/include/llmr/style/style_parser.hpp index 10cd3d2e8..27dfd4757 100644 --- a/include/llmr/style/style_parser.hpp +++ b/include/llmr/style/style_parser.hpp @@ -17,6 +17,7 @@ namespace llmr { enum class ClassID : uint32_t; +class Map; class StyleLayer; class StyleLayerGroup; @@ -24,6 +25,8 @@ class StyleParser { public: using JSVal = const rapidjson::Value&; + StyleParser(Map &map); + void parse(JSVal document); std::shared_ptr getLayers() { @@ -92,6 +95,8 @@ private: std::forward_list parseValues(JSVal values); private: + Map ↦ + std::unordered_map constants; std::unordered_map> sources; diff --git a/include/llmr/style/style_properties.hpp b/include/llmr/style/style_properties.hpp index 71758563a..bc46e2d85 100644 --- a/include/llmr/style/style_properties.hpp +++ b/include/llmr/style/style_properties.hpp @@ -14,7 +14,6 @@ namespace llmr { struct FillProperties { FillProperties() {} - bool enabled = true; bool antialias = true; float opacity = 1.0f; Color fill_color = {{ 0, 0, 0, 1 }}; @@ -24,13 +23,12 @@ struct FillProperties { std::string image; inline bool isVisible() const { - return enabled && opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0); + return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0); } }; struct LineProperties { inline LineProperties() {} - bool enabled = true; float opacity = 1.0f; Color color = {{ 0, 0, 0, 1 }}; std::array translate = {{ 0, 0 }}; @@ -42,25 +40,23 @@ struct LineProperties { std::string image; inline bool isVisible() const { - return enabled && opacity > 0 && color[3] > 0 && width > 0; + return opacity > 0 && color[3] > 0 && width > 0; } }; struct IconProperties { inline IconProperties() {} - bool enabled = true; float opacity = 1.0f; float rotate = 0.0f; RotateAnchorType rotate_anchor = RotateAnchorType::Default; inline bool isVisible() const { - return enabled && opacity > 0; + return opacity > 0; } }; struct TextProperties { inline TextProperties() {} - bool enabled = true; float opacity = 1.0f; float size = 12.0f; Color color = {{ 0, 0, 0, 1 }}; @@ -69,23 +65,21 @@ struct TextProperties { float halo_blur = 1.0f; inline bool isVisible() const { - return enabled && opacity > 0 && (color[3] > 0 || halo_color[3] > 0) && size > 0; + return opacity > 0 && (color[3] > 0 || halo_color[3] > 0) && size > 0; } }; struct CompositeProperties { inline CompositeProperties() {} - bool enabled = true; float opacity = 1.0f; inline bool isVisible() const { - return enabled && opacity > 0; + return opacity > 0; } }; struct RasterProperties { inline RasterProperties() {} - bool enabled = true; float opacity = 1.0f; float spin = 0.0f; std::array brightness = {{ 0, 1 }}; @@ -94,7 +88,7 @@ struct RasterProperties { float fade = 0.0f; inline bool isVisible() const { - return enabled && opacity > 0; + return opacity > 0; } }; diff --git a/include/llmr/style/types.hpp b/include/llmr/style/types.hpp index fd862c00d..fc0cc99ab 100644 --- a/include/llmr/style/types.hpp +++ b/include/llmr/style/types.hpp @@ -9,19 +9,20 @@ namespace llmr { // Stores a premultiplied color, with all four channels ranging from 0..1 typedef std::array Color; -enum class BucketType : uint8_t { - None, +enum class StyleLayerType : uint8_t { + Unknown, Fill, Line, Icon, Text, Raster, - Default = None + Composite, + Background }; -BucketType parseBucketType(const std::string &type); -const char *stringifyBucketType(BucketType type); -std::ostream& operator<<(std::ostream&, BucketType type); +StyleLayerType parseStyleLayerType(const std::string &type); +const char *stringifyStyleLayerType(StyleLayerType type); +std::ostream& operator<<(std::ostream&, StyleLayerType type); enum class WindingType : uint8_t { diff --git a/include/llmr/style/value.hpp b/include/llmr/style/value.hpp index bdcba4cad..fac316d3d 100644 --- a/include/llmr/style/value.hpp +++ b/include/llmr/style/value.hpp @@ -10,12 +10,6 @@ typedef util::variant Value; std::string toString(const Value &value); -inline std::string& operator+=(std::string& out, const Value& value) { - out += toString(value); - return out; -} - - Value parseValue(pbf data); namespace util { diff --git a/include/llmr/util/timer.hpp b/include/llmr/util/timer.hpp index a1e8e05a9..5dc0cfaf3 100644 --- a/include/llmr/util/timer.hpp +++ b/include/llmr/util/timer.hpp @@ -1,6 +1,8 @@ #ifndef LLMR_UTIL_TIMER #define LLMR_UTIL_TIMER +#include + #include namespace llmr { @@ -9,24 +11,29 @@ namespace util { #ifndef DISABLE_TIMER class timer { public: - timer(); - timer(const std::string &name); + timer(Event event = Event::General); + timer(EventSeverity severity, Event event = Event::General); + timer(const std::string &name, Event event = Event::General); + timer(const std::string &name, EventSeverity severity, Event event = Event::General); void report(const std::string &name); ~timer(); private: const std::string name; + EventSeverity severity = EventSeverity::Debug; + Event event = Event::General; uint64_t start; }; #else class timer { - inline timer() {} - inline timer(const std::string &name) {} - inline void report (const std::string &name) {} + inline timer(Event event = Event::General); + inline timer(EventSeverity severity, Event event = Event::General); + inline timer(const std::string &name, Event event = Event::General); + inline timer(const std::string &name, EventSeverity severity, Event event = Event::General); + inline void report(const std::string &name) {} inline ~timer() {} }; #endif - } } diff --git a/include/llmr/util/token.hpp b/include/llmr/util/token.hpp index db5b5fa0c..6795b97d1 100644 --- a/include/llmr/util/token.hpp +++ b/include/llmr/util/token.hpp @@ -9,40 +9,43 @@ namespace regex_impl = boost; namespace regex_impl = std; #endif +#include + namespace llmr { namespace util { namespace detail { -const regex_impl::regex tokenRegex("\\{\\{(\\w+)\\}\\}"); +const regex_impl::regex tokenRegex("\\{(\\w+)\\}"); const regex_impl::sregex_token_iterator tokensEnd = regex_impl::sregex_token_iterator(); } -template -std::string replaceTokens(const std::string &source, const Tokens &tokens) { +template +std::string replaceTokens(const std::string &source, const Lookup &lookup) { std::string result; result.reserve(source.size()); bool token = false; for (auto token_it = regex_impl::sregex_token_iterator(source.begin(), source.end(), detail::tokenRegex, {-1, 1}); - token_it != detail::tokensEnd; ++token_it, token = !token) { + token_it != detail::tokensEnd; ++token_it, token = !token) { if (!token_it->matched) { continue; } - if (token) { - const auto it_prop = tokens.find(token_it->str()); - if (it_prop != tokens.end()) { - result += it_prop->second; - } - } else { - result += token_it->str(); - } + result += token ? lookup(token_it->str()) : token_it->str(); } return result; } +template +inline std::string replaceTokens(const std::string &source, const std::map &properties) { + return replaceTokens(source, [&properties](const std::string &token) -> std::string { + const auto it_prop = properties.find(token); + return it_prop != properties.end() ? toString(it_prop->second) : ""; + }); +} + } // end namespace util } // end namespace llmr diff --git a/ios/Info.plist b/ios/Info.plist deleted file mode 100644 index 9c96d492a..000000000 --- a/ios/Info.plist +++ /dev/null @@ -1,47 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - ${PRODUCT_NAME} - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.mapbox.${PRODUCT_NAME:rfc1034identifier} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 0.0.1 - CFBundleSignature - LLMR - CFBundleVersion - 0.0.1 - LSRequiresIPhoneOS - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - NSHumanReadableCopyright - (c) 2014 Mapbox - - diff --git a/ios/MBXAppDelegate.h b/ios/MBXAppDelegate.h deleted file mode 100644 index 102343332..000000000 --- a/ios/MBXAppDelegate.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// MBXAppDelegate.h -// ios -// -// Created by Justin R. Miller on 1/27/14. -// -// - -#import - -@interface MBXAppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - -@end \ No newline at end of file diff --git a/ios/MBXAppDelegate.m b/ios/MBXAppDelegate.m deleted file mode 100644 index 0fbcc6e81..000000000 --- a/ios/MBXAppDelegate.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// MBXAppDelegate.m -// ios -// -// Created by Justin R. Miller on 1/27/14. -// -// - -#import "MBXAppDelegate.h" - -#import "MBXViewController.h" - -@implementation MBXAppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.rootViewController = [MBXViewController new]; - [self.window makeKeyAndVisible]; - - return YES; -} - -@end diff --git a/ios/MBXViewController.h b/ios/MBXViewController.h deleted file mode 100644 index 924d3af60..000000000 --- a/ios/MBXViewController.h +++ /dev/null @@ -1,5 +0,0 @@ -#import - -@interface MBXViewController : UIViewController - -@end diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm deleted file mode 100644 index 33e2f6e5e..000000000 --- a/ios/MBXViewController.mm +++ /dev/null @@ -1,214 +0,0 @@ -#import "MBXViewController.h" - -#import "MGLMapView.h" - -#import "../common/settings_nsuserdefaults.hpp" - -#import - -@interface MBXViewController () - -@property (nonatomic) MGLMapView *mapView; -@property (nonatomic) BOOL debug; -@property (nonatomic) UIView *palette; -@property (nonatomic) CLLocationManager *locationManager; - -@end - -@implementation MBXViewController - -llmr::Settings_NSUserDefaults *settings = nullptr; - -#pragma mark - Setup - -- (id)init -{ - self = [super init]; - - if (self) - { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveState:) name:UIApplicationDidEnterBackgroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(restoreState:) name:UIApplicationWillEnterForegroundNotification object:nil]; - } - - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds]; - self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - [self.view addSubview:self.mapView]; - - self.mapView.viewControllerForLayoutGuides = self; - - settings = new llmr::Settings_NSUserDefaults(); - [self restoreState:nil]; - - [self setupDebugUI]; - - self.locationManager = [CLLocationManager new]; - self.locationManager.delegate = self; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" - -- (void)saveState:(NSNotification *)notification -{ - if (self.mapView && settings) - { - settings->longitude = self.mapView.centerCoordinate.longitude; - settings->latitude = self.mapView.centerCoordinate.latitude; - settings->zoom = self.mapView.zoomLevel; - settings->angle = self.mapView.direction; - settings->debug = self.mapView.isDebugActive; - settings->save(); - } -} - -- (void)restoreState:(NSNotification *)notification -{ - if (self.mapView && settings) { - settings->load(); - [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(settings->latitude, settings->longitude) zoomLevel:settings->zoom animated:NO]; - self.mapView.direction = settings->angle; - [self.mapView setDebugActive:settings->debug]; - } -} - -#pragma clang diagnostic pop - -- (void)setupDebugUI -{ - UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapGesture:)]; - singleTap.numberOfTapsRequired = 1; - [self.mapView addGestureRecognizer:singleTap]; - - NSArray *selectorNames = @[ @"unrotate", @"resetPosition", @"toggleDebug", @"toggleStyle", @"locateUser" ]; - CGFloat buttonSize = 40; - CGFloat bufferSize = 20; - CGFloat alpha = 0.75; - CGFloat paletteWidth = buttonSize + (2 * bufferSize); - CGFloat paletteHeight = [selectorNames count] * (buttonSize + bufferSize) + bufferSize; - self.palette = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width - paletteWidth, - (self.view.bounds.size.height - paletteHeight) / 2, - paletteWidth, - paletteHeight)]; - self.palette.backgroundColor = [UIColor colorWithWhite:0 alpha:alpha]; - self.palette.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; - self.palette.layer.cornerRadius = bufferSize; - [self.view addSubview:self.palette]; - for (NSString *selectorName in selectorNames) - { - UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - button.frame = CGRectMake(bufferSize, - ([selectorNames indexOfObject:selectorName] * (buttonSize + bufferSize)) + bufferSize, - buttonSize, - buttonSize); - [button setImage:[UIImage imageNamed:[selectorName stringByAppendingString:@".png"]] forState:UIControlStateNormal]; - [button addTarget:self action:NSSelectorFromString(selectorName) forControlEvents:UIControlEventTouchUpInside]; - [self.palette addSubview:button]; - } -} - -- (NSUInteger)supportedInterfaceOrientations -{ - return UIInterfaceOrientationMaskAll; -} - -#pragma mark - Debugging UI - -- (void)handleSingleTapGesture:(UITapGestureRecognizer *)singleTap -{ - if (singleTap.state == UIGestureRecognizerStateEnded) - { - [self togglePalette]; - } -} - -- (void)togglePalette -{ - if (self.palette.alpha < 1) - { - self.palette.userInteractionEnabled = YES; - - [UIView animateWithDuration:0.25 animations:^(void) - { - self.palette.alpha = 1; - }]; - } - else - { - self.palette.userInteractionEnabled = NO; - - [UIView animateWithDuration:0.25 animations:^(void) - { - self.palette.alpha = 0; - }]; - } -} - -- (void)unrotate -{ - [self.mapView resetNorth]; -} - -- (void)resetPosition -{ - [self.mapView resetPosition]; -} - -- (void)toggleDebug -{ - [self.mapView toggleDebug]; - - self.debug = ! self.debug; -} - -- (void)toggleStyle -{ - [self.mapView toggleStyle]; -} - -- (void)locateUser -{ - [self.locationManager startUpdatingLocation]; -} - -#pragma mark - Destruction - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - if (settings) - { - [self saveState:nil]; - delete settings; - settings = nullptr; - } -} - -#pragma mark - User location - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" - -- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations -{ - CLLocation *latestLocation = locations.lastObject; - - if ([latestLocation distanceFromLocation:[[CLLocation alloc] initWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude]] > 100) - { - [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(latestLocation.coordinate.latitude, latestLocation.coordinate.longitude) zoomLevel:17 animated:YES]; - } - - [self.locationManager stopUpdatingLocation]; -} - -#pragma clang diagnostic pop - -@end diff --git a/ios/img/Default-568h@2x.png b/ios/img/Default-568h@2x.png deleted file mode 100644 index 0891b7aab..000000000 Binary files a/ios/img/Default-568h@2x.png and /dev/null differ diff --git a/ios/img/Icon-40.png b/ios/img/Icon-40.png deleted file mode 100644 index eca13393e..000000000 Binary files a/ios/img/Icon-40.png and /dev/null differ diff --git a/ios/img/Icon-40@2x.png b/ios/img/Icon-40@2x.png deleted file mode 100644 index 070d03753..000000000 Binary files a/ios/img/Icon-40@2x.png and /dev/null differ diff --git a/ios/img/Icon-60.png b/ios/img/Icon-60.png deleted file mode 100644 index ff4c6ab4b..000000000 Binary files a/ios/img/Icon-60.png and /dev/null differ diff --git a/ios/img/Icon-60@2x.png b/ios/img/Icon-60@2x.png deleted file mode 100644 index b7f25955f..000000000 Binary files a/ios/img/Icon-60@2x.png and /dev/null differ diff --git a/ios/img/Icon-72.png b/ios/img/Icon-72.png deleted file mode 100644 index 0c876f664..000000000 Binary files a/ios/img/Icon-72.png and /dev/null differ diff --git a/ios/img/Icon-72@2x.png b/ios/img/Icon-72@2x.png deleted file mode 100644 index 6da408204..000000000 Binary files a/ios/img/Icon-72@2x.png and /dev/null differ diff --git a/ios/img/Icon-76.png b/ios/img/Icon-76.png deleted file mode 100644 index 895b4a176..000000000 Binary files a/ios/img/Icon-76.png and /dev/null differ diff --git a/ios/img/Icon-76@2x.png b/ios/img/Icon-76@2x.png deleted file mode 100644 index 7bc520897..000000000 Binary files a/ios/img/Icon-76@2x.png and /dev/null differ diff --git a/ios/img/Icon-Small-50.png b/ios/img/Icon-Small-50.png deleted file mode 100644 index 6d17da4b0..000000000 Binary files a/ios/img/Icon-Small-50.png and /dev/null differ diff --git a/ios/img/Icon-Small-50@2x.png b/ios/img/Icon-Small-50@2x.png deleted file mode 100644 index ac4ec1928..000000000 Binary files a/ios/img/Icon-Small-50@2x.png and /dev/null differ diff --git a/ios/img/Icon-Small.png b/ios/img/Icon-Small.png deleted file mode 100644 index aecbbc8a1..000000000 Binary files a/ios/img/Icon-Small.png and /dev/null differ diff --git a/ios/img/Icon-Small@2x.png b/ios/img/Icon-Small@2x.png deleted file mode 100644 index 7773852e7..000000000 Binary files a/ios/img/Icon-Small@2x.png and /dev/null differ diff --git a/ios/img/Icon-Spotlight-40.png b/ios/img/Icon-Spotlight-40.png deleted file mode 100644 index eca13393e..000000000 Binary files a/ios/img/Icon-Spotlight-40.png and /dev/null differ diff --git a/ios/img/Icon-Spotlight-40@2x.png b/ios/img/Icon-Spotlight-40@2x.png deleted file mode 100644 index 070d03753..000000000 Binary files a/ios/img/Icon-Spotlight-40@2x.png and /dev/null differ diff --git a/ios/img/Icon.png b/ios/img/Icon.png deleted file mode 100644 index 9ca8194ee..000000000 Binary files a/ios/img/Icon.png and /dev/null differ diff --git a/ios/img/Icon@2x.png b/ios/img/Icon@2x.png deleted file mode 100644 index 7c2e8ba03..000000000 Binary files a/ios/img/Icon@2x.png and /dev/null differ diff --git a/ios/img/iTunesArtwork b/ios/img/iTunesArtwork deleted file mode 100644 index ac6a0c58e..000000000 Binary files a/ios/img/iTunesArtwork and /dev/null differ diff --git a/ios/img/iTunesArtwork.png b/ios/img/iTunesArtwork.png deleted file mode 100644 index b10824b04..000000000 Binary files a/ios/img/iTunesArtwork.png and /dev/null differ diff --git a/ios/img/iTunesArtwork@2x b/ios/img/iTunesArtwork@2x deleted file mode 100644 index fae1dad8b..000000000 Binary files a/ios/img/iTunesArtwork@2x and /dev/null differ diff --git a/ios/img/iTunesArtwork@2x.png b/ios/img/iTunesArtwork@2x.png deleted file mode 100644 index fdee900aa..000000000 Binary files a/ios/img/iTunesArtwork@2x.png and /dev/null differ diff --git a/ios/img/locateUser.png b/ios/img/locateUser.png deleted file mode 100644 index e0599e542..000000000 Binary files a/ios/img/locateUser.png and /dev/null differ diff --git a/ios/img/resetPosition.png b/ios/img/resetPosition.png deleted file mode 100644 index 81269cd4f..000000000 Binary files a/ios/img/resetPosition.png and /dev/null differ diff --git a/ios/img/toggleDebug.png b/ios/img/toggleDebug.png deleted file mode 100644 index aa5e3042f..000000000 Binary files a/ios/img/toggleDebug.png and /dev/null differ diff --git a/ios/img/toggleStyle.png b/ios/img/toggleStyle.png deleted file mode 100644 index 59a6f330f..000000000 Binary files a/ios/img/toggleStyle.png and /dev/null differ diff --git a/ios/img/unrotate.png b/ios/img/unrotate.png deleted file mode 100644 index 63361e99d..000000000 Binary files a/ios/img/unrotate.png and /dev/null differ diff --git a/ios/llmr-app.gyp b/ios/llmr-app.gyp deleted file mode 100644 index aeccd573f..000000000 --- a/ios/llmr-app.gyp +++ /dev/null @@ -1,70 +0,0 @@ -{ - 'includes': [ - '../common.gypi', - '../config.gypi' - ], - 'targets': [ - { - "target_name": "iosapp", - "product_name": "Mapbox GL", - "type": "executable", - "sources": [ - "./main.m", - "./MBXAppDelegate.h", - "./MBXAppDelegate.m", - "./MBXViewController.h", - "./MBXViewController.mm", - ' - -#import "MBXAppDelegate.h" - -int main(int argc, char * argv[]) -{ - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([MBXAppDelegate class])); - } -} diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 698f31b3c..9d403d2ce 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 698f31b3c777b50839aa116340614f6f18d5087a +Subproject commit 9d403d2cefcd63797a3da2c67d4b653e287aeec5 diff --git a/linux/llmr-app.gyp b/linux/llmr-app.gyp index 0a524c088..e53a12224 100644 --- a/linux/llmr-app.gyp +++ b/linux/llmr-app.gyp @@ -15,6 +15,8 @@ '../common/glfw_view.hpp', '../common/glfw_view.cpp', '../common/curl_request.cpp', + '../common/stderr_log.hpp', + '../common/stderr_log.cpp', ], 'conditions': [ diff --git a/linux/main.cpp b/linux/main.cpp index 25898fab2..11a21880f 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -8,6 +8,7 @@ #include "../common/settings_json.hpp" #include "../common/glfw_view.hpp" +#include "../common/stderr_log.hpp" GLFWView *view = nullptr; @@ -22,6 +23,8 @@ void quit_handler(int) { } int main(int argc, char *argv[]) { + llmr::Log::Set(); + int fullscreen_flag = 0; const struct option long_options[] = { @@ -60,6 +63,14 @@ int main(int argc, char *argv[]) { map.setAngle(settings.angle); map.setDebug(settings.debug); + // Set access token if present + const char *token = getenv("MAPBOX_ACCESS_TOKEN"); + if (token == nullptr) { + llmr::Log::Warning(llmr::Event::Setup, "no access token set. mapbox.com tiles won't work."); + } else { + map.setAccessToken(std::string(token)); + } + // Load style map.setStyleJSON(stylejson.str()); diff --git a/macosx/ATTRIBUTION b/macosx/ATTRIBUTION deleted file mode 100644 index dff33b3b9..000000000 --- a/macosx/ATTRIBUTION +++ /dev/null @@ -1 +0,0 @@ -Icon from http://dryicons.com/icon/architecture-blueprint-icons-set/map/ \ No newline at end of file diff --git a/macosx/llmr-app.gyp b/macosx/llmr-app.gyp index 02319da94..139cb744c 100644 --- a/macosx/llmr-app.gyp +++ b/macosx/llmr-app.gyp @@ -16,6 +16,8 @@ '../common/glfw_view.cpp', '../common/foundation_request.h', '../common/foundation_request.mm', + '../common/nslog_log.hpp', + '../common/nslog_log.mm', ], 'product_extension': 'app', 'mac_bundle': 1, diff --git a/macosx/main.mm b/macosx/main.mm index 4c5da2f32..f72476cde 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,9 +1,12 @@ #include "../common/settings_nsuserdefaults.hpp" #include "../common/glfw_view.hpp" +#include "../common/nslog_log.hpp" #import int main() { + llmr::Log::Set(); + GLFWView view; llmr::Map map(view); @@ -13,6 +16,14 @@ int main() { map.setAngle(settings.angle); map.setDebug(settings.debug); + // Set access token if present + const char *token = getenv("MAPBOX_ACCESS_TOKEN"); + if (token == nullptr) { + llmr::Log::Warning(llmr::Event::Setup, "no access token set. mapbox.com tiles won't work."); + } else { + map.setAccessToken(std::string(token)); + } + // Load style NSString *path = [[NSBundle mainBundle] pathForResource:@"style.min" ofType:@"js"]; NSString *json = [NSString stringWithContentsOfFile:path @@ -20,8 +31,6 @@ int main() { error:nil]; map.setStyleJSON((std::string)[json cStringUsingEncoding:[NSString defaultCStringEncoding]]); - // fprintf(stderr, "lon: %f, lat: %f, zoom: %f, angle: %f, debug: %d\n", settings.l) - int ret = view.run(); // Save settings diff --git a/scripts/compare_images.js b/scripts/compare_images.js new file mode 100755 index 000000000..ef854b038 --- /dev/null +++ b/scripts/compare_images.js @@ -0,0 +1,117 @@ +#!/usr/bin/env node + +var fs = require('fs'); +var path = require('path'); +var spawn = require('child_process').spawn; + +var base_dir = path.join(path.resolve('.'), 'test/fixtures/styles'); + +var files = fs.readdirSync(base_dir).filter(function(name) { + return name.match(/\.info\.json$/); +}); + +var html = + '\n' + + '\n' + + '\n' + + ' \n' + + ' \n' + + ' \n' + + '\n'; + +var exitCode = 0; +var failures = 0; + +processFiles(); + +function processFiles() { + if (!files.length) return done(); + + var name = files.shift(); + + var info = require(path.join(base_dir, name)); + + var keys = Object.keys(info); + + processFileTest(); + + function processFileTest() { + if (!keys.length) return processFiles(); + + var key = keys.shift(); + + var base = path.basename(name, '.info.json'); + + var actual = path.join(base_dir, base + '/' + key + '.actual.png'); + var expected = path.join(base_dir, base + '/' + key + '.expected.png'); + var diff = path.join(base_dir, base + '/' + key + '.diff.png'); + + var compare = spawn('compare', ['-metric', 'MAE', actual, expected, diff ]); + var error = ''; + compare.stderr.on('data', function(data) { + error += data.toString(); + }); + compare.on('exit', function(code, signal) { + // The compare program returns 2 on error otherwise 0 if the images are similar or 1 if they are dissimilar. + if (code == 2) { + writeResult(base, key, info[key], error.trim(), Infinity); + exitCode = 2; + } else { + var match = error.match(/^\d+(?:\.\d+)?\s+\(([^\)]+)\)\s*$/); + var difference = match ? parseFloat(match[1]) : Infinity; + writeResult(base, key, info[key], match ? '' : error, difference); + + } + processFileTest(); + }); + compare.stdin.end(); + } +} + +function writeResult(base, key, info, error, difference) { + var color = 'green'; + var allowedDifference = ('diff' in info) ? info.diff : 0.01; + if (difference > allowedDifference) { + color = 'red'; + if (exitCode < 1) { + exitCode = 1; + } + failures++; + } + + html += + '\n' + + ' \n' + + ' \n' + + ' \n' + + '\n' + ; +} + +function done() { + html += "
ActualExpectedInfo
\n' + + '

' + base + '/' + key + '

\n' + + (error ? '

' + error + '

\n' : '') + + '
    \n' + + '
  • diff: ' + difference + '
  • \n' + + '
  • zoom: ' + (info.zoom || 0) + '
  • \n' + + '
  • center: ' + (info.center || [0, 0]) + '
  • \n' + + '
  • bearing: ' + (info.bearing || 0) + '
  • \n' + + '
  • width: ' + (info.width || 512) + '
  • \n' + + '
  • height: ' + (info.height || 512) + '
  • \n' + + '
\n' + + '
\n"; + + fs.writeFileSync(path.join(base_dir, 'index.html'), html); + console.warn('Results at: ' + path.join(base_dir, 'index.html')); + if (failures) { + console.warn('\x1B[1m\x1B[31m' + failures + ' ' + (failures == 1 ? 'image doesn\'t' : 'images don\'t') + ' match\x1B[39m\x1B[22m'); + } else { + console.warn('\x1B[1m\x1B[32mAll images match\x1B[39m\x1B[22m'); + } + + process.exit(exitCode); +} \ No newline at end of file diff --git a/scripts/create_result_table.js b/scripts/create_result_table.js deleted file mode 100644 index ad604890f..000000000 --- a/scripts/create_result_table.js +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env node - -var fs = require('fs'); -var path = require('path'); - -var html = - '\n' + - '\n' + - '\n' + - ' \n' + - ' \n' + - ' \n' + - '\n'; - -var dir = fs.readdirSync('./test/fixtures/styles').filter(function(name) { - return name.match(/\.info\.json$/); -}).forEach(function(name) { - var info = require(path.join(path.resolve('.'), './test/fixtures/styles', name)); - var base = path.basename(name, '.info.json'); - - html += - '\n' + - ' \n' + - ' \n' + - ' \n' + - '\n' - ; -}); - -html += "()), + style(std::make_shared
ActualExpectedInfo
\n' + - '

' + base + '

\n' + - '
    \n' + - '
  • zoom: ' + (info.zoom || 0) + '
  • \n' + - '
  • latitude: ' + (info.latitude || 0) + '
  • \n' + - '
  • longitude: ' + (info.longitude || 0) + '
  • \n' + - '
  • angle: ' + (info.angle || 0) + '
  • \n' + - '
  • width: ' + (info.width || 0) + '
  • \n' + - '
  • height: ' + (info.height || 0) + '
  • \n' + - '
\n' + - '