[OpenLayers-Commits] r12242 - in sandbox/mpriour/temporal_map/openlayers: examples lib/OpenLayers/Control lib/OpenLayers/Control/TimeManager

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Aug 12 22:49:25 EDT 2011


Author: mpriour
Date: 2011-08-12 19:49:25 -0700 (Fri, 12 Aug 2011)
New Revision: 12242

Modified:
   sandbox/mpriour/temporal_map/openlayers/examples/wmst.html
   sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager.js
   sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager/WMS.js
Log:
Simplest WMS-Time example with most TimeManager control functions demonstrated.

Modified: sandbox/mpriour/temporal_map/openlayers/examples/wmst.html
===================================================================
--- sandbox/mpriour/temporal_map/openlayers/examples/wmst.html	2011-08-13 00:59:01 UTC (rev 12241)
+++ sandbox/mpriour/temporal_map/openlayers/examples/wmst.html	2011-08-13 02:49:25 UTC (rev 12242)
@@ -31,26 +31,37 @@
 			},{
 				timeInterval:[last65min,last5min],
 				timeStep:5,
-				timeUnit:OpenLayers.TimeUnit.MINUTE
+				timeUnit:OpenLayers.TimeUnit.MINUTES,
+				singleTile:true,
+				ratio:1
 			});
 
             jpl_wms.setVisibility(false);
 			
 			timeCtl = new OpenLayers.Control.TimeManager({
 				range:ia_wms.timeInterval,
-				unit:ia_wms.timeUnit,
+				units:ia_wms.timeUnit,
 				step:ia_wms.timeStep,
 				layers:[ia_wms]
 			});
-			timeCtl.events.on({'tick':update_date,scope:timeCtl});
+			timeCtl.events.on({
+				'tick': update_date,
+				'reset': update_date,
+				'stop':function(evt){if(evt.rangeExceeded)alert('End of time range')},
+				scope: timeCtl
+			});
 
             map.addLayers([ol_wms, jpl_wms, ia_wms]);
             map.addControl(new OpenLayers.Control.LayerSwitcher());
             map.zoomToExtent(new OpenLayers.Bounds(-100.898437,22.148438,-78.398437,39.726563));
-			update_date(timeCtl.currentTime);
+			update_date({
+				object: timeCtl,
+				currentTime: timeCtl.currentTime
+			});
         }
