Merge pull request #1169 from mapnik/new-debug

implement new debug system
This commit is contained in:
Lucio Asnaghi 2012-04-07 17:20:58 -07:00
commit e360a34602
133 changed files with 1870 additions and 1065 deletions

View file

@ -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 file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -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 file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include <mapnik/datasource_cache.hpp>

View file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
extern "C"
{

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
extern "C"
{

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -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 file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>

View file

@ -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 file

@ -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 file

@ -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 file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -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 file

@ -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 file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -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_;
};

127
include/mapnik/debug.hpp Normal file
View file

@ -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 file

@ -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 @@ public:
~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 @@ public:
~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 @@ public:
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 file

@ -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 @@ private:
public:
hit_grid(int width, int height, std::string const& key, unsigned int resolution)
:width_(width),
height_(height),
@ -136,7 +136,9 @@ public:
}
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 @@ public:
}
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 file

@ -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 file

@ -24,6 +24,7 @@
#define MAPNIK_MEMORY_FEATURESET_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/memory_datasource.hpp>
// boost
@ -52,10 +53,11 @@ public:
{
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 file

@ -87,7 +87,7 @@ protected:
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 file

@ -24,6 +24,7 @@
#define MAPNIK_POOL_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
// boost
@ -100,8 +101,8 @@ public:
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 @@ public:
}
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 @@ public:
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 @@ public:
{
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 file

@ -203,7 +203,7 @@ private:
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 file

@ -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 @@ public:
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 file

@ -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 @@ public:
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 @@ protected:
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 @@ public:
catch (...) {} // eat any exceptions
}
void discard() {
_stopped = true;
void discard()
{
stopped_ = true;
}
private:
@ -122,4 +157,5 @@ private:
};
};
#endif // MAPNIK_TIMER_HPP

View file

@ -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 @@ public:
// 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 @@ protected:
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 file

@ -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 file

@ -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 @@ public:
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 @@ private:
mutable mapnik::context_ptr ctx_;
};
#endif // MAPNIK_CSV_DATASOURCE_HPP

View file

@ -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 file

@ -46,6 +46,7 @@ public:
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 @@ private:
mutable bool shared_dataset_;
double filter_factor_;
boost::optional<double> nodata_value_;
inline GDALDataset* open_dataset() const;
};
#endif // GDAL_DATASOURCE_HPP

View file

