Ticket #808: remote_loading.patch
| File remote_loading.patch, 15.1 kB (added by crschmidt, 1 year ago) |
|---|
-
tests/owls.xml
old new 1 <?xml version='1.0' encoding="ISO-8859-1" ?> 2 <wfs:FeatureCollection 3 xmlns:bsc="http://www.bsc-eoc.org/bsc" 4 xmlns:wfs="http://www.opengis.net/wfs" 5 xmlns:gml="http://www.opengis.net/gml" 6 xmlns:ogc="http://www.opengis.net/ogc" 7 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 8 xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd 9 http://www.bsc-eoc.org/bsc http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=OWLS&OUTPUTFORMAT=XMLSCHEMA"> 10 <gml:boundedBy> 11 <gml:Box srsName="EPSG:4326"> 12 <gml:coordinates>-89.817223,45.005555 -74.755001,51.701388</gml:coordinates> 13 </gml:Box> 14 </gml:boundedBy> 15 <gml:featureMember><bsc:OWLS> 16 <gml:boundedBy> 17 <gml:Box srsName="EPSG:4326"> 18 <gml:coordinates>-79.771668,45.891110 -79.771668,45.891110</gml:coordinates> 19 </gml:Box> 20 </gml:boundedBy> 21 <bsc:msGeometry> 22 <gml:Point srsName="EPSG:4326"> 23 <gml:coordinates>-79.771668,45.891110</gml:coordinates> 24 </gml:Point> 25 </bsc:msGeometry> 26 </bsc:OWLS> 27 </gml:featureMember> 28 <gml:featureMember> 29 <bsc:OWLS> 30 <gml:boundedBy> 31 <gml:Box srsName="EPSG:4326"> 32 <gml:coordinates>-83.755834,46.365277 -83.755834,46.365277</gml:coordinates> 33 </gml:Box> 34 </gml:boundedBy> 35 <bsc:owlname>owl</bsc:owlname> 36 <bsc:msGeometry> 37 <gml:Point srsName="EPSG:4326"> 38 <gml:coordinates>-83.755834,46.365277</gml:coordinates> 39 </gml:Point> 40 </bsc:msGeometry> 41 </bsc:OWLS> 42 </gml:featureMember> 43 <gml:featureMember> 44 <bsc:OWLS> 45 <gml:boundedBy> 46 <gml:Box srsName="EPSG:4326"> 47 <gml:coordinates>-83.808612,46.175277 -83.808612,46.175277</gml:coordinates> 48 </gml:Box> 49 </gml:boundedBy> 50 <bsc:msGeometry> 51 <gml:Point srsName="EPSG:4326"> 52 <gml:coordinates>-83.808612,46.175277</gml:coordinates> 53 </gml:Point> 54 </bsc:msGeometry> 55 </bsc:OWLS> 56 </gml:featureMember> 57 <gml:featureMember> 58 <bsc:OWLS> 59 <gml:boundedBy> 60 <gml:Box srsName="EPSG:4326"> 61 <gml:coordinates>-84.111112,46.309166 -84.111112,46.309166</gml:coordinates> 62 </gml:Box> 63 </gml:boundedBy> 64 <bsc:msGeometry> 65 <gml:Point srsName="EPSG:4326"> 66 <gml:coordinates>-84.111112,46.309166</gml:coordinates> 67 </gml:Point> 68 </bsc:msGeometry> 69 </bsc:OWLS> 70 </gml:featureMember> 71 <gml:featureMember> 72 <bsc:OWLS> 73 <gml:boundedBy> 74 <gml:Box srsName="EPSG:4326"> 75 <gml:coordinates>-83.678612,46.821110 -83.678612,46.821110</gml:coordinates> 76 </gml:Box> 77 </gml:boundedBy> 78 <bsc:msGeometry> 79 <gml:Point srsName="EPSG:4326"> 80 <gml:coordinates>-83.678612,46.821110</gml:coordinates> 81 </gml:Point> 82 </bsc:msGeometry> 83 </bsc:OWLS> 84 </gml:featureMember> 85 <gml:featureMember> 86 <bsc:OWLS> 87 <gml:boundedBy> 88 <gml:Box srsName="EPSG:4326"> 89 <gml:coordinates>-83.664445,46.518888 -83.664445,46.518888</gml:coordinates> 90 </gml:Box> 91 </gml:boundedBy> 92 <bsc:msGeometry> 93 <gml:Point srsName="EPSG:4326"> 94 <gml:coordinates>-83.664445,46.518888</gml:coordinates> 95 </gml:Point> 96 </bsc:msGeometry> 97 </bsc:OWLS> 98 </gml:featureMember> 99 <gml:featureMember> 100 <bsc:OWLS> 101 <gml:boundedBy> 102 <gml:Box srsName="EPSG:4326"> 103 <gml:coordinates>-80.613334,46.730277 -80.613334,46.730277</gml:coordinates> 104 </gml:Box> 105 </gml:boundedBy> 106 <bsc:msGeometry> 107 <gml:Point srsName="EPSG:4326"> 108 <gml:coordinates>-80.613334,46.730277</gml:coordinates> 109 </gml:Point> 110 </bsc:msGeometry> 111 </bsc:OWLS> 112 </gml:featureMember> 113 <gml:featureMember> 114 <bsc:OWLS> 115 <gml:boundedBy> 116 <gml:Box srsName="EPSG:4326"> 117 <gml:coordinates>-79.676946,45.428054 -79.676946,45.428054</gml:coordinates> 118 </gml:Box> 119 </gml:boundedBy> 120 <bsc:msGeometry> 121 <gml:Point srsName="EPSG:4326"> 122 <gml:coordinates>-79.676946,45.428054</gml:coordinates> 123 </gml:Point> 124 </bsc:msGeometry> 125 </bsc:OWLS> 126 </gml:featureMember> 127 <gml:featureMember> 128 <bsc:OWLS> 129 <gml:boundedBy> 130 <gml:Box srsName="EPSG:4326"> 131 <gml:coordinates>-83.853056,46.236944 -83.853056,46.236944</gml:coordinates> 132 </gml:Box> 133 </gml:boundedBy> 134 <bsc:msGeometry> 135 <gml:Point srsName="EPSG:4326"> 136 <gml:coordinates>-83.853056,46.236944</gml:coordinates> 137 </gml:Point> 138 </bsc:msGeometry> 139 </bsc:OWLS> 140 </gml:featureMember> 141 <gml:featureMember> 142 <bsc:OWLS> 143 <gml:boundedBy> 144 <gml:Box srsName="EPSG:4326"> 145 <gml:coordinates>-82.289167,45.896388 -82.289167,45.896388</gml:coordinates> 146 </gml:Box> 147 </gml:boundedBy> 148 <bsc:msGeometry> 149 <gml:Point srsName="EPSG:4326"> 150 <gml:coordinates>-82.289167,45.896388</gml:coordinates> 151 </gml:Point> 152 </bsc:msGeometry> 153 </bsc:OWLS> 154 </gml:featureMember> 155 </wfs:FeatureCollection> 156 -
tests/Layer/test_GML.html
old new 5 5 6 6 var name = "GML Layer"; 7 7 8 var gml = "./owls.xml"; 9 10 // if this test is running online, different rules apply 11 var isMSIE = (navigator.userAgent.indexOf("MSIE") > -1); 12 if (isMSIE) { 13 gml = "." + gml; 14 } 15 8 16 function test_01_Layer_GML_constructor(t) { 9 17 t.plan(3); 10 18 … … 14 22 t.ok(layer.renderer.CLASS_NAME, "layer has a renderer"); 15 23 16 24 } 25 function test_Layer_GML_events(t) { 26 t.plan(3); 27 28 var layer = new OpenLayers.Layer.GML(name, gml, {isBaseLayer: true}); 29 layer.events.register("loadstart", layer, function() { t.ok(true, "loadstart called.")}); 30 layer.events.register("loadend", layer, function() { t.ok(true, "loadend called.")}); 31 var map = new OpenLayers.Map("map"); 32 map.addLayer(layer); 33 map.zoomToMaxExtent(); 34 t.delay_call(1, function() { t.ok(true, "waited for 1s"); } ); 35 36 } 17 37 </script> 18 38 </head> 19 39 <body> -
tests/Layer/test_Text.html
old new 95 95 t.eq(map.popups.length, 0, "no popup on second marker"); 96 96 }); 97 97 } 98 function test_Layer_Text_loadend_Event(t) { 99 t.plan(2); 100 layer = new OpenLayers.Layer.Text('Test Layer', {location:datafile}); 101 t.delay_call(2, function() { 102 layer.events.register('loadend', layer, function() { t.ok(true, "Loadend event fired"); }); 103 layer.parseData({'responseText':''}); 104 t.ok(true, "waited for load"); }); 105 } 98 106 99 107 function test_99_Layer_Text_destroy (t) { 100 108 t.plan( 1 ); -
tests/Layer/test_GeoRSS.html
old new 71 71 map.addLayer(layer); 72 72 map.setCenter(new OpenLayers.LonLat(0,0),0); 73 73 var event = {}; 74 t.delay_call( 1, function() {74 t.delay_call( 2, function() { 75 75 t.ok(layer.markers[0].events, "First marker has an events object"); 76 76 t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object"); 77 77 layer.markers[0].events.triggerEvent('click', event); … … 150 150 t.eq(otherLayer.markers[0].icon.url, the_icon.url,"The layer with an icon has that icon."); 151 151 }); 152 152 } 153 function test_Layer_GeoRSS_loadend_Event(t) { 154 var browserCode = OpenLayers.Util.getBrowserName(); 155 if (browserCode == "msie") { 156 t.plan(1); 157 t.ok(true, "IE fails the GeoRSS test. This could probably be fixed by someone with enough energy to fix it."); 158 } else { 159 t.plan(2); 160 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt); 161 t.delay_call(2, function() { 162 layer.events.register('loadend', layer, function() { t.ok(true, "Loadend event fired"); }); 163 layer.parseData({'responseText':'<xml xmlns="http://example.com"><title> </title></xml>'}); 164 t.ok(true, "waited for load"); }); 165 } 166 } 153 167 154 168 function test_99_Layer_GeoRSS_destroy (t) { 155 169 t.plan( 1 ); -
lib/OpenLayers/Tile/WFS.js
old new 75 75 */ 76 76 draw:function() { 77 77 if (OpenLayers.Tile.prototype.draw.apply(this, arguments)) { 78 if (this.isLoading) { 79 //if we're already loading, send 'reload' instead of 'loadstart'. 80 this.events.triggerEvent("reload"); 81 } else { 82 this.isLoading = true; 83 this.events.triggerEvent("loadstart"); 84 } 78 85 this.loadFeaturesForRegion(this.requestSuccess); 79 86 } 80 87 }, … … 115 122 var resultFeatures = OpenLayers.Ajax.getElementsByTagNameNS(doc, "http://www.opengis.net/gml","gml", "featureMember"); 116 123 this.addResults(resultFeatures); 117 124 } 125 if (this.isLoading) { 126 this.isLoading = false; 127 this.events.triggerEvent("loadend"); 128 } 118 129 }, 119 130 120 131 /** -
lib/OpenLayers/Layer/GML.js
old new 81 81 // loaded after the GML is paited. 82 82 // See http://trac.openlayers.org/ticket/404 83 83 if(this.visibility && !this.loaded){ 84 this.events.triggerEvent("loadstart"); 84 85 this.loadGML(); 85 86 } 86 87 }, … … 113 114 114 115 var gml = this.format ? new this.format() : new OpenLayers.Format.GML(); 115 116 this.addFeatures(gml.read(doc)); 117 this.events.triggerEvent("loadend"); 116 118 }, 117 119 118 120 /** … … 125 127 */ 126 128 requestFailure: function(request) { 127 129 alert("Error in loading GML file "+this.url); 130 this.events.triggerEvent("loadend"); 128 131 }, 129 132 130 133 CLASS_NAME: "OpenLayers.Layer.GML" -
lib/OpenLayers/Layer/Text.js
old new 47 47 OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); 48 48 this.features = new Array(); 49 49 if (this.location != null) { 50 this.events.triggerEvent("loadstart"); 50 51 OpenLayers.loadURL(this.location, null, this, this.parseData); 51 52 } 52 53 }, … … 150 151 } 151 152 } 152 153 } 154 this.events.triggerEvent("loadend"); 153 155 }, 154 156 155 157 /** -
lib/OpenLayers/Layer/WFS.js
old new 29 29 */ 30 30 ratio: 2, 31 31 32 /** 33 * Property: numLoadingTiles 34 * {Int} The number of tiles outstanding. 35 */ 36 numLoadingTiles: 0, 37 32 38 /** 33 39 * Property: DEFAULT_PARAMS 34 40 * {Object} Hashtable of default key/value parameters … … 225 231 if (!this.tile) { 226 232 this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds, 227 233 url, tileSize); 234 this.addTileMonitoringHooks(this.tile); 228 235 this.tile.draw(); 229 236 } else { 230 237 if (this.vectorMode) { … … 234 241 this.clearMarkers(); 235 242 } 236 243 this.tile.destroy(); 244 this.removeTileMonitoringHooks(this.tile); 237 245 238 246 this.tile = null; 239 247 this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds, … … 243 251 } 244 252 }, 245 253 254 /** 255 * Method: addTileMonitoringHooks 256 * This function takes a tile as input and adds the appropriate hooks to 257 * the tile so that the layer can keep track of the loading tiles. 258 * 259 * Parameters: 260 * tile - {<OpenLayers.Tile>} 261 */ 262 addTileMonitoringHooks: function(tile) { 263 tile.onLoadStart = function() { 264 //if that was first tile then trigger a 'loadstart' on the layer 265 if (this.numLoadingTiles == 0) { 266 this.events.triggerEvent("loadstart"); 267 } 268 this.numLoadingTiles++; 269 }; 270 tile.events.register("loadstart", this, tile.onLoadStart); 271 272 tile.onLoadEnd = function() { 273 this.numLoadingTiles--; 274 this.events.triggerEvent("tileloaded"); 275 //if that was the last tile, then trigger a 'loadend' on the layer 276 if (this.numLoadingTiles == 0) { 277 this.events.triggerEvent("loadend"); 278 } 279 }; 280 tile.events.register("loadend", this, tile.onLoadEnd); 281 }, 282 283 /** 284 * Method: removeTileMonitoringHooks 285 * This function takes a tile as input and removes the tile hooks 286 * that were added in addTileMonitoringHooks() 287 * 288 * Parameters: 289 * tile - {<OpenLayers.Tile>} 290 */ 291 removeTileMonitoringHooks: function(tile) { 292 tile.events.unregister("loadstart", this, tile.onLoadStart); 293 tile.events.unregister("loadend", this, tile.onLoadEnd); 294 }, 295 246 296 /** 247 297 * Method: onMapResize 248 298 * Call the onMapResize method of the appropriate parent class. -
lib/OpenLayers/Layer/GeoRSS.js
old new 61 61 OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name, options]); 62 62 this.location = location; 63 63 this.features = []; 64 this.events.triggerEvent("loadstart"); 64 65 OpenLayers.loadURL(location, null, this, this.parseData); 65 66 }, 66 67 … … 198 199 marker.events.register('click', feature, this.markerClick); 199 200 this.addMarker(marker); 200 201 } 202 this.events.triggerEvent("loadend"); 201 203 }, 202 204 203 205 /**
