From 1fa27227b9b0c27bc2eb62d9132d726d2bdf9bb6 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 26 Mar 2015 12:57:23 -0500 Subject: [PATCH 1/5] For windows only increased the pixel difference threshold from 0 to 3 --- tests/visual_tests/compare.py | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/tests/visual_tests/compare.py b/tests/visual_tests/compare.py index 65720af1a..f93a54462 100644 --- a/tests/visual_tests/compare.py +++ b/tests/visual_tests/compare.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import mapnik +import os from unittest import TestCase try: @@ -8,28 +9,6 @@ try: except ImportError: import simplejson as json - -# returns true if pixels are not nearly identical -def compare_pixels(pixel1, pixel2, alpha=True, pixel_threshold=0): - if pixel1 == pixel2: - return False - r_diff = abs((pixel1 & 0xff) - (pixel2 & 0xff)) - g_diff = abs(((pixel1 >> 8) & 0xff) - ((pixel2 >> 8) & 0xff)) - b_diff = abs(((pixel1 >> 16) & 0xff)- ((pixel2 >> 16) & 0xff)) - if alpha: - a_diff = abs(((pixel1 >> 24) & 0xff) - ((pixel2 >> 24) & 0xff)) - if(r_diff > pixel_threshold or - g_diff > pixel_threshold or - b_diff > pixel_threshold or - a_diff > pixel_threshold): - return True - else: - if(r_diff > pixel_threshold or - g_diff > pixel_threshold or - b_diff > pixel_threshold): - return True - return False - # compare two images and return number of different pixels def compare(actual, expected, alpha=True): im1 = mapnik.Image.open(actual) @@ -38,7 +17,10 @@ def compare(actual, expected, alpha=True): delta_pixels = (im2.width() * im2.height()) - pixels if delta_pixels != 0: return delta_pixels - return im1.compare(im2, 0, alpha) + if os.name == 'nt': + return im1.compare(im2, 3, alpha) + else: + return im1.compare(im2, 0, alpha) def compare_grids(actual, expected, threshold=0, alpha=True): global errors From 8c93d057965554c620683371621efbaeaac459c1 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 26 Mar 2015 14:50:17 -0500 Subject: [PATCH 2/5] More attempts to fix visual tests for windows 32 bit --- tests/visual_tests/compare.py | 5 +---- tests/visual_tests/test.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/visual_tests/compare.py b/tests/visual_tests/compare.py index f93a54462..30ccfc260 100644 --- a/tests/visual_tests/compare.py +++ b/tests/visual_tests/compare.py @@ -17,10 +17,7 @@ def compare(actual, expected, alpha=True): delta_pixels = (im2.width() * im2.height()) - pixels if delta_pixels != 0: return delta_pixels - if os.name == 'nt': - return im1.compare(im2, 3, alpha) - else: - return im1.compare(im2, 0, alpha) + return im1.compare(im2, 0, alpha) def compare_grids(actual, expected, threshold=0, alpha=True): global errors diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index b8d69fa14..75549c0f7 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -7,6 +7,7 @@ import mapnik #mapnik.logger.set_severity(mapnik.severity_type.Debug) import shutil import os.path +import os from compare import compare, compare_grids import platform import glob @@ -27,9 +28,14 @@ defaults = { 'grid': mapnik.has_grid_renderer() } -cairo_threshold = 0 -agg_threshold = 0 -grid_threshold = 0 +if os.name == 'nt': + cairo_threshold = 10 + agg_threshold = 0 + grid_threshold = 0 +else: + cairo_threshold = 0 + agg_threshold = 0 + grid_threshold = 0 def render_cairo(m, output, scale_factor): mapnik.render_to_file(m, output, 'ARGB32', scale_factor) From 51b65534f5b6f11a6403e27de52cbfea66b86958 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 27 Mar 2015 10:32:52 +0100 Subject: [PATCH 3/5] geojson bounding box grammar - don't require `"type": "Feature"` to appear in particular order (ref #2745) --- .../extract_bounding_box_grammar_impl.hpp | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/include/mapnik/json/extract_bounding_box_grammar_impl.hpp b/include/mapnik/json/extract_bounding_box_grammar_impl.hpp index 49ac87cf8..55eb5a75e 100644 --- a/include/mapnik/json/extract_bounding_box_grammar_impl.hpp +++ b/include/mapnik/json/extract_bounding_box_grammar_impl.hpp @@ -62,6 +62,7 @@ extract_bounding_box_grammar::extract_bounding_box_gramm start = features(_r1) ; + features = iter_pos[_a = _1] >> -(lit('{') >> -lit("\"type\"") >> lit(':') >> lit("\"FeatureCollection\"") >> *(lit(',') >> (json.key_value - lit("\"features\""))) @@ -69,45 +70,58 @@ extract_bounding_box_grammar::extract_bounding_box_gramm >> lit(':')) >> lit('[') >> (feature(_r1,_a) % lit(',')) >> lit(']') ; - feature = raw[lit('{')[_a = 1] >> lit("\"type\"") >> lit(':') >> lit("\"Feature\"") - >> *(eps(_a > 0) >> (lit('{')[_a += 1] - | - lit('}')[_a -=1] - | - coords[_b = _1] - | - char_))][push_box(_r1, _r2, _b, _1)] + + feature = raw[lit('{')[_a = 1] + >> *(eps(_a > 0) >> (lit('{')[_a += 1] + | + lit('}')[_a -=1] + | + coords[_b = _1] + | + char_))][push_box(_r1, _r2, _b, _1)] ; - coords = lit("\"coordinates\"") >> lit(':') >> (rings_array(_a) | rings (_a) | ring(_a) | pos[calculate_bounding_box(_a,_1)])[_val = _a] + + coords = lit("\"coordinates\"") + >> lit(':') >> (rings_array(_a) | rings (_a) | ring(_a) | pos[calculate_bounding_box(_a,_1)])[_val = _a] ; + pos = lit('[') > -(double_ > lit(',') > double_) > omit[*(lit(',') > double_)] > lit(']') ; + ring = lit('[') >> pos[calculate_bounding_box(_r1,_1)] % lit(',') > lit(']') ; + rings = lit('[') >> ring(_r1) % lit(',') > lit(']') ; + rings_array = lit('[') >> rings(_r1) % lit(',') > lit(']') ; // generic json types json.value = json.object | json.array | json.string_ | json.number ; + json.pairs = json.key_value % lit(',') ; + json.key_value = (json.string_ >> lit(':') >> json.value) ; + json.object = lit('{') >> *json.pairs >> lit('}') ; + json.array = lit('[') >> json.value >> *(lit(',') >> json.value) >> lit(']') ; + json.number = json.strict_double | json.int__ | lit("true") | lit("false") | lit("null") ; + coords.name("Coordinates"); pos.name("Position"); ring.name("Ring"); From 01a9b4c0771ca3f63d39d4275147d6f6b818fc1b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 27 Mar 2015 09:10:04 -0700 Subject: [PATCH 4/5] add regression coverage for #2745 --- tests/data/json/escaped.geojson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/json/escaped.geojson b/tests/data/json/escaped.geojson index 0836c2838..6f1531846 100644 --- a/tests/data/json/escaped.geojson +++ b/tests/data/json/escaped.geojson @@ -3,7 +3,6 @@ "features": [ { - "type":"Feature", "geometry": { "type":"Point", @@ -24,7 +23,8 @@ "NOM_FR":"Qu\u00e9bec", "object": {"value":{"type":"\u041c\u0430pni\u043a","array": [3,0,"x"]}}, "array" : [ [ [1], ["deux"]],[["\u0442\u0440\u0438","four","\u4e94"]]] - } + }, + "type":"Feature" } ] } From 6d84d03c0bbefaf3b44ab010528fd7d72ee3a330 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 3 Apr 2015 12:14:26 -0400 Subject: [PATCH 5/5] add script to easily check the sizes of structures --- scripts/check-padding | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 scripts/check-padding diff --git a/scripts/check-padding b/scripts/check-padding new file mode 100755 index 000000000..b10d34b73 --- /dev/null +++ b/scripts/check-padding @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -eu +set -o pipefail + +cpp="/tmp/alignment.cpp" +app="/tmp/alignment" + +function usage() { + echo "Usage:" + echo "" + echo "./scripts/rebuild.sh [header] [class name]" + echo "" + echo "Please pass a header file and a class name" + echo "" + echo " ./scripts/check-padding include/mapnik/attribute.hpp mapnik::attribute" + echo "" + exit 1 + +} + +function add() { + echo $1 >> ${cpp} +} + +CXX=${CXX:-clang++} + +function compile() { + ${CXX} -o ${app} ${cpp} -Wpadded -I./ -isystem ./mason_packages/.link/include `mapnik-config --all-flags` -Ideps -Lsrc -Ideps/agg/include -Iinclude +} + +if [[ ${1:-unset} == "unset" ]] || [[ ${2:-unset} == "unset" ]] || [[ $@ == '-h' ]] || [[ $@ == '--help' ]]; then + usage +fi + +echo '' > ${cpp} + +add "#include " +add "#include " + +add "#include \"$1\"" + +add "" + +add '#define REPORT(type) std::clog << "sizeof(" #type ") " << sizeof(type) << "\n";' + +add "int main() {" +add "" + +add "REPORT(std::string)" +add "REPORT(unsigned int)" +add "REPORT(int)" +add "REPORT(bool)" +add "REPORT(std::vector)" +add "REPORT(std::size_t)" + +add "REPORT($2)" + +add "return 0;" +add "}" + +compile +${app}