@ -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;
case GCI_AlphaBand:
alpha = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found alpha band" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Found alpha band";
#endif
break;
case GCI_GrayIndex:
grey = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found gray band" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Found gray band";
#endif
break;
case GCI_PaletteIndex:
{
grey = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found gray band, and colortable..." << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Found gray band, and colortable...";
#endif
GDALColorTable *color_table = band->GetColorTable();
if (color_table)
{
int count = color_table->GetColorEntryCount();
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Color Table count = " << count << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Color Table count=" << count;
#endif
for (int j = 0; j < count; j++)
{
const GDALColorEntry *ce = color_table->GetColorEntry (j);
if (! ce) continue;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Color entry RGB (" << ce->c1 << "," <<ce->c2 << "," << ce->c3 << ")" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Color entry RGB=" << ce->c1 << "," <<ce->c2 << "," << ce->c3;
#endif
}
}
break;
}
case GCI_Undefined:
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found undefined band (assumming gray band)" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Found undefined band (assumming gray band)";
#endif
grey = band;
break;
default:
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: band type unknown!" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Band type unknown!";
#endif
break;
}
@ -348,8 +353,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
if (red && green && blue)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: processing rgb bands..." << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Processing rgb bands...";
#endif
int hasNoData(0);
double nodata(0);
@ -401,8 +406,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
else if (grey)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: processing gray band..." << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Processing gray band...";
#endif
int hasNoData(0);
double nodata(0);
@ -419,13 +424,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
if (hasNoData && ! color_table)
{
if (hasNoData)
{
feature->put("NODATA",nodata);
}
#ifdef MAPNIK_DEBUG
std::clog << "\tno data value for layer: " << nodata << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: No data value for layer=" << nodata;
#endif
feature->put("NODATA",nodata);
// first read the data in and create an alpha channel from the nodata values
float* imageData = (float*)image.getBytes();
grey->RasterIO(GF_Read, x_off, y_off, width, height,
@ -456,8 +458,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
if (color_table)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Loading colour table..." << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: Loading colour table...";
#endif
unsigned nodata_value = static_cast<unsigned>(nodata);
if (hasNoData)
@ -496,8 +498,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
if (alpha)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: processing alpha band..." << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "gdal_featureset: processing alpha band...";
#endif
alpha->RasterIO(GF_Read, x_off, y_off, width, height, image.getBytes() + 3,
image.width(), image.height(), GDT_Byte, 4, 4 * image.width());
@ -533,9 +535,9 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
if (x < raster_xsize && y < raster_ysize)
{
#ifdef MAPNIK_DEBUG
std::clog << boost::format("GDAL Plugin: pt.x=%f pt.y=%f") % pt.x % pt.y << std::endl;
std::clog << boost::format("GDAL Plugin: x=%f y=%f") % x % y << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << boost::format("gdal_featureset: pt.x=%f pt.y=%f") % pt.x % pt.y;
mapnik::log() << boost::format("gdal_featureset: x=%f y=%f") % x % y;
#endif
GDALRasterBand* band = dataset_.GetRasterBand(band_);
int hasNoData;
@ -558,24 +560,24 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
return feature_ptr();
}
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
void gdal_featureset::get_overview_meta(GDALRasterBand* band)
{
int band_overviews = band->GetOverviewCount();
if (band_overviews > 0)
{
std::clog << "GDAL Plugin: "<< band_overviews << " overviews found!" << std::endl;
mapnik::log() << "gdal_featureset: " << band_overviews << " overviews found!";
for (int b = 0; b < band_overviews; b++)
{
GDALRasterBand * overview = band->GetOverview(b);
std::clog << boost::format("GDAL Plugin: Overview=%d Width=%d Height=%d")
% b % overview->GetXSize() % overview->GetYSize() << std::endl;
mapnik::log() << boost::format("gdal_featureset: Overview=%d Width=%d Height=%d")
% b % overview->GetXSize() % overview->GetYSize();
}
}
else
{
std::clog << "GDAL Plugin: No overviews found!" << std::endl;
mapnik::log() << "gdal_featureset: No overviews found!";
}
int bsx,bsy;
@ -583,8 +585,8 @@ void gdal_featureset::get_overview_meta(GDALRasterBand* band)
band->GetBlockSize(&bsx, &bsy);
scale = band->GetScale();
std::clog << boost::format("GDAL Plugin: Block=%dx%d Scale=%f Type=%s Color=%s") % bsx % bsy % scale
mapnik::log() << boost::format("gdal_featureset: Block=%dx%d Scale=%f Type=%s Color=%s") % bsx % bsy % scale
% GDALGetDataTypeName(band->GetRasterDataType())
% GDALGetColorInterpretationName(band->GetColorInterpretation()) << std::endl;
% GDALGetColorInterpretationName(band->GetColorInterpretation());
}
#endif

View file

@ -55,7 +55,7 @@ public:
private:
mapnik::feature_ptr get_feature(mapnik::query const& q);
mapnik::feature_ptr get_feature_at_point(mapnik::coord2d const& p);
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
void get_overview_meta(GDALRasterBand * band);
#endif
GDALDataset & dataset_;

View file

@ -30,8 +30,10 @@
#include <cstdarg>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/timer.hpp>
// boost
#include <boost/algorithm/string.hpp>
@ -63,8 +65,10 @@ DATASOURCE_PLUGIN(geos_datasource)
void geos_notice(const char* fmt, ...)
{
// TODO - handle with mapnik::log
va_list ap;
fprintf( stdout, "GEOS Plugin: (GEOS NOTICE) ");
fprintf( stdout, "Mapnik LOG> geos_datasource: (GEOS NOTICE) ");
va_start (ap, fmt);
vfprintf( stdout, fmt, ap);
@ -74,8 +78,10 @@ void geos_notice(const char* fmt, ...)
void geos_error(const char* fmt, ...)
{
// TODO - handle with mapnik::log
va_list ap;
fprintf( stdout, "GEOS Plugin: (GEOS ERROR) ");
fprintf( stdout, "Mapnik LOG> geos_datasource: (GEOS ERROR) ");
va_start (ap, fmt);
vfprintf( stdout, fmt, ap);
@ -94,6 +100,8 @@ geos_datasource::geos_datasource(parameters const& params, bool bind)
geometry_data_name_("name"),
geometry_id_(1)
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
boost::optional<std::string> geometry = params.get<std::string>("wkt");
if (! geometry) throw datasource_exception("missing <wkt> parameter");
geometry_string_ = *geometry;
@ -132,6 +140,10 @@ void geos_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::bind");
#endif
// open geos driver
initGEOS(geos_notice, geos_error);
@ -145,8 +157,12 @@ void geos_datasource::bind() const
// try to obtain the extent from the geometry itself
if (! extent_initialized_)
{
#ifdef MAPNIK_DEBUG
std::clog << "GEOS Plugin: initializing extent from geometry" << std::endl;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "geos_datasource::bind(initialize_extent)");
#endif
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "geos_datasource: Initializing extent from geometry";
#endif
if (GEOSGeomTypeId(*geometry_) == GEOS_POINT)
@ -168,10 +184,13 @@ void geos_datasource::bind() const
geos_feature_ptr envelope (GEOSEnvelope(*geometry_));
if (*envelope != NULL && GEOSisValid(*envelope))
{
#ifdef MAPNIK_DEBUG
char* wkt = GEOSGeomToWKT(*envelope);
std::clog << "GEOS Plugin: getting coord sequence from: " << wkt << std::endl;
GEOSFree(wkt);
#ifdef MAPNIK_LOG
if (log_enabled_)
{
char* wkt = GEOSGeomToWKT(*envelope);
mapnik::log() << "geos_datasource: Getting coord sequence from=" << wkt;
GEOSFree(wkt);
}
#endif
const GEOSGeometry* exterior = GEOSGetExteriorRing(*envelope);
@ -180,8 +199,8 @@ void geos_datasource::bind() const
const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(exterior);
if (cs != NULL)
{
#ifdef MAPNIK_DEBUG
std::clog << "GEOS Plugin: iterating boundary points" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "geos_datasource: Iterating boundary points";
#endif
double x, y;
@ -242,6 +261,10 @@ boost::optional<mapnik::datasource::geometry_t> geos_datasource::get_geometry_ty
if (! is_bound_) bind();
boost::optional<mapnik::datasource::geometry_t> result;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::get_geometry_type");
#endif
// get geometry type
const int type = GEOSGeomTypeId(*geometry_);
switch (type)
@ -280,6 +303,10 @@ featureset_ptr geos_datasource::features(query const& q) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::features");
#endif
const mapnik::box2d<double> extent = q.get_bbox();
std::ostringstream s;
@ -291,8 +318,8 @@ featureset_ptr geos_datasource::features(query const& q) const
<< extent.minx() << " " << extent.miny()
<< "))";
#ifdef MAPNIK_DEBUG
std::clog << "GEOS Plugin: using extent: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "geos_datasource: Using extent=" << s.str();
#endif
return boost::make_shared<geos_featureset>(*geometry_,
@ -307,11 +334,15 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::features_at_point");
#endif
std::ostringstream s;
s << "POINT(" << pt.x << " " << pt.y << ")";
#ifdef MAPNIK_DEBUG
std::clog << "GEOS Plugin: using point: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "geos_datasource: Using point=" << s.str();
#endif
return boost::make_shared<geos_featureset>(*geometry_,

View file

@ -26,6 +26,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
@ -104,8 +105,8 @@ feature_ptr geos_featureset::next()
break;
default:
#ifdef MAPNIK_DEBUG
std::clog << "GEOS Plugin: unknown extent geometry_type=" << type << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "geos_featureset: Unknown extent geometry_type=" << type;
#endif
break;
}

View file

@ -34,6 +34,7 @@
// mapnik
#include <mapnik/boolean.hpp>
#include <mapnik/debug.hpp>
// boost
#include <boost/algorithm/string.hpp>
@ -79,6 +80,8 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind)
srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"),
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8"))
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
boost::optional<std::string> host = params_.get<std::string>("host");
if (host)
{
@ -156,7 +159,9 @@ featureset_ptr kismet_datasource::features(query const& q) const
{
if (! is_bound_) bind();
// std::clog << "kismet_datasource::features()" << endl;
#ifdef MAPNIK_LOG
// mapnik::log() << "kismet_datasource::features()";
#endif
// TODO: use box2d to filter bbox before adding to featureset_ptr
// mapnik::box2d<double> const& e = q.get_bbox();
@ -174,15 +179,17 @@ featureset_ptr kismet_datasource::features_at_point(coord2d const& pt) const
{
if (! is_bound_) bind();
// std::clog << "kismet_datasource::features_at_point()" << endl;
#ifdef MAPNIK_LOG
// mapnik::log() << "kismet_datasource::features_at_point()";
#endif
return featureset_ptr();
}
void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
{
#ifdef MAPNIK_DEBUG
std::clog << "Kismet Plugin: enter run" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "kismet_datasource: Enter run";
#endif
int sockfd, n;
@ -219,7 +226,7 @@ void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
if (connect(sockfd, (struct sockaddr*) &sock_addr, sizeof(sock_addr)))
{
std::cerr << "KISMET Plugin: Error while connecting" << std::endl;
std::cerr << "Kismet Plugin: Error while connecting" << std::endl;
return;
}
@ -227,7 +234,7 @@ void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
if (write(sockfd, command.c_str(), command.length()) != (signed)command.length())
{
std::cerr << "KISMET Plugin: Error sending command to " << ip_host << std::endl;
std::cerr << "Kismet Plugin: Error sending command to " << ip_host << std::endl;
close(sockfd);
return;
@ -248,8 +255,8 @@ void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
buffer[n] = '\0';
std::string bufferObj(buffer); // TCP data send from kismet_server as STL string
#ifdef MAPNIK_DEBUG
std::clog << "Kismet Plugin: buffer_obj=" << bufferObj << "[END]" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "kismet_datasource: buffer_obj=" << bufferObj;
#endif
std::string::size_type found = 0;
@ -262,8 +269,8 @@ void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
{
kismet_line.assign(bufferObj, search_start, found - search_start);
#ifdef MAPNIK_DEBUG
std::clog << "Kismet Plugin: line=" << kismet_line << " [ENDL]" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "kismet_datasource: line=" << kismet_line;
#endif
int param_number = 5; // the number of parameters to parse
@ -277,9 +284,12 @@ void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
&bestlat,
&bestlon) == param_number)
{
#ifdef MAPNIK_DEBUG
std::clog << "Kismet Plugin: ssid=" << ssid << ", bssid=" << bssid
<< ", crypt=" << crypt << ", bestlat=" << bestlat << ", bestlon=" << bestlon << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_)
{
mapnik::log() << "kismet_datasource: ssid=" << ssid << ", bssid=" << bssid
<< ", crypt=" << crypt << ", bestlat=" << bestlat << ", bestlon=" << bestlon;
}
#endif
kismet_network_data knd(ssid, bssid, bestlat, bestlon, crypt);
@ -312,8 +322,8 @@ void kismet_datasource::run(const std::string& ip_host, const unsigned int port)
close(sockfd);
#ifdef MAPNIK_DEBUG
std::clog << "Kismet Plugin: exit run" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "kismet_datasource: Exit run";
#endif
}

View file

@ -25,8 +25,10 @@
#include "occi_featureset.hpp"
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/sql_utils.hpp>
#include <mapnik/timer.hpp>
// boost
#include <boost/algorithm/string.hpp>
@ -68,18 +70,21 @@ const std::string occi_datasource::METADATA_TABLE = "USER_SDO_GEOM_METADATA";
DATASOURCE_PLUGIN(occi_datasource)
occi_datasource::occi_datasource(parameters const& params, bool bind)
: datasource (params),
type_(datasource::Vector),
fields_(*params_.get<std::string>("fields", "*")),
geometry_field_(*params_.get<std::string>("geometry_field", "")),
srid_initialized_(false),
extent_initialized_(false),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
row_limit_(*params_.get<int>("row_limit", 0)),
row_prefetch_(*params_.get<int>("row_prefetch", 100)),
pool_(0),
conn_(0)
: datasource (params),
type_(datasource::Vector),
fields_(*params_.get<std::string>("fields", "*")),
geometry_field_(*params_.get<std::string>("geometry_field", "")),
srid_initialized_(false),
extent_initialized_(false),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
use_wkb_(*params_.get<mapnik::boolean>("use_wkb", false)),
row_limit_(*params_.get<int>("row_limit", 0)),
row_prefetch_(*params_.get<int>("row_prefetch", 100)),
pool_(0),
conn_(0)
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
if (! params_.get<std::string>("user")) throw datasource_exception("OCCI Plugin: no <user> specified");
if (! params_.get<std::string>("password")) throw datasource_exception("OCCI Plugin: no <password> specified");
if (! params_.get<std::string>("host")) throw datasource_exception("OCCI Plugin: no <host> string specified");
@ -140,6 +145,10 @@ void occi_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::bind");
#endif
// connect to environment
if (use_connection_pool_)
{
@ -184,6 +193,10 @@ void occi_datasource::bind() const
// get SRID and/or GEOMETRY_FIELD from metadata table only if we need to
if (! srid_initialized_ || geometry_field_ == "")
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::get_srid_and_geometry_field");
#endif
std::ostringstream s;
s << "SELECT srid, column_name FROM " << METADATA_TABLE << " WHERE";
s << " LOWER(table_name) = LOWER('" << table_name_ << "')";
@ -193,8 +206,8 @@ void occi_datasource::bind() const
s << " AND LOWER(column_name) = LOWER('" << geometry_field_ << "')";
}
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: " << s.str();
#endif
try
@ -226,11 +239,15 @@ void occi_datasource::bind() const
// get columns description
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::get_column_description");
#endif
std::ostringstream s;
s << "SELECT " << fields_ << " FROM (" << table_name_ << ") WHERE rownum < 1";
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: " << s.str();
#endif
try
@ -321,16 +338,22 @@ void occi_datasource::bind() const
case oracle::occi::OCCI_SQLT_CLOB:
case oracle::occi::OCCI_SQLT_BLOB:
case oracle::occi::OCCI_SQLT_RSET:
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: unsupported datatype "
<< occi_enums::resolve_datatype(type_oid)
<< " (type_oid=" << type_oid << ")" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_)
{
mapnik::log() << "occi_datasource: Unsupported datatype "
<< occi_enums::resolve_datatype(type_oid)
<< " (type_oid=" << type_oid << ")";
}
#endif
break;
default:
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: unknown datatype "
<< "(type_oid=" << type_oid << ")" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_)
{
mapnik::log() << "occi_datasource: Unknown datatype "
<< "(type_oid=" << type_oid << ")";
}
#endif
break;
}
@ -368,13 +391,17 @@ box2d<double> occi_datasource::envelope() const
if (estimate_extent && *estimate_extent)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::envelope(estimate_extent)");
#endif
std::ostringstream s;
s << "SELECT MIN(c.x), MIN(c.y), MAX(c.x), MAX(c.y) FROM ";
s << " (SELECT SDO_AGGR_MBR(" << geometry_field_ << ") shape FROM " << table_ << ") a, ";
s << " TABLE(SDO_UTIL.GETVERTICES(a.shape)) c";
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: " << s.str();
#endif
try
@ -397,7 +424,7 @@ box2d<double> occi_datasource::envelope() const
}
catch (bad_lexical_cast& ex)
{
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
std::cerr << "OCCI Plugin: " << ex.what() << std::endl;
}
}
}
@ -408,6 +435,10 @@ box2d<double> occi_datasource::envelope() const
}
else if (use_spatial_index_)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::envelope(use_spatial_index)");
#endif
std::ostringstream s;
s << "SELECT dim.sdo_lb, dim.sdo_ub FROM ";
s << METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
@ -417,8 +448,8 @@ box2d<double> occi_datasource::envelope() const
s << METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name_ << "') AND dim.sdo_dimname = 'Y'";
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: " << s.str();
#endif
try
@ -439,7 +470,7 @@ box2d<double> occi_datasource::envelope() const
}
catch (bad_lexical_cast& ex)
{
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
std::cerr << "OCCI Plugin: " << ex.what() << std::endl;
}
}
@ -452,7 +483,7 @@ box2d<double> occi_datasource::envelope() const
}
catch (bad_lexical_cast& ex)
{
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
std::cerr << "OCCI Plugin: " << ex.what() << std::endl;
}
}
@ -493,15 +524,27 @@ featureset_ptr occi_datasource::features(query const& q) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::features");
#endif
box2d<double> const& box = q.get_bbox();
std::ostringstream s;
s << "SELECT " << geometry_field_;
s << "SELECT ";
if (use_wkb_)
{
s << "SDO_UTIL.TO_WKBGEOMETRY(" << geometry_field_ << ")";
}
else
{
s << geometry_field_;
}
std::set<std::string> const& props = q.property_names();
std::set<std::string>::const_iterator pos = props.begin();
std::set<std::string>::const_iterator end = props.end();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
for ( ;pos != end;++pos)
for (; pos != end; ++pos)
{
s << ", " << *pos;
ctx->push(*pos);
@ -532,8 +575,8 @@ featureset_ptr occi_datasource::features(query const& q) const
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: cannot determine where to add the spatial filter declaration" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: cannot determine where to add the spatial filter declaration";
#endif
}
}
@ -552,16 +595,16 @@ featureset_ptr occi_datasource::features(query const& q) const
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: cannot determine where to add the row limit declaration" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: Cannot determine where to add the row limit declaration";
#endif
}
}
s << query;
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: " << s.str();
#endif
return boost::make_shared<occi_featureset>(pool_,
@ -570,6 +613,7 @@ featureset_ptr occi_datasource::features(query const& q) const
s.str(),
desc_.get_encoding(),
use_connection_pool_,
use_wkb_,
row_prefetch_);
}
@ -577,8 +621,20 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::features_at_point");
#endif
std::ostringstream s;
s << "SELECT " << geometry_field_;
s << "SELECT ";
if (use_wkb_)
{
s << "SDO_UTIL.TO_WKBGEOMETRY(" << geometry_field_ << ")";
}
else
{
s << geometry_field_;
}
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
@ -613,8 +669,8 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: cannot determine where to add the spatial filter declaration" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: Cannot determine where to add the spatial filter declaration";
#endif
}
}
@ -633,16 +689,16 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: cannot determine where to add the row limit declaration" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: Cannot determine where to add the row limit declaration";
#endif
}
}
s << query;
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "occi_datasource: " << s.str();
#endif
return boost::make_shared<occi_featureset>(pool_,
@ -651,5 +707,6 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
s.str(),
desc_.get_encoding(),
use_connection_pool_,
use_wkb_,
row_prefetch_);
}