-        function update_date(time) {
-            OpenLayers.Util.getElement('year').value = time.getFullYear();
+        function update_date(evt) {
+            var time = this.currentTime||evt.currentTime;
+			OpenLayers.Util.getElement('year').value = time.getFullYear();
 			OpenLayers.Util.getElement('month').value = time.getMonth();
             OpenLayers.Util.getElement('day').value = time.getDate();
             OpenLayers.Util.getElement('hour').value = time.getHours();
@@ -65,7 +76,7 @@
         </div>
         <p id="shortdesc">
             Shows the use of the TimeManager control with a single simple WMS-T (time) layer<br>
-			Click on the 
+			Click on the PLAY button to start.
         </p>
     <input size="4" type='text' id='year' value="" readonly="true" />-
 	<input size="2" type="text" id="month" value="" readonly="true" />-
@@ -73,17 +84,18 @@
 	<input type="text" size="2" id="hour" value="" readonly="true" />:
 	<input type="text" size="2" id="minute" value=""  readonly="true"/>:00
 	<div>
-		<button type="button" onclick="timeCtl.stop()">Stop</button>
+		<button type="button" onclick="timeCtl.loop=false;timeCtl.stop()">Stop</button>
 		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.reset()">Reset</button>
+		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.loop=true;timeCtl.play()">Loop</button>
+		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.tick()">Step</button>
 		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.play()">Play</button>
 	</div>
     <div id="map" class="smallmap"></div>
     <div id="docs">
-        <p>WMS-T example: update the times, and the radar image will change.
-        Uses Layer.mergeNewParams to update the date element with the strings
-        from the input fields every time one of them is changed. The inputs
-        above describe a timestamp: The minute increments can only be updated
-        in units of 5.</p>
+        <p>WMS-T example: hit PLAY, and the radar image will change along with the<br>
+		time display. Uses the OpenLayers.Control.TimeManager to update the date<br>
+		elements with the time of the animation. Starts 1 hour before the nearest 5 min<br>
+		interval to the current time.</p>
     </div>
   </body>
 </html>

Modified: sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager/WMS.js
===================================================================
--- sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager/WMS.js	2011-08-13 00:59:01 UTC (rev 12241)
+++ sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager/WMS.js	2011-08-13 02:49:25 UTC (rev 12242)
@@ -42,6 +42,7 @@
 	initialize:function(options){
 		options = options||{};
 		OpenLayers.Util.extend(this,options);
+		OpenLayers.Control.prototype.initialize.call(this,options);
 		var timeConfig = this.buildRangeAndIntervals(this.layers);
 		this.range = timeConfig.range;
 		this.intervals = timeConfig.intervals;
@@ -51,7 +52,7 @@
 		this.currentTime = evt.currentTime;
 		if(this.currentTime<=this.range[1] && this.currentTime>=this.range[0]){
 			for(var i=0,len=this.layers.length;i<len;i++){
-				this.applyTime(layers[i],currentTime);
+				this.applyTime(this.layers[i],this.currentTime);
 			}
 		}else{
 			for(var i=0,len=this.layers.length;i<len;i++){
@@ -60,7 +61,7 @@
 		}
 	},
 	
-	buildRangeAndIntervals:function(layer){
+	buildRangeAndIntervals:function(layers){
 		var range = [], intervals=[];
 		for(var i=0,len=layers.length;i<len;i++){
 			var lyr = layers[i];
@@ -95,7 +96,7 @@
 	},
 	
 	applyTime:function(layer,time){
-		if(layer.timeIntervals.length>2 && this.useLastValidInterval){
+		if(layer.timeInterval.length>2 && this.useLastValidInterval){
 			//TODO implement special case handling
 		}else{
 			//format time in ISO:8601 format

Modified: sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager.js
===================================================================
--- sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager.js	2011-08-13 00:59:01 UTC (rev 12241)
+++ sandbox/mpriour/temporal_map/openlayers/lib/OpenLayers/Control/TimeManager.js	2011-08-13 02:49:25 UTC (rev 12242)
@@ -118,7 +118,7 @@
 	 * Private Property: utcOffset
 	 * {Number} millisecond difference between local & UTC time. Read-Only
 	 */
-	utcOffset:0,
+	utcOffset:new Date().getTimezoneOffset() * -6e4,
 	
 	/**
      * Constructor: OpenLayers.Control.TimeManager
@@ -131,7 +131,6 @@
     initialize: function(options){
 		options = options||{};
 		OpenLayers.Control.prototype.initialize.call(this,options);
-		this.utcOffset = new Date().getTimezoneOffset() * -6e4;
 		if(this.intervals){
 			for(var i=0,len=this.intervals.length;i<len;i++){
 				var interval = this.intervals[i];
@@ -180,7 +179,7 @@
 			//stop in normal mode
 			else {
 				this.timer && clearInterval(this.timer) && (this.timer=null);
-				this.triggerEvent('stop', {'rangeExceeded': true});
+				this.events.triggerEvent('stop', {'rangeExceeded': true});
 			}
 		}
 		else {
@@ -198,7 +197,7 @@
 		//start playing
 		this.events.triggerEvent('play');
 		this.tick();
-		this.timer = setInterval(this.tick,1000/this.frameRate);
+		this.timer = setInterval(OpenLayers.Function.bind(this.tick,this),1000/this.frameRate);
 	},
 	/**
 	 * Method: stop
@@ -206,7 +205,7 @@
 	 */
 	stop:function(){
 		this.timer && clearInterval(this.timer) && (this.timer=null);
-		this.triggerEvent('stop',{'rangeExceeded':false});
+		this.events.triggerEvent('stop',{'rangeExceeded':false});
 	},
 	/**
 	 * Method: setRange
@@ -285,7 +284,7 @@
 	 */
 	incrementTime:function(step,stepUnit){
 		step = step || this.step;
-		stepUnit = stepUnit || this.unit;
+		stepUnit = stepUnit || this.units;
 		this.currentTime['setUTC'+stepUnit](this.currentTime['getUTC'+stepUnit]()+step);
 	},
 	/**
@@ -319,11 +318,11 @@
 				parentControl:this
 			},options);
 			var ctl = new ctlClass(ctlOptions);
-			ctl.events.on({
+			this.events.on({
 				'tick': ctl.onTick,
 				scope: ctl
 			})
-			childControls.push(new OpenLayers)
+			childControls.push(ctl)
 		}
 		return childControls;
 	},



More information about the Commits mailing list