Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implement new debug system

  • Loading branch information...
commit 1f351e0e097270940c7c9257b5b685176737fac2 1 parent 19f5f77
@kunitoki kunitoki authored
Showing with 1,867 additions and 1,062 deletions.
  1. +27 −6 SConstruct
  2. +0 −1  bindings/python/mapnik_color.cpp
  3. +0 −1  bindings/python/mapnik_coord.cpp
  4. +3 −1 bindings/python/mapnik_datasource.cpp
  5. +0 −2  bindings/python/mapnik_datasource_cache.cpp
  6. +0 −1  bindings/python/mapnik_envelope.cpp
  7. +3 −2 bindings/python/mapnik_expression.cpp
  8. +0 −3  bindings/python/mapnik_feature.cpp
  9. +1 −1  bindings/python/mapnik_featureset.cpp
  10. +0 −1  bindings/python/mapnik_font_engine.cpp
  11. +0 −1  bindings/python/mapnik_geometry.cpp
  12. +0 −1  bindings/python/mapnik_grid.cpp
  13. +0 −1  bindings/python/mapnik_grid_view.cpp
  14. +0 −1  bindings/python/mapnik_image.cpp
  15. +0 −1  bindings/python/mapnik_image_view.cpp
  16. +0 −1  bindings/python/mapnik_inmem_metawriter.cpp
  17. +0 −2  bindings/python/mapnik_layer.cpp
  18. +0 −1  bindings/python/mapnik_line_pattern_symbolizer.cpp
  19. +0 −1  bindings/python/mapnik_line_symbolizer.cpp
  20. +0 −1  bindings/python/mapnik_map.cpp
  21. +1 −1  bindings/python/mapnik_markers_symbolizer.cpp
  22. +0 −1  bindings/python/mapnik_palette.cpp
  23. +4 −1 bindings/python/mapnik_parameters.cpp
  24. +0 −1  bindings/python/mapnik_point_symbolizer.cpp
  25. +0 −1  bindings/python/mapnik_polygon_pattern_symbolizer.cpp
  26. +0 −1  bindings/python/mapnik_polygon_symbolizer.cpp
  27. +1 −1  bindings/python/mapnik_proj_transform.cpp
  28. +1 −2  bindings/python/mapnik_projection.cpp
  29. +4 −1 bindings/python/mapnik_query.cpp
  30. +3 −1 bindings/python/mapnik_raster_colorizer.cpp
  31. +3 −1 bindings/python/mapnik_raster_symbolizer.cpp
  32. +2 −1  bindings/python/mapnik_rule.cpp
  33. +3 −1 bindings/python/mapnik_shield_symbolizer.cpp
  34. +0 −1  bindings/python/mapnik_stroke.cpp
  35. +2 −1  bindings/python/mapnik_style.cpp
  36. +2 −1  bindings/python/mapnik_symbolizer.cpp
  37. +0 −1  bindings/python/mapnik_view_transform.cpp
  38. +0 −1  bindings/python/python_cairo.cpp
  39. +4 −1 bindings/python/python_grid_utils.hpp
  40. +0 −1  bindings/python/python_optional.hpp
  41. +21 −20 include/mapnik/ctrans.hpp
  42. +11 −0 include/mapnik/datasource.hpp
  43. +127 −0 include/mapnik/debug.hpp
  44. +7 −5 include/mapnik/font_engine_freetype.hpp
  45. +7 −3 include/mapnik/grid/grid.hpp
  46. +1 −1  include/mapnik/json/feature_collection_grammar.hpp
  47. +5 −3 include/mapnik/memory_featureset.hpp
  48. +1 −1  include/mapnik/metawriter_json.hpp
  49. +9 −8 include/mapnik/pool.hpp
  50. +1 −1  include/mapnik/rule.hpp
  51. +8 −5 include/mapnik/svg/svg_renderer.hpp
  52. +58 −22 include/mapnik/timer.hpp
  53. +17 −7 include/mapnik/utils.hpp
  54. +82 −41 plugins/input/csv/csv_datasource.cpp
  55. +24 −1 plugins/input/csv/csv_datasource.hpp
  56. +35 −14 plugins/input/gdal/gdal_datasource.cpp
  57. +1 −2  plugins/input/gdal/gdal_datasource.hpp
  58. +65 −63 plugins/input/gdal/gdal_featureset.cpp
  59. +1 −1  plugins/input/gdal/gdal_featureset.hpp
  60. +45 −14 plugins/input/geos/geos_datasource.cpp
  61. +3 −2 plugins/input/geos/geos_featureset.cpp
  62. +25 −15 plugins/input/kismet/kismet_datasource.cpp
  63. +101 −44 plugins/input/occi/occi_datasource.cpp
  64. +3 −1 plugins/input/occi/occi_datasource.hpp
  65. +49 −33 plugins/input/occi/occi_featureset.cpp
  66. +5 −0 plugins/input/occi/occi_featureset.hpp
  67. +5 −4 plugins/input/occi/occi_types.hpp
  68. +6 −3 plugins/input/ogr/ogr_converter.cpp
  69. +38 −12 plugins/input/ogr/ogr_datasource.cpp
  70. +14 −13 plugins/input/ogr/ogr_featureset.cpp
  71. +11 −11 plugins/input/ogr/ogr_index_featureset.cpp
  72. +15 −12 plugins/input/ogr/ogr_layer_ptr.hpp
  73. +10 −3 plugins/input/osm/dataset_deliverer.cpp
  74. +18 −20 plugins/input/osm/osm.cpp
  75. +14 −7 plugins/input/osm/osm_datasource.cpp
  76. +2 −4 plugins/input/osm/osm_datasource.hpp
  77. +62 −40 plugins/input/postgis/connection.hpp
  78. +12 −7 plugins/input/postgis/connection_manager.hpp
  79. +64 −36 plugins/input/postgis/cursorresultset.hpp
  80. +77 −91 plugins/input/postgis/postgis_datasource.cpp
  81. +2 −5 plugins/input/postgis/postgis_datasource.hpp
  82. +3 −2 plugins/input/postgis/postgis_featureset.cpp
  83. +3 −3 plugins/input/postgis/resultset.hpp
  84. +21 −17 plugins/input/raster/raster_datasource.cpp
  85. +2 −3 plugins/input/raster/raster_datasource.hpp
  86. +4 −3 plugins/input/raster/raster_featureset.cpp
  87. +13 −8 plugins/input/raster/raster_featureset.hpp
  88. +35 −30 plugins/input/rasterlite/rasterlite_datasource.cpp
  89. +2 −1  plugins/input/rasterlite/rasterlite_datasource.hpp
  90. +15 −17 plugins/input/rasterlite/rasterlite_featureset.cpp
  91. +65 −24 plugins/input/shape/shape_datasource.cpp
  92. +2 −4 plugins/input/shape/shape_datasource.hpp
  93. +6 −5 plugins/input/shape/shape_featureset.cpp
  94. +5 −4 plugins/input/shape/shape_index_featureset.cpp
  95. +3 −2 plugins/input/shape/shape_io.cpp
  96. +12 −1 plugins/input/sqlite/sqlite_connection.hpp
  97. +53 −28 plugins/input/sqlite/sqlite_datasource.cpp
  98. +4 −6 plugins/input/sqlite/sqlite_datasource.hpp
  99. +3 −3 plugins/input/sqlite/sqlite_featureset.cpp
  100. +14 −16 src/agg/agg_renderer.cpp
  101. +4 −1 src/agg/process_line_pattern_symbolizer.cpp
  102. +19 −7 src/agg/process_markers_symbolizer.cpp
  103. +7 −2 src/agg/process_polygon_pattern_symbolizer.cpp
  104. +27 −24 src/cairo_renderer.cpp
  105. +20 −15 src/datasource_cache.cpp
  106. +25 −13 src/feature_style_processor.cpp
  107. +8 −4 src/font_engine_freetype.cpp
  108. +18 −20 src/grid/grid_renderer.cpp
  109. +4 −2 src/grid/process_markers_symbolizer.cpp
  110. +4 −1 src/grid/process_raster_symbolizer.cpp
  111. +0 −4 src/jpeg_reader.cpp
  112. +2 −2 src/libxml2_loader.cpp
  113. +64 −22 src/load_map.cpp
  114. +12 −16 src/map.cpp
  115. +1 −3 src/memory.cpp
  116. +5 −3 src/memory_datasource.cpp
  117. +12 −7 src/metawriter.cpp
  118. +8 −8 src/placement_finder.cpp
  119. +6 −5 src/png_reader.cpp
  120. +1 −1  src/proj_transform.cpp
  121. +15 −11 src/raster_colorizer.cpp
  122. +0 −1  src/save_map.cpp
  123. +10 −10 src/svg/svg_renderer.cpp
  124. +3 −3 src/svg_parser.cpp
  125. +3 −2 src/text_properties.cpp
  126. +6 −1 src/text_symbolizer.cpp
  127. +8 −4 src/tiff_reader.cpp
  128. +0 −4 src/unicode.cpp
  129. +7 −11 src/wkb.cpp
  130. +66 −15 tests/python_tests/csv_test.py
  131. +15 −3 tests/python_tests/datasource_test.py
  132. +94 −33 workspace/mapnik.pro
  133. +2 −1  workspace/plugins.pri