View file

@ -50,6 +50,8 @@ public:
void bind() const;
private:
static const std::string METADATA_TABLE;
mapnik::datasource::datasource_t type_;
mutable std::string table_;
mutable std::string table_name_;
@ -60,13 +62,13 @@ private:
mutable bool extent_initialized_;
mutable mapnik::box2d<double> extent_;
mutable mapnik::layer_descriptor desc_;
mutable bool use_wkb_;
int row_limit_;
int row_prefetch_;
mutable oracle::occi::StatelessConnectionPool* pool_;
mutable oracle::occi::Connection* conn_;
bool use_connection_pool_;
bool use_spatial_index_;
static const std::string METADATA_TABLE;
};
#endif // OCCI_DATASOURCE_HPP

View file

@ -22,6 +22,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
@ -61,10 +62,12 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
std::string const& sqlstring,
std::string const& encoding,
bool use_connection_pool,
bool use_wkb,
unsigned prefetch_rows)
: tr_(new transcoder(encoding)),
feature_id_(1),
ctx_(ctx)
ctx_(ctx),
use_wkb_(use_wkb)
{
if (use_connection_pool)
{
@ -81,7 +84,7 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
}
catch (SQLException &ex)
{
std::clog << "OCCI Plugin: error processing " << sqlstring << " : " << ex.getMessage() << std::endl;
std::cerr << "OCCI Plugin: error processing " << sqlstring << " : " << ex.getMessage() << std::endl;
}
}
@ -96,10 +99,31 @@ feature_ptr occi_featureset::next()
feature_ptr feature(feature_factory::create(ctx_,feature_id_));
++feature_id_;
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
if (geom.get())
if (use_wkb_)
{
convert_geometry(geom.get(), feature);
Blob blob = rs_->getBlob (1);
blob.open(oracle::occi::OCCI_LOB_READONLY);
int size = blob.length();
if (buffer_.size() < size)
{
buffer_.resize(size);
}
oracle::occi::Stream* instream = blob.getStream(1,0);
instream->readBuffer(buffer_.data(), size);
blob.closeStream(instream);
blob.close();
geometry_utils::from_wkb(feature->paths(), buffer_.data(), size);
}
else
{
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
if (geom.get())
{
convert_geometry(geom.get(), feature);
}
}
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
@ -180,18 +204,22 @@ feature_ptr occi_featureset::next()
case oracle::occi::OCCI_SQLT_CLOB:
case oracle::occi::OCCI_SQLT_BLOB:
case oracle::occi::OCCI_SQLT_RSET:
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: unsupported datatype "
<< occi_enums::resolve_datatype(type_oid)
<< " (type_oid=" << type_oid << ")" << std::endl;
{
#ifdef MAPNIK_LOG
mapnik::log() << "occi_featureset: Unsupported datatype "
<< occi_enums::resolve_datatype(type_oid)
<< " (type_oid=" << type_oid << ")";
#endif
break;
break;
}
default: // shouldn't get here
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: unknown datatype "
<< "(type_oid=" << type_oid << ")" << std::endl;
{
#ifdef MAPNIK_LOG
mapnik::log() << "occi_featureset: Unknown datatype "
<< "(type_oid=" << type_oid << ")";
#endif
break;
break;
}
}
}
@ -209,20 +237,6 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature)
int lrsvalue = (gtype - dimensions * 1000) / 100;
int geomtype = (gtype - dimensions * 1000 - lrsvalue * 100);
#if 0
std::clog << "-----------Geometry Object ------------" << std::endl;
std::clog << "SDO GTYPE = " << gtype << std::endl;
std::clog << "SDO DIMENSIONS = " << dimensions << std::endl;
std::clog << "SDO LRS = " << lrsvalue << std::endl;
std::clog << "SDO GEOMETRY TYPE = " << geomtype << std::endl;
Number sdo_srid = geom->getSdo_srid();
if (sdo_srid.isNull())
std::clog << "SDO SRID = " << "Null" << std::endl;
else
std::clog << "SDO SRID = " << (int)sdo_srid << std::endl;
#endif
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
const int ordinates_size = (int)ordinates.size();
@ -344,12 +358,14 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature)
break;
case SDO_GTYPE_UNKNOWN:
default:
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: unknown <occi> "
<< occi_enums::resolve_gtype(geomtype)
<< "(gtype=" << gtype << ")" << std::endl;
{
#ifdef MAPNIK_LOG
mapnik::log() << "occi_featureset: Unknown oracle enum "
<< occi_enums::resolve_gtype(geomtype)
<< "(gtype=" << gtype << ")";
#endif
break;
}
break;
}
}

View file

@ -35,6 +35,8 @@
// oci
#include "occi_types.hpp"
#include <vector>
class occi_featureset : public mapnik::Featureset
{
public:
@ -44,6 +46,7 @@ public:
std::string const& sqlstring,
std::string const& encoding,
bool use_connection_pool,
bool use_wkb,
unsigned prefetch_rows);
virtual ~occi_featureset();
mapnik::feature_ptr next();
@ -70,6 +73,8 @@ private:
const char* fidcolumn_;
mutable int feature_id_;
mapnik::context_ptr ctx_;
bool use_wkb_;
std::vector<char> buffer_;
};
#endif // OCCI_FEATURESET_HPP

View file

@ -24,6 +24,7 @@
#define OCCI_TYPES_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
// occi
@ -87,8 +88,8 @@ public:
{
if (env_ == 0)
{
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: occi_environment constructor" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "occi_environment: constructor";
#endif
const int mode = oracle::occi::Environment::OBJECT
@ -111,8 +112,8 @@ private:
{
if (env_)
{
#ifdef MAPNIK_DEBUG
std::clog << "OCCI Plugin: occi_environment destructor" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "occi_environment: destructor";
#endif
oracle::occi::Environment::terminateEnvironment(env_);

View file

@ -22,6 +22,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/feature.hpp>
@ -68,10 +69,12 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature)
case wkbNone:
case wkbUnknown:
default:
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unknown <ogr> geometry_type="
<< wkbFlatten(geom->getGeometryType()) << std::endl;
{
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_converter: unknown <ogr> geometry_type="
<< wkbFlatten(geom->getGeometryType());
#endif
}
break;
}
}

View file

@ -33,8 +33,10 @@
#include <gdal_version.h>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/timer.hpp>
// boost
#include <boost/algorithm/string.hpp>
@ -63,6 +65,8 @@ ogr_datasource::ogr_datasource(parameters const& params, bool bind)
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
indexed_(false)
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
boost::optional<std::string> file = params.get<std::string>("file");
boost::optional<std::string> string = params.get<std::string>("string");
if (! file && ! string)
@ -108,6 +112,10 @@ void ogr_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::bind");
#endif
// initialize ogr formats
OGRRegisterAll();
@ -182,6 +190,10 @@ void ogr_datasource::bind() const
}
else if (layer_by_sql)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats_sql__(std::clog, "ogr_datasource::bind(layer_by_sql)");
#endif
layer_.layer_by_sql(dataset_, *layer_by_sql);
layer_name_ = layer_.layer_name();
}
@ -259,15 +271,23 @@ void ogr_datasource::bind() const
indexed_ = true;
index_file.close();
}
#ifdef MAPNIK_LOG
#if 0
// TODO - enable this warning once the ogrindex tool is a bit more stable/mature
else
{
std::clog << "### Notice: no ogrindex file found for " << dataset_name_
<< ", use the 'ogrindex' program to build an index for faster rendering"
<< std::endl;
if (log_enabled_)
{
mapnik::log() << "ogr_datasource: no ogrindex file found for " << dataset_name_
<< ", use the 'ogrindex' program to build an index for faster rendering";
}
}
#endif
#endif // MAPNIK_LOG
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "ogr_datasource::bind(get_column_description)");
#endif
// deal with attributes descriptions
OGRFeatureDefn* def = layer->GetLayerDefn();
@ -304,16 +324,16 @@ void ogr_datasource::bind() const
case OFTRealList:
case OFTStringList:
case OFTWideStringList: // deprecated !
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "ogr_datasource: Unhandled type_oid=" << type_oid;
#endif
break;
case OFTDate:
case OFTTime:
case OFTDateTime: // unhandled !
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "ogr_datasource: Unhandled type_oid=" << type_oid;
#endif
desc_.add_descriptor(attribute_descriptor(fld_name, mapnik::Object));
break;
@ -350,7 +370,7 @@ boost::optional<mapnik::datasource::geometry_t> ogr_datasource::get_geometry_typ
#if GDAL_VERSION_NUM < 1800
switch (wkbFlatten(layer->GetLayerDefn()->GetGeomType()))
#else
switch (wkbFlatten(layer->GetGeomType()))
switch (wkbFlatten(layer->GetGeomType()))
#endif
{
case wkbPoint:
@ -464,6 +484,10 @@ featureset_ptr ogr_datasource::features(query const& q) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features");
#endif
if (dataset_ && layer_.is_valid())
{
// First we validate query fields: https://github.com/mapnik/mapnik/issues/792
@ -511,6 +535,10 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt) const
{
if (!is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point");
#endif
if (dataset_ && layer_.is_valid())
{
std::vector<attribute_descriptor> const& desc_ar = desc_.get_descriptors();
@ -532,8 +560,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt) const
*layer,
filter,
index_name_,
desc_.get_encoding()
));
desc_.get_encoding()));
}
else
{
@ -545,8 +572,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt) const
*dataset_,
*layer,
point,
desc_.get_encoding()
));
desc_.get_encoding()));
}
}

View file

@ -22,6 +22,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
@ -102,11 +103,10 @@ feature_ptr ogr_featureset::next()
{
ogr_converter::convert_geometry(geom, feature);
}
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
else
{
std::clog << "OGR Plugin: feature with null geometry: "
<< (*feat)->GetFID() << std::endl;
mapnik::log() << "ogr_featureset: Feature with null geometry=" << (*feat)->GetFID();
}
#endif
++count_;
@ -145,16 +145,16 @@ feature_ptr ogr_featureset::next()
case OFTStringList:
case OFTWideStringList: // deprecated !
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_featureset: Unhandled type_oid=" << type_oid;
#endif
break;
}
case OFTBinary:
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_featureset: Unhandled type_oid=" << type_oid;
#endif
//feature->put(name,feat->GetFieldAsBinary (i, size));
break;
@ -164,16 +164,16 @@ feature_ptr ogr_featureset::next()
case OFTTime:
case OFTDateTime: // unhandled !
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_featureset: Unhandled type_oid=" << type_oid;
#endif
break;
}
default: // unknown
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unknown type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_featureset: Unknown type_oid=" << type_oid;
#endif
break;
}
@ -182,8 +182,9 @@ feature_ptr ogr_featureset::next()
return feature;
}
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: " << count_ << " features" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_featureset: " << count_ << " features";
#endif
return feature_ptr();
}

View file

