From 67d4fbbe0311d8355926e5d40f19f4c06436fb03 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Mon, 25 Feb 2013 08:17:10 +0100 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20render=20resources=20outside=20?= =?UTF-8?q?the=20view=20port=20when=20the=20render=20limit=20is=20about=20?= =?UTF-8?q?to=20be=20hit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/utils_misc.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/code/utils_misc.js b/code/utils_misc.js index 48704d0c..e208fcc0 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -117,6 +117,7 @@ window.getPaddedBounds = function() { window._storedPaddedBounds = null; }); } + if(renderLimitReached(0.7)) return window.map.getBounds(); if(window._storedPaddedBounds) return window._storedPaddedBounds; var p = window.map.getBounds().pad(VIEWPORT_PAD_RATIO); @@ -124,10 +125,16 @@ window.getPaddedBounds = function() { return p; } -window.renderLimitReached = function() { - if(Object.keys(portals).length >= MAX_DRAWN_PORTALS) return true; - if(Object.keys(links).length >= MAX_DRAWN_LINKS) return true; - if(Object.keys(fields).length >= MAX_DRAWN_FIELDS) return true; +// returns true if the render limit has been reached. The default ratio +// is 1, which means it will tell you if there are more items drawn than +// acceptable. A value of 0.9 will tell you if 90% of the amount of +// acceptable entities have been drawn. You can use this to heuristi- +// cally detect if the render limit will be hit. +window.renderLimitReached = function(ratio) { + ratio = ratio || 1; + if(Object.keys(portals).length*ratio >= MAX_DRAWN_PORTALS) return true; + if(Object.keys(links).length*ratio >= MAX_DRAWN_LINKS) return true; + if(Object.keys(fields).length*ratio >= MAX_DRAWN_FIELDS) return true; return false; }