add the concept of portal detail level zoom, separate from map level zoom
this allows us to override the zoom used to retrieve server data, giving options to either retrieve lower zoom levels to reduce the number of requests, or higher zoom levels to retrieve lower level portals from the server
This commit is contained in:
parent
049bc9dbbc
commit
ca76e7ed60
@ -14,10 +14,13 @@ window.requestData = function() {
|
||||
|
||||
var bounds = clampLatLngBounds(map.getBounds());
|
||||
|
||||
var x1 = lngToTile(bounds.getWest(), map.getZoom());
|
||||
var x2 = lngToTile(bounds.getEast(), map.getZoom());
|
||||
var y1 = latToTile(bounds.getNorth(), map.getZoom());
|
||||
var y2 = latToTile(bounds.getSouth(), map.getZoom());
|
||||
//we query the server as if the zoom level was effectiveZoom
|
||||
var z = getPortalDataZoom();
|
||||
|
||||
var x1 = lngToTile(bounds.getWest(), z);
|
||||
var x2 = lngToTile(bounds.getEast(), z);
|
||||
var y1 = latToTile(bounds.getNorth(), z);
|
||||
var y2 = latToTile(bounds.getSouth(), z);
|
||||
|
||||
// will group requests by second-last quad-key quadrant
|
||||
tiles = {};
|
||||
@ -25,16 +28,16 @@ window.requestData = function() {
|
||||
// walk in x-direction, starts right goes left
|
||||
for (var x = x1; x <= x2; x++) {
|
||||
for (var y = y1; y <= y2; y++) {
|
||||
var tile_id = pointToTileId(map.getZoom(), x, y);
|
||||
var tile_id = pointToTileId(z, x, y);
|
||||
var bucket = Math.floor(x / 2) + "" + Math.floor(y / 2);
|
||||
if (!tiles[bucket])
|
||||
tiles[bucket] = [];
|
||||
tiles[bucket].push(generateBoundsParams(
|
||||
tile_id,
|
||||
tileToLat(y + 1, map.getZoom()),
|
||||
tileToLng(x, map.getZoom()),
|
||||
tileToLat(y, map.getZoom()),
|
||||
tileToLng(x + 1, map.getZoom())
|
||||
tileToLat(y + 1, z),
|
||||
tileToLng(x, z),
|
||||
tileToLat(y, z),
|
||||
tileToLng(x + 1, z)
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -43,7 +46,7 @@ window.requestData = function() {
|
||||
portalRenderLimit.init();
|
||||
// finally send ajax requests
|
||||
$.each(tiles, function(ind, tls) {
|
||||
data = { zoom: map.getZoom() };
|
||||
data = { zoom: z };
|
||||
data.boundsParamsList = tls;
|
||||
window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest));
|
||||
});
|
||||
|
@ -228,8 +228,28 @@ window.renderLimitReached = function(ratio) {
|
||||
return param.reached;
|
||||
}
|
||||
|
||||
window.getMinPortalLevel = function() {
|
||||
window.getPortalDataZoom = function() {
|
||||
var z = map.getZoom();
|
||||
|
||||
// limiting the mazimum zoom level for data retrieval reduces the number of requests at high zoom levels
|
||||
// (as all portal data is retrieved at z=17, why retrieve multiple z=18 tiles when fewer z=17 would do?)
|
||||
// a potential downside - we end up requesting more data than we needed from the larger tiles that go off
|
||||
// the window edge.
|
||||
if (z > 17) z=17;
|
||||
|
||||
// we could consider similar zoom-level consolidation, as, e.g. level 16 and 15 both return L1+, always
|
||||
// request zoom 15 tiles. however, there are quirks in the current data stream, where small fields aren't
|
||||
// returned by the server. using larger tiles always would amplify this issue.
|
||||
|
||||
|
||||
//sanity check - should never happen
|
||||
if (z < 0) z=0;
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
window.getMinPortalLevel = function() {
|
||||
var z = getPortalDataZoom();
|
||||
if(z >= 17) return 0;
|
||||
if(z < 0) return 8;
|
||||
var conv = [8,8,8,8,7,7,6,6,5,4,4,3,3,2,2,1,1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user