@ -23,6 +23,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
@ -76,8 +77,8 @@ ogr_index_featureset<filterT>::ogr_index_featureset(mapnik::context_ptr const &
std::sort(ids_.begin(),ids_.end());
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: query size=" << ids_.size() << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_index_featureset: Query size=" << ids_.size();
#endif
itr_ = ids_.begin();
@ -110,10 +111,10 @@ feature_ptr ogr_index_featureset<filterT>::next()
{
ogr_converter::convert_geometry (geom, feature);
}
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
else
{
std::clog << "### Warning: feature with null geometry: " << (*feat)->GetFID() << "\n";
mapnik::log() << "ogr_index_featureset: Feature with null geometry=" << (*feat)->GetFID();
}
#endif
@ -151,16 +152,16 @@ feature_ptr ogr_index_featureset<filterT>::next()
case OFTStringList:
case OFTWideStringList: // deprecated !
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_index_featureset: Unhandled type_oid=" << type_oid;
#endif
break;
}
case OFTBinary:
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_index_featureset: Unhandled type_oid=" << type_oid;
#endif
//feature->put(name,feat->GetFieldAsBinary (i, size));
break;
@ -170,8 +171,8 @@ feature_ptr ogr_index_featureset<filterT>::next()
case OFTTime:
case OFTDateTime: // unhandled !
{
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_index_featureset: Unhandled type_oid=" << type_oid;
#endif
break;
}
@ -186,4 +187,3 @@ feature_ptr ogr_index_featureset<filterT>::next()
template class ogr_index_featureset<mapnik::filter_in_box>;
template class ogr_index_featureset<mapnik::filter_at_point>;

View file

@ -23,6 +23,9 @@
#ifndef OGR_LAYER_PTR_HPP
#define OGR_LAYER_PTR_HPP
// mapnik
#include <mapnik/debug.hpp>
// stl
#include <iostream>
#include <fstream>
@ -75,12 +78,12 @@ public:
layer_ = ogr_layer;
is_valid_ = true;
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: layer_from_name layer is " << layer_name_ << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_layer_ptr: layer_from_name layer=" << layer_name_;
#endif
}
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
debug_print_last_error();
#endif
}
@ -102,13 +105,13 @@ public:
layer_name_ = def->GetName();
is_valid_ = true;
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: layer_from_index layer is " << layer_name_ << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_layer_ptr: layer_from_index layer=" << layer_name_;
#endif
}
}
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
debug_print_last_error();
#endif
}
@ -138,13 +141,13 @@ public:
layer_name_ = def->GetName();
is_valid_ = true;
#ifdef MAPNIK_DEBUG
std::clog << "OGR Plugin: layer_from_sql layer is " << layer_name_ << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "ogr_layer_ptr: layer_from_sql layer=" << layer_name_;
#endif
}
}
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
debug_print_last_error();
#endif
}
@ -166,7 +169,7 @@ public:
private:
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
void debug_print_last_error()
{
if (! is_valid_)
@ -174,11 +177,11 @@ private:
const std::string err = CPLGetLastErrorMsg();
if (err.size() == 0)
{
std::clog << "OGR Plugin: error getting layer" << std::endl;
mapnik::log() << "ogr_layer_ptr: Error getting layer";
}
else
{
std::clog << "OGR Plugin: " << err << std::endl;
mapnik::log() << "ogr_layer_ptr: " << err;
}
}
}

View file

