Adding an option to make the bbox strategy more agressive. Thanks for completing the tests crschmidt. r=crschmidt,igrcic (closes #1830)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9087 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -24,6 +24,12 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
*/
|
||||
bounds: null,
|
||||
|
||||
/**
|
||||
* Property: resolution
|
||||
* {Float} The current data resolution.
|
||||
*/
|
||||
resolution: null,
|
||||
|
||||
/**
|
||||
* APIProperty: ratio
|
||||
* {Float} The ratio of the data bounds to the viewport bounds (in each
|
||||
@@ -31,6 +37,21 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
*/
|
||||
ratio: 2,
|
||||
|
||||
/**
|
||||
* Property: resFactor
|
||||
* {Float} Optional factor used to determine when previously requested
|
||||
* features are invalid. If set, the resFactor will be compared to the
|
||||
* resolution of the previous request to the current map resolution.
|
||||
* If resFactor > (old / new) and 1/resFactor < (old / new). If you
|
||||
* set a resFactor of 1, data will be requested every time the
|
||||
* resolution changes. If you set a resFactor of 3, data will be
|
||||
* requested if the old resolution is 3 times the new, or if the new is
|
||||
* 3 times the old. If the old bounds do not contain the new bounds
|
||||
* new data will always be requested (with or without considering
|
||||
* resFactor).
|
||||
*/
|
||||
resFactor: null,
|
||||
|
||||
/**
|
||||
* Property: response
|
||||
* {<OpenLayers.Protocol.Response>} The protocol response object returned
|
||||
@@ -107,6 +128,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
var mapBounds = this.getMapBounds();
|
||||
if ((options && options.force) || this.invalidBounds(mapBounds)) {
|
||||
this.calculateBounds(mapBounds);
|
||||
this.resolution = this.layer.map.getResolution();
|
||||
this.triggerRead();
|
||||
}
|
||||
},
|
||||
@@ -130,6 +152,10 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
|
||||
/**
|
||||
* Method: invalidBounds
|
||||
* Determine whether the previously requested set of features is invalid.
|
||||
* This occurs when the new map bounds do not contain the previously
|
||||
* requested bounds. In addition, if <resFactor> is set, it will be
|
||||
* considered.
|
||||
*
|
||||
* Parameters:
|
||||
* mapBounds - {<OpenLayers.Bounds>} the current map extent, will be
|
||||
@@ -142,7 +168,12 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
||||
if(!mapBounds) {
|
||||
mapBounds = this.getMapBounds();
|
||||
}
|
||||
return !this.bounds || !this.bounds.containsBounds(mapBounds);
|
||||
var invalid = !this.bounds || !this.bounds.containsBounds(mapBounds);
|
||||
if(!invalid && this.resFactor) {
|
||||
var ratio = this.resolution / this.layer.map.getResolution();
|
||||
invalid = (ratio >= this.resFactor || ratio <= (1 / this.resFactor));
|
||||
}
|
||||
return invalid;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user