The bounding box views argument is great!

However, there is just one problem: It only works with the centroid of the geometry. This is problematic if you are working with, for example, a long road that crosses the view-port but who's centroid is outside of it. The road doesn't show up! Or consider a polygon that is partially within the view-port - it is not shown until it's centroid is within the view-port then suddenly it 'pops' into view.

I think that the current argument works fine as it, but we should add additional bounding-box arguments that work on the full bbox of the geometry. What we need to do is check for any of these two circumstances:

1. is the geometry-bbox fully or partially inside the argument-bbox? OR
2. Is the argument-bbox fully or partially inside the geometry-bbox?

We can still make this really really fast since it will still be using fully indexed floats.

Comments

phayes’s picture

Issue summary: View changes

spelling

jeffschuler’s picture

Title: Better bounding boxe argument » Bounding Box arg handling for polygons

Good idea!

I haven't dealt much with polygons up to this point, and was wondering about how they would be affected.

Anyone care to take a stab at this?

clemens.tolboom’s picture

Checking out the geofield.install we could use the bounding box values for geofield.

The logic for views_geojson_bbox_argument::query should then use top, left, bottom, right instead.

I have no shapes just POINTs so cannot check whether that will work. But it is an interesting feature.

clemens.tolboom’s picture

Issue summary: View changes

spelling

pol’s picture

Issue summary: View changes
Status: Active » Fixed

I guess I can close this too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

glbr’s picture

This is a very old issue. Point me elsewhere if more appropriate.

I still have this problem when using views_geojson with leaflet on latest 7.x-1.x dev. Polygon features only appear within the bounding box when their centroid is in the bounding box. I think this should still be open.

Attaching a patch that fixes case 1 above (geometry bbox is partially or fully inside the search bbox). Does not deal with case 2 above.

The following screen shots show the effect of the patch. The 1st shows polygon selection based only on the centroid (latest dev version). The 2nd shows polygon selection when any geometry bbox corner being in the search box causes the geometry to be selected (polygons at the northern and eastern edges of the map have been added). Note that there is an area at the western edge of the map that does not show a polygon - this is an example of case 2 (the search bbox is partially inside the geometry bbox but no corner of the geometry is inside the search bbox). That case still needs work.

Without patch:
Polygon selection without patch

With patch:
Polygon selection with patch

avpaderno’s picture

glbr’s picture

Cumulative patch combining the changes in #5 with fixes to also check if any corner of the search bbox is inside a feature bbox. This is the part of the fix that was discussed but skipped then. With this change the bounding box checks for polygons work well for me. No more odd skipped polygons as shown in the final image above,

jeffschuler’s picture

Status: Closed (fixed) » Needs review
jeffschuler’s picture