@ -20,11 +20,18 @@
*
*****************************************************************************/
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
// boost
#include <boost/filesystem/operations.hpp>
// std
#include <sstream>
#include "dataset_deliverer.h"
#include "basiccurl.h"
#include <sstream>
osm_dataset * dataset_deliverer::dataset = NULL;
std::string dataset_deliverer::last_bbox = "";
@ -76,8 +83,8 @@ osm_dataset* dataset_deliverer::load_from_url(const string& url, const string& b
}
else if (bbox != last_bbox)
{
#ifdef MAPNIK_DEBUG
std::cerr << "Osm Plugin: BBOXES ARE DIFFERENT: " << last_bbox << "," << bbox << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset_deliverer: BBoxes are different=" << last_bbox << "," << bbox;
#endif
// Reload the dataset

View file

@ -24,6 +24,8 @@
#include "osmparser.h"
#include "basiccurl.h"
#include <mapnik/debug.hpp>
#include <libxml/parser.h>
#include <iostream>
#include <fstream>
@ -47,8 +49,8 @@ bool osm_dataset::load_from_url(const std::string& url,
{
if (parser == "libxml2")
{
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: osm_dataset::load_from_url url=" << url << " bbox=" << bbox << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: load_from_url url=" << url << ",bbox=" << bbox;
#endif
std::ostringstream str;
@ -57,8 +59,8 @@ bool osm_dataset::load_from_url(const std::string& url,
str << url << "?bbox=" << bbox;
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: FULL URL " << str.str() << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: Full url=" << str.str();
#endif
CURL_LOAD_DATA* resp = grab_http_response(str.str().c_str());
@ -69,8 +71,8 @@ bool osm_dataset::load_from_url(const std::string& url,
memcpy(blx, resp->data, resp->nbytes);
blx[resp->nbytes] = '\0';
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: CURL RESPONSE: " << blx << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: CURL Response=" << blx;
#endif
delete[] blx;
@ -88,36 +90,32 @@ osm_dataset::~osm_dataset()
void osm_dataset::clear()
{
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: osm_dataset::clear()" << std::endl;
std::clog << "Osm Plugin: deleting ways" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: Clear";
#endif
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: -- Deleting ways";
#endif
for (unsigned int count = 0; count < ways.size(); ++count)
{
delete ways[count];
ways[count] = NULL;
}
ways.clear();
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: deleting nodes" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: -- Deleting nodes";
#endif
for (unsigned int count = 0; count < nodes.size(); ++count)
{
delete nodes[count];
nodes[count] = NULL;
}
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: clearing ways/nodes" << std::endl;
#endif
ways.clear();
nodes.clear();
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: done" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "osm_dataset: Clear done";
#endif
}

View file

@ -28,8 +28,10 @@
#include <set>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/query.hpp>
#include <mapnik/boolean.hpp>
// boost
#include <boost/make_shared.hpp>
@ -51,11 +53,13 @@ using mapnik::attribute_descriptor;
DATASOURCE_PLUGIN(osm_datasource)
osm_datasource::osm_datasource(const parameters& params, bool bind)
: datasource (params),
extent_(),
type_(datasource::Vector),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8"))
: datasource (params),
extent_(),
type_(datasource::Vector),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8"))
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
if (bind)
{
this->bind();
@ -77,9 +81,10 @@ void osm_datasource::bind() const
if (url != "" && bbox != "")
{
// if we supplied a url and a bounding box, load from the url
#ifdef MAPNIK_DEBUG
std::clog << "Osm Plugin: loading_from_url: url=" << url << " bbox=" << bbox << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "osm_datasource: loading_from_url url=" << url << ",bbox=" << bbox;
#endif
if ((osm_data_ = dataset_deliverer::load_from_url(url, bbox, parser)) == NULL)
{
throw datasource_exception("Error loading from URL");
@ -94,7 +99,9 @@ void osm_datasource::bind() const
s << "OSM Plugin: Error loading from file '" << osm_filename << "'";
throw datasource_exception(s.str());
}
} else {
}
else
{
throw datasource_exception("OSM Plugin: Neither 'file' nor 'url' and 'bbox' specified");
}

View file

@ -43,21 +43,19 @@ public:
osm_datasource(const parameters& params, bool bind = true);
virtual ~osm_datasource();
mapnik::datasource::datasource_t type() const;
static std::string name();
featureset_ptr features(const query& q) const;
featureset_ptr features_at_point(coord2d const& pt) const;
box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
static std::string name();
void bind() const;
private:
mutable box2d<double> extent_;
mutable osm_dataset* osm_data_;
mapnik::datasource::datasource_t type_;
mutable layer_descriptor desc_;
// no copying
osm_datasource(const osm_datasource&);
osm_datasource& operator=(const osm_datasource&);
};
#endif // OSM_DATASOURCE_HPP

View file

@ -20,10 +20,15 @@
*
*****************************************************************************/
#ifndef CONNECTION_HPP
#define CONNECTION_HPP
#ifndef POSTGIS_CONNECTION_HPP
#define POSTGIS_CONNECTION_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/timer.hpp>
// boost
#include <boost/make_shared.hpp>
// std
@ -38,14 +43,10 @@ extern "C" {
class Connection
{
private:
PGconn *conn_;
int cursorId;
bool closed_;
public:
Connection(std::string const& connection_str)
:cursorId(0),
closed_(false)
: cursorId(0),
closed_(false)
{
conn_ = PQconnectdb(connection_str.c_str());
if (PQstatus(conn_) != CONNECTION_OK)
@ -54,10 +55,10 @@ public:
s << "Postgis Plugin: ";
if (conn_ )
{
std::string msg = PQerrorMessage( conn_ );
if ( ! msg.empty() )
std::string msg = PQerrorMessage(conn_);
if (! msg.empty())
{
s << msg.substr( 0, msg.size() - 1 );
s << msg.substr(0, msg.size() - 1);
}
else
{
@ -69,39 +70,62 @@ public:
s << "unable to connect to postgres server";
}
s << "\n" << connection_str;
throw mapnik::datasource_exception( s.str() );
throw mapnik::datasource_exception(s.str());
}
}
~Connection()
{
if (! closed_)
{
PQfinish(conn_);
#ifdef MAPNIK_LOG
mapnik::log() << "postgis_connection: postgresql connection closed - " << conn_;
#endif
closed_ = true;
}
}
bool execute(const std::string& sql) const
{
PGresult *result = PQexec(conn_,sql.c_str());
bool ok=(result && (PQresultStatus(result) == PGRES_COMMAND_OK));
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, std::string("postgis_connection::execute ") + sql);
#endif
PGresult *result = PQexec(conn_, sql.c_str());
bool ok = (result && (PQresultStatus(result) == PGRES_COMMAND_OK));
PQclear(result);
return ok;
}
boost::shared_ptr<ResultSet> executeQuery(const std::string& sql,int type=0) const
boost::shared_ptr<ResultSet> executeQuery(const std::string& sql, int type = 0) const
{
PGresult *result=0;
if (type==1)
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, std::string("postgis_connection::execute_query ") + sql);
#endif
PGresult* result = 0;
if (type == 1)
{
result = PQexecParams(conn_,sql.c_str(),0,0,0,0,0,1);
result = PQexecParams(conn_,sql.c_str(), 0, 0, 0, 0, 0, 1);
}
else
{
result = PQexec(conn_,sql.c_str());
result = PQexec(conn_, sql.c_str());
}
if(!result || (PQresultStatus(result) != PGRES_TUPLES_OK))
if (! result || (PQresultStatus(result) != PGRES_TUPLES_OK))
{
std::ostringstream s;
s << "Postgis Plugin: PSQL error";
if (conn_ )
if (conn_)
{
std::string msg = PQerrorMessage( conn_ );
if ( ! msg.empty() )
std::string msg = PQerrorMessage(conn_);
if (! msg.empty())
{
s << ":\n" << msg.substr( 0, msg.size() - 1 );
s << ":\n" << msg.substr(0, msg.size() - 1);
}
s << "\nFull sql was: '" << sql << "'\n";
@ -110,9 +134,13 @@ public:
{
s << "unable to connect to database";
}
if (result)
{
PQclear(result);
throw mapnik::datasource_exception( s.str() );
}
throw mapnik::datasource_exception(s.str());
}
return boost::make_shared<ResultSet>(result);
@ -120,7 +148,7 @@ public:
std::string client_encoding() const
{
return PQparameterStatus(conn_,"client_encoding");
return PQparameterStatus(conn_, "client_encoding");
}
bool isOK() const
@ -130,11 +158,12 @@ public:
void close()
{
if (!closed_)
if (! closed_)
{
PQfinish(conn_);
#ifdef MAPNIK_DEBUG
std::clog << "PostGIS: datasource closed, also closing connection - " << conn_ << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "postgis_connection: datasource closed, also closing connection - " << conn_;
#endif
closed_ = true;
}
@ -147,17 +176,10 @@ public:
return s.str();
}
~Connection()
{
if (!closed_)
{
PQfinish(conn_);
#ifdef MAPNIK_DEBUG
std::clog << "PostGIS: postgresql connection closed - " << conn_ << std::endl;
#endif
closed_ = true;
}
}
private:
PGconn *conn_;
int cursorId;
bool closed_;
};
#endif //CONNECTION_HPP

View file

@ -20,23 +20,28 @@
*
*****************************************************************************/
#ifndef CONNECTION_MANAGER_HPP
#define CONNECTION_MANAGER_HPP
#ifndef POSTGIS_CONNECTION_MANAGER_HPP
#define POSTGIS_CONNECTION_MANAGER_HPP
#include <string>
#include <sstream>
#include "connection.hpp"
// mapnik
#include <mapnik/pool.hpp>
#include <mapnik/utils.hpp>
#include "connection.hpp"
// boost
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/optional.hpp>
#ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp>
//using boost::mutex;
#endif
// stl
#include <string>
#include <sstream>
using mapnik::Pool;
using mapnik::singleton;
using mapnik::CreateStatic;
@ -150,4 +155,4 @@ private:
ConnectionManager& operator=(const ConnectionManager);
};
#endif //CONNECTION_MANAGER_HPP
#endif // POSTGIS_CONNECTION_MANAGER_HPP

View file

@ -1,33 +1,35 @@
#ifndef CURSORRESULTSET_HPP
#define CURSORRESULTSET_HPP
/*****************************************************************************
*
* 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 POSTGIS_CURSORRESULTSET_HPP
#define POSTGIS_CURSORRESULTSET_HPP
#include <mapnik/debug.hpp>
#include "connection.hpp"
#include "resultset.hpp"
class CursorResultSet : public IResultSet
{
private:
boost::shared_ptr<Connection> conn_;
std::string cursorName_;
boost::shared_ptr<ResultSet> rs_;
int fetch_size_;
bool is_closed_;
int *refCount_;
void getNextResultSet()
{
std::ostringstream s;
s << "FETCH FORWARD " << fetch_size_ << " FROM " << cursorName_;
#ifdef MAPNIK_DEBUG
std::clog << "Postgis Plugin: " << s.str() << std::endl;
#endif
rs_ = conn_->executeQuery(s.str());
is_closed_ = false;
#ifdef MAPNIK_DEBUG
std::clog << "Postgis Plugin: FETCH result (" << cursorName_ << "): " << rs_->size() << " rows" << std::endl;
#endif
}
public:
CursorResultSet(boost::shared_ptr<Connection> const &conn, std::string cursorName, int fetch_count)
: conn_(conn),
@ -50,6 +52,15 @@ public:
(*refCount_)++;
}
virtual ~CursorResultSet()
{
if (--(*refCount_)==0)
{
close();
delete refCount_,refCount_=0;
}
}
CursorResultSet& operator=(const CursorResultSet& rhs)
{
if (this==&rhs) return *this;
@ -73,25 +84,18 @@ public:
if (!is_closed_)
{
rs_.reset();
std::ostringstream s;
s << "CLOSE " << cursorName_;
#ifdef MAPNIK_DEBUG
std::clog << "Postgis Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "postgis_cursor_resultset: " << s.str();
#endif
conn_->execute(s.str());
is_closed_ = true;
}
}
virtual ~CursorResultSet()
{
if (--(*refCount_)==0)
{
close();
delete refCount_,refCount_=0;
}
}
virtual int getNumFields() const
{
return rs_->getNumFields();
@ -148,6 +152,30 @@ public:
{
return rs_->getValue(name);
}
private:
void getNextResultSet()
{
std::ostringstream s;
s << "FETCH FORWARD " << fetch_size_ << " FROM " << cursorName_;
#ifdef MAPNIK_LOG
mapnik::log() << "postgis_cursor_resultset: " << s.str();
#endif
rs_ = conn_->executeQuery(s.str());
is_closed_ = false;
#ifdef MAPNIK_LOG
mapnik::log() << "postgis_cursor_resultset: FETCH result (" << cursorName_ << "): " << rs_->size() << " rows";
#endif
}
boost::shared_ptr<Connection> conn_;
std::string cursorName_;
boost::shared_ptr<ResultSet> rs_;
int fetch_size_;
bool is_closed_;
int *refCount_;
};
#endif //CURSORRESULTSET_HPP
#endif // POSTGIS_CURSORRESULTSET_HPP

View file

@ -25,10 +25,12 @@
#include "postgis_featureset.hpp"
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/global.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/sql_utils.hpp>
#include <mapnik/util/conversions.hpp>
#include <mapnik/timer.hpp>
// boost
#include <boost/algorithm/string.hpp>
@ -79,8 +81,9 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind)
// params below are for testing purposes only (will likely be removed at any time)
intersect_min_scale_(*params_.get<int>("intersect_min_scale", 0)),
intersect_max_scale_(*params_.get<int>("intersect_max_scale", 0))
//show_queries_(*params_.get<mapnik::boolean>("show_queries",false))
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
if (table_.empty())
{
throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter");
@ -105,6 +108,10 @@ void postgis_datasource::bind() const
return;
}
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::bind");
#endif
boost::optional<int> initial_size = params_.get<int>("initial_size", 1);
boost::optional<int> max_size = params_.get<int>("max_size", 10);
boost::optional<mapnik::boolean> autodetect_key_field = params_.get<mapnik::boolean>("autodetect_key_field", false);
@ -148,6 +155,10 @@ void postgis_datasource::bind() const
geometryColumn_ = geometry_field_;
if (geometryColumn_.empty() || srid_ == 0)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::bind(get_srid_and_geometry_column)");
#endif
std::ostringstream s;
s << "SELECT f_geometry_column, srid FROM "
<< GEOMETRY_COLUMNS <<" WHERE f_table_name='"
@ -168,13 +179,6 @@ void postgis_datasource::bind() const
<< "'";
}
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % s.str();
}
*/
shared_ptr<ResultSet> rs = conn->executeQuery(s.str());
if (rs->next())
{
@ -205,13 +209,6 @@ void postgis_datasource::bind() const
s << "SELECT ST_SRID(\"" << geometryColumn_ << "\") AS srid FROM "
<< populate_tokens(table_) << " WHERE \"" << geometryColumn_ << "\" IS NOT NULL LIMIT 1;";
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % s.str();
}
*/
shared_ptr<ResultSet> rs = conn->executeQuery(s.str());
if (rs->next())
{
@ -232,6 +229,10 @@ void postgis_datasource::bind() const
// detect primary key
if (*autodetect_key_field && key_field_.empty())
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::bind(get_primary_key)");
#endif
std::ostringstream s;
s << "SELECT a.attname, a.attnum, t.typname, t.typname in ('int2','int4','int8') "
"AS is_int FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n, pg_index i "
@ -267,9 +268,11 @@ void postgis_datasource::bind() const
{
key_field_ = std::string(key_field_string);
#ifdef MAPNIK_DEBUG
std::clog << "PostGIS Plugin: auto-detected key field of '"
<< key_field_ << "' on table '"
<< geometry_table_ << "'\n";
if (log_enabled_)
{
mapnik::log() << "postgis_datasource: auto-detected key field of '"
<< key_field_ << "' on table '" << geometry_table_ << "'";
}
#endif
}
}
@ -310,31 +313,29 @@ void postgis_datasource::bind() const
{
srid_ = -1;
#ifdef MAPNIK_DEBUG
std::clog << "Postgis Plugin: SRID warning, using srid=-1 for '" << table_ << "'" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "postgis_datasource: Table " << table_ << " is using SRID=-1";
#endif
}
// At this point the geometry_field may still not be known
// but we'll catch that where more useful...
#ifdef MAPNIK_DEBUG
std::clog << "Postgis Plugin: using SRID=" << srid_ << std::endl;
std::clog << "Postgis Plugin: using geometry_column=" << geometryColumn_ << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_)
{
mapnik::log() << "postgis_datasource: Using SRID=" << srid_;
mapnik::log() << "postgis_datasource: Using geometry_column=" << geometryColumn_;
}
#endif
// collect attribute desc
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::bind(get_column_description)");
#endif
std::ostringstream s;
s << "SELECT * FROM " << populate_tokens(table_) << " LIMIT 0";
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % s.str();
}
*/
shared_ptr<ResultSet> rs = conn->executeQuery(s.str());
int count = rs->getNumFields();
bool found_key_field = false;
@ -400,28 +401,24 @@ void postgis_datasource::bind() const
desc_.add_descriptor(attribute_descriptor(fld_name, mapnik::String));
break;
default: // should not get here
#ifdef MAPNIK_DEBUG
s.str("");
s << "SELECT oid, typname FROM pg_type WHERE oid = " << type_oid;
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % s.str();
}
*/
shared_ptr<ResultSet> rs_oid = conn->executeQuery(s.str());
if (rs_oid->next())
#ifdef MAPNIK_LOG
if (log_enabled_)
{
std::clog << "Postgis Plugin: unknown type = " << rs_oid->getValue("typname")
<< " (oid:" << rs_oid->getValue("oid") << ")" << std::endl;
s.str("");
s << "SELECT oid, typname FROM pg_type WHERE oid = " << type_oid;
shared_ptr<ResultSet> rs_oid = conn->executeQuery(s.str());
if (rs_oid->next())
{
mapnik::log() << "postgis_datasource: Unknown type=" << rs_oid->getValue("typname")
<< " (oid:" << rs_oid->getValue("oid") << ")";
}
else
{
mapnik::log() << "postgis_datasource: Unknown type_oid=" << type_oid;
}
rs_oid->close();
}
else
{
std::clog << "Postgis Plugin: unknown oid type =" << type_oid << std::endl;
}
rs_oid->close();
#endif
break;
}
@ -435,6 +432,23 @@ void postgis_datasource::bind() const
}
}
postgis_datasource::~postgis_datasource()
{
if (is_bound_ && ! persist_connection_)
{
ConnectionManager* mgr = ConnectionManager::instance();
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool)
{
shared_ptr<Connection> conn = pool->borrowObject();
if (conn)
{
conn->close();
}
}
}
}
std::string postgis_datasource::name()
{
return "postgis";
@ -547,13 +561,6 @@ boost::shared_ptr<IResultSet> postgis_datasource::get_resultset(boost::shared_pt
csql << "DECLARE " << cursor_name << " BINARY INSENSITIVE NO SCROLL CURSOR WITH HOLD FOR " << sql << " FOR READ ONLY";
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % csql.str();
}
*/
if (! conn->execute(csql.str()))
{
// TODO - better error
@ -567,13 +574,6 @@ boost::shared_ptr<IResultSet> postgis_datasource::get_resultset(boost::shared_pt
{
// no cursor
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % sql;
}
*/
return conn->executeQuery(sql, 1);
}
}
@ -585,6 +585,10 @@ featureset_ptr postgis_datasource::features(const query& q) const
bind();
}
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features");
#endif
box2d<double> const& box = q.get_bbox();
double scale_denom = q.scale_denominator();
@ -678,6 +682,10 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const
bind();
}
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features_at_point");
#endif
ConnectionManager* mgr = ConnectionManager::instance();
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool)
@ -836,13 +844,6 @@ box2d<double> postgis_datasource::envelope() const
}
}
/*
if (show_queries_)
{
std::clog << boost::format("PostGIS: sending query: %s\n") % s.str();
}
*/
shared_ptr<ResultSet> rs = conn->executeQuery(s.str());
if (rs->next() && ! rs->isNull(0))
{
@ -857,7 +858,9 @@ box2d<double> postgis_datasource::envelope() const
}
else
{
std::clog << boost::format("Postgis Plugin: warning: could not determine extent from query: %s\n") % s.str() << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << boost::format("Mapnik LOG> postgis_datasource: Could not determine extent from query: %s") % s.str();
#endif
}
}
rs->close();
@ -990,20 +993,3 @@ boost::optional<mapnik::datasource::geometry_t> postgis_datasource::get_geometry
return result;
}
postgis_datasource::~postgis_datasource()
{
if (is_bound_ && ! persist_connection_)
{
ConnectionManager* mgr = ConnectionManager::instance();
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool)
{
shared_ptr<Connection> conn = pool->borrowObject();
if (conn)
{
conn->close();
}
}
}
}

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id: postgis.hpp 44 2005-04-22 18:53:54Z pavlenko $
#ifndef POSTGIS_DATASOURCE_HPP
#define POSTGIS_DATASOURCE_HPP
@ -67,12 +65,11 @@ private:
std::string populate_tokens(const std::string& sql) const;
static std::string unquote(const std::string& sql);
boost::shared_ptr<IResultSet> get_resultset(boost::shared_ptr<Connection> const &conn, std::string const& sql) const;
postgis_datasource(const postgis_datasource&);
postgis_datasource& operator=(const postgis_datasource&);
static const std::string GEOMETRY_COLUMNS;
static const std::string SPATIAL_REF_SYS;
static const double FMAX;
const std::string uri_;
const std::string username_;
const std::string password_;
@ -100,4 +97,4 @@ private:
//bool show_queries_;
};
#endif //POSTGIS_DATASOURCE_HPP
#endif // POSTGIS_DATASOURCE_HPP

