[Potlatch-dev] Reducing the amount of data P2 requests

Richard Fairhurst richard at systemeD.net
Wed May 18 11:50:44 BST 2011


I'd like to pick the brains of those of you who are better at maths, 
geometry etc. than I am (probably all of you).

At present, P2 sends a /map request to the server every time it needs 
data for the current viewport. It does cache data (subject to not 
boggling Flash Player by keeping too much around), so if you return to a 
previously loaded area, it won't issue a /map call again.

But if the user is in a densely mapped area, and pans (say) a couple of 
hundred metres northwest into an area not currently loaded, P2 will 
issue a /map call for the new viewport.

It would be much better if it issued two smaller /map calls: one for the 
northern edge, one for the western edge. That way, the 90% of data 
already in memory wouldn't be rerequested.

I'd love to code this but figuring out the maths is beyond me. So can 
anyone supply pseudo-code[1] that:

- given a - an array of already loaded bboxes (each one being left, 
right, top, bottom)
- given b - the bbox we now want to load
- given n - a maximum number of /map calls to make (e.g. 3)
- returns c - an array of no more than n bboxes, covering the areas 
within b which are not in a?

cheers
Richard

[1] real code even better ;)




More information about the Potlatch-dev mailing list