From 495d47ab422988053666c0d3d647e3e235fa21e3 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 21 Feb 2014 16:00:01 -0800 Subject: [PATCH 1/4] refs #60: add some more point styles --- bin/style.js | 77 +++++++++++++++++++++++++++++++++++++++----- resources/style.pbf | Bin 1090 -> 1622 bytes 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/bin/style.js b/bin/style.js index 0383c3210..7675f101e 100644 --- a/bin/style.js +++ b/bin/style.js @@ -52,13 +52,41 @@ module.exports = { "layer": "building", "type": "fill" }, - "alcohol": { + "alcohol_poi": { "datasource": "streets", "layer": "poi_label", "field": "type", "value": ["Alcohol"], "type": "point" - } + }, + "cafe_poi": { + "datasource": "streets", + "layer": "poi_label", + "field": "type", + "value": ["Cafe"], + "type": "point" + }, + "embassy_poi": { + "datasource": "streets", + "layer": "poi_label", + "field": "type", + "value": ["Embassy"], + "type": "point" + }, + "park_poi": { + "datasource": "streets", + "layer": "poi_label", + "field": "type", + "value": ["Park"], + "type": "point" + }, + "restaurant_poi": { + "datasource": "streets", + "layer": "poi_label", + "field": "type", + "value": ["Restaurant"], + "type": "point" + }, }, "sprite": "img/maki-sprite", "structure": [ @@ -69,7 +97,11 @@ module.exports = { { "name": "road_limited", "bucket": "road_limited" }, { "name": "road_regular", "bucket": "road_regular" }, { "name": "road_large", "bucket": "road_large" }, - { "name": "alcohol", "bucket": "alcohol" } + { "name": "alcohol_poi", "bucket": "alcohol_poi" }, + { "name": "cafe_poi", "bucket": "cafe_poi" }, + { "name": "embassy_poi", "bucket": "embassy_poi" }, + { "name": "park_poi", "bucket": "park_poi" }, + { "name": "restaurant_poi", "bucket": "restaurant_poi" }, ], "classes": [ { @@ -138,12 +170,41 @@ module.exports = { { z: 30, val: 64 } ], }, - "alcohol": { + "alcohol_poi": { "type": "marker", - "color": "#999999", - "size": 24, - "image": "alcohol-shop" - } + "color": "#cccccc", + "size": 18, + "image": "alcohol-shop", + "opacity": 0.75 + }, + "cafe_poi": { + "type": "marker", + "color": "#cccccc", + "size": 18, + "image": "cafe", + "opacity": 0.75 + }, + "embassy_poi": { + "type": "marker", + "color": "#cccccc", + "size": 18, + "image": "embassy", + "opacity": 0.75 + }, + "park_poi": { + "type": "marker", + "color": "#cccccc", + "size": 18, + "image": "park", + "opacity": 0.75 + }, + "restaurant_poi": { + "type": "marker", + "color": "#cccccc", + "size": 18, + "image": "restaurant", + "opacity": 0.75 + }, } } ] diff --git a/resources/style.pbf b/resources/style.pbf index 46e117e52dcff7d78ee2fbec60fb4842abc611c5..6823fc7b813619ba42f38beb845537d3cc2b5f80 100644 GIT binary patch delta 530 zcmX@aagArgJw`qgF7CvfLoFRnlCLs}obA;dy69Vc$a*PlP2dD$)8X*Kr0o^S^aJO+n94B>wW%E9!SjKwP zP?7zA=FAx-4h|+E76yh1jz&Pe8{Fh8LyN2q22DN!;-_b6@+T!`2K0LuEJ_5c6? delta 105 zcmcb{bBJTZJw`4AF80KnK|>LU36jm@=sr=FMy@v5e|! fa5>rkGiT0J;^1HsVqsu7;ON8yHBq-XBfkIuz#$-x From b6d7169b831e07fd7e1d0d9507c8cfe28a5a220d Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 21 Feb 2014 16:00:55 -0800 Subject: [PATCH 2/4] refs #60: add support for point colorization & opacity --- src/shader/point.fragment.glsl | 2 +- src/shader/shaders.cpp | 2 +- src/style/resources.cpp | 113 +++++++++++++++++++++------------ 3 files changed, 75 insertions(+), 42 deletions(-) diff --git a/src/shader/point.fragment.glsl b/src/shader/point.fragment.glsl index 2343f7db0..2f099feb7 100644 --- a/src/shader/point.fragment.glsl +++ b/src/shader/point.fragment.glsl @@ -17,5 +17,5 @@ void main() { vec4 color = texture2D(u_image, mix(u_tl, u_br, pos)) * inbounds; - gl_FragColor = color; + gl_FragColor = color * u_color; } diff --git a/src/shader/shaders.cpp b/src/shader/shaders.cpp index b6ee1b46b..638c554cf 100644 --- a/src/shader/shaders.cpp +++ b/src/shader/shaders.cpp @@ -26,6 +26,6 @@ const shader_source llmr::shaders[SHADER_COUNT] = { }, { "attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform float u_size;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n gl_PointSize = u_size;\n}\n", - "#define root2 1.4142135623730951\n\nuniform sampler2D u_image;\nuniform vec2 u_tl;\nuniform vec2 u_br;\nuniform vec4 u_color;\n\nuniform vec2 pos;\nuniform float inbounds;\nuniform vec4 color;\n\nvoid main() {\n vec2 pos = (gl_PointCoord * 2.0 - 1.0) * root2 / 2.0 + 0.5;\n\n float inbounds = step(0.0, pos.x) * step(0.0, pos.y) *\n (1.0 - step(1.0, pos.x)) * (1.0 - step(1.0, pos.y));\n\n vec4 color = texture2D(u_image, mix(u_tl, u_br, pos)) * inbounds;\n\n gl_FragColor = color;\n}\n", + "#define root2 1.4142135623730951\n\nuniform sampler2D u_image;\nuniform vec2 u_tl;\nuniform vec2 u_br;\nuniform vec4 u_color;\n\nuniform vec2 pos;\nuniform float inbounds;\nuniform vec4 color;\n\nvoid main() {\n vec2 pos = (gl_PointCoord * 2.0 - 1.0) * root2 / 2.0 + 0.5;\n\n float inbounds = step(0.0, pos.x) * step(0.0, pos.y) *\n (1.0 - step(1.0, pos.x)) * (1.0 - step(1.0, pos.y));\n\n vec4 color = texture2D(u_image, mix(u_tl, u_br, pos)) * inbounds;\n\n gl_FragColor = color * u_color;\n}\n", } }; diff --git a/src/style/resources.cpp b/src/style/resources.cpp index bf0eb207e..1b819223b 100644 --- a/src/style/resources.cpp +++ b/src/style/resources.cpp @@ -33,45 +33,78 @@ const unsigned char resources::style[] = { 108, 97, 110, 100, 117, 115, 101, 42, 5, 99, 108, 97, 115, 115, 50, 12, 10, 10, 105, 110, 100, 117, 115, 116, 114, 105, 97, 108, 10, 31, 10, 8, 98, 117, 105, 108, 100, 105, 110, 103, 16, 1, 26, 7, 115, 116, 114, 101, - 101, 116, 115, 34, 8, 98, 117, 105, 108, 100, 105, 110, 103, 10, 48, 10, - 7, 97, 108, 99, 111, 104, 111, 108, 16, 3, 26, 7, 115, 116, 114, 101, - 101, 116, 115, 34, 9, 112, 111, 105, 95, 108, 97, 98, 101, 108, 42, 4, - 116, 121, 112, 101, 50, 9, 10, 7, 65, 108, 99, 111, 104, 111, 108, 18, - 12, 10, 4, 112, 97, 114, 107, 18, 4, 112, 97, 114, 107, 18, 12, 10, - 4, 119, 111, 111, 100, 18, 4, 119, 111, 111, 100, 18, 14, 10, 5, 119, - 97, 116, 101, 114, 18, 5, 119, 97, 116, 101, 114, 18, 20, 10, 8, 98, - 117, 105, 108, 100, 105, 110, 103, 18, 8, 98, 117, 105, 108, 100, 105, 110, - 103, 18, 28, 10, 12, 114, 111, 97, 100, 95, 108, 105, 109, 105, 116, 101, - 100, 18, 12, 114, 111, 97, 100, 95, 108, 105, 109, 105, 116, 101, 100, 18, - 28, 10, 12, 114, 111, 97, 100, 95, 114, 101, 103, 117, 108, 97, 114, 18, - 12, 114, 111, 97, 100, 95, 114, 101, 103, 117, 108, 97, 114, 18, 24, 10, - 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 18, 10, 114, 111, 97, - 100, 95, 108, 97, 114, 103, 101, 18, 18, 10, 7, 97, 108, 99, 111, 104, - 111, 108, 18, 7, 97, 108, 99, 111, 104, 111, 108, 26, 132, 3, 10, 7, - 100, 101, 102, 97, 117, 108, 116, 18, 27, 10, 4, 112, 97, 114, 107, 34, - 8, 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, 159, 223, 200, 66, 4, - 112, 97, 114, 107, 18, 31, 10, 4, 119, 111, 111, 100, 34, 8, 8, 2, - 18, 4, 0, 0, 128, 63, 45, 255, 102, 170, 51, 58, 8, 8, 2, 18, - 4, 205, 204, 204, 61, 18, 39, 10, 5, 119, 97, 116, 101, 114, 34, 8, - 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, 233, 224, 186, 53, 255, 230, - 182, 115, 66, 10, 119, 97, 116, 101, 114, 95, 101, 116, 115, 121, 18, 51, - 10, 8, 98, 117, 105, 108, 100, 105, 110, 103, 34, 8, 8, 2, 18, 4, - 0, 0, 128, 63, 45, 255, 0, 0, 0, 58, 24, 8, 4, 18, 20, 0, - 0, 80, 65, 0, 0, 0, 0, 205, 204, 204, 61, 0, 0, 0, 0, 205, - 204, 204, 61, 26, 41, 10, 12, 114, 111, 97, 100, 95, 108, 105, 109, 105, - 116, 101, 100, 29, 255, 187, 187, 187, 34, 20, 8, 3, 18, 16, 0, 0, - 0, 0, 0, 0, 128, 63, 0, 0, 240, 65, 0, 0, 128, 63, 26, 65, - 10, 12, 114, 111, 97, 100, 95, 114, 101, 103, 117, 108, 97, 114, 29, 255, - 153, 153, 153, 34, 44, 8, 3, 18, 40, 0, 0, 0, 0, 0, 0, 0, - 63, 0, 0, 80, 65, 0, 0, 0, 63, 0, 0, 128, 65, 0, 0, 0, - 64, 0, 0, 160, 65, 0, 0, 0, 66, 0, 0, 240, 65, 0, 0, 0, - 66, 26, 71, 10, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 29, - 255, 102, 102, 102, 34, 52, 8, 3, 18, 48, 0, 0, 0, 0, 0, 0, - 0, 63, 0, 0, 48, 65, 0, 0, 0, 63, 0, 0, 80, 65, 0, 0, - 128, 63, 0, 0, 128, 65, 0, 0, 128, 64, 0, 0, 160, 65, 0, 0, - 128, 66, 0, 0, 240, 65, 0, 0, 128, 66, 34, 38, 10, 7, 97, 108, - 99, 111, 104, 111, 108, 29, 255, 153, 153, 153, 34, 8, 8, 2, 18, 4, - 0, 0, 192, 65, 66, 12, 97, 108, 99, 111, 104, 111, 108, 45, 115, 104, - 111, 112 + 101, 116, 115, 34, 8, 98, 117, 105, 108, 100, 105, 110, 103, 10, 52, 10, + 11, 97, 108, 99, 111, 104, 111, 108, 95, 112, 111, 105, 16, 3, 26, 7, + 115, 116, 114, 101, 101, 116, 115, 34, 9, 112, 111, 105, 95, 108, 97, 98, + 101, 108, 42, 4, 116, 121, 112, 101, 50, 9, 10, 7, 65, 108, 99, 111, + 104, 111, 108, 10, 46, 10, 8, 99, 97, 102, 101, 95, 112, 111, 105, 16, + 3, 26, 7, 115, 116, 114, 101, 101, 116, 115, 34, 9, 112, 111, 105, 95, + 108, 97, 98, 101, 108, 42, 4, 116, 121, 112, 101, 50, 6, 10, 4, 67, + 97, 102, 101, 10, 52, 10, 11, 101, 109, 98, 97, 115, 115, 121, 95, 112, + 111, 105, 16, 3, 26, 7, 115, 116, 114, 101, 101, 116, 115, 34, 9, 112, + 111, 105, 95, 108, 97, 98, 101, 108, 42, 4, 116, 121, 112, 101, 50, 9, + 10, 7, 69, 109, 98, 97, 115, 115, 121, 10, 46, 10, 8, 112, 97, 114, + 107, 95, 112, 111, 105, 16, 3, 26, 7, 115, 116, 114, 101, 101, 116, 115, + 34, 9, 112, 111, 105, 95, 108, 97, 98, 101, 108, 42, 4, 116, 121, 112, + 101, 50, 6, 10, 4, 80, 97, 114, 107, 10, 58, 10, 14, 114, 101, 115, + 116, 97, 117, 114, 97, 110, 116, 95, 112, 111, 105, 16, 3, 26, 7, 115, + 116, 114, 101, 101, 116, 115, 34, 9, 112, 111, 105, 95, 108, 97, 98, 101, + 108, 42, 4, 116, 121, 112, 101, 50, 12, 10, 10, 82, 101, 115, 116, 97, + 117, 114, 97, 110, 116, 18, 12, 10, 4, 112, 97, 114, 107, 18, 4, 112, + 97, 114, 107, 18, 12, 10, 4, 119, 111, 111, 100, 18, 4, 119, 111, 111, + 100, 18, 14, 10, 5, 119, 97, 116, 101, 114, 18, 5, 119, 97, 116, 101, + 114, 18, 20, 10, 8, 98, 117, 105, 108, 100, 105, 110, 103, 18, 8, 98, + 117, 105, 108, 100, 105, 110, 103, 18, 28, 10, 12, 114, 111, 97, 100, 95, + 108, 105, 109, 105, 116, 101, 100, 18, 12, 114, 111, 97, 100, 95, 108, 105, + 109, 105, 116, 101, 100, 18, 28, 10, 12, 114, 111, 97, 100, 95, 114, 101, + 103, 117, 108, 97, 114, 18, 12, 114, 111, 97, 100, 95, 114, 101, 103, 117, + 108, 97, 114, 18, 24, 10, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, + 101, 18, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 18, 26, 10, + 11, 97, 108, 99, 111, 104, 111, 108, 95, 112, 111, 105, 18, 11, 97, 108, + 99, 111, 104, 111, 108, 95, 112, 111, 105, 18, 20, 10, 8, 99, 97, 102, + 101, 95, 112, 111, 105, 18, 8, 99, 97, 102, 101, 95, 112, 111, 105, 18, + 26, 10, 11, 101, 109, 98, 97, 115, 115, 121, 95, 112, 111, 105, 18, 11, + 101, 109, 98, 97, 115, 115, 121, 95, 112, 111, 105, 18, 20, 10, 8, 112, + 97, 114, 107, 95, 112, 111, 105, 18, 8, 112, 97, 114, 107, 95, 112, 111, + 105, 18, 32, 10, 14, 114, 101, 115, 116, 97, 117, 114, 97, 110, 116, 95, + 112, 111, 105, 18, 14, 114, 101, 115, 116, 97, 117, 114, 97, 110, 116, 95, + 112, 111, 105, 26, 208, 4, 10, 7, 100, 101, 102, 97, 117, 108, 116, 18, + 27, 10, 4, 112, 97, 114, 107, 34, 8, 8, 2, 18, 4, 0, 0, 128, + 63, 45, 255, 159, 223, 200, 66, 4, 112, 97, 114, 107, 18, 31, 10, 4, + 119, 111, 111, 100, 34, 8, 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, + 102, 170, 51, 58, 8, 8, 2, 18, 4, 205, 204, 204, 61, 18, 39, 10, + 5, 119, 97, 116, 101, 114, 34, 8, 8, 2, 18, 4, 0, 0, 128, 63, + 45, 255, 233, 224, 186, 53, 255, 230, 182, 115, 66, 10, 119, 97, 116, 101, + 114, 95, 101, 116, 115, 121, 18, 51, 10, 8, 98, 117, 105, 108, 100, 105, + 110, 103, 34, 8, 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, 0, 0, + 0, 58, 24, 8, 4, 18, 20, 0, 0, 80, 65, 0, 0, 0, 0, 205, + 204, 204, 61, 0, 0, 0, 0, 205, 204, 204, 61, 26, 41, 10, 12, 114, + 111, 97, 100, 95, 108, 105, 109, 105, 116, 101, 100, 29, 255, 187, 187, 187, + 34, 20, 8, 3, 18, 16, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, + 240, 65, 0, 0, 128, 63, 26, 65, 10, 12, 114, 111, 97, 100, 95, 114, + 101, 103, 117, 108, 97, 114, 29, 255, 153, 153, 153, 34, 44, 8, 3, 18, + 40, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 80, 65, 0, 0, 0, + 63, 0, 0, 128, 65, 0, 0, 0, 64, 0, 0, 160, 65, 0, 0, 0, + 66, 0, 0, 240, 65, 0, 0, 0, 66, 26, 71, 10, 10, 114, 111, 97, + 100, 95, 108, 97, 114, 103, 101, 29, 255, 102, 102, 102, 34, 52, 8, 3, + 18, 48, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 48, 65, 0, 0, + 0, 63, 0, 0, 80, 65, 0, 0, 128, 63, 0, 0, 128, 65, 0, 0, + 128, 64, 0, 0, 160, 65, 0, 0, 128, 66, 0, 0, 240, 65, 0, 0, + 128, 66, 34, 52, 10, 11, 97, 108, 99, 111, 104, 111, 108, 95, 112, 111, + 105, 29, 255, 204, 204, 204, 34, 8, 8, 2, 18, 4, 0, 0, 144, 65, + 50, 8, 8, 2, 18, 4, 0, 0, 64, 63, 66, 12, 97, 108, 99, 111, + 104, 111, 108, 45, 115, 104, 111, 112, 34, 41, 10, 8, 99, 97, 102, 101, + 95, 112, 111, 105, 29, 255, 204, 204, 204, 34, 8, 8, 2, 18, 4, 0, + 0, 144, 65, 50, 8, 8, 2, 18, 4, 0, 0, 64, 63, 66, 4, 99, + 97, 102, 101, 34, 47, 10, 11, 101, 109, 98, 97, 115, 115, 121, 95, 112, + 111, 105, 29, 255, 204, 204, 204, 34, 8, 8, 2, 18, 4, 0, 0, 144, + 65, 50, 8, 8, 2, 18, 4, 0, 0, 64, 63, 66, 7, 101, 109, 98, + 97, 115, 115, 121, 34, 41, 10, 8, 112, 97, 114, 107, 95, 112, 111, 105, + 29, 255, 204, 204, 204, 34, 8, 8, 2, 18, 4, 0, 0, 144, 65, 50, + 8, 8, 2, 18, 4, 0, 0, 64, 63, 66, 4, 112, 97, 114, 107, 34, + 53, 10, 14, 114, 101, 115, 116, 97, 117, 114, 97, 110, 116, 95, 112, 111, + 105, 29, 255, 204, 204, 204, 34, 8, 8, 2, 18, 4, 0, 0, 144, 65, + 50, 8, 8, 2, 18, 4, 0, 0, 64, 63, 66, 10, 114, 101, 115, 116, + 97, 117, 114, 97, 110, 116 }; const unsigned long resources::style_size = sizeof(resources::style); From 7a48e8ddce1261c94ef2e9a0527e4d1eadadae21 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 21 Feb 2014 16:22:45 -0800 Subject: [PATCH 3/4] move to linear properties for POI opacity --- bin/style.js | 10 +++++----- resources/style.pbf | Bin 1622 -> 1702 bytes src/style/resources.cpp | 27 ++++++++++++++++----------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/bin/style.js b/bin/style.js index 7675f101e..50b365c1d 100644 --- a/bin/style.js +++ b/bin/style.js @@ -175,35 +175,35 @@ module.exports = { "color": "#cccccc", "size": 18, "image": "alcohol-shop", - "opacity": 0.75 + "opacity": [ "linear", 15, 0, 1.0, 0, 0.75 ] }, "cafe_poi": { "type": "marker", "color": "#cccccc", "size": 18, "image": "cafe", - "opacity": 0.75 + "opacity": [ "linear", 15, 0, 1.0, 0, 0.75 ] }, "embassy_poi": { "type": "marker", "color": "#cccccc", "size": 18, "image": "embassy", - "opacity": 0.75 + "opacity": [ "linear", 15, 0, 1.0, 0, 0.75 ] }, "park_poi": { "type": "marker", "color": "#cccccc", "size": 18, "image": "park", - "opacity": 0.75 + "opacity": [ "linear", 15, 0, 1.0, 0, 0.75 ] }, "restaurant_poi": { "type": "marker", "color": "#cccccc", "size": 18, "image": "restaurant", - "opacity": 0.75 + "opacity": [ "linear", 15, 0, 1.0, 0, 0.75 ] }, } } diff --git a/resources/style.pbf b/resources/style.pbf index 6823fc7b813619ba42f38beb845537d3cc2b5f80..0cec5c89254ea3012d00fdf05a51de8d0d3f0a8f 100644 GIT binary patch delta 246 zcmcb{vy68G3k%Z%*3E1zv5Z_UT-=E{$@v-iIg=N#ifBr3un37TFcdg4fI)*jgm$oZ z;(;pDEzZa)sdFgO4J delta 166 zcmZ3+dyQuU3k%Z)md$J|v5Z_MT-=E{$@v-iIg>ZAib!&BFbT0RFgVyd@j!)ji!<^I zlr$%=VwI9Y$g(6Srll(Bb8)BUCM6aZSAsMnNwY(Rl{C3H3KEO5LDGUqx Date: Fri, 21 Feb 2014 16:25:42 -0800 Subject: [PATCH 4/4] refs #60: size POIs properly based on pixel ratio --- src/renderer/painter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 83bf8d4d9..d1ab26389 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -405,7 +405,7 @@ void Painter::renderPoint(PointBucket& bucket, const std::string& layer_name, co pointShader->setMatrix(matrix); pointShader->setImage(0); pointShader->setColor(color); - const float pointSize = properties.size * 1.4142135623730951; + const float pointSize = properties.size * 1.4142135623730951 * transform.pixelRatio; #if defined(GL_ES_VERSION_2_0) pointShader->setSize(pointSize); #else