View file

@ -26,6 +26,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/sql_utils.hpp>
@ -197,8 +198,8 @@ feature_ptr postgis_featureset::next()
default:
{
#ifdef MAPNIK_DEBUG
std::clog << "Postgis Plugin: uknown OID = " << oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "postgis_featureset: Uknown type_oid=" << oid;
#endif
break;
}

View file

@ -20,8 +20,8 @@
*
*****************************************************************************/
#ifndef RESULTSET_HPP
#define RESULTSET_HPP
#ifndef POSTGIS_RESULTSET_HPP
#define POSTGIS_RESULTSET_HPP
extern "C" {
#include "libpq-fe.h"
@ -187,4 +187,4 @@ private:
int *refCount_;
};
#endif //RESULTSET_HPP
#endif // POSTGIS_RESULTSET_HPP

View file

@ -26,7 +26,9 @@
#include <boost/make_shared.hpp>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/image_reader.hpp>
#include <mapnik/boolean.hpp>
#include "raster_featureset.hpp"
#include "raster_info.hpp"
@ -46,12 +48,14 @@ using mapnik::image_reader;
DATASOURCE_PLUGIN(raster_datasource)
raster_datasource::raster_datasource(const parameters& params, bool bind)
: datasource(params),
desc_(*params.get<std::string>("type"), "utf-8"),
extent_initialized_(false)
: datasource(params),
desc_(*params.get<std::string>("type"), "utf-8"),
extent_initialized_(false)
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: Initializing..." << std::endl;
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: Initializing...";
#endif
boost::optional<std::string> file = params.get<std::string>("file");
@ -148,8 +152,8 @@ void raster_datasource::bind() const
}
}
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: RASTER SIZE(" << width_ << "," << height_ << ")" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: Raster size=" << width_ << "," << height_;
#endif
is_bound_ = true;
@ -195,14 +199,14 @@ featureset_ptr raster_datasource::features(query const& q) const
const int width = int(ext.maxx() + 0.5) - int(ext.minx() + 0.5);
const int height = int(ext.maxy() + 0.5) - int(ext.miny() + 0.5);
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: BOX SIZE(" << width << " " << height << ")" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: Box size=" << width << "," << height;
#endif
if (multi_tiles_)
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: MULTI-TILED policy" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: Multi-Tiled policy";
#endif
tiled_multi_file_policy policy(filename_, format_, tile_size_, extent_, q.get_bbox(), width_, height_, tile_stride_);
@ -211,8 +215,8 @@ featureset_ptr raster_datasource::features(query const& q) const
}
else if (width * height > 512*512)
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: TILED policy" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: Tiled policy";
#endif
tiled_file_policy policy(filename_, format_, 256, extent_, q.get_bbox(), width_, height_);
@ -221,8 +225,8 @@ featureset_ptr raster_datasource::features(query const& q) const
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: SINGLE FILE" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: Single file";
#endif
raster_info info(filename_, format_, extent_, width_, height_);
@ -234,8 +238,8 @@ featureset_ptr raster_datasource::features(query const& q) const
featureset_ptr raster_datasource::features_at_point(coord2d const&) const
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: feature_at_point not supported for raster.input" << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "raster_datasource: feature_at_point not supported";
#endif
return featureset_ptr();

View file

@ -40,7 +40,9 @@ public:
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
bool log_enabled() const;
void bind() const;
private:
mapnik::layer_descriptor desc_;
std::string filename_;
@ -52,9 +54,6 @@ private:
unsigned tile_stride_;
mutable unsigned width_;
mutable unsigned height_;
//no copying
raster_datasource(const raster_datasource&);
raster_datasource& operator=(const raster_datasource&);
};
#endif // RASTER_DATASOURCE_HPP

View file

@ -21,6 +21,7 @@
*****************************************************************************/
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/image_reader.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/feature_factory.hpp>
@ -69,9 +70,9 @@ feature_ptr raster_featureset<LookupPolicy>::next()
{
std::auto_ptr<image_reader> reader(mapnik::get_image_reader(curIter_->file(),curIter_->format()));
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: READER = " << curIter_->format() << " " << curIter_->file()
<< " size(" << curIter_->width() << "," << curIter_->height() << ")" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "raster_featureset: Reader=" << curIter_->format() << "," << curIter_->file()
<< ",size(" << curIter_->width() << "," << curIter_->height() << ")";
#endif
if (reader.get())

View file

@ -26,6 +26,9 @@
#include "raster_datasource.hpp"
#include "raster_info.hpp"
// mapnik
#include <mapnik/debug.hpp>
// stl
#include <vector>
@ -137,8 +140,8 @@ public:
double pixel_x = extent.width() / double(width);
double pixel_y = extent.height() / double(height);
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: PIXEL SIZE("<< pixel_x << "," << pixel_y << ")" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "tiled_file_policy: Raster Plugin PIXEL SIZE("<< pixel_x << "," << pixel_y << ")";
#endif
box2d<double> e = bbox.intersect(extent);
@ -160,8 +163,9 @@ public:
}
}
}
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: INFO SIZE=" << infos_.size() << " " << file << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "tiled_file_policy: Raster Plugin INFO SIZE=" << infos_.size() << " " << file;
#endif
}
@ -223,8 +227,8 @@ public:
double pixel_x = extent.width() / double(width);
double pixel_y = extent.height() / double(height);
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: PIXEL SIZE("<< pixel_x << "," << pixel_y << ")" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "tiled_multi_file_policy: Raster Plugin PIXEL SIZE(" << pixel_x << "," << pixel_y << ")";
#endif
// intersection of query with extent => new query
@ -256,8 +260,9 @@ public:
}
}
}
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: INFO SIZE=" << infos_.size() << " " << file_pattern << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "tiled_multi_file_policy: Raster Plugin INFO SIZE=" << infos_.size() << " " << file_pattern;
#endif
}

View file

