Skip to content
This repository

BBox clipping fails when there's no intersection #127

Closed
artemp opened this Issue · 3 comments

1 participant

Artem Pavlenko
Artem Pavlenko
Owner

When Mapnik is processing layers, it tries to clip the map bbox to the
layer extent... unfortunately it doesn't test for intersection first,
so the "clipped" bbox is completely bogus. The layer is then asked for
features for this bbox, and if you have a lot of small raster layers
then this has a big performance impact.

I've attached a patch that fixes this, and also returns something
slightly more sensible from Envelope.intersects in the same situation.

Artem Pavlenko
Owner

[randomjunk] sorry, can't attach patch properly...
{{{
Trac Error

expected integer, got u'1048576 # 1MB'
}}}

patch is:
{{{

Index: include/mapnik/feature_style_processor.hpp

--- include/mapnik/feature_style_processor.hpp (revision 729)
+++ include/mapnik/feature_style_processor.hpp (working copy)
@@ -123,6 +123,12 @@
// back project layers extent into main map projection
prj_trans.backward(lx0,ly0,lz0);
prj_trans.backward(lx1,ly1,lz1);
+

  • // if no intersection then nothing to do for layer
  • if ( lx0 > ext.maxx() || lx1 < ext.minx() || ly0 > ext.maxy() || ly1 < ext.miny() ) {
  • return;
  • } + // clip query bbox lx0 = std::max(ext.minx(),lx0); ly0 = std::max(ext.miny(),ly0); Index: src/envelope.cpp =================================================================== --- src/envelope.cpp (revision 729) +++ src/envelope.cpp (working copy) @@ -239,14 +239,17 @@ #endif Envelope Envelope::intersect(const EnvelopeType& other) const {
  • if (intersects(other)) {
  • T x0=std::max(minx_,other.minx_);
  •        T y0=std::max(miny_,other.miny_);
    
  •    T x0=std::max(minx_,other.minx_);
    
  • T y0=std::max(miny_,other.miny_);
  • T x1=std::min(maxx_,other.maxx_);
  •        T y1=std::min(maxy_,other.maxy_);
    
  •    T x1=std::min(maxx_,other.maxx_);
    

- T y1=std::min(maxy_,other.maxy_);

  • return Envelope(x0,y0,x1,y1);
  • return Envelope(x0,y0,x1,y1);
  • } else {
  • return Envelope();
  •    }
    

    }

    template
    }}}

Artem Pavlenko
Owner

[artem] Applied, thanks!

Artem Pavlenko
Owner

[springmeyer] will appear in the 0.6.0 release, so back-assigning to 0.6.0 milestone.

Artem Pavlenko artemp closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.