Merge branch 'master' of github.com:mapnik/mapnik into hsla-filter

This commit is contained in:
Dane Springmeyer 2013-02-27 11:06:14 -05:00
commit a4f1dcf891
6 changed files with 50 additions and 128 deletions

View file

@ -456,7 +456,7 @@ HELP_REQUESTED = False
if ('-h' in command_line_args) or ('--help' in command_line_args): if ('-h' in command_line_args) or ('--help' in command_line_args):
HELP_REQUESTED = True HELP_REQUESTED = True
if ('-c' in command_line_args) or ('--clean' in command_line_args): if ('install' not in command_line_args) and ('-c' in command_line_args) or ('--clean' in command_line_args):
HELP_REQUESTED = True HELP_REQUESTED = True
if 'configure' in command_line_args and not HELP_REQUESTED: if 'configure' in command_line_args and not HELP_REQUESTED:

View file

@ -20,6 +20,8 @@
#include <QtGui> #include <QtGui>
#define BOOST_CHRONO_HEADER_ONLY
#include <boost/timer/timer.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <mapnik/agg_renderer.hpp> #include <mapnik/agg_renderer.hpp>
@ -502,7 +504,10 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
try try
{ {
ren.apply(); {
boost::timer::auto_cpu_timer t;
ren.apply();
}
QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32); QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32);
pix = QPixmap::fromImage(image.rgbSwapped()); pix = QPixmap::fromImage(image.rgbSwapped());
} }

View file

@ -3,10 +3,10 @@
###################################################################### ######################################################################
TEMPLATE = app TEMPLATE = app
QMAKE_CXX = clang++ QMAKE_CXX = clang++
QMAKE_CXXFLAGS += $$system(mapnik-config --cflags) QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags)
QMAKE_LFLAGS += $$system(mapnik-config --libs) QMAKE_LFLAGS += $$system(mapnik-config --libs)
QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs) QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs)
QMAKE_LFLAGS += -lboost_timer
# Input # Input
CONFIG += qt debug_and_release CONFIG += qt debug_and_release
@ -19,17 +19,17 @@ HEADERS += mainwindow.hpp \
layerwidget.hpp \ layerwidget.hpp \
layerlistmodel.hpp \ layerlistmodel.hpp \
layerdelegate.hpp \ layerdelegate.hpp \
styles_model.hpp styles_model.hpp
HEADERS += about_dialog.hpp \ HEADERS += about_dialog.hpp \
info_dialog.hpp \ info_dialog.hpp \
layer_info_dialog.hpp layer_info_dialog.hpp
SOURCES += main.cpp \ SOURCES += main.cpp \
mainwindow.cpp \ mainwindow.cpp \
mapwidget.cpp \ mapwidget.cpp \
layerwidget.cpp \ layerwidget.cpp \
layerlistmodel.cpp \ layerlistmodel.cpp \
layerdelegate.cpp \ layerdelegate.cpp \
styles_model.cpp styles_model.cpp

View file

@ -152,6 +152,24 @@ bool string2float(const char * iter, const char * end, float & result)
return r && (iter == end); return r && (iter == end);
} }
// double conversion - here we use sprintf over karma to work
// around https://github.com/mapnik/mapnik/issues/1741
bool to_string(std::string & s, double val)
{
s.resize(s.capacity());
while (true)
{
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val));
if (n2 <= s.size())
{
s.resize(n2);
break;
}
s.resize(n2);
}
return true;
}
#ifdef MAPNIK_KARMA_TO_STRING #ifdef MAPNIK_KARMA_TO_STRING
bool to_string(std::string & str, int value) bool to_string(std::string & str, int value)
@ -184,95 +202,6 @@ bool to_string(std::string & str, bool value)
return karma::generate(sink, value); return karma::generate(sink, value);
} }
namespace detail {
template <typename T>
struct double_policy : boost::spirit::karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) {
using namespace boost::spirit; // for traits
if (traits::test_zero(n))
return base_type::fmtflags::fixed;
T abs_n = traits::get_absolute_value(n);
return (abs_n >= 1e16 || abs_n < 1e-4)
? base_type::fmtflags::scientific : base_type::fmtflags::fixed;
}
static unsigned precision(T n) {
if ( n == 0.0 ) return 0;
using namespace boost::spirit; // for traits
return static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n))));
}
template <typename OutputIterator>
static bool dot(OutputIterator& sink, T n, unsigned precision) {
if (n == 0.0) return true; // avoid trailing zeroes
return base_type::dot(sink, n, precision);
}
template <typename OutputIterator>
static bool fraction_part (OutputIterator& sink, T n
, unsigned precision_, unsigned precision)
{
// NOTE: copied from karma only to avoid trailing zeroes
// (maybe a bug ?)
// allow for ADL to find the correct overload for floor and log10
using namespace std;
using namespace boost::spirit; // for traits
using namespace boost::spirit::karma; // for char_inserter
if ( traits::test_zero(n) ) return true; // this part added to karma
// The following is equivalent to:
// generate(sink, right_align(precision, '0')[ulong], n);
// but it's spelled out to avoid inter-modular dependencies.
typename boost::remove_const<T>::type digits =
(traits::test_zero(n) ? 0 : floor(log10(n))) + 1;
bool r = true;
for (/**/; r && digits < precision_; digits = digits + 1)
r = char_inserter<>::call(sink, '0');
if (precision && r)
r = int_inserter<10>::call(sink, n);
return r;
}
template <typename CharEncoding, typename Tag, typename OutputIterator>
static bool exponent (OutputIterator& sink, long n)
{
// NOTE: copied from karma to force sign in exponent
const bool force_sign = true;
using namespace boost::spirit; // for traits
using namespace boost::spirit::karma; // for char_inserter, sign_inserter
unsigned long abs_n = traits::get_absolute_value(n);
bool r = char_inserter<CharEncoding, Tag>::call(sink, 'e') &&
sign_inserter::call(sink, traits::test_zero(n)
, traits::test_negative(n), force_sign);
// the C99 Standard requires at least two digits in the exponent
if (r && abs_n < 10)
r = char_inserter<CharEncoding, Tag>::call(sink, '0');
return r && int_inserter<10>::call(sink, abs_n);
}
};
}
bool to_string(std::string & str, double value)
{
namespace karma = boost::spirit::karma;
typedef karma::real_generator<double, detail::double_policy<double> > double_type;
std::back_insert_iterator<std::string> sink(str);
return karma::generate(sink, double_type(), value);
}
#else #else
bool to_string(std::string & s, int val) bool to_string(std::string & s, int val)
@ -332,22 +261,6 @@ bool to_string(std::string & s, bool val)
return true; return true;
} }
bool to_string(std::string & s, double val)
{
s.resize(s.capacity());
while (true)
{
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val));
if (n2 <= s.size())
{
s.resize(n2);
break;
}
s.resize(n2);
}
return true;
}
#endif #endif
} // end namespace util } // end namespace util

View file

@ -65,11 +65,6 @@ int main( int, char*[] )
BOOST_TEST_EQ( out, "-0.0001" ); BOOST_TEST_EQ( out, "-0.0001" );
out.clear(); out.clear();
to_string(out, double(0.0001234567890123456));
// TODO: https://github.com/mapnik/mapnik/issues/1676
BOOST_TEST_EQ( out, "0.000123457" );
out.clear();
to_string(out, double(0.0001)); to_string(out, double(0.0001));
BOOST_TEST_EQ( out, "0.0001" ); BOOST_TEST_EQ( out, "0.0001" );
out.clear(); out.clear();
@ -98,6 +93,23 @@ int main( int, char*[] )
BOOST_TEST_EQ( out, "1e-10" ); BOOST_TEST_EQ( out, "1e-10" );
out.clear(); out.clear();
to_string(out, double(-1.234e+16));
BOOST_TEST_EQ( out, "-1.234e+16" );
out.clear();
// critical failure when karam is used
// https://github.com/mapnik/mapnik/issues/1741
// https://github.com/mapbox/tilemill/issues/1456
to_string(out, double(8.3));
BOOST_TEST_EQ( out, "8.3" );
out.clear();
// non-critical failures if karma is used
to_string(out, double(0.0001234567890123456));
// TODO: https://github.com/mapnik/mapnik/issues/1676
BOOST_TEST_EQ( out, "0.000123457" );
out.clear();
to_string(out, double(0.00000000001)); to_string(out, double(0.00000000001));
BOOST_TEST_EQ( out, "1e-11" ); BOOST_TEST_EQ( out, "1e-11" );
out.clear(); out.clear();
@ -185,15 +197,7 @@ int main( int, char*[] )
to_string(out, double(1.234e+16)); to_string(out, double(1.234e+16));
BOOST_TEST_EQ( out, "1.234e+16" ); BOOST_TEST_EQ( out, "1.234e+16" );
out.clear(); out.clear();
to_string(out, double(-1.234e+16));
BOOST_TEST_EQ( out, "-1.234e+16" );
out.clear();
// https://github.com/mapbox/tilemill/issues/1456
to_string(out, double(8.3));
BOOST_TEST_EQ( out, "8.3" );
out.clear();
// int // int
to_string(out, int(2)); to_string(out, int(2));
BOOST_TEST_EQ( out, "2" ); BOOST_TEST_EQ( out, "2" );

View file

@ -27,7 +27,7 @@ Known values for OPTION are:
--libs print library linking information --libs print library linking information
--dep-libs print library linking information for Mapnik dependencies --dep-libs print library linking information for Mapnik dependencies
--ldflags print library paths (-L) information --ldflags print library paths (-L) information
--cflags print pre-processor and compiler flags --cxxflags print pre-processor and compiler flags
--fonts print default fonts directory --fonts print default fonts directory
--input-plugins print default input plugins directory --input-plugins print default input plugins directory
--json print all config options as json object --json print all config options as json object
@ -89,7 +89,7 @@ while test $# -gt 0; do
echo ${CONFIG_INPUT_PLUGINS} echo ${CONFIG_INPUT_PLUGINS}
;; ;;
--cflags) --cxxflags)
echo -I${CONFIG_MAPNIK_INCLUDE} -I${CONFIG_MAPNIK_AGG_INCLUDE} ${CONFIG_OTHER_INCLUDES} echo -I${CONFIG_MAPNIK_INCLUDE} -I${CONFIG_MAPNIK_AGG_INCLUDE} ${CONFIG_OTHER_INCLUDES}
;; ;;