Merge branch 'master' of github.com:mapnik/mapnik into mapnik-geometry
This commit is contained in:
commit
ecbacc5933
4 changed files with 75 additions and 27 deletions
63
scripts/check-padding
Executable file
63
scripts/check-padding
Executable file
|
@ -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 <iostream>"
|
||||||
|
add "#include <vector>"
|
||||||
|
|
||||||
|
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<double>)"
|
||||||
|
add "REPORT(std::size_t)"
|
||||||
|
|
||||||
|
add "REPORT($2)"
|
||||||
|
|
||||||
|
add "return 0;"
|
||||||
|
add "}"
|
||||||
|
|
||||||
|
compile
|
||||||
|
${app}
|
|
@ -3,7 +3,6 @@
|
||||||
"features":
|
"features":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type":"Feature",
|
|
||||||
"geometry":
|
"geometry":
|
||||||
{
|
{
|
||||||
"type":"Point",
|
"type":"Point",
|
||||||
|
@ -24,7 +23,8 @@
|
||||||
"NOM_FR":"Qu\u00e9bec",
|
"NOM_FR":"Qu\u00e9bec",
|
||||||
"object": {"value":{"type":"\u041c\u0430pni\u043a","array": [3,0,"x"]}},
|
"object": {"value":{"type":"\u041c\u0430pni\u043a","array": [3,0,"x"]}},
|
||||||
"array" : [ [ [1], ["deux"]],[["\u0442\u0440\u0438","four","\u4e94"]]]
|
"array" : [ [ [1], ["deux"]],[["\u0442\u0440\u0438","four","\u4e94"]]]
|
||||||
}
|
},
|
||||||
|
"type":"Feature"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import mapnik
|
import mapnik
|
||||||
|
import os
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -8,28 +9,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
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
|
# compare two images and return number of different pixels
|
||||||
def compare(actual, expected, alpha=True):
|
def compare(actual, expected, alpha=True):
|
||||||
im1 = mapnik.Image.open(actual)
|
im1 = mapnik.Image.open(actual)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import mapnik
|
||||||
#mapnik.logger.set_severity(mapnik.severity_type.Debug)
|
#mapnik.logger.set_severity(mapnik.severity_type.Debug)
|
||||||
import shutil
|
import shutil
|
||||||
import os.path
|
import os.path
|
||||||
|
import os
|
||||||
from compare import compare, compare_grids
|
from compare import compare, compare_grids
|
||||||
import platform
|
import platform
|
||||||
import glob
|
import glob
|
||||||
|
@ -27,9 +28,14 @@ defaults = {
|
||||||
'grid': mapnik.has_grid_renderer()
|
'grid': mapnik.has_grid_renderer()
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_threshold = 0
|
if os.name == 'nt':
|
||||||
agg_threshold = 0
|
cairo_threshold = 10
|
||||||
grid_threshold = 0
|
agg_threshold = 0
|
||||||
|
grid_threshold = 0
|
||||||
|
else:
|
||||||
|
cairo_threshold = 0
|
||||||
|
agg_threshold = 0
|
||||||
|
grid_threshold = 0
|
||||||
|
|
||||||
def render_cairo(m, output, scale_factor):
|
def render_cairo(m, output, scale_factor):
|
||||||
mapnik.render_to_file(m, output, 'ARGB32', scale_factor)
|
mapnik.render_to_file(m, output, 'ARGB32', scale_factor)
|
||||||
|
|
Loading…
Reference in a new issue