<commit_before>/*****************************************************************************
 * 
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 <NAME>, <NAME>
 *
 * 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
 *
 *****************************************************************************/
//$Id: mapnik_python.cc 27 2005-03-30 21:45:40Z pavlenko $

#include <boost/python.hpp>
#include <boost/get_pointer.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/exception_translator.hpp>

void register_cairo();
void export_color();
void export_coord();
void export_layer();
void export_parameters();
void export_envelope();
void export_query();
void export_image();
void export_image_view();
void export_map();
void export_python();
void export_filter();
void export_rule();
void export_style();
void export_stroke();
void export_feature();
void export_featureset();
void export_datasource();
void export_datasource_cache();
void export_point_symbolizer();
void export_line_symbolizer();
void export_line_pattern_symbolizer();
void export_polygon_symbolizer();
void export_polygon_pattern_symbolizer();
void export_raster_symbolizer();
void export_text_symbolizer();
void export_shield_symbolizer();
void export_font_engine();
void export_projection();

#include <mapnik/map.hpp>
#include <mapnik/agg_renderer.hpp>
#ifdef HAVE_CAIRO
#include <mapnik/cairo_renderer.hpp>
#endif
#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/save_map.hpp>

#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
#include <pycairo.h>
#endif

void render(const mapnik::Map& map,mapnik::Image32& image, unsigned offset_x = 0, unsigned offset_y = 0)
{
    Py_BEGIN_ALLOW_THREADS
    mapnik::agg_renderer<mapnik::Image32> ren(map,image,offset_x, offset_y);
    ren.apply();
    Py_END_ALLOW_THREADS
}

void render2(const mapnik::Map& map,mapnik::Image32& image)
{
    Py_BEGIN_ALLOW_THREADS
    mapnik::agg_renderer<mapnik::Image32> ren(map,image);
    ren.apply();
    Py_END_ALLOW_THREADS
}

#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)

void render3(const mapnik::Map& map,PycairoSurface* surface, unsigned offset_x = 0, unsigned offset_y = 0)
{
    Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
    mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
    ren.apply();
}

void render4(const mapnik::Map& map,PycairoSurface* surface)
{
    Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
    mapnik::cairo_renderer<Cairo::Surface> ren(map,s);
    ren.apply();
}

#endif

void render_tile_to_file(const mapnik::Map& map, 
                         unsigned offset_x, unsigned offset_y,
                         unsigned width, unsigned height,
                         const std::string& file,
                         const std::string& format)
{
    mapnik::Image32 image(width,height);
    render(map,image,offset_x, offset_y);
    mapnik::save_to_file(image.data(),file,format);
}

void render_to_file1(const mapnik::Map& map,
                    const std::string& filename,
                    const std::string& format)
{
   mapnik::Image32 image(map.getWidth(),map.getHeight());
   render(map,image,0,0);
   mapnik::save_to_file(image,filename,format); 
}

void render_to_file2(const mapnik::Map& map,<commit_msg>+ enable multiple python threads with Cairo rennderer patch from jonb<commit_after>/*****************************************************************************
 * 
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 <NAME>, <NAME>
 *
 * 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
 *
 *****************************************************************************/
//$Id: mapnik_python.cc 27 2005-03-30 21:45:40Z pavlenko $

#include <boost/python.hpp>
#include <boost/get_pointer.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/exception_translator.hpp>

void register_cairo();
void export_color();
void export_coord();
void export_layer();
void export_parameters();
void export_envelope();
void export_query();
void export_image();
void export_image_view();
void export_map();
void export_python();
void export_filter();
void export_rule();
void export_style();
void export_stroke();
void export_feature();
void export_featureset();
void export_datasource();
void export_datasource_cache();
void export_point_symbolizer();
void export_line_symbolizer();
void export_line_pattern_symbolizer();
void export_polygon_symbolizer();
void export_polygon_pattern_symbolizer();
void export_raster_symbolizer();
void export_text_symbolizer();
void export_shield_symbolizer();
void export_font_engine();
void export_projection();

#include <mapnik/map.hpp>
#include <mapnik/agg_renderer.hpp>
#ifdef HAVE_CAIRO
#include <mapnik/cairo_renderer.hpp>
#endif
#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/save_map.hpp>

#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
#include <pycairo.h>
#endif

void render(const mapnik::Map& map,mapnik::Image32& image, unsigned offset_x = 0, unsigned offset_y = 0)
{
    Py_BEGIN_ALLOW_THREADS
    mapnik::agg_renderer<mapnik::Image32> ren(map,image,offset_x, offset_y);
    ren.apply();
    Py_END_ALLOW_THREADS
}

void render2(const mapnik::Map& map,mapnik::Image32& image)
{
    Py_BEGIN_ALLOW_THREADS
    mapnik::agg_renderer<mapnik::Image32> ren(map,image);
    ren.apply();
    Py_END_ALLOW_THREADS
}

#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)

void render3(const mapnik::Map& map,PycairoSurface* surface, unsigned offset_x = 0, unsigned offset_y = 0)
{
    Py_BEGIN_ALLOW_THREADS
    Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
    mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
    ren.apply();
    Py_END_ALLOW_THREADS
}

void render4(const mapnik::Map& map,PycairoSurface* surface)
{
    Py_BEGIN_ALLOW_THREADS
    Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
    mapnik::cairo_renderer<Cairo::Surface> ren(map,s);
    ren.apply();
    Py_END_ALLOW_THREADS
}

#endif

void render_tile_to_file(const mapnik::Map& map, 
                         unsigned offset_x, unsigned offset_y,
                         unsigned width, unsigned height,
                         const std::string& file,
                         const std::string& format)
{
    mapnik::Image32 image(width,height);
    render(map,image,offset_x, offset_y);
    mapnik::save_to_file(image.data(),file,format);
}

void render_to_file1(const mapnik::Map& map,
                    const std::string& filename,
                    const std::string& format)
{
   mapnik::Image32 image(map.getWidth(),map.getHeight());
   render(map,image,0,0);
   mapnik::save_to_file(image,filename,format); 
}

void render_to_file2(const mapnik::Map& map,
{'fraction_non_alphanumeric': 0.14713603818615753, 'fraction_numerical': 0.013365155131264916, 'mean_word_length': 5.077592458303118, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3607769', 'n_tokens_mistral': 2696, 'n_tokens_neox': 2578, 'n_words': 671}