Changeset 6364
- Timestamp:
- 02/25/08 10:43:59 (11 months ago)
- Files:
-
- sandbox/achipa/openlayers/examples/time-select-control.html (modified) (3 diffs)
- sandbox/achipa/openlayers/examples/timed-point-track-markers.html (modified) (4 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/ExtDate.js (modified) (3 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/Layer.js (modified) (3 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/Layer/TimedPointTrack.js (modified) (4 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/Map.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/achipa/openlayers/examples/time-select-control.html
r6312 r6364 44 44 //alert(dumpObj(map.getControlsByClass('OpenLayers.Control.PanTimeBar')[0], 'object', '-', 8)); 45 45 46 lineLayer.dateTimeFromFeatures(); 47 48 // make sure the highlights stays turned on and current with the map zoom 49 map.events.register("zoomend", lineLayer, lineLayer.updateHighlight); 50 51 // update the date of the layer from the map property and redraw to keeep up with changes 52 map.events.register("datechanged", lineLayer, lineLayer.setTimeFromMap); 53 map.events.register("datechanged", lineLayer, lineLayer.updateHighlight) 54 46 55 rss.setName(rss.name + " Comments"); 47 56 … … 55 64 } 56 65 57 lineLayer.updateDateTimeInterval();58 59 66 // keep markers on top of tracks 60 67 map.raiseLayer(rss, 1); … … 63 70 64 71 function setTime() { 65 var targetdate = OpenLayers.DateTime.fromRFC3339(OpenLayers.Util.getElement('date').value);66 lineLayer.setDateTime(targetdate);72 var targetdate = Date.fromRFC3339(OpenLayers.Util.getElement('date').value); 73 map.setTime(targetdate); 67 74 } 68 75 </script> sandbox/achipa/openlayers/examples/timed-point-track-markers.html
r6264 r6364 39 39 lineLayer.addNodes(rss.features); 40 40 map.addLayer(lineLayer); 41 42 // VERY IMPORTANT - set the validity interval of the layer so it encompasses all the Dates of the features 43 lineLayer.dateTimeFromFeatures(); 44 45 // make sure the highlights stays turned on and current with the map zoom 46 map.events.register("zoomend", lineLayer, lineLayer.updateHighlight); 47 48 // update the date of the layer from the map property and redraw to keeep up with changes 49 map.events.register("datechanged", lineLayer, lineLayer.setTimeFromMap); 50 map.events.register("datechanged", lineLayer, lineLayer.updateHighlight); 41 51 52 42 53 rss.setName(rss.name + " Comments"); 43 54 … … 51 62 } 52 63 53 lineLayer.updateDateTimeInterval();54 55 64 // keep markers on top of tracks 56 65 map.raiseLayer(rss, 1); … … 58 67 59 68 function setTime() { 60 var targetdate = OpenLayers.DateTime.fromRFC3339(OpenLayers.Util.getElement('date').value);69 var targetdate = Date.fromRFC3339(OpenLayers.Util.getElement('date').value); 61 70 lineLayer.permanentHighlight = OpenLayers.Util.getElement('phighlight').checked; 62 71 lineLayer.interpolatePoints = OpenLayers.Util.getElement('ipoints').checked; 63 lineLayer.setDateTime(targetdate);72 map.setTime(targetdate); 64 73 } 65 74 </script> … … 69 78 <p style="font-size:.9em;">This demo uses OpenLayers.Layer.GeoRSS and OpenLayers.Layer.TimedPointTrack. The track is created by connecting the points of the GeoRSS feed.</a></p> 70 79 <form onsubmit="return false;"> 71 Load GeoRSS URL: <input type="text" id="url" size="50" /><input type="submit" onclick="addUrl(); return false;" value="Load Feed" onsubmit="addUrl(); return false;" />80 Load GeoRSS URL: <input type="text" id="url" size="50" value="xml/track1.xml" /><input type="submit" onclick="addUrl(); return false;" value="Load Feed" onsubmit="addUrl(); return false;" /> 72 81 </form> <form onsubmit="return false;"> 73 82 <input type="checkbox" id="phighlight"> permanentHighlight <BR> sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/ExtDate.js
r6362 r6364 21 21 */ 22 22 Date.prototype.contains = function(targetdate) { 23 if (targetdate >= this && targetdate.get Time() + targetdate.duration <= this.getTime() + this.duration)23 if (targetdate >= this && targetdate.getEndDate() <= this.getEndDate()) 24 24 return true; 25 25 … … 36 36 Date.prototype.getEndDate = function() { 37 37 return new Date(this.getTime() + this.duration); 38 }; 39 40 /** 41 * Method: merge 42 * Extends the start or duration of this Date object so it encompasses the interval targetdate object as well 43 * as the currect interval. 44 * 45 * Parameters: 46 * {Date} targetdate 47 */ 48 Date.prototype.merge = function(targetdate) { 49 if (targetdate < this) { 50 this.duration += this - targetdate; 51 this.setTime(targetdate.getTime()); 52 } 53 if (targetdate.getEndDate() > this.getEndDate()){ 54 this.duration += targetdate.getEndDate() - this.getEndDate(); 55 } 38 56 }; 39 57 … … 55 73 */ 56 74 Date.prototype.getPlaceInInterval = function(targetdate, center) { 57 var centerdate = targetdate; 75 if (!targetdate) return 0; 76 var centerdate = new Date(targetdate); 58 77 if (center && targetdate.duration != 0) 59 centerdate = new Date(targetdate.getTime() + targetdate.duration/2);78 centerdate.setTime(targetdate.getTime() + targetdate.duration/2); 60 79 61 if (centerdate .getTime() > this.getTime() + this.duration)80 if (centerdate > this.getEndDate()) 62 81 return 1; 63 else if (t argetdate <= centerdate) // using <= to accomodate for non-interval datetimes82 else if (this >= centerdate) // using <= to accomodate for non-interval datetimes 64 83 return 0; 65 84 else sandbox/achipa/openlayers/lib/OpenLayers/Layer.js
r6362 r6364 42 42 * {Array(String)} Supported application event types 43 43 */ 44 EVENT_TYPES: ["loadstart", "loadend", "loadcancel", "visibilitychanged" , "datetimechanged"],44 EVENT_TYPES: ["loadstart", "loadend", "loadcancel", "visibilitychanged"], 45 45 46 46 /** … … 1048 1048 1049 1049 /** 1050 * Method: set DateTime1051 * {Date} Sets the current date/time in the layer s1050 * Method: setTime 1051 * {Date} Sets the current date/time in the layer 1052 1052 * 1053 1053 */ … … 1056 1056 return; 1057 1057 1058 if (!this.currentDateTime .equals(dt)){1058 if (!this.currentDateTime || !this.currentDateTime.equals(dt)){ 1059 1059 this.currentDateTime = dt; 1060 this.events.triggerEvent("datetimechanged"); 1060 } 1061 }, 1062 1063 /** 1064 * Method: setTimeFromMap 1065 * Sets the current date/time in the layer 1066 * 1067 */ 1068 setTimeFromMap: function () { 1069 if (!this.isTemporalLayer()) 1070 return; 1071 1072 if (!this.currentDateTime || !this.currentDateTime.equals(this.map.currentDateTime)){ 1073 this.currentDateTime = this.map.currentDateTime; 1061 1074 } 1062 1075 }, sandbox/achipa/openlayers/lib/OpenLayers/Layer/TimedPointTrack.js
r6362 r6364 78 78 defaultStyle = this.sty 79 79 this.events.register("datetimechanged", this, this.updateHighlight); 80 // this.map.events.register("zoomend", this, this.updateHighlight);81 80 }, 82 81 … … 103 102 Math.abs( this.features[i].dateTime.getEndDate() - this.currentDateTime ) 104 103 ) 104 && (this.features[i].dateTime.contains(this.currentDateTime) || !this.features[i].dateTime.duration || this.permanentHighlight) // allow Points to match as they might not have intervals 105 105 ){ 106 106 closesttime = this.features[i].dateTime; … … 115 115 // if PointTrack was to work with something else, this would have to be adapted, too 116 116 closestpoint = new OpenLayers.Geometry.Point( 117 closestgeom.components[0].x + (closestgeom.components[1].x - closestgeom.components[0].x) * closestfeature.dateTime.getPlaceInInterval(this.currentDateTime .from),118 closestgeom.components[0].y + (closestgeom.components[1].y - closestgeom.components[0].y) * closestfeature.dateTime.getPlaceInInterval(this.currentDateTime .from)117 closestgeom.components[0].x + (closestgeom.components[1].x - closestgeom.components[0].x) * closestfeature.dateTime.getPlaceInInterval(this.currentDateTime), 118 closestgeom.components[0].y + (closestgeom.components[1].y - closestgeom.components[0].y) * closestfeature.dateTime.getPlaceInInterval(this.currentDateTime) 119 119 ); 120 120 } … … 136 136 * 137 137 */ 138 updateDateTimeInterval: function() {138 dateTimeFromFeatures: function() { 139 139 var begin = Date.UTC(2038,0,0); 140 140 var end = Date.UTC(1970,0,0); sandbox/achipa/openlayers/lib/OpenLayers/Map.js
r6362 r6364 59 59 "addmarker", "removemarker", "clearmarkers", "mouseover", 60 60 "mouseout", "mousemove", "dragstart", "drag", "dragend", 61 "changebaselayer"], 61 "changebaselayer", 62 "datechanged"], 62 63 63 64 /** … … 161 162 */ 162 163 zoom: 0, 164 165 /** 166 * Property: currentDateTime 167 * {Date} The current date/time if the map has temporal layers 168 */ 169 currentDateTime: null, 163 170 164 171 /** … … 1925 1932 * 1926 1933 * Parameters: 1927 * {Date} Sets the current date/time in all layers1934 * {Date} Sets the current date/time for the map and emits the datechanged signal 1928 1935 * 1929 1936 */ 1930 1937 setTime: function (dt) { 1931 for(var i=0; i < this.layers.length; i++) 1932 if (this.layers[i].isTemporalLayer()) 1933 this.layers[i].setTime(dt); 1938 if (!this.currentDateTime || !this.currentDateTime.equals(dt)){ 1939 this.currentDateTime = dt; 1940 } 1941 1942 this.events.triggerEvent("datechanged"); 1943 1934 1944 }, 1935 1945