@ -29,6 +29,7 @@
#include <boost/make_shared.hpp>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
@ -45,7 +46,6 @@ using mapnik::layer_descriptor;
using mapnik::datasource_exception;
/*
* Opens a GDALDataset and returns a pointer to it.
* Caller is responsible for calling GDALClose on it
@ -74,8 +74,10 @@ rasterlite_datasource::rasterlite_datasource(parameters const& params, bool bind
: datasource(params),
desc_(*params.get<std::string>("type"),"utf-8")
{
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: Initializing..." << std::endl;
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "rasterlite_datasource: Initializing...";
#endif
boost::optional<std::string> file = params.get<std::string>("file");
@ -118,40 +120,43 @@ void rasterlite_datasource::bind() const
extent_.init(x0,y0,x1,y1);
#ifdef MAPNIK_DEBUG
int srid, auth_srid;
const char *auth_name;
const char *ref_sys_name;
const char *proj4text;
int tile_count;
double pixel_x_size, pixel_y_size;
int levels = rasterliteGetLevels (dataset);
if (rasterliteGetSrid(dataset, &srid, &auth_name, &auth_srid, &ref_sys_name, &proj4text) != RASTERLITE_OK)
#ifdef MAPNIK_LOG
if (log_enabled_)
{
std::string error (rasterliteGetLastError(dataset));
int srid, auth_srid;
const char *auth_name;
const char *ref_sys_name;
const char *proj4text;
rasterliteClose (dataset);
int tile_count;
double pixel_x_size, pixel_y_size;
int levels = rasterliteGetLevels (dataset);
throw datasource_exception(error);
}
std::clog << "Rasterlite Plugin: Data Source=" << rasterliteGetTablePrefix(dataset) << std::endl;
std::clog << "Rasterlite Plugin: SRID=" << srid << std::endl;
std::clog << "Rasterlite Plugin: Authority=" << auth_name << std::endl;
std::clog << "Rasterlite Plugin: AuthSRID=" << auth_srid << std::endl;
std::clog << "Rasterlite Plugin: RefSys Name=" << ref_sys_name << std::endl;
std::clog << "Rasterlite Plugin: Proj4Text=" << proj4text << std::endl;
std::clog << "Rasterlite Plugin: Extent(" << x0 << "," << y0 << " " << x1 << "," << y1 << ")" << std::endl;
std::clog << "Rasterlite Plugin: Levels=" << levels << std::endl;
for (int i = 0; i < levels; i++)
{
if (rasterliteGetResolution(dataset, i, &pixel_x_size, &pixel_y_size, &tile_count) == RASTERLITE_OK)
if (rasterliteGetSrid(dataset, &srid, &auth_name, &auth_srid, &ref_sys_name, &proj4text) != RASTERLITE_OK)
{
std::clog << "Rasterlite Plugin: Level=" << i
<< " x=" << pixel_x_size << " y=" << pixel_y_size << " tiles=" << tile_count << std::endl;
std::string error (rasterliteGetLastError(dataset));
rasterliteClose (dataset);
throw datasource_exception(error);
}
mapnik::log() << "rasterlite_datasource: Data Source=" << rasterliteGetTablePrefix(dataset);
mapnik::log() << "rasterlite_datasource: SRID=" << srid;
mapnik::log() << "rasterlite_datasource: Authority=" << auth_name;
mapnik::log() << "rasterlite_datasource: AuthSRID=" << auth_srid;
mapnik::log() << "rasterlite_datasource: RefSys Name=" << ref_sys_name;
mapnik::log() << "rasterlite_datasource: Proj4Text=" << proj4text;
mapnik::log() << "rasterlite_datasource: Extent=" << x0 << "," << y0 << " " << x1 << "," << y1 << ")";
mapnik::log() << "rasterlite_datasource: Levels=" << levels;
for (int i = 0; i < levels; i++)
{
if (rasterliteGetResolution(dataset, i, &pixel_x_size, &pixel_y_size, &tile_count) == RASTERLITE_OK)
{
mapnik::log() << "rasterlite_datasource: Level=" << i
<< " x=" << pixel_x_size << " y=" << pixel_y_size << " tiles=" << tile_count;
}
}
}
#endif

View file

@ -46,7 +46,8 @@ public:
void bind() const;
private:
inline void* open_dataset() const;
void* open_dataset() const;
mutable mapnik::box2d<double> extent_;
std::string dataset_name_;
std::string table_name_;

View file

@ -23,6 +23,7 @@
#include "rasterlite_featureset.hpp"
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/feature_factory.hpp>
@ -53,8 +54,8 @@ rasterlite_featureset::rasterlite_featureset(void* dataset, rasterlite_query q)
rasterlite_featureset::~rasterlite_featureset()
{
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: closing dataset" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "rasterlite_featureset: Closing";
#endif
rasterliteClose(dataset_);
@ -86,8 +87,8 @@ feature_ptr rasterlite_featureset::next()
feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
{
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: get_feature" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "rasterlite_featureset: Running get_feature";
#endif
feature_ptr feature(feature_factory::create(ctx_,1));
@ -104,14 +105,13 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
const double pixel_size = (intersect.width() >= intersect.height()) ?
(intersect.width() / (double) width) : (intersect.height() / (double) height);
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: Raster extent=" << raster_extent << std::endl;
std::clog << "Rasterlite Plugin: View extent=" << q.get_bbox() << std::endl;
std::clog << "Rasterlite Plugin: Intersect extent=" << intersect << std::endl;
std::clog << "Rasterlite Plugin: Query resolution="
<< boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution()) << std::endl;
std::clog << "Rasterlite Plugin: Size=" << width << " " << height << std::endl;
std::clog << "Rasterlite Plugin: Pixel Size=" << pixel_size << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "rasterlite_featureset: Raster extent=" << raster_extent;
mapnik::log() << "rasterlite_featureset: View extent=" << q.get_bbox();
mapnik::log() << "rasterlite_featureset: Intersect extent=" << intersect;
mapnik::log() << "rasterlite_featureset: Query resolution=" << boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution());
mapnik::log() << "rasterlite_featureset: Size=" << width << " " << height;
mapnik::log() << "rasterlite_featureset: Pixel Size=" << pixel_size;
#endif
if (width > 0 && height > 0)
@ -145,15 +145,13 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
free (raster);
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: done" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "rasterlite_featureset: Done";
#endif
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: error=" << rasterliteGetLastError (dataset_) << std::endl;
#endif
std::cerr << "Rasterlite Plugin: Error " << rasterliteGetLastError (dataset_) << std::endl;
}
}

View file

@ -20,8 +20,9 @@
*
*****************************************************************************/
// mapnik
#include <mapnik/geom_util.hpp>
#include "shape_datasource.hpp"
#include "shape_featureset.hpp"
#include "shape_index_featureset.hpp"
// boost
#include <boost/version.hpp>
@ -30,15 +31,20 @@
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/global.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/sql_utils.hpp>
#include <mapnik/util/conversions.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/timer.hpp>
// stl
#include <iostream>
#include <fstream>
#include <stdexcept>
#include "shape_datasource.hpp"
#include "shape_featureset.hpp"
#include "shape_index_featureset.hpp"
DATASOURCE_PLUGIN(shape_datasource)
using mapnik::String;
@ -57,6 +63,8 @@ shape_datasource::shape_datasource(const parameters &params, bool bind)
row_limit_(*params_.get<int>("row_limit",0)),
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8"))
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
boost::optional<std::string> file = params.get<std::string>("file");
if (!file) throw datasource_exception("Shape Plugin: missing <file> parameter");
@ -78,6 +86,10 @@ void shape_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::bind");
#endif
if (!boost::filesystem::exists(shape_name_ + ".shp"))
{
throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist");
@ -96,6 +108,10 @@ void shape_datasource::bind() const
try
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "shape_datasource::bind(get_column_description)");
#endif
boost::shared_ptr<shape_io> shape_ref = boost::make_shared<shape_io>(shape_name_);
init(*shape_ref);
for (int i=0;i<shape_ref->dbf().num_fields();++i)
@ -126,11 +142,11 @@ void shape_datasource::bind() const
break;
}
default:
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
// I - long
// G - ole
// + - autoincrement
std::clog << "Shape Plugin: unknown type " << fd.type_ << std::endl;
if (log_enabled_) mapnik::log() << "shape_datasource: Unknown type=" << fd.type_;
#endif
break;
}
@ -143,17 +159,17 @@ void shape_datasource::bind() const
}
catch (const datasource_exception& ex)
{
std::clog << "Shape Plugin: error processing field attributes, " << ex.what() << std::endl;
std::cerr << "Shape Plugin: error processing field attributes, " << ex.what() << std::endl;
throw;
}
catch (const std::exception& ex)
{
std::clog << "Shape Plugin: error processing field attributes, " << ex.what() << std::endl;
std::cerr << "Shape Plugin: error processing field attributes, " << ex.what() << std::endl;
throw;
}
catch (...) // exception: pipe_select_interrupter: Too many open files
{
std::clog << "Shape Plugin: error processing field attributes" << std::endl;
std::cerr << "Shape Plugin: error processing field attributes" << std::endl;
throw;
}
@ -162,8 +178,12 @@ void shape_datasource::bind() const
shape_datasource::~shape_datasource() {}
void shape_datasource::init(shape_io& shape) const
void shape_datasource::init(shape_io& shape) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::init");
#endif
//first read header from *.shp
int file_code=shape.shp().read_xdr_integer();
if (file_code!=9994)
@ -188,14 +208,17 @@ void shape_datasource::init(shape_io& shape) const
shape.shp().read_envelope(extent_);
#ifdef MAPNIK_DEBUG
double zmin = shape.shp().read_double();
double zmax = shape.shp().read_double();
double mmin = shape.shp().read_double();
double mmax = shape.shp().read_double();
#ifdef MAPNIK_LOG
if (log_enabled_)
{
double zmin = shape.shp().read_double();
double zmax = shape.shp().read_double();
double mmin = shape.shp().read_double();
double mmax = shape.shp().read_double();
std::clog << "Shape Plugin: Z min/max " << zmin << "," << zmax << std::endl;
std::clog << "Shape Plugin: M min/max " << mmin << "," << mmax << "\n";
mapnik::log() << "shape_datasource: Z min/max=" << zmin << "," << zmax;
mapnik::log() << "shape_datasource: M min/max=" << mmin << "," << mmax;
}
#else
shape.shp().skip(4*8);
#endif
@ -213,13 +236,19 @@ void shape_datasource::init(shape_io& shape) const
//}
//else
//{
// std::clog << "### Notice: no .index file found for " + shape_name_ + ".shp, use the 'shapeindex' program to build an index for faster rendering\n";
// #ifdef MAPNIK_LOG
// mapnik::log() << "shape_datasource: No .index file found for "
// << shape_name_ << ".shp, use the 'shapeindex' program to build an index for faster rendering";
// #endif
//}
#ifdef MAPNIK_DEBUG
std::clog << "Shape Plugin: extent=" << extent_ << std::endl;
std::clog << "Shape Plugin: file_length=" << file_length_ << std::endl;
std::clog << "Shape Plugin: shape_type=" << shape_type_ << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_)
{
mapnik::log() << "shape_datasource: Extent=" << extent_;
mapnik::log() << "shape_datasource: File length=" << file_length_;
mapnik::log() << "shape_datasource: Shape type=" << shape_type_;
}
#endif
}
@ -244,6 +273,10 @@ featureset_ptr shape_datasource::features(const query& q) const
{
if (!is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features");
#endif
filter_in_box filter(q.get_bbox());
if (indexed_)
{
@ -272,6 +305,10 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt) const
{
if (!is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point");
#endif
filter_at_point filter(pt);
// collect all attribute names
std::vector<attribute_descriptor> const& desc_vector = desc_.get_descriptors();
@ -317,6 +354,10 @@ box2d<double> shape_datasource::envelope() const
boost::optional<mapnik::datasource::geometry_t> shape_datasource::get_geometry_type() const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::get_geometry_type");
#endif
boost::optional<mapnik::datasource::geometry_t> result;
switch (shape_type_)
{

View file

@ -44,7 +44,6 @@ class shape_datasource : public datasource
public:
shape_datasource(const parameters &params, bool bind=true);
virtual ~shape_datasource();
datasource::datasource_t type() const;
static std::string name();
featureset_ptr features(const query& q) const;
@ -53,11 +52,10 @@ public:
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
void bind() const;
private:
shape_datasource(const shape_datasource&);
shape_datasource& operator=(const shape_datasource&);
void init(shape_io& shape) const;
private:
datasource::datasource_t type_;
std::string shape_name_;
mutable boost::shared_ptr<shape_io> shape_;

View file

@ -24,6 +24,7 @@
#include <iostream>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/feature_factory.hpp>
#include "shape_featureset.hpp"
@ -145,8 +146,8 @@ feature_ptr shape_featureset<filterT>::next()
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Shape Plugin: total shapes read=" << count_ << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "shape_featureset: Total shapes read=" << count_;
#endif
return feature_ptr();
}
@ -247,7 +248,7 @@ feature_ptr shape_featureset<filterT>::next()
}
catch (...)
{
std::clog << "Shape Plugin: error processing attributes " << std::endl;
std::cerr << "Shape Plugin: error processing attributes " << std::endl;
}
}
@ -255,8 +256,8 @@ feature_ptr shape_featureset<filterT>::next()
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Shape Plugin: total shapes read=" << count_ << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "shape_featureset: Total shapes read=" << count_;
#endif
return feature_ptr();
}

View file

@ -24,6 +24,7 @@
#include <fstream>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/feature_factory.hpp>
// boost
@ -66,8 +67,8 @@ shape_index_featureset<filterT>::shape_index_featureset(filterT const& filter,
std::sort(ids_.begin(), ids_.end());
#ifdef MAPNIK_DEBUG
std::clog << "Shape Plugin: query size=" << ids_.size() << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "shape_index_featureset: Query size=" << ids_.size();
#endif
itr_ = ids_.begin();
@ -202,8 +203,8 @@ feature_ptr shape_index_featureset<filterT>::next()
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Shape Plugin: " << count_ << " features" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "shape_index_featureset: " << count_ << " features";
#endif
return feature_ptr();
}

View file

@ -23,6 +23,7 @@
#include "shape_io.hpp"
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
// boost
@ -57,8 +58,8 @@ shape_io::shape_io(const std::string& shape_name, bool open_index)
}
catch (...)
{
#ifdef MAPNIK_DEBUG
std::clog << "Shape Plugin: warning - could not open index: '" + shape_name + INDEX + "'" << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "shape_io: Could not open index=" << shape_name << INDEX;
#endif
}
}

