check for valid datasource in the main loop

This commit is contained in:
Artem Pavlenko 2005-11-30 00:21:07 +00:00
parent 64427961d7
commit 7f4df91371
2 changed files with 22 additions and 15 deletions

View file

@ -39,9 +39,15 @@ namespace mapnik
static void render(const Map& map,Image& image); static void render(const Map& map,Image& image);
private: private:
Renderer(); Renderer();
static void render_vector_layer(const Layer& l,unsigned width,unsigned height, static void render_vector_layer(datasource_p const& ds,
std::vector<std::string> const& ,
unsigned width,
unsigned height,
const Envelope<double>& bbox,Image& image); const Envelope<double>& 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<std::string> const& namedStyles,
unsigned width,
unsigned height,
const Envelope<double>& bbox,Image& image); const Envelope<double>& bbox,Image& image);
}; };
} }

View file

@ -43,13 +43,12 @@ namespace mapnik
{ {
template <typename Image> template <typename Image>
void Renderer<Image>::render_vector_layer(const Layer& l,unsigned width,unsigned height, void Renderer<Image>::render_vector_layer(datasource_p const& ds,
const Envelope<double>& bbox,Image& image) std::vector<std::string> const& namedStyles,
unsigned width,unsigned height,
const Envelope<double>& bbox,Image& image)
{ {
const datasource_p& ds=l.datasource();
if (!ds) return;
CoordTransform t(width,height,bbox); CoordTransform t(width,height,bbox);
std::vector<std::string> const& namedStyles=l.styles();
std::vector<std::string>::const_iterator stylesIter=namedStyles.begin(); std::vector<std::string>::const_iterator stylesIter=namedStyles.begin();
while (stylesIter!=namedStyles.end()) while (stylesIter!=namedStyles.end())
{ {
@ -174,11 +173,11 @@ namespace mapnik
} }
template <typename Image> template <typename Image>
void Renderer<Image>::render_raster_layer(const Layer& l,unsigned width,unsigned height, void Renderer<Image>::render_raster_layer(datasource_p const& ds,
const Envelope<double>& bbox,Image& image) std::vector<std::string> const& ,
unsigned width,unsigned height,
const Envelope<double>& bbox,Image& image)
{ {
const datasource_p& ds=l.datasource();
if (!ds) return;
query q(bbox,width,height); query q(bbox,width,height);
featureset_ptr fs=ds->features(q); featureset_ptr fs=ds->features(q);
if (fs) if (fs)
@ -216,13 +215,15 @@ namespace mapnik
const Layer& l=map.getLayer(n); const Layer& l=map.getLayer(n);
if (l.isVisible(scale)) // TODO: extent check 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);
} }
} }
} }