From 7f4df913713222b846a42e6e90d274a3b92213a0 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 30 Nov 2005 00:21:07 +0000 Subject: [PATCH] check for valid datasource in the main loop --- include/render.hpp | 10 ++++++++-- src/render.cpp | 27 ++++++++++++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/render.hpp b/include/render.hpp index ff11c762c..ee2f328ef 100644 --- a/include/render.hpp +++ b/include/render.hpp @@ -39,9 +39,15 @@ namespace mapnik static void render(const Map& map,Image& image); private: Renderer(); - static void render_vector_layer(const Layer& l,unsigned width,unsigned height, + static void render_vector_layer(datasource_p const& ds, + std::vector const& , + unsigned width, + unsigned height, const Envelope& bbox,Image& image); - static void render_raster_layer(const Layer& l,unsigned width,unsigned height, + static void render_raster_layer(datasource_p const& ds, + std::vector const& namedStyles, + unsigned width, + unsigned height, const Envelope& bbox,Image& image); }; } diff --git a/src/render.cpp b/src/render.cpp index 80c95c91e..57a2960ff 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -43,13 +43,12 @@ namespace mapnik { template - void Renderer::render_vector_layer(const Layer& l,unsigned width,unsigned height, - const Envelope& bbox,Image& image) + void Renderer::render_vector_layer(datasource_p const& ds, + std::vector const& namedStyles, + unsigned width,unsigned height, + const Envelope& bbox,Image& image) { - const datasource_p& ds=l.datasource(); - if (!ds) return; CoordTransform t(width,height,bbox); - std::vector const& namedStyles=l.styles(); std::vector::const_iterator stylesIter=namedStyles.begin(); while (stylesIter!=namedStyles.end()) { @@ -174,11 +173,11 @@ namespace mapnik } template - void Renderer::render_raster_layer(const Layer& l,unsigned width,unsigned height, - const Envelope& bbox,Image& image) + void Renderer::render_raster_layer(datasource_p const& ds, + std::vector const& , + unsigned width,unsigned height, + const Envelope& bbox,Image& image) { - const datasource_p& ds=l.datasource(); - if (!ds) return; query q(bbox,width,height); featureset_ptr fs=ds->features(q); if (fs) @@ -216,13 +215,15 @@ namespace mapnik const Layer& l=map.getLayer(n); if (l.isVisible(scale)) // TODO: extent check { - if (l.datasource()->type() == datasource::Vector) + const datasource_p& ds=l.datasource(); + if (!ds) continue; + if (ds->type() == datasource::Vector) { - render_vector_layer(l,width,height,extent,image); + render_vector_layer(ds,l.styles(),width,height,extent,image); } - else if (l.datasource()->type() == datasource::Raster) + else if (ds->type() == datasource::Raster) { - render_raster_layer(l,width,height,extent,image); + render_raster_layer(ds,l.styles(),width,height,extent,image); } } }