View file

@ -29,7 +29,7 @@
// mapnik
#include <mapnik/datasource.hpp>
#include <mapnik/sql_utils.hpp>
#include <mapnik/timer.hpp>
// boost
#include <boost/shared_ptr.hpp>
@ -120,6 +120,9 @@ public:
boost::shared_ptr<sqlite_resultset> execute_query(const std::string& sql)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute_query ") + sql);
#endif
sqlite3_stmt* stmt = 0;
const int rc = sqlite3_prepare_v2 (db_, sql.c_str(), -1, &stmt, 0);
@ -133,6 +136,10 @@ public:
void execute(const std::string& sql)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute ") + sql);
#endif
const int rc = sqlite3_exec(db_, sql.c_str(), 0, 0, 0);
if (rc != SQLITE_OK)
{
@ -142,6 +149,10 @@ public:
int execute_with_code(const std::string& sql)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute_with_code ") + sql);
#endif
const int rc = sqlite3_exec(db_, sql.c_str(), 0, 0, 0);
return rc;
}

View file

@ -26,9 +26,11 @@
#include "sqlite_utils.hpp"
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/sql_utils.hpp>
#include <mapnik/util/geometry_to_ds_type.hpp>
#include <mapnik/timer.hpp>
#include <mapnik/wkb.hpp>
// boost
@ -51,23 +53,25 @@ using mapnik::parameters;
DATASOURCE_PLUGIN(sqlite_datasource)
sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
: datasource(params),
extent_(),
extent_initialized_(false),
type_(datasource::Vector),
table_(*params_.get<std::string>("table", "")),
fields_(*params_.get<std::string>("fields", "*")),
metadata_(*params_.get<std::string>("metadata", "")),
geometry_table_(*params_.get<std::string>("geometry_table", "")),
geometry_field_(*params_.get<std::string>("geometry_field", "")),
index_table_(*params_.get<std::string>("index_table", "")),
key_field_(*params_.get<std::string>("key_field", "")),
row_offset_(*params_.get<int>("row_offset", 0)),
row_limit_(*params_.get<int>("row_limit", 0)),
intersects_token_("!intersects!"),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
format_(mapnik::wkbAuto)
: datasource(params),
extent_(),
extent_initialized_(false),
type_(datasource::Vector),
table_(*params_.get<std::string>("table", "")),
fields_(*params_.get<std::string>("fields", "*")),
metadata_(*params_.get<std::string>("metadata", "")),
geometry_table_(*params_.get<std::string>("geometry_table", "")),
geometry_field_(*params_.get<std::string>("geometry_field", "")),
index_table_(*params_.get<std::string>("index_table", "")),
key_field_(*params_.get<std::string>("key_field", "")),
row_offset_(*params_.get<int>("row_offset", 0)),
row_limit_(*params_.get<int>("row_limit", 0)),
intersects_token_("!intersects!"),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
format_(mapnik::wkbAuto)
{
log_enabled_ = *params_.get<mapnik::boolean>("log", MAPNIK_DEBUG_AS_BOOL);
/* TODO
- throw if no primary key but spatial index is present?
- remove auto-indexing
@ -87,6 +91,10 @@ void sqlite_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::bind");
#endif
boost::optional<std::string> file = params_.get<std::string>("file");
if (! file) throw datasource_exception("Sqlite Plugin: missing <file> parameter");
@ -209,8 +217,8 @@ void sqlite_datasource::bind() const
for (std::vector<std::string>::const_iterator iter = init_statements_.begin();
iter != init_statements_.end(); ++iter)
{
#ifdef MAPNIK_DEBUG
std::clog << "Sqlite Plugin: Execute init sql: " << *iter << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "sqlite_datasource: Execute init sql=" << *iter;
#endif
dataset_->execute(*iter);
}
@ -283,6 +291,10 @@ void sqlite_datasource::bind() const
has_spatial_index_ = false;
if (use_spatial_index_)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::bind(use_spatial_index)");
#endif
if (boost::filesystem::exists(index_db))
{
dataset_->execute("attach database '" + index_db + "' as " + index_table_);
@ -315,8 +327,6 @@ void sqlite_datasource::bind() const
dataset_->execute("attach database '" + index_db + "' as " + index_table_);
}
}
*/
boost::shared_ptr<sqlite_resultset> rs = dataset_->execute_query(query.str());
if (sqlite_utils::create_spatial_index(index_db,index_table_,rs))
@ -343,7 +353,6 @@ void sqlite_datasource::bind() const
if (! extent_initialized_)
{
// TODO - clean this up - reducing arguments
std::string query = populate_tokens(table_);
if (!sqlite_utils::detect_extent(dataset_,
@ -487,8 +496,12 @@ box2d<double> sqlite_datasource::envelope() const
boost::optional<mapnik::datasource::geometry_t> sqlite_datasource::get_geometry_type() const
{
if (! is_bound_) bind();
boost::optional<mapnik::datasource::geometry_t> result;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::get_geometry_type");
#endif
boost::optional<mapnik::datasource::geometry_t> result;
if (dataset_)
{
// finally, get geometry type by querying first feature
@ -542,6 +555,10 @@ featureset_ptr sqlite_datasource::features(query const& q) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features");
#endif
if (dataset_)
{
mapnik::box2d<double> const& e = q.get_bbox();
@ -579,7 +596,8 @@ featureset_ptr sqlite_datasource::features(query const& q) const
key_field_,
index_table_,
geometry_table_,
intersects_token_); }
intersects_token_);
}
else
{
query = populate_tokens(table_);
@ -597,9 +615,12 @@ featureset_ptr sqlite_datasource::features(query const& q) const
s << " OFFSET " << row_offset_;
}
#ifdef MAPNIK_DEBUG
std::clog << "Sqlite Plugin: table: " << table_ << "\n\n";
std::clog << "Sqlite Plugin: query: " << s.str() << "\n\n";
#ifdef MAPNIK_LOG
if (log_enabled_)
{
mapnik::log() << "sqlite_datasource: Table=" << table_;
mapnik::log() << "sqlite_datasource: Query=" << s.str();
}
#endif
boost::shared_ptr<sqlite_resultset> rs(dataset_->execute_query(s.str()));
@ -618,6 +639,10 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features_at_point");
#endif
if (dataset_)
{
// TODO - need tolerance
@ -678,8 +703,8 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const
s << " OFFSET " << row_offset_;
}
#ifdef MAPNIK_DEBUG
std::clog << "Sqlite Plugin: " << s.str() << std::endl;
#ifdef MAPNIK_LOG
if (log_enabled_) mapnik::log() << "sqlite_datasource: " << s.str();
#endif
boost::shared_ptr<sqlite_resultset> rs(dataset_->execute_query(s.str()));

View file

@ -52,11 +52,14 @@ public:
void bind() const;
private:
// Fill init_statements with any statements
// needed to attach auxillary databases
void parse_attachdb(std::string const& attachdb) const;
std::string populate_tokens(const std::string& sql) const;
// FIXME: remove mutable qualifier from data members
// by factoring out bind() logic out from
// datasource impl !!!
mutable mapnik::box2d<double> extent_;
mutable bool extent_initialized_;
mapnik::datasource::datasource_t type_;
@ -79,11 +82,6 @@ private:
mutable bool has_spatial_index_;
mutable bool using_subquery_;
mutable std::vector<std::string> init_statements_;
// Fill init_statements with any statements
// needed to attach auxillary databases
void parse_attachdb(std::string const& attachdb) const;
std::string populate_tokens(const std::string& sql) const;
};
#endif // MAPNIK_SQLITE_DATASOURCE_HPP

View file

@ -22,6 +22,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
@ -124,9 +125,8 @@ feature_ptr sqlite_featureset::next()
break;
default:
#ifdef MAPNIK_DEBUG
std::clog << "Sqlite Plugin: field " << fld_name_str
<< " unhandled type_oid=" << type_oid << std::endl;
#ifdef MAPNIK_LOG
mapnik::log() << "sqlite_featureset: Field=" << fld_name_str << " unhandled type_oid=" << type_oid;
#endif
break;
}

View file

@ -76,7 +76,7 @@
#include <boost/math/special_functions/round.hpp>
// stl
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
#include <iostream>
#endif
@ -174,8 +174,9 @@ void agg_renderer<T>::setup(Map const &m)
}
}
}
#ifdef MAPNIK_DEBUG
std::clog << "scale=" << m.scale() << "\n";
#ifdef MAPNIK_LOG
mapnik::log() << "agg_renderer: Scale=" << m.scale();
#endif
}
@ -185,9 +186,8 @@ agg_renderer<T>::~agg_renderer() {}
template <typename T>
void agg_renderer<T>::start_map_processing(Map const& map)
{
#ifdef MAPNIK_DEBUG
std::clog << "start map processing bbox="
<< map.get_current_extent() << "\n";
#ifdef MAPNIK_LOG
mapnik::log() << "agg_renderer: Start map processing bbox=" << map.get_current_extent();
#endif
ras_ptr->clip_box(0,0,width_,height_);
}
@ -195,18 +195,18 @@ void agg_renderer<T>::start_map_processing(Map const& map)
template <typename T>
void agg_renderer<T>::end_map_processing(Map const& )
{
#ifdef MAPNIK_DEBUG
std::clog << "end map processing\n";
#ifdef MAPNIK_LOG
mapnik::log() << "agg_renderer: End map processing";
#endif
}
template <typename T>
void agg_renderer<T>::start_layer_processing(layer const& lay, box2d<double> const& query_extent)
{
#ifdef MAPNIK_DEBUG
std::clog << "start layer processing : " << lay.name() << "\n";
std::clog << "datasource = " << lay.datasource().get() << "\n";
std::clog << "query_extent = " << query_extent << "\n";
#ifdef MAPNIK_LOG
mapnik::log() << "agg_renderer: Start processing layer=" << lay.name();
mapnik::log() << "agg_renderer: -- datasource=" << lay.datasource().get();
mapnik::log() << "agg_renderer: -- query_extent=" << query_extent;
#endif
if (lay.clear_label_cache())
{
@ -218,8 +218,8 @@ void agg_renderer<T>::start_layer_processing(layer const& lay, box2d<double> con
template <typename T>
void agg_renderer<T>::end_layer_processing(layer const&)
{
#ifdef MAPNIK_DEBUG
std::clog << "end layer processing\n";
#ifdef MAPNIK_LOG
mapnik::log() << "agg_renderer: End layer processing";
#endif
}
@ -258,8 +258,6 @@ void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& mar
(*marker.get_vector_data())->attributes());
svg_renderer.render(*ras_ptr, sl, renb, mtx, opacity, bbox);
}
else
{

Some files were not shown because too many files have changed in this diff Show more