OpenLayers OpenLayers

Changeset 8000

Show
Ignore:
Timestamp:
09/11/08 13:39:41 (3 months ago)
Author:
tschaub
Message:

Adding a BBOX strategy. This triggers requests for data within a bounding box. When the map bounds invalidate previous data bounds, another request is issued. Reads are triggered with a spatial filter, and protocols that understand how to deal with filters may serialize the filter to request a subset of the data collection. The HTTP protocol understands one filter - the bbox filter. So the BBOX strategy can be used in conjunction with the HTTP protocol to request data via http in a bounding box. Thanks for the collaboration and tests Eric. r=elemoine,crschmidt (#1731)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers.js

    r7971 r8000  
    186186            "OpenLayers/Strategy.js", 
    187187            "OpenLayers/Strategy/Fixed.js", 
     188            "OpenLayers/Strategy/BBOX.js", 
    188189            "OpenLayers/Protocol.js", 
    189190            "OpenLayers/Protocol/HTTP.js", 
  • trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js

    r7960 r8000  
    113113     *     This object is modified and should not be reused. 
    114114     * 
     115     * Valid options: 
     116     * url - {String} Url for the request. 
     117     * params - {Object} Parameters to get serialized as a query string. 
     118     * headers - {Object} Headers to be set on the request. 
     119     * filter - {<OpenLayers.Filter.BBOX>} If a bbox filter is sent, it will be 
     120     *     serialized according to the OpenSearch Geo extension 
     121     *     (bbox=minx,miny,maxx,maxy).  Note that a BBOX filter as the child 
     122     *     of a logical filter will not be serialized. 
     123     * 
    115124     * Returns: 
    116125     * {<OpenLayers.Protocol.Response>} A response object, whose "priv" property 
     
    122131        options = OpenLayers.Util.applyDefaults(options, this.options); 
    123132        var resp = new OpenLayers.Protocol.Response({requestType: "read"}); 
     133         
     134        if(options.filter && options.filter instanceof OpenLayers.Filter.Spatial) { 
     135            if(options.filter.type == OpenLayers.Filter.Spatial.BBOX) { 
     136                options.params = OpenLayers.Util.extend(options.params, { 
     137                    bbox: options.filter.value.toArray() 
     138                }); 
     139            } 
     140        } 
    124141 
    125142        resp.priv = OpenLayers.Request.GET({ 
  • trunk/openlayers/tests/Protocol/HTTP.html

    r7940 r8000  
    103103 
    104104        var resp = protocol.read(readOptions); 
     105    } 
     106 
     107    function test_read_bbox(t) { 
     108        t.plan(1); 
     109        var protocol = new OpenLayers.Protocol.HTTP(); 
     110 
     111        // fake XHR request object 
     112        var request = {'status': 200}; 
     113 
     114        var _get = OpenLayers.Request.GET; 
     115 
     116        var bounds = new OpenLayers.Bounds(1, 2, 3, 4); 
     117        var filter = new OpenLayers.Filter.Spatial({ 
     118            type: OpenLayers.Filter.Spatial.BBOX, 
     119            value: bounds, 
     120            projection: "foo" 
     121        }); 
     122         
     123        OpenLayers.Request.GET = function(options) { 
     124            t.eq(options.params['bbox'].toString(), bounds.toArray().toString(), 
     125                'GET called with bbox filter in params'); 
     126            return request; 
     127        }; 
     128 
     129        var resp = protocol.read({filter: filter}); 
    105130    } 
    106131 
  • trunk/openlayers/tests/list-tests.html

    r7952 r8000  
    126126    <li>Strategy.html</li> 
    127127    <li>Strategy/Fixed.html</li> 
     128    <li>Strategy/BBOX.html</li> 
    128129    <li>Style.html</li> 
    129130    <li>StyleMap.html</li>