diff --git a/datasources/postgis/postgisfs.cpp b/datasources/postgis/postgisfs.cpp index 741492228..788e7d157 100644 --- a/datasources/postgis/postgisfs.cpp +++ b/datasources/postgis/postgisfs.cpp @@ -50,7 +50,7 @@ Feature* PostgisFeatureset::next() if (geom) { feature=new Feature(id,geom); - + feature->reserve_props(num_attrs_); unsigned start=2; for (unsigned pos=0;pos::next() } if (attr_ids_.size()) { + f->reserve_props(attr_ids_.size()); shape_.dbf().move_to(shape_.id_); std::vector::const_iterator pos=attr_ids_.begin(); while (pos!=attr_ids_.end()) { try { - shape_.dbf().add_attribute(*pos,f);//TODO optimize!!! + shape_.dbf().add_attribute(*pos,f); } catch (...) { diff --git a/include/colorcube.hpp b/include/colorcube.hpp index ee546bc91..c20a525ea 100644 --- a/include/colorcube.hpp +++ b/include/colorcube.hpp @@ -18,7 +18,6 @@ //$Id$ -#include "mapnik.hpp" #include #ifndef COLORCUBE_HPP diff --git a/include/feature.hpp b/include/feature.hpp index 6d49f3f4f..698e219b0 100644 --- a/include/feature.hpp +++ b/include/feature.hpp @@ -86,7 +86,11 @@ namespace mapnik { return raster_; } - + void reserve_props(unsigned n) + { + props_.reserve(n); + } + void add_property(int v) { return props_.push_back(value(v)); diff --git a/include/image_data.hpp b/include/image_data.hpp index f373f0339..b4778f0a9 100644 --- a/include/image_data.hpp +++ b/include/image_data.hpp @@ -21,6 +21,8 @@ #ifndef IMAGE_DATA_HPP #define IMAGE_DATA_HPP +#include + namespace mapnik { template class ImageData diff --git a/include/image_reader.hpp b/include/image_reader.hpp index 5affe0831..86e2b09a9 100644 --- a/include/image_reader.hpp +++ b/include/image_reader.hpp @@ -21,10 +21,11 @@ #ifndef IMAGE_READER_HPP #define IMAGE_READER_HPP -#include "mapnik.hpp" +#include "image_data.hpp" #include #include + namespace mapnik { class ImageReaderException : public std::exception diff --git a/include/line_symbolizer.hpp b/include/line_symbolizer.hpp index 1dd1b9db5..1be7e8a0c 100644 --- a/include/line_symbolizer.hpp +++ b/include/line_symbolizer.hpp @@ -47,8 +47,8 @@ #include "symbolizer.hpp" #include "stroke.hpp" -#include "line_aa.hpp" -#include "scanline_aa.hpp" +//#include "line_aa.hpp" +//#include "scanline_aa.hpp" namespace mapnik { diff --git a/include/local_datasource.hpp b/include/local_datasource.hpp index 9b8de74b0..9c0bab8d8 100644 --- a/include/local_datasource.hpp +++ b/include/local_datasource.hpp @@ -21,7 +21,6 @@ #ifndef LOCAL_DATASOURCE_HPP #define LOCAL_DATASOURCE_HPP -#include "mapnik.hpp" #include namespace mapnik diff --git a/include/polygon_symbolizer.hpp b/include/polygon_symbolizer.hpp index 967f6b514..d5f4ef645 100644 --- a/include/polygon_symbolizer.hpp +++ b/include/polygon_symbolizer.hpp @@ -22,8 +22,18 @@ #define POLYGON_SYMBOLIZER_HPP #include "symbolizer.hpp" -#include "scanline_aa.hpp" -#include "line_aa.hpp" +#include "image_reader.hpp" +//#include "scanline_aa.hpp" +//#include "line_aa.hpp" +#include "agg_basics.h" +#include "agg_rendering_buffer.h" +#include "agg_rasterizer_scanline_aa.h" +#include "agg_scanline_p.h" +#include "agg_scanline_u.h" +#include "agg_renderer_scanline.h" +#include "agg_pixfmt_rgba.h" +#include "agg_path_storage.h" +#include "agg_span_pattern_rgba.h" namespace mapnik { @@ -40,15 +50,102 @@ namespace mapnik void render(geometry_type& geom,Image32& image) const { - ScanlineRasterizerAA rasterizer(image); - rasterizer.render(geom,fill_); + //ScanlineRasterizerAA rasterizer(image); + //rasterizer.render(geom,fill_); + typedef agg::renderer_base ren_base; + typedef agg::renderer_scanline_aa_solid renderer; + agg::row_ptr_cache buf(image.raw_data(),image.width(),image.height(), + image.width()*4); + agg::pixfmt_rgba32 pixf(buf); + ren_base renb(pixf); + + double r=fill_.red()/255.0; + double g=fill_.green()/255.0; + double b=fill_.blue()/255.0; + + renderer ren(renb); + + agg::rasterizer_scanline_aa<> ras; + agg::scanline_u8 sl; + ras.clip_box(0,0,image.width(),image.height()); + ras.add_path(geom); + ren.color(agg::rgba(r, g, b, 1.0)); + agg::render_scanlines(ras, sl, ren); } private: polygon_symbolizer(const polygon_symbolizer&); - polygon_symbolizer& operator=(const polygon_symbolizer&); - + polygon_symbolizer& operator=(const polygon_symbolizer&); }; + + struct pattern_symbolizer : public symbolizer + { + private: + ImageData32 pattern_; + public: + pattern_symbolizer(std::string const& file, + std::string const& type, + unsigned width,unsigned height) + : symbolizer(), + pattern_(width,height) + { + try + { + std::auto_ptr reader(get_image_reader(type,file)); + std::cout<<"image width="<width()< ren_base; + typedef agg::renderer_scanline_aa_solid renderer_solid; + + agg::row_ptr_cache buf(image.raw_data(),image.width(),image.height(), + image.width()*4); + agg::pixfmt_rgba32 pixf(buf); + ren_base renb(pixf); + + unsigned w=pattern_.width(); + unsigned h=pattern_.height(); + agg::row_ptr_cache pattern_rbuf((agg::int8u*)pattern_.getBytes(),w,h,w*4); + + typedef agg::wrap_mode_repeat wrap_x_type; + typedef agg::wrap_mode_repeat wrap_y_type; + typedef agg::span_pattern_rgba span_gen_type; + typedef agg::renderer_scanline_aa renderer_type; + + unsigned offset_x = 0; + unsigned offset_y = 0; + agg::span_allocator sa; + span_gen_type sg(sa, pattern_rbuf, offset_x, offset_y); + renderer_type rp(renb, sg); + + agg::rasterizer_scanline_aa<> ras; + agg::scanline_u8 sl; + ras.clip_box(0,0,image.width(),image.height()); + ras.add_path(geom); + //ren.color(agg::rgba(r, g, b, 1.0)); + agg::render_scanlines(ras, sl, rp); + + } + + private: + pattern_symbolizer(const pattern_symbolizer&); + pattern_symbolizer& operator=(const pattern_symbolizer&); + }; + } #endif // POLYGON_SYMBOLIZER_HPP diff --git a/python/mapnik_python.cpp b/python/mapnik_python.cpp index 4aad6858e..d070bab86 100644 --- a/python/mapnik_python.cpp +++ b/python/mapnik_python.cpp @@ -98,6 +98,10 @@ ref_ptr create_polygon_symbolizer(const Color& fill) return ref_ptr(new polygon_symbolizer(fill)); } +ref_ptr create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h) +{ + return ref_ptr(new pattern_symbolizer(file,"png",w,h)); +} BOOST_PYTHON_MODULE(mapnik) { @@ -136,7 +140,7 @@ BOOST_PYTHON_MODULE(mapnik) def("line_symbolizer",&create_line_symbolizer); def("line_symbolizer",&create_line_symbolizer2); def("polygon_symbolizer",&create_polygon_symbolizer); - + def("polygon_symbolizer",&create_polygon_symbolizer2); register_ptr_to_python >(); register_ptr_to_python(); } diff --git a/src/image_reader.cpp b/src/image_reader.cpp index f498dce34..4f68602a1 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -20,6 +20,8 @@ #include "image_reader.hpp" +#include "factory.hpp" + namespace mapnik { typedef factory +#include namespace mapnik { diff --git a/src/render.cpp b/src/render.cpp index 90fded950..5fff7cb4c 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -32,6 +32,7 @@ #include "line_symbolizer.hpp" #include "query.hpp" #include "feature_layer_desc.hpp" +#include "attribute_collector.hpp" #include "property_index.hpp" #include @@ -126,6 +127,7 @@ namespace mapnik (*symIter)->render(*geom,image); ++symIter; } + break;// not sure !! } ++itr; }