View
33 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.
View
1  bindings/python/mapnik_color.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
View
1  bindings/python/mapnik_coord.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
View
4 bindings/python/mapnik_datasource.cpp
@@ -19,10 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
+
// boost
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
+
// stl
#include <sstream>
#include <vector>
@@ -89,6 +90,7 @@ boost::python::dict describe(boost::shared_ptr<mapnik::datasource> 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;
}
View
2  bindings/python/mapnik_datasource_cache.cpp
@@ -20,8 +20,6 @@
*
*****************************************************************************/
-//$Id$
-
#include <boost/python.hpp>
#include <mapnik/datasource_cache.hpp>
View
1  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 <boost/python.hpp>
View
5 bindings/python/mapnik_expression.cpp
@@ -19,9 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
+// boost
#include <boost/python.hpp>
+#include <boost/variant.hpp>
+
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/expression.hpp>
@@ -30,7 +32,6 @@
#include <mapnik/parse_path.hpp>
#include <mapnik/value.hpp>
-#include <boost/variant.hpp>
using mapnik::Feature;
using mapnik::expression_ptr;
View
3  bindings/python/mapnik_feature.cpp
@@ -19,13 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
-
#include <boost/python/suite/indexing/indexing_suite.hpp>
//#include <boost/python/suite/indexing/map_indexing_suite.hpp>
-
#include <boost/python/iterator.hpp>
#include <boost/python/call_method.hpp>
#include <boost/python/tuple.hpp>
View
2  bindings/python/mapnik_featureset.cpp
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
+
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/datasource.hpp>
View
1  bindings/python/mapnik_font_engine.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
#include <boost/python.hpp>
#include <mapnik/font_engine_freetype.hpp>
View
1  bindings/python/mapnik_geometry.cpp
@@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
View
1  bindings/python/mapnik_grid.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
View
1  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 <boost/python.hpp>
View
1  bindings/python/mapnik_image.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
extern "C"
{
View
1  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"
{
View
1  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 <boost/python.hpp>
View
2  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 <boost/python.hpp>
View
1  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 <boost/python.hpp>
View
1  bindings/python/mapnik_line_symbolizer.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
#include <boost/python.hpp>
#include "mapnik_enumeration.hpp"
View
1  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 <boost/python.hpp>
View
2  bindings/python/mapnik_markers_symbolizer.cpp
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
#include <boost/python.hpp>
+
#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/markers_symbolizer.hpp>
View
1  bindings/python/mapnik_palette.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
View
5 bindings/python/mapnik_parameters.cpp
@@ -25,6 +25,7 @@
#include <boost/make_shared.hpp>
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/params.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value.hpp>
@@ -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
}
}
}
View
1  bindings/python/mapnik_point_symbolizer.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
#include <boost/python.hpp>
#include "mapnik_enumeration.hpp"
View
1  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 <boost/python.hpp>
#include <mapnik/image_util.hpp>
View
1  bindings/python/mapnik_polygon_symbolizer.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
#include <boost/python.hpp>
#include "mapnik_enumeration.hpp"
View
2  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 <mapnik/proj_transform.hpp>
+
// boost
#include <boost/python.hpp>
View
3  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 <boost/python.hpp>
// mapnik
View
5 bindings/python/mapnik_query.cpp
@@ -19,11 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
+// boost
#include <boost/python.hpp>
+
+// mapnik
#include <mapnik/query.hpp>
#include <mapnik/box2d.hpp>
+
using mapnik::query;
using mapnik::box2d;
View
4 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 <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
+
+// mapnik
#include <mapnik/raster_colorizer.hpp>
using mapnik::raster_colorizer;
View
4 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 <boost/python.hpp>
+
+// mapnik
#include <mapnik/raster_symbolizer.hpp>
using mapnik::raster_symbolizer;
View
3  bindings/python/mapnik_rule.cpp
@@ -19,13 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
+// boost
#include <boost/python.hpp>
#include <boost/python/implicit.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
+// mapnik
#include <mapnik/rule.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/expression_string.hpp>
View
4 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 <boost/python.hpp>
+
+// mapnik
#include <mapnik/shield_symbolizer.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/path_expression_grammar.hpp>
View
1  bindings/python/mapnik_stroke.cpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
// boost
#include <boost/python.hpp>
View
3  bindings/python/mapnik_style.cpp
@@ -19,11 +19,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
+// boost
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
+// mapnik
#include "mapnik_enumeration.hpp"
#include <mapnik/feature_type_style.hpp>
View
3  bindings/python/mapnik_symbolizer.cpp
@@ -19,10 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
+// boost
#include <boost/python.hpp>
+// mapnik
//symbolizer typdef here rather than mapnik/symbolizer.hpp
#include <mapnik/rule.hpp>
View
1  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 <boost/python.hpp>
View
1  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)
View
5 bindings/python/python_grid_utils.hpp
@@ -28,6 +28,7 @@
#include <boost/foreach.hpp>
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/grid/grid_renderer.hpp>
#include <mapnik/grid/grid.hpp>
#include <mapnik/grid/grid_util.hpp>
@@ -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
}
}
}
View
1  bindings/python/python_optional.hpp
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
-//$Id$
#include <boost/optional/optional.hpp>
#include <boost/python.hpp>
View
41 include/mapnik/ctrans.hpp
@@ -24,6 +24,7 @@
#define MAPNIK_CTRANS_HPP
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/coord_array.hpp>
@@ -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_;
}
*/
View
11 include/mapnik/datasource.hpp
@@ -88,6 +88,7 @@ class MAPNIK_DECL datasource : private boost::noncopyable
datasource (parameters const& params)
: params_(params),
+ log_enabled_(false),
is_bound_(false)
{
}
@@ -105,6 +106,15 @@ class MAPNIK_DECL datasource : private boost::noncopyable
}
/*!
+ * @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 @@ class MAPNIK_DECL datasource : private boost::noncopyable
virtual ~datasource() {}
protected:
parameters params_;
+ bool log_enabled_;
mutable bool is_bound_;
};
View
127 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 <mapnik/global.hpp>
+
+// boost
+#ifdef MAPNIK_THREADSAFE
+#include <boost/thread/mutex.hpp>
+#endif
+
+// std
+#include <iostream>
+#include <cassert>
+#include <sstream>
+#include <ctime>
+#include <ostream>
+#include <fstream>
+
+#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 Ch, class Tr, class A>
+ class no_output {
+ private:
+ struct null_buffer {
+ template<class T>
+ null_buffer &operator<<(const T &) {
+ return *this;
+ }
+ };
+ public:
+ typedef null_buffer stream_buffer;
+
+ public:
+ void operator()(const stream_buffer &) {
+ }
+ };
+
+ template<class Ch, class Tr, class A>
+ class output_to_clog {
+ public:
+ typedef std::basic_ostringstream<Ch, Tr, A> 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<template <class Ch, class Tr, class A> class OutputPolicy,
+ class Ch = char,
+ class Tr = std::char_traits<Ch>,
+ class A = std::allocator<Ch> >
+ class base_log {
+ typedef OutputPolicy<Ch, Tr, A> output_policy;
+ public:
+ ~base_log() {
+ output_policy()(streambuf_);
+ }
+ public:
+ template<class T>
+ base_log &operator<<(const T &x) {
+ streambuf_ << x;
+ return *this;
+ }
+ private:
+ typename output_policy::stream_buffer streambuf_;
+ };
+ }
+
+ class log : public logger::base_log<logger::output_to_clog>
+ {
+ };
+
+}
+
+#endif
View
12 include/mapnik/font_engine_freetype.hpp
@@ -24,6 +24,7 @@
#define MAPNIK_FONT_ENGINE_FREETYPE_HPP
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/color.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/ctrans.hpp>
@@ -138,9 +139,8 @@ class font_face : boost::noncopyable
~font_face()
{
-#ifdef MAPNIK_DEBUG
- std::clog << "~font_face: Clean up face \"" << family_name()
- << " " << style_name() << "\"" << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "font_face: Clean up face \"" << family_name() << " " << style_name() << "\"";
#endif
FT_Done_Face(face_);
}
@@ -225,9 +225,10 @@ class stroker : boost::noncopyable
~stroker()
{
-#ifdef MAPNIK_DEBUG
- std::clog << "~stroker: destroy stroker:" << s_ << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "stroker: Destroy stroker=" << s_;
#endif
+
FT_Stroker_Done(s_);
}
private:
@@ -310,6 +311,7 @@ class MAPNIK_DECL face_manager : private boost::noncopyable
face_set->add(face);
} else {
#ifdef MAPNIK_DEBUG
+ // TODO - handle with mapnik::log
std::cerr << "Failed to find face '" << *name << "' in font set '" << fset.get_name() << "'\n";
#endif
}
View
10 include/mapnik/grid/grid.hpp
@@ -25,6 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
+#include <mapnik/debug.hpp>
#include <mapnik/image_data.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/grid/grid_view.hpp>
@@ -72,7 +73,6 @@ class MAPNIK_DECL hit_grid
public:
-
hit_grid(int width, int height, std::string const& key, unsigned int resolution)
:width_(width),
height_(height),
@@ -136,7 +136,9 @@ class MAPNIK_DECL hit_grid
}
else
{
- std::clog << "should not get here: key '" << key_ << "' not found in feature properties\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "hit_grid: Should not get here: key '" << key_ << "' not found in feature properties";
+#endif
}
}
@@ -153,7 +155,9 @@ class MAPNIK_DECL hit_grid
}
else
{
- std::clog << "### Warning: key '" << key_ << "' was blank for " << *feature << "\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "hit_grid: Warning - key '" << key_ << "' was blank for " << *feature;
+#endif
}
}
View
2  include/mapnik/json/feature_collection_grammar.hpp
@@ -103,7 +103,7 @@ struct feature_collection_grammar :
qi::on_error<qi::fail>
(
feature_collection
- , std::clog
+ , std::cerr
<< phoenix::val("Error parsing GeoJSON ")
<< qi::_4
<< phoenix::val(" here: \"")
View
8 include/mapnik/memory_featureset.hpp
@@ -24,6 +24,7 @@
#define MAPNIK_MEMORY_FEATURESET_HPP
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/memory_datasource.hpp>
// boost
@@ -52,10 +53,11 @@ class memory_featureset : public Featureset
{
while (pos_ != end_)
{
- for (unsigned i=0; i<(*pos_)->num_geometries();++i) {
+ for (unsigned i=0; i<(*pos_)->num_geometries();++i)
+ {
geometry_type & geom = (*pos_)->get_geometry(i);
-#ifdef MAPNIK_DEBUG
- std::clog << "bbox_=" << bbox_ << ", geom.envelope=" << geom.envelope() << "\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "memory_featureset: BBox=" << bbox_ << ",Envelope=" << geom.envelope();
#endif
if (bbox_.intersects(geom.envelope()))
{
View
2  include/mapnik/metawriter_json.hpp
@@ -87,7 +87,7 @@ class metawriter_json_stream : public metawriter, private boost::noncopyable
bool pixel_coordinates_;
virtual void write_header();
inline void write_feature_header(std::string type) {
-#ifdef MAPNIK_DEBUG
+#ifdef MAPNIK_LOG
if (count_ == STOPPED)
{
std::cerr << "WARNING: Metawriter not started before using it.\n";
View
17 include/mapnik/pool.hpp
@@ -24,6 +24,7 @@
#define MAPNIK_POOL_HPP
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
// boost
@@ -100,8 +101,8 @@ class Pool : private boost::noncopyable
typename ContType::iterator itr=unusedPool_.begin();
while ( itr!=unusedPool_.end())
{
-#ifdef MAPNIK_DEBUG
- std::clog<<"borrow "<<(*itr).get()<<"\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "pool: Borrow instance=" << (*itr).get();
#endif
if ((*itr)->isOK())
{
@@ -111,8 +112,8 @@ class Pool : private boost::noncopyable
}
else
{
-#ifdef MAPNIK_DEBUG
- std::clog<<"bad connection (erase)" << (*itr).get()<<"\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "pool: Bad connection (erase) instance=" << (*itr).get();
#endif
itr=unusedPool_.erase(itr);
}
@@ -123,8 +124,8 @@ class Pool : private boost::noncopyable
if (conn->isOK())
{
usedPool_.push_back(conn);
-#ifdef MAPNIK_DEBUG
- std::clog << "create << " << conn.get() << "\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "pool: Create connection=" << conn.get();
#endif
return conn;
}
@@ -142,8 +143,8 @@ class Pool : private boost::noncopyable
{
if (obj.get()==(*itr).get())
{
-#ifdef MAPNIK_DEBUG
- std::clog<<"return "<<(*itr).get()<<"\n";
+#ifdef MAPNIK_LOG
+ mapnik::log() << "pool: Return instance=" << (*itr).get();
#endif
unusedPool_.push_back(*itr);
usedPool_.erase(itr);
View
2  include/mapnik/rule.hpp
@@ -203,7 +203,7 @@ class rule
template <class T>
void copy_text_ptr(T & sym) const
{
-#ifdef MAPNIK_DEBUG
+#ifdef MAPNIK_LOG
std::cerr << "Warning: Deep copying TextSymbolizers is broken!\n";
#endif
}
View
13 include/mapnik/svg/svg_renderer.hpp
@@ -24,6 +24,7 @@
#define MAPNIK_SVG_RENDERER_HPP
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/gradient.hpp>
#include <mapnik/box2d.hpp>
@@ -141,11 +142,13 @@ class svg_renderer : boost::noncopyable
BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() )
{
mapnik::color const& stop_color = st.second;
- unsigned r= stop_color.red();
- unsigned g= stop_color.green();
- unsigned b= stop_color.blue();
- unsigned a= stop_color.alpha();
- //std::clog << "r: " << r << " g: " << g << " b: " << b << "a: " << a << "\n";
+ unsigned r = stop_color.red();
+ unsigned g = stop_color.green();
+ unsigned b = stop_color.blue();
+ unsigned a = stop_color.alpha();
+#ifdef MAPNIK_LOG
+ //mapnik::log() << "svg_renderer: r=" << r << ",g=" << g << ",b=" << b << ",a=" << a;
+#endif
m_gradient_lut.add_color(st.first, agg::rgba8(r, g, b, int(a * opacity)));
}
m_gradient_lut.build_lut();
View
80 include/mapnik/timer.hpp
@@ -30,8 +30,34 @@
#include <iomanip>
#include <ctime>
+#ifndef WIN32
+#include <sys/time.h> // for gettimeofday() on unix
+#include <sys/resource.h>
+#else
+#include <windows.h>
+#endif
+
+
namespace mapnik {
+
+// Try to return the time now
+inline double time_now()
+{
+#ifndef WIN32
+ struct timeval t;
+ struct timezone tzp;
+ gettimeofday(&t, &tzp);
+ return t.tv_sec + t.tv_usec * 1e-6;
+#else
+ LARGE_INTEGER t, f;
+ QueryPerformanceCounter(&t);
+ QueryPerformanceFrequency(&f);
+ return double(t.QuadPart) / double(f.QuadPart);
+#endif
+}
+
+
// Measure times in both wall clock time and CPU times. Results are returned in milliseconds.
class timer
{
@@ -41,44 +67,50 @@ class timer
restart();
}
+ virtual ~timer()
+ {
+ }
+
void restart()
{
- _stopped = false;
- gettimeofday(&_wall_clock_start, NULL);
- _cpu_start = clock();
+ stopped_ = false;
+ wall_clock_start_ = time_now();
+ cpu_start_ = clock();
}
virtual void stop() const
{
- _stopped = true;
- _cpu_end = clock();
- gettimeofday(&_wall_clock_end, NULL);
+ stopped_ = true;
+ cpu_end_ = clock();
+ wall_clock_end_ = time_now();
}
double cpu_elapsed() const
{
// return elapsed CPU time in ms
- if (!_stopped)
+ if (! stopped_)
+ {
stop();
+ }
- return ((double) (_cpu_end - _cpu_start)) / CLOCKS_PER_SEC * 1000.0;
+ return ((double) (cpu_end_ - cpu_start_)) / CLOCKS_PER_SEC * 1000.0;
}
double wall_clock_elapsed() const
{
// return elapsed wall clock time in ms
- if (!_stopped)
+ if (! stopped_)
+ {
stop();
+ }
- long seconds = _wall_clock_end.tv_sec - _wall_clock_start.tv_sec;
- long useconds = _wall_clock_end.tv_usec - _wall_clock_start.tv_usec;
-
- return ((seconds) * 1000 + useconds / 1000.0) + 0.5;
+ return (wall_clock_end_ - wall_clock_start_) * 1000.0;
}
+
protected:
- mutable timeval _wall_clock_start, _wall_clock_end;
- mutable clock_t _cpu_start, _cpu_end;
- mutable bool _stopped;
+ mutable double wall_clock_start_, wall_clock_end_;
+ mutable clock_t cpu_start_, cpu_end_;
+ mutable bool stopped_;
};
// A progress_timer behaves like a timer except that the destructor displays
@@ -86,15 +118,17 @@ class timer
class progress_timer : public timer
{
public:
- progress_timer(std::ostream & os, std::string const& base_message):
- os_(os),
- base_message_(base_message)
+ progress_timer(std::ostream & os, std::string const& base_message)
+ : os_(os),
+ base_message_(base_message)
{}
~progress_timer()
{
- if (!_stopped)
+ if (! stopped_)
+ {
stop();
+ }
}
void stop() const
@@ -112,8 +146,9 @@ class progress_timer : public timer
catch (...) {} // eat any exceptions
}
- void discard() {
- _stopped = true;
+ void discard()
+ {
+ stopped_ = true;
}
private:
@@ -122,4 +157,5 @@ class progress_timer : public timer
};
};
+
#endif // MAPNIK_TIMER_HPP
View
24 include/mapnik/utils.hpp
@@ -23,10 +23,14 @@
#ifndef MAPNIK_UTILS_HPP
#define MAPNIK_UTILS_HPP
+// boost
#ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp>
#endif
+// mapnik
+#include <mapnik/debug.hpp>
+
// stl
#include <stdexcept>
#include <cstdlib>
@@ -86,7 +90,7 @@ class CreateStatic
// Sun C++ Compiler doesn't handle `volatile` keyword same as GCC.
static void destroy(T* obj)
#else
- static void destroy(volatile T* obj)
+ static void destroy(volatile T* obj)
#endif
{
obj->~T();
@@ -109,6 +113,7 @@ template <typename T,
static bool destroyed_;
singleton(const singleton &rhs);
singleton& operator=(const singleton&);
+
static void onDeadReference()
{
throw std::runtime_error("dead reference!");
@@ -119,8 +124,9 @@ template <typename T,
CreatePolicy<T>::destroy(pInstance_);
pInstance_ = 0;
destroyed_=true;
-#ifdef MAPNIK_DEBUG
- std::clog << " destroyed singleton \n";
+
+#ifdef MAPNIK_LOG
+ mapnik::log() << "singleton: Destroyed instance";
#endif
}
@@ -132,21 +138,25 @@ template <typename T,
public:
static T* instance()
{
- if (!pInstance_)
+ if (! pInstance_)
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
#endif
- if (!pInstance_)
+ if (! pInstance_)
{
-
if (destroyed_)
{
onDeadReference();
}
else
{
- pInstance_=CreatePolicy<T>::create();
+ pInstance_ = CreatePolicy<T>::create();
+
+#ifdef MAPNIK_LOG
+ mapnik::log() << "singleton: Created instance";
+#endif
+
// register destruction
std::atexit(&DestroySingleton);
}
View
123 plugins/input/csv/csv_datasource.cpp
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ *
+ * 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
+ *
+ *****************************************************************************/
+
#include "csv_datasource.hpp"
// boost
@@ -9,6 +31,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/geometry.hpp>
@@ -31,24 +54,26 @@ using namespace boost::spirit;
DATASOURCE_PLUGIN(csv_datasource)
csv_datasource::csv_datasource(parameters const& params, bool bind)
-: datasource(params),
- desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
- extent_(),
- filename_(),
- inline_string_(),
- file_length_(0),
- row_limit_(*params_.get<int>("row_limit", 0)),
- features_(),
- escape_(*params_.get<std::string>("escape", "")),
- separator_(*params_.get<std::string>("separator", "")),
- quote_(*params_.get<std::string>("quote", "")),
- headers_(),
- manual_headers_(boost::trim_copy(*params_.get<std::string>("headers", ""))),
- strict_(*params_.get<mapnik::boolean>("strict", false)),
- quiet_(*params_.get<mapnik::boolean>("quiet", false)),
- filesize_max_(*params_.get<float>("filesize_max", 20.0)), // MB
- ctx_(boost::make_shared<mapnik::context_type>())
+ : datasource(params),
+ desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
+ extent_(),
+ filename_(),
+ inline_string_(),
+ file_length_(0),
+ row_limit_(*params_.get<int>("row_limit", 0)),
+ features_(),
+ escape_(*params_.get<std::string>("escape", "")),
+ separator_(*params_.get<std::string>("separator", "")),
+ quote_(*params_.get<std::string>("quote", "")),
+ headers_(),
+ manual_headers_(boost::trim_copy(*params_.get<std::string>("headers", ""))),
+ strict_(*params_.get<mapnik::boolean>("strict", false)),
+ quiet_(*params_.get<mapnik::boolean>("quiet", false)),
+ filesize_max_(*params_.get<float>("filesize_max", 20.0)), // MB
+ ctx_(boost::make_shared<mapnik::context_type>())
{
+ log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
+
/* TODO:
general:
- refactor parser into generic class
@@ -197,8 +222,9 @@ void csv_datasource::parse_csv(T& stream,
if (num_tabs > num_commas)
{
sep = "\t";
-#ifdef MAPNIK_DEBUG
- std::clog << "CSV Plugin: auto detected tab separator\n";
+
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "csv_datasource: auto detected tab separator";
#endif
}
}
@@ -208,8 +234,9 @@ void csv_datasource::parse_csv(T& stream,
if (num_pipes > num_commas)
{
sep = "|";
-#ifdef MAPNIK_DEBUG
- std::clog << "CSV Plugin: auto detected '|' separator\n";
+
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "csv_datasource: auto detected '|' separator";
#endif
}
else // semicolons
@@ -218,8 +245,9 @@ void csv_datasource::parse_csv(T& stream,
if (num_semicolons > num_commas)
{
sep = ";";
-#ifdef MAPNIK_DEBUG
- std::clog << "CSV Plugin: auto detected ';' separator\n";
+
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "csv_datasource: auto detected ';' separator";
#endif
}
}
@@ -237,8 +265,8 @@ void csv_datasource::parse_csv(T& stream,
std::string quo = boost::trim_copy(quote);
if (quo.empty()) quo = "\"";
-#ifdef MAPNIK_DEBUG
- std::clog << "CSV Plugin: csv grammer: sep: '" << sep << "' quo: '" << quo << "' esc: '" << esc << "'\n";
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "csv_datasource: csv grammer: sep: '" << sep << "' quo: '" << quo << "' esc: '" << esc;
#endif
boost::escaped_list_separator<char> grammer;
@@ -404,8 +432,8 @@ void csv_datasource::parse_csv(T& stream,
{
if ((row_limit_ > 0) && (line_number > row_limit_))
{
-#ifdef MAPNIK_DEBUG
- std::clog << "CSV Plugin: row limit hit, exiting at feature: " << feature_count << "\n";
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "csv_datasource: row limit hit, exiting at feature: " << feature_count;
#endif
break;
}
@@ -417,12 +445,15 @@ void csv_datasource::parse_csv(T& stream,
{
std::string trimmed = csv_line;
boost::trim_if(trimmed,boost::algorithm::is_any_of("\",'\r\n"));
- if (trimmed.empty()){
+ if (trimmed.empty())
+ {
++line_number;
- continue;
-#ifdef MAPNIK_DEBUG
- std::clog << "CSV Plugin: empty row encountered at line: " << line_number << "\n";
+
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "csv_datasource: empty row encountered at line: " << line_number;
#endif
+
+ continue;
}
}
@@ -524,7 +555,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
}
}
}
@@ -548,7 +580,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
}
}
}
@@ -585,7 +618,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
}
}
}
@@ -618,7 +652,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
}
}
}
@@ -711,7 +746,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
continue;
}
}
@@ -744,7 +780,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
continue;
}
}
@@ -795,7 +832,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
continue;
}
}
@@ -810,7 +848,8 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << ex.what() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << ex.what() << "\n";
}
}
catch(const std::exception & ex)
@@ -825,13 +864,15 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
- if (!quiet_) std::clog << s.str() << "\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << s.str() << "\n";
}
}
}
if (!feature_count > 0)
{
- if (!quiet_) std::clog << "CSV Plugin: could not parse any lines of data\n";
+ // TODO - handle this with mapnik::log
+ if (!quiet_) std::cerr << "CSV Plugin: could not parse any lines of data\n";
}
}
View
25 plugins/input/csv/csv_datasource.hpp
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ *
+ * 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_CSV_DATASOURCE_HPP
#define MAPNIK_CSV_DATASOURCE_HPP
@@ -20,11 +42,13 @@ class csv_datasource : public mapnik::datasource
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
void bind() const;
+
template <typename T>
void parse_csv(T& stream,
std::string const& escape,
std::string const& separator,
std::string const& quote) const;
+
private:
mutable mapnik::layer_descriptor desc_;
mutable mapnik::box2d<double> extent_;
@@ -44,5 +68,4 @@ class csv_datasource : public mapnik::datasource
mutable mapnik::context_ptr ctx_;
};
-
#endif // MAPNIK_CSV_DATASOURCE_HPP
View
49 plugins/input/gdal/gdal_datasource.cpp
@@ -25,8 +25,10 @@
#include "gdal_featureset.hpp"
// mapnik
+#include <mapnik/debug.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
+#include <mapnik/timer.hpp>
#include <gdal_version.h>
@@ -49,9 +51,8 @@ using mapnik::datasource_exception;
*/
inline GDALDataset* gdal_datasource::open_dataset() const
{
-
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: opening: " << dataset_name_ << std::endl;
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "gdal_datasource: Opening " << dataset_name_;
#endif
GDALDataset *dataset;
@@ -81,8 +82,10 @@ gdal_datasource::gdal_datasource(parameters const& params, bool bind)
filter_factor_(*params_.get<double>("filter_factor", 0.0)),
nodata_value_(params_.get<double>("nodata"))
{
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Initializing..." << std::endl;
+ log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
+
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "gdal_datasource: Initializing...";
#endif
GDALAllRegister();
@@ -110,6 +113,10 @@ void gdal_datasource::bind() const
{
if (is_bound_) return;
+#ifdef MAPNIK_STATS
+ mapnik::progress_timer __stats__(std::clog, "gdal_datasource::bind");
+#endif
+
shared_dataset_ = *params_.get<mapnik::boolean>("shared", false);
band_ = *params_.get<int>("band", -1);
@@ -124,8 +131,8 @@ void gdal_datasource::bind() const
boost::optional<std::string> bbox_s = params_.get<std::string>("bbox");
if (bbox_s)
{
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: bbox parameter=" << *bbox_s << std::endl;
+#ifdef MAPNIK_LOG
+ if (log_enabled_) mapnik::log() << "gdal_datasource: BBox Parameter=" << *bbox_s;
#endif
bbox_override = extent_.from_string(*bbox_s);
@@ -149,10 +156,13 @@ void gdal_datasource::bind() const
dataset->GetGeoTransform(tr);
}
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: geotransform=" << tr[0] << "," << tr[1] << ","
- << tr[2] << "," << tr[3] << ","
- << tr[4] << "," << tr[5] << std::endl;
+#ifdef MAPNIK_LOG
+ if (log_enabled_)
+ {
+ mapnik::log() << "gdal_datasource Geotransform=" << tr[0] << "," << tr[1] << ","
+ << tr[2] << "," << tr[3] << ","
+ << tr[4] << "," << tr[5];
+ }
#endif
// TODO - We should throw for true non-north up images, but the check
@@ -188,9 +198,12 @@ void gdal_datasource::bind() const
GDALClose(dataset);
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Raster Size=" << width_ << "," << height_ << std::endl;
- std::clog << "GDAL Plugin: Raster Extent=" << extent_ << std::endl;
+#ifdef MAPNIK_LOG
+ if (log_enabled_)
+ {
+ mapnik::log() << "gdal_datasource: Raster Size=" << width_ << "," << height_;
+ mapnik::log() << "gdal_datasource: Raster Extent=" << extent_;
+ }
#endif
is_bound_ = true;
@@ -231,6 +244,10 @@ featureset_ptr gdal_datasource::features(query const& q) const
{
if (! is_bound_) bind();
+#ifdef MAPNIK_STATS
+ mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features");
+#endif
+
gdal_query gq = q;
// TODO - move to boost::make_shared, but must reduce # of args to <= 9
@@ -251,6 +268,10 @@ featureset_ptr gdal_datasource::features_at_point(coord2d const& pt) const
{
if (! is_bound_) bind();
+#ifdef MAPNIK_STATS
+ mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features_at_point");
+#endif
+
gdal_query gq = pt;
// TODO - move to boost::make_shared, but must reduce # of args to <= 9
View
3  plugins/input/gdal/gdal_datasource.hpp
@@ -46,6 +46,7 @@ class gdal_datasource : public mapnik::datasource
mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private:
+ GDALDataset* open_dataset() const;
mutable mapnik::box2d<double> extent_;
std::string dataset_name_;
mutable int band_;
@@ -58,8 +59,6 @@ class gdal_datasource : public mapnik::datasource
mutable bool shared_dataset_;
double filter_factor_;
boost::optional<double> nodata_value_;
- inline GDALDataset* open_dataset() const;
};
-
#endif // GDAL_DATASOURCE_HPP
View
128 plugins/input/gdal/gdal_featureset.cpp
@@ -22,14 +22,15 @@
// mapnik
#include <mapnik/global.hpp>
+#include <mapnik/debug.hpp>
#include <mapnik/feature_factory.hpp>
-#include "gdal_featureset.hpp"
-#include <gdal_priv.h>
-
// boost
#include <boost/format.hpp>
+#include "gdal_featureset.hpp"
+#include <gdal_priv.h>
+
using mapnik::query;
using mapnik::coord2d;
using mapnik::box2d;
@@ -75,8 +76,8 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
gdal_featureset::~gdal_featureset()
{
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: closing dataset = " << &dataset_ << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Closing Dataset=" << &dataset_;
#endif
GDALClose(&dataset_);
@@ -87,8 +88,9 @@ feature_ptr gdal_featureset::next()
if (first_)
{
first_ = false;
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: featureset, dataset = " << &dataset_ << std::endl;
+
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Next feature in Dataset=" << &dataset_;
#endif
query *q = boost::get<query>(&gquery_);
@@ -125,7 +127,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
double dx = tr[1];
double dy = tr[5];
- std::clog << "dx_: " << dx_ << " dx: " << dx << " dy_: " << dy_ << "dy: " << dy << "\n";
+#ifdef MAPNIK_DEBUG
+ mapnik::log() << "gdal_featureset: dx_=" << dx_ << " dx=" << dx << " dy_=" << dy_ << "dy=" << dy;
+#endif
*/
CoordTransform t(raster_width_, raster_height_, raster_extent_, 0, 0);
@@ -184,11 +188,11 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
box2d<double> feature_raster_extent(x_off, y_off, x_off + width, y_off + height);
intersect = t.backward(feature_raster_extent);
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Raster extent=" << raster_extent_ << std::endl;
- std::clog << "GDAL Plugin: View extent=" << intersect << std::endl;
- std::clog << "GDAL Plugin: Query resolution=" << boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution()) << std::endl;
- std::clog << boost::format("GDAL Plugin: StartX=%d StartY=%d Width=%d Height=%d") % x_off % y_off % width % height << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Raster extent=" << raster_extent_;
+ mapnik::log() << "gdal_featureset: View extent=" << intersect;
+ mapnik::log() << "gdal_featureset: Query resolution=" << boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution());
+ mapnik::log() << boost::format("gdal_featureset: StartX=%d StartY=%d Width=%d Height=%d") % x_off % y_off % width % height;
#endif
if (width > 0 && height > 0)
@@ -203,8 +207,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
im_width *= filter_factor_;
im_height *= filter_factor_;
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: applying layer filter_factor: " << filter_factor_ << "\n";
+
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Applying layer filter_factor=" << filter_factor_;
#endif
}
// otherwise respect symbolizer level factor applied to query, default of 1.0
@@ -228,9 +233,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
mapnik::image_data_32 image(im_width, im_height);
image.set(0xffffffff);
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Image Size=(" << im_width << "," << im_height << ")" << std::endl;
- std::clog << "GDAL Plugin: Reading band " << band_ << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Image Size=(" << im_width << "," << im_height << ")";
+ mapnik::log() << "gdal_featureset: Reading band=" << band_;
#endif
typedef std::vector<int,int> pallete;
@@ -270,7 +275,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
GDALRasterBand * band = dataset_.GetRasterBand(i + 1);
-#ifdef MAPNIK_DEBUG
+#ifdef MAPNIK_LOG
get_overview_meta(band);
#endif
@@ -279,68 +284,68 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
case GCI_RedBand:
red = band;
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Found red band" << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Found red band";
#endif
break;
case GCI_GreenBand:
green = band;
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Found green band" << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Found green band";
#endif
break;
case GCI_BlueBand:
blue = band;
-#ifdef MAPNIK_DEBUG
- std::clog << "GDAL Plugin: Found blue band" << std::endl;
+#ifdef MAPNIK_LOG
+ mapnik::log() << "gdal_featureset: Found blue band";
#endif
break;