diff --git a/SConstruct b/SConstruct index 569ff4b09..419bc56d5 100644 --- a/SConstruct +++ b/SConstruct @@ -325,7 +325,7 @@ opts.AddVariables( # Variables affecting rendering back-ends BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'), - + BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'), BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'), @@ -345,7 +345,12 @@ opts.AddVariables( PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('RASTERLITE_INCLUDES', 'Search path for RASTERLITE include files', '/usr/include/', PathVariable.PathAccept), PathVariable('RASTERLITE_LIBS', 'Search path for RASTERLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), - + + # Variables for logging and statistics + BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'), + BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'), + ('LOG_FORMAT_STRING', 'The format string used before log output string, piped through strftime (max length of 255 characters)', 'Mapnik LOG> %Y-%m-%d %H:%M:%S:'), + # Other variables BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'), ('SYSTEM_FONTS','Provide location for python bindings to register fonts (if given aborts installation of bundled DejaVu fonts)',''), @@ -1163,7 +1168,7 @@ if not preconfigured: env.Append(CXXFLAGS = '-DBOOST_REGEX_HAS_ICU') else: env['SKIPPED_DEPS'].append('boost_regex_icu') - + env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] if len(env['REQUESTED_PLUGINS']): @@ -1411,10 +1416,26 @@ if not preconfigured: # Common debugging flags. # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' - ndebug_flags = '-DNDEBUG' - - + + # Enable logging in debug mode (always) and release mode (when specified) + log_enabled = ' -DMAPNIK_LOG -DMAPNIK_LOG_FORMAT="%s"' % env['LOG_FORMAT_STRING'] + + if env['DEBUG']: + debug_flags += log_enabled + else: + if env['ENABLE_LOG']: + ndebug_flags += log_enabled + + # Enable statistics reporting + if env['ENABLE_STATS']: + debug_flags += ' -DMAPNIK_STATS' + ndebug_flags += ' -DMAPNIK_STATS' + + # Add rdynamic to allow using statics between application and plugins + # http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux + env.MergeFlags('-rdynamic') + # Customizing the C++ compiler flags depending on: # (1) the C++ compiler used; and # (2) whether debug binaries are requested. diff --git a/bindings/python/mapnik_color.cpp b/bindings/python/mapnik_color.cpp index 1b6e34fb2..82611ff48 100644 --- a/bindings/python/mapnik_color.cpp +++ b/bindings/python/mapnik_color.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_coord.cpp b/bindings/python/mapnik_coord.cpp index 103dad3f8..b9b4e6277 100644 --- a/bindings/python/mapnik_coord.cpp +++ b/bindings/python/mapnik_coord.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index d7b83040e..7d424431d 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ + // boost #include #include + // stl #include #include @@ -89,6 +90,7 @@ boost::python::dict describe(boost::shared_ptr const& ds) description["name"] = ld.get_name(); description["geometry_type"] = ds->get_geometry_type(); description["encoding"] = ld.get_encoding(); + description["log"] = ds->log_enabled(); return description; } diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index 6b62b7129..c4381837b 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -20,8 +20,6 @@ * *****************************************************************************/ -//$Id$ - #include #include diff --git a/bindings/python/mapnik_envelope.cpp b/bindings/python/mapnik_envelope.cpp index 5aa35a0bf..099f319cc 100644 --- a/bindings/python/mapnik_envelope.cpp +++ b/bindings/python/mapnik_envelope.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id: mapnik_envelope.cc 27 2005-03-30 21:45:40Z pavlenko $ // boost #include diff --git a/bindings/python/mapnik_expression.cpp b/bindings/python/mapnik_expression.cpp index d95d5879b..b75281394 100644 --- a/bindings/python/mapnik_expression.cpp +++ b/bindings/python/mapnik_expression.cpp @@ -19,9 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include +#include + // mapnik #include #include @@ -30,7 +32,6 @@ #include #include -#include using mapnik::Feature; using mapnik::expression_ptr; diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index e55842e26..c4d7f75b6 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -19,13 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost - #include //#include - #include #include #include diff --git a/bindings/python/mapnik_featureset.cpp b/bindings/python/mapnik_featureset.cpp index c7f4722d3..21eb7b796 100644 --- a/bindings/python/mapnik_featureset.cpp +++ b/bindings/python/mapnik_featureset.cpp @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include + // mapnik #include #include diff --git a/bindings/python/mapnik_font_engine.cpp b/bindings/python/mapnik_font_engine.cpp index 1b2596e3c..5f4160756 100644 --- a/bindings/python/mapnik_font_engine.cpp +++ b/bindings/python/mapnik_font_engine.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include #include diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 06aa96207..cd2506628 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -17,7 +17,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_grid.cpp b/bindings/python/mapnik_grid.cpp index 2cfce2b7b..95a20efaf 100644 --- a/bindings/python/mapnik_grid.cpp +++ b/bindings/python/mapnik_grid.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_grid_view.cpp b/bindings/python/mapnik_grid_view.cpp index bb39a5b88..926ee18f6 100644 --- a/bindings/python/mapnik_grid_view.cpp +++ b/bindings/python/mapnik_grid_view.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 5ade76573..ff4d17c0b 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ extern "C" { diff --git a/bindings/python/mapnik_image_view.cpp b/bindings/python/mapnik_image_view.cpp index 9e07a29e6..f3cf2e44f 100644 --- a/bindings/python/mapnik_image_view.cpp +++ b/bindings/python/mapnik_image_view.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ extern "C" { diff --git a/bindings/python/mapnik_inmem_metawriter.cpp b/bindings/python/mapnik_inmem_metawriter.cpp index 44ebbdd08..34760f45b 100644 --- a/bindings/python/mapnik_inmem_metawriter.cpp +++ b/bindings/python/mapnik_inmem_metawriter.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_layer.cpp b/bindings/python/mapnik_layer.cpp index 512d895b4..0b2e8d63b 100644 --- a/bindings/python/mapnik_layer.cpp +++ b/bindings/python/mapnik_layer.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id: mapnik_layer.cc 17 2005-03-08 23:58:43Z pavlenko $ - // boost #include diff --git a/bindings/python/mapnik_line_pattern_symbolizer.cpp b/bindings/python/mapnik_line_pattern_symbolizer.cpp index aae24bac0..e982edf05 100644 --- a/bindings/python/mapnik_line_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_line_pattern_symbolizer.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include diff --git a/bindings/python/mapnik_line_symbolizer.cpp b/bindings/python/mapnik_line_symbolizer.cpp index 9c7053b90..93f96e693 100644 --- a/bindings/python/mapnik_line_symbolizer.cpp +++ b/bindings/python/mapnik_line_symbolizer.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include #include "mapnik_enumeration.hpp" diff --git a/bindings/python/mapnik_map.cpp b/bindings/python/mapnik_map.cpp index c6e2467cd..3bc1ca983 100644 --- a/bindings/python/mapnik_map.cpp +++ b/bindings/python/mapnik_map.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id: mapnik_map.cc 17 2005-03-08 23:58:43Z pavlenko $ // boost #include diff --git a/bindings/python/mapnik_markers_symbolizer.cpp b/bindings/python/mapnik_markers_symbolizer.cpp index 17d860f11..d6388c6f7 100644 --- a/bindings/python/mapnik_markers_symbolizer.cpp +++ b/bindings/python/mapnik_markers_symbolizer.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include + #include #include #include diff --git a/bindings/python/mapnik_palette.cpp b/bindings/python/mapnik_palette.cpp index 4e6c39666..54b0b3146 100644 --- a/bindings/python/mapnik_palette.cpp +++ b/bindings/python/mapnik_palette.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_parameters.cpp b/bindings/python/mapnik_parameters.cpp index 5a015c0ae..1bc7d853a 100644 --- a/bindings/python/mapnik_parameters.cpp +++ b/bindings/python/mapnik_parameters.cpp @@ -25,6 +25,7 @@ #include // mapnik +#include #include #include #include @@ -102,7 +103,9 @@ struct parameters_pickle_suite : boost::python::pickle_suite } else { - std::clog << "could not unpickle key: " << key << "\n"; +#ifdef MAPNIK_LOG + mapnik::log() << "parameters_pickle_suite: Could not unpickle key=" << key; +#endif } } } diff --git a/bindings/python/mapnik_point_symbolizer.cpp b/bindings/python/mapnik_point_symbolizer.cpp index ddd10bf41..2ca6c9acb 100644 --- a/bindings/python/mapnik_point_symbolizer.cpp +++ b/bindings/python/mapnik_point_symbolizer.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include #include "mapnik_enumeration.hpp" diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index 6aee342b8..dc155c5f6 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include #include diff --git a/bindings/python/mapnik_polygon_symbolizer.cpp b/bindings/python/mapnik_polygon_symbolizer.cpp index dd809ac5d..06f35f0d8 100644 --- a/bindings/python/mapnik_polygon_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_symbolizer.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include #include "mapnik_enumeration.hpp" diff --git a/bindings/python/mapnik_proj_transform.cpp b/bindings/python/mapnik_proj_transform.cpp index ed5e7c9a0..7dec3b36b 100644 --- a/bindings/python/mapnik_proj_transform.cpp +++ b/bindings/python/mapnik_proj_transform.cpp @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // mapnik #include + // boost #include diff --git a/bindings/python/mapnik_projection.cpp b/bindings/python/mapnik_projection.cpp index f555ab11a..54fba845f 100644 --- a/bindings/python/mapnik_projection.cpp +++ b/bindings/python/mapnik_projection.cpp @@ -19,9 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ -//boost +// boost #include // mapnik diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index 08133b17a..f2b5c368f 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -19,11 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include + +// mapnik #include #include + using mapnik::query; using mapnik::box2d; diff --git a/bindings/python/mapnik_raster_colorizer.cpp b/bindings/python/mapnik_raster_colorizer.cpp index 0aa43b3f2..7d9d6b755 100644 --- a/bindings/python/mapnik_raster_colorizer.cpp +++ b/bindings/python/mapnik_raster_colorizer.cpp @@ -19,10 +19,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include #include + +// mapnik #include using mapnik::raster_colorizer; diff --git a/bindings/python/mapnik_raster_symbolizer.cpp b/bindings/python/mapnik_raster_symbolizer.cpp index 63a18b851..dacaea5de 100644 --- a/bindings/python/mapnik_raster_symbolizer.cpp +++ b/bindings/python/mapnik_raster_symbolizer.cpp @@ -19,9 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include + +// mapnik #include using mapnik::raster_symbolizer; diff --git a/bindings/python/mapnik_rule.cpp b/bindings/python/mapnik_rule.cpp index 528a87a63..378e22f10 100644 --- a/bindings/python/mapnik_rule.cpp +++ b/bindings/python/mapnik_rule.cpp @@ -19,13 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include #include #include #include +// mapnik #include #include #include diff --git a/bindings/python/mapnik_shield_symbolizer.cpp b/bindings/python/mapnik_shield_symbolizer.cpp index 41eff7536..28ae7083e 100644 --- a/bindings/python/mapnik_shield_symbolizer.cpp +++ b/bindings/python/mapnik_shield_symbolizer.cpp @@ -20,9 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include + +// mapnik #include #include #include diff --git a/bindings/python/mapnik_stroke.cpp b/bindings/python/mapnik_stroke.cpp index a75f614c6..1f21071c3 100644 --- a/bindings/python/mapnik_stroke.cpp +++ b/bindings/python/mapnik_stroke.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index 1ab130c04..9437e87d5 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -19,11 +19,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include #include +// mapnik #include "mapnik_enumeration.hpp" #include diff --git a/bindings/python/mapnik_symbolizer.cpp b/bindings/python/mapnik_symbolizer.cpp index a4c4c3512..bd87b0db8 100644 --- a/bindings/python/mapnik_symbolizer.cpp +++ b/bindings/python/mapnik_symbolizer.cpp @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ +// boost #include +// mapnik //symbolizer typdef here rather than mapnik/symbolizer.hpp #include diff --git a/bindings/python/mapnik_view_transform.cpp b/bindings/python/mapnik_view_transform.cpp index 7a9da32d5..090e65f9c 100644 --- a/bindings/python/mapnik_view_transform.cpp +++ b/bindings/python/mapnik_view_transform.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ // boost #include diff --git a/bindings/python/python_cairo.cpp b/bindings/python/python_cairo.cpp index e5420c1b1..ee6c900c3 100644 --- a/bindings/python/python_cairo.cpp +++ b/bindings/python/python_cairo.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) diff --git a/bindings/python/python_grid_utils.hpp b/bindings/python/python_grid_utils.hpp index 09b72573c..2a9b21cf4 100644 --- a/bindings/python/python_grid_utils.hpp +++ b/bindings/python/python_grid_utils.hpp @@ -28,6 +28,7 @@ #include // mapnik +#include #include #include #include @@ -271,7 +272,9 @@ static void write_features(T const& grid_type, } else { - std::clog << "should not get here: key '" << key << "' not found in grid feature properties\n"; +#ifdef MAPNIK_LOG + mapnik::log() << "write_features: Should not get here: key " << key << " not found in grid feature properties"; +#endif } } } diff --git a/bindings/python/python_optional.hpp b/bindings/python/python_optional.hpp index 7707f0053..29c1990db 100644 --- a/bindings/python/python_optional.hpp +++ b/bindings/python/python_optional.hpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -//$Id$ #include #include diff --git a/include/mapnik/ctrans.hpp b/include/mapnik/ctrans.hpp index 31c62f391..2d8423d85 100644 --- a/include/mapnik/ctrans.hpp +++ b/include/mapnik/ctrans.hpp @@ -24,6 +24,7 @@ #define MAPNIK_CTRANS_HPP // mapnik +#include #include #include #include @@ -239,9 +240,9 @@ struct MAPNIK_DECL coord_transform_parallel angle_a = atan2((m_pre_y-m_cur_y),(m_pre_x-m_cur_x)); dx_pre = cos(angle_a + pi_by_2); dy_pre = sin(angle_a + pi_by_2); -#ifdef MAPNIK_DEBUG - std::clog << "offsetting line by: " << offset_ << "\n"; - std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n"; +#ifdef MAPNIK_LOG + mapnik::log() << "coord_transform_parallel: Offsetting line by=" << offset_; + mapnik::log() << "coord_transform_parallel: Initial dx=" << (dx_pre * offset_) << ",dy=" << (dy_pre * offset_); #endif *x = m_pre_x + (dx_pre * offset_); *y = m_pre_y + (dy_pre * offset_); @@ -290,14 +291,14 @@ struct MAPNIK_DECL coord_transform_parallel else // skip sharp spikes { -#ifdef MAPNIK_DEBUG +#ifdef MAPNIK_LOG dx_curr = cos(angle_a + pi_by_2); dy_curr = sin(angle_a + pi_by_2); sin_curve = dx_curr*dy_pre-dy_curr*dx_pre; - std::clog << "angle a: " << angle_a << "\n"; - std::clog << "angle b: " << angle_b << "\n"; - std::clog << "h: " << h << "\n"; - std::clog << "sin_curve: " << sin_curve << "\n"; + mapnik::log() << "coord_transform_parallel: angle a=" << angle_a; + mapnik::log() << "coord_transform_parallel: angle b=" << angle_b; + mapnik::log() << "coord_transform_parallel: h=" << h; + mapnik::log() << "coord_transform_parallel: sin_curve=" << sin_curve; #endif m_status = process; break; @@ -309,21 +310,21 @@ struct MAPNIK_DECL coord_transform_parallel sin_curve = dx_curr*dy_pre-dy_curr*dx_pre; cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr; - #ifdef MAPNIK_DEBUG - std::clog << "sin_curve value: " << sin_curve << "\n"; + #ifdef MAPNIK_LOG + mapnik::log() << "coord_transform_parallel: sin_curve value=" << sin_curve; #endif if(sin_curve > -0.3 && sin_curve < 0.3) { - angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x)); - h = tan((angle_b - angle_a)/2.0); - *x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_); - *y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_); + angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x)); + h = tan((angle_b - angle_a)/2.0); + *x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_); + *y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_); } else { - if (angle_b - angle_a > 0) - h = -1.0*(1.0+cos_curve)/sin_curve; - else - h = (1.0+cos_curve)/sin_curve; - *x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_; - *y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_; + if (angle_b - angle_a > 0) + h = -1.0*(1.0+cos_curve)/sin_curve; + else + h = (1.0+cos_curve)/sin_curve; + *x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_; + *y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_; } */ diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 6ae828a94..0e7b71f7c 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -88,6 +88,7 @@ public: datasource (parameters const& params) : params_(params), + log_enabled_(false), is_bound_(false) { } @@ -104,6 +105,15 @@ public: return params_; } + /*! + * @brief Get the status of detasource logging + * @return Return true if log is enabled, false otherwise + */ + bool log_enabled() const + { + return log_enabled_; + } + /*! * @brief Get the type of the datasource * @return The type of the datasource (Vector or Raster) @@ -123,6 +133,7 @@ public: virtual ~datasource() {} protected: parameters params_; + bool log_enabled_; mutable bool is_bound_; }; diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp new file mode 100644 index 000000000..3abe24538 --- /dev/null +++ b/include/mapnik/debug.hpp @@ -0,0 +1,127 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_DEBUG_HPP +#define MAPNIK_DEBUG_HPP + +// mapnik +#include + +// boost +#ifdef MAPNIK_THREADSAFE +#include +#endif + +// std +#include +#include +#include +#include +#include +#include + +#ifdef MAPNIK_DEBUG +#define MAPNIK_DEBUG_AS_BOOL true +#else +#define MAPNIK_DEBUG_AS_BOOL false +#endif + +#ifndef MAPNIK_LOG_FORMAT +#error Must run configure again to regenerate the correct log format string. See LOG_FORMAT_STRING scons option. +#endif + +namespace mapnik { + + namespace logger { + +#define __xstr__(s) __str__(s) +#define __str__(s) #s + + static inline std::string format_logger() { + char buf[256]; + const time_t tm = time(0); + strftime(buf, sizeof(buf), __xstr__(MAPNIK_LOG_FORMAT), localtime(&tm)); + return buf; + } + +#undef __xstr__ +#undef __str__ + + template + class no_output { + private: + struct null_buffer { + template + null_buffer &operator<<(const T &) { + return *this; + } + }; + public: + typedef null_buffer stream_buffer; + + public: + void operator()(const stream_buffer &) { + } + }; + + template + class output_to_clog { + public: + typedef std::basic_ostringstream stream_buffer; + public: + void operator()(const stream_buffer &s) { +#ifdef MAPNIK_THREADSAFE + static boost::mutex mutex; + boost::mutex::scoped_lock lock(mutex); +#endif + std::clog << format_logger() << " " << s.str() << std::endl; + } + }; + + template