Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Annotation of /trunk/web/www/routino/visualiser.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1394 - (hide annotations) (download) (as text)
Wed Jun 12 18:03:47 2013 UTC (11 years, 9 months ago) by amb
File MIME type: application/javascript
File size: 33518 byte(s)
Add links to the OpenStreetMap browse URLs from the error logs.

1 amb 569 //
2     // Routino data visualiser web page Javascript
3     //
4     // Part of the Routino routing software.
5     //
6 amb 1239 // This file Copyright 2008-2013 Andrew M. Bishop
7 amb 569 //
8     // This program is free software: you can redistribute it and/or modify
9     // it under the terms of the GNU Affero General Public License as published by
10     // the Free Software Foundation, either version 3 of the License, or
11     // (at your option) any later version.
12     //
13     // This program is distributed in the hope that it will be useful,
14     // but WITHOUT ANY WARRANTY; without even the implied warranty of
15     // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     // GNU Affero General Public License for more details.
17     //
18     // You should have received a copy of the GNU Affero General Public License
19     // along with this program. If not, see <http://www.gnu.org/licenses/>.
20     //
21    
22    
23     //
24     // Data types
25     //
26    
27 amb 577 var data_types=[
28     "junctions",
29     "super",
30     "oneway",
31 amb 1003 "highway",
32 amb 1002 "transport",
33 amb 1077 "barrier",
34 amb 623 "turns",
35 amb 577 "speed",
36     "weight",
37     "height",
38     "width",
39 amb 1248 "length",
40 amb 1321 "property",
41     "errorlogs"
42 amb 577 ];
43 amb 569
44    
45 amb 577 ////////////////////////////////////////////////////////////////////////////////
46 amb 985 /////////////////////////////// Initialisation /////////////////////////////////
47     ////////////////////////////////////////////////////////////////////////////////
48    
49     // Process the URL query string and extract the arguments
50    
51     var legal={"^lon" : "^[-0-9.]+$",
52     "^lat" : "^[-0-9.]+$",
53     "^zoom" : "^[0-9]+$"};
54    
55     var args={};
56    
57     if(location.search.length>1)
58     {
59     var query,queries;
60    
61     query=location.search.replace(/^\?/,"");
62     query=query.replace(/;/g,'&');
63     queries=query.split('&');
64    
65     for(var i=0;i<queries.length;i++)
66     {
67     queries[i].match(/^([^=]+)(=(.*))?$/);
68    
69     k=RegExp.$1;
70     v=unescape(RegExp.$3);
71    
72     for(var l in legal)
73     {
74     if(k.match(RegExp(l)) && v.match(RegExp(legal[l])))
75     args[k]=v;
76     }
77     }
78     }
79    
80    
81     ////////////////////////////////////////////////////////////////////////////////
82 amb 577 ///////////////////////////////// Map handling /////////////////////////////////
83     ////////////////////////////////////////////////////////////////////////////////
84 amb 569
85     var map;
86 amb 1326 var layerMap=[], layerHighlights, layerVectors, layerBoxes;
87 amb 569 var epsg4326, epsg900913;
88    
89     var box;
90 amb 1321 var select;
91 amb 569
92     //
93     // Initialise the 'map' object
94     //
95    
96 amb 1035 function map_init() // called from visualiser.html
97 amb 569 {
98 amb 985 lon =args["lon"];
99     lat =args["lat"];
100     zoom=args["zoom"];
101    
102 amb 1260 // Map URLs and limits are in mapprops.js.
103 amb 569
104     //
105     // Create the map
106     //
107    
108     epsg4326=new OpenLayers.Projection("EPSG:4326");
109     epsg900913=new OpenLayers.Projection("EPSG:900913");
110    
111     map = new OpenLayers.Map ("map",
112     {
113     controls:[
114     new OpenLayers.Control.Navigation(),
115     new OpenLayers.Control.PanZoomBar(),
116     new OpenLayers.Control.ScaleLine(),
117     new OpenLayers.Control.LayerSwitcher()
118     ],
119    
120     projection: epsg900913,
121     displayProjection: epsg4326,
122    
123 amb 933 minZoomLevel: mapprops.zoomout,
124     numZoomLevels: mapprops.zoomin-mapprops.zoomout+1,
125 amb 1013 maxResolution: 156543.03390625 / Math.pow(2,mapprops.zoomout),
126 amb 569
127 amb 1013 // These two lines are not needed with OpenLayers 2.12
128     units: "m",
129 amb 577 maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
130 amb 569
131 amb 1013 restrictedExtent: new OpenLayers.Bounds(mapprops.westedge,mapprops.southedge,mapprops.eastedge,mapprops.northedge).transform(epsg4326,epsg900913)
132 amb 569 });
133    
134 amb 933 // Add map tile layers
135 amb 569
136 amb 933 for(var l=0;l < mapprops.mapdata.length;l++)
137     {
138     layerMap[l] = new OpenLayers.Layer.TMS(mapprops.mapdata[l].label,
139 amb 1239 mapprops.mapdata[l].tileurl,
140 amb 933 {
141     getURL: limitedUrl,
142     displayOutsideMaxExtent: true,
143     buffer: 1
144     });
145     map.addLayer(layerMap[l]);
146     }
147 amb 569
148 amb 1239 // Update the attribution if the layer changes
149 amb 569
150 amb 1239 map.events.register("changelayer",layerMap,change_attribution_event);
151    
152     function change_attribution_event(event)
153 amb 569 {
154 amb 1239 for(var l=0;l < mapprops.mapdata.length;l++)
155     if(this[l] == event.layer)
156     change_attribution(l);
157     }
158 amb 569
159 amb 1239 function change_attribution(l)
160     {
161     var data_url =mapprops.mapdata[l].attribution.data_url;
162     var data_text=mapprops.mapdata[l].attribution.data_text;
163     var tile_url =mapprops.mapdata[l].attribution.tile_url;
164     var tile_text=mapprops.mapdata[l].attribution.tile_text;
165 amb 569
166 amb 1239 document.getElementById("attribution_data").innerHTML="<a href=\"" + data_url + "\" target=\"data_attribution\">" + data_text + "</a>";
167     document.getElementById("attribution_tile").innerHTML="<a href=\"" + tile_url + "\" target=\"tile_attribution\">" + tile_text + "</a>";
168     }
169    
170     change_attribution(0);
171    
172     // Get a URL for the tile (mostly copied from OpenLayers/Layer/XYZ.js).
173    
174     function limitedUrl(bounds)
175     {
176 amb 569 var res = map.getResolution();
177 amb 1239
178     var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
179 amb 569 var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
180 amb 1239 var z = map.getZoom() + map.minZoomLevel;
181    
182 amb 569 var limit = Math.pow(2, z);
183 amb 1239 x = ((x % limit) + limit) % limit;
184 amb 569
185 amb 1239 var xyz = {'x': x, 'y': y, 'z': z};
186     var url = this.url;
187 amb 569
188 amb 1239 if (OpenLayers.Util.isArray(url))
189     {
190     var s = '' + xyz.x + xyz.y + xyz.z;
191     url = this.selectUrl(s, url);
192     }
193    
194     return OpenLayers.String.format(url, xyz);
195 amb 569 }
196    
197 amb 1326 // Add two vectors layers (one for highlights that display behind the vectors)
198 amb 569
199 amb 1328 layerHighlights = new OpenLayers.Layer.Vector("Highlights",{displayInLayerSwitcher: false});
200 amb 1326 map.addLayer(layerHighlights);
201    
202 amb 1328 layerVectors = new OpenLayers.Layer.Vector("Markers",{displayInLayerSwitcher: false});
203 amb 569 map.addLayer(layerVectors);
204    
205 amb 1326 // Handle feature selection and popup
206    
207 amb 1321 select = new OpenLayers.Control.SelectFeature(layerVectors,
208     {onSelect: selectFeature, onUnselect: unselectFeature});
209 amb 623
210 amb 1321 map.addControl(select);
211     select.activate();
212    
213 amb 1326 createPopup();
214    
215 amb 569 // Add a boxes layer
216    
217 amb 1328 layerBoxes = new OpenLayers.Layer.Boxes("Boundary",{displayInLayerSwitcher: false});
218 amb 569 map.addLayer(layerBoxes);
219    
220     box=null;
221    
222 amb 572 // Set the map centre to the limited range specified
223    
224 amb 577 map.setCenter(map.restrictedExtent.getCenterLonLat(), map.getZoomForExtent(map.restrictedExtent,true));
225 amb 572 map.maxResolution = map.getResolution();
226    
227 amb 569 // Move the map
228    
229 amb 1014 if(lon != undefined && lat != undefined && zoom != undefined)
230 amb 569 {
231 amb 933 if(lon<mapprops.westedge) lon=mapprops.westedge;
232     if(lon>mapprops.eastedge) lon=mapprops.eastedge;
233    
234     if(lat<mapprops.southedge) lat=mapprops.southedge;
235     if(lat>mapprops.northedge) lat=mapprops.northedge;
236    
237     if(zoom<mapprops.zoomout) zoom=mapprops.zoomout;
238     if(zoom>mapprops.zoomin) zoom=mapprops.zoomin;
239    
240 amb 1009 var lonlat = new OpenLayers.LonLat(lon,lat);
241     lonlat.transform(epsg4326,epsg900913);
242 amb 569
243     map.moveTo(lonlat,zoom-map.minZoomLevel);
244     }
245 amb 1334
246     // Unhide editing URL if variable set
247    
248     if(mapprops.editurl != undefined && mapprops.editurl != "")
249     {
250     edit_url=document.getElementById("edit_url");
251    
252     edit_url.style.display="";
253     edit_url.href=mapprops.editurl;
254     }
255 amb 569 }
256    
257    
258     //
259 amb 986 // Format a number in printf("%.5f") format.
260 amb 569 //
261    
262 amb 986 function format5f(number)
263 amb 569 {
264 amb 986 var newnumber=Math.floor(number*100000+0.5);
265     var delta=0;
266    
267     if(newnumber>=0 && newnumber<100000) delta= 100000;
268     if(newnumber<0 && newnumber>-100000) delta=-100000;
269    
270     var string=String(newnumber+delta);
271    
272     var intpart =string.substring(0,string.length-5);
273     var fracpart=string.substring(string.length-5,string.length);
274    
275     if(delta>0) intpart="0";
276     if(delta<0) intpart="-0";
277    
278     return(intpart + "." + fracpart);
279     }
280    
281    
282     //
283     // Build a set of URL arguments for the map location
284     //
285    
286     function buildMapArguments()
287     {
288 amb 1009 var lonlat = map.getCenter().clone();
289     lonlat.transform(epsg900913,epsg4326);
290 amb 569
291 amb 986 var zoom = map.getZoom() + map.minZoomLevel;
292 amb 569
293 amb 986 return "lat=" + format5f(lonlat.lat) + ";lon=" + format5f(lonlat.lon) + ";zoom=" + zoom;
294 amb 577 }
295    
296    
297     //
298 amb 986 // Update a URL
299 amb 577 //
300    
301 amb 1035 function updateURL(element) // called from visualiser.html
302 amb 577 {
303 amb 986 if(element.id == "permalink_url")
304     element.href=location.pathname + "?" + buildMapArguments();
305 amb 569
306 amb 986 if(element.id == "router_url")
307     element.href="router.html" + "?" + buildMapArguments();
308    
309     if(element.id == "edit_url")
310 amb 1334 element.href=mapprops.editurl + "?" + buildMapArguments();
311 amb 986
312     if(element.id.match(/^lang_([a-zA-Z-]+)_url$/))
313     element.href="visualiser.html" + "." + RegExp.$1 + "?" + buildMapArguments();
314 amb 569 }
315    
316    
317 amb 1326 ////////////////////////////////////////////////////////////////////////////////
318     ///////////////////////// Popup and selection handling /////////////////////////
319     ////////////////////////////////////////////////////////////////////////////////
320    
321     var popup=null;
322    
323 amb 1321 //
324 amb 1326 // Create a popup - not using OpenLayers because want it fixed on screen not fixed on map.
325 amb 1321 //
326    
327 amb 1326 function createPopup()
328     {
329     popup=document.createElement('div');
330 amb 1321
331 amb 1326 popup.className = "popup";
332    
333     popup.innerHTML = "<span></span>";
334    
335     popup.style.display = "none";
336    
337     popup.style.position = "fixed";
338     popup.style.top = "-4000px";
339     popup.style.left = "-4000px";
340     popup.style.zIndex = "100";
341    
342     popup.style.padding = "5px";
343    
344     popup.style.opacity=0.85;
345 amb 1332 popup.style.backgroundColor="#C0C0C0";
346     popup.style.border="4px solid #404040";
347 amb 1326
348     document.body.appendChild(popup);
349     }
350    
351    
352     //
353     // Draw a popup - not using OpenLayers because want it fixed on screen not fixed on map.
354     //
355    
356     function drawPopup(html)
357 amb 1321 {
358 amb 1326 if(html==null)
359     {
360     popup.style.display="none";
361     return;
362     }
363 amb 1321
364 amb 1326 if(popup.style.display=="none")
365     {
366     var map_div=document.getElementById("map");
367 amb 1321
368 amb 1326 popup.style.left =map_div.offsetParent.offsetLeft+map_div.offsetLeft+60 + "px";
369     popup.style.top = map_div.offsetTop +30 + "px";
370     popup.style.width =map_div.clientWidth-100 + "px";
371 amb 1321
372 amb 1326 popup.style.display="";
373     }
374    
375     popup.innerHTML=html;
376 amb 1321 }
377    
378 amb 1326
379     //
380     // Select a feature
381     //
382    
383     function selectFeature(feature)
384 amb 1321 {
385 amb 1329 if(feature.attributes.dump)
386     OpenLayers.Request.GET({url: "visualiser.cgi?dump=" + feature.attributes.dump, success: runDumpSuccess});
387 amb 1321
388 amb 1326 layerHighlights.destroyFeatures();
389    
390 amb 1329 highlight_style = new OpenLayers.Style({},{strokeColor: "#F0F000",strokeWidth: 8,
391     fillColor: "#F0F000",pointRadius: 6});
392    
393 amb 1326 highlight = new OpenLayers.Feature.Vector(feature.geometry.clone(),{},highlight_style);
394    
395     layerHighlights.addFeatures([highlight]);
396 amb 1321 }
397    
398 amb 1326
399     //
400     // Un-select a feature
401     //
402    
403     function unselectFeature(feature)
404 amb 1321 {
405 amb 1326 layerHighlights.destroyFeatures();
406    
407     drawPopup(null);
408 amb 1321 }
409    
410    
411 amb 1329 //
412     // Display the dump data
413     //
414    
415     function runDumpSuccess(response)
416     {
417 amb 1394 var string=response.responseText;
418    
419     if(mapprops.editurl != undefined && mapprops.editurl != "")
420     {
421     var types=["node", "way", "relation"];
422     var Types=["Node", "Way", "Relation"];
423    
424     for(var t in types)
425     {
426     var Type=Types[t];
427     var type=types[t];
428    
429     var regexp=RegExp(Type + " [0-9]+");
430    
431     while((match=string.match(regexp)) != null)
432     {
433     match=String(match);
434    
435     var id=match.slice(1+type.length,match.length);
436    
437     string=string.replace(regexp,Type + " <a href='" + mapprops.browseurl + "/" + type + "/" + id + "' target='" + type + id + "'>" + id + "</a>");
438     }
439     }
440     }
441    
442     drawPopup(string.split("\n").join("<br>"));
443 amb 1329 }
444    
445    
446 amb 577 ////////////////////////////////////////////////////////////////////////////////
447     /////////////////////////////// Server handling ////////////////////////////////
448     ////////////////////////////////////////////////////////////////////////////////
449    
450 amb 569 //
451 amb 936 // Display the status
452     //
453    
454     function displayStatus(type,subtype,content)
455     {
456 amb 1011 var child=document.getElementById("result_status").firstChild;
457 amb 936
458     do
459     {
460     if(child.id != undefined)
461     child.style.display="none";
462    
463     child=child.nextSibling;
464     }
465     while(child != undefined);
466    
467     var chosen_status=document.getElementById("result_status_" + type);
468    
469     chosen_status.style.display="";
470    
471     if(subtype != null)
472     {
473     var format_status=document.getElementById("result_status_" + subtype).innerHTML;
474    
475     chosen_status.innerHTML=format_status.replace('#',String(content));
476     }
477     }
478    
479    
480     //
481 amb 569 // Display data statistics
482     //
483    
484     function displayStatistics()
485     {
486     // Use AJAX to get the statistics
487    
488 amb 1013 OpenLayers.Request.GET({url: "statistics.cgi", success: runStatisticsSuccess});
489 amb 569 }
490    
491    
492     //
493 amb 577 // Success in running data statistics generation.
494 amb 569 //
495    
496     function runStatisticsSuccess(response)
497     {
498 amb 1011 document.getElementById("statistics_data").innerHTML="<pre>" + response.responseText + "</pre>";
499     document.getElementById("statistics_link").style.display="none";
500 amb 569 }
501    
502    
503     //
504     // Get the requested data
505     //
506    
507 amb 1035 function displayData(datatype) // called from visualiser.html
508 amb 569 {
509 amb 577 for(var data in data_types)
510     hideshow_hide(data_types[data]);
511 amb 569
512     if(datatype != "")
513     hideshow_show(datatype);
514    
515     // Delete the old data
516    
517 amb 1326 unselectFeature();
518 amb 1321
519 amb 1326 select.deactivate();
520    
521 amb 569 layerVectors.destroyFeatures();
522 amb 1326 layerHighlights.destroyFeatures();
523 amb 569
524     if(box != null)
525     layerBoxes.removeMarker(box);
526     box=null;
527    
528     // Print the status
529    
530 amb 936 displayStatus("no_data");
531 amb 569
532     // Return if just here to clear the data
533    
534     if(datatype == "")
535     return;
536    
537     // Get the new data
538    
539     var mapbounds=map.getExtent().clone();
540     mapbounds.transform(epsg900913,epsg4326);
541    
542     var url="visualiser.cgi";
543    
544     url=url + "?lonmin=" + mapbounds.left;
545     url=url + ";latmin=" + mapbounds.bottom;
546     url=url + ";lonmax=" + mapbounds.right;
547     url=url + ";latmax=" + mapbounds.top;
548     url=url + ";data=" + datatype;
549    
550     // Use AJAX to get the data
551    
552     switch(datatype)
553     {
554     case 'junctions':
555 amb 1013 OpenLayers.Request.GET({url: url, success: runJunctionsSuccess, failure: runFailure});
556 amb 569 break;
557     case 'super':
558 amb 1013 OpenLayers.Request.GET({url: url, success: runSuperSuccess, faliure: runFailure});
559 amb 569 break;
560     case 'oneway':
561 amb 1013 OpenLayers.Request.GET({url: url, success: runOnewaySuccess, failure: runFailure});
562 amb 569 break;
563 amb 1003 case 'highway':
564     var highways=document.forms["highways"].elements["highway"];
565     for(var h in highways)
566     if(highways[h].checked)
567     highway=highways[h].value;
568     url+="-" + highway;
569 amb 1013 OpenLayers.Request.GET({url: url, success: runHighwaySuccess, falure: runFailure});
570 amb 1003 break;
571 amb 1002 case 'transport':
572     var transports=document.forms["transports"].elements["transport"];
573     for(var t in transports)
574     if(transports[t].checked)
575     transport=transports[t].value;
576     url+="-" + transport;
577 amb 1013 OpenLayers.Request.GET({url: url, success: runTransportSuccess, failure: runFailure});
578 amb 1002 break;
579 amb 1077 case 'barrier':
580     var transports=document.forms["barriers"].elements["barrier"];
581     for(var t in transports)
582     if(transports[t].checked)
583     transport=transports[t].value;
584     url+="-" + transport;
585     OpenLayers.Request.GET({url: url, success: runBarrierSuccess, failure: runFailure});
586     break;
587 amb 623 case 'turns':
588 amb 1013 OpenLayers.Request.GET({url: url, success: runTurnsSuccess, failure: runFailure});
589 amb 623 break;
590 amb 569 case 'speed':
591     case 'weight':
592     case 'height':
593     case 'width':
594     case 'length':
595 amb 1013 OpenLayers.Request.GET({url: url, success: runLimitSuccess, failure: runFailure});
596 amb 569 break;
597 amb 1248 case 'property':
598     var properties=document.forms["properties"].elements["property"];
599     for(var p in properties)
600     if(properties[p].checked)
601     property=properties[p].value;
602     url+="-" + property;
603     OpenLayers.Request.GET({url: url, success: runPropertySuccess, falure: runFailure});
604     break;
605 amb 1321 case 'errorlogs':
606     OpenLayers.Request.GET({url: url, success: runErrorlogSuccess, falure: runFailure});
607     break;
608 amb 569 }
609     }
610    
611    
612     //
613     // Success in getting the junctions.
614     //
615    
616     function runJunctionsSuccess(response)
617     {
618     var lines=response.responseText.split('\n');
619    
620 amb 1329 var junction_colours={
621     0: "#FFFFFF",
622     1: "#FF0000",
623     2: "#FFFF00",
624     3: "#00FF00",
625     4: "#8B4513",
626     5: "#00BFFF",
627     6: "#FF69B4",
628     7: "#000000",
629     8: "#000000",
630     9: "#000000"
631     };
632    
633     var styles={};
634    
635     for(var colour in junction_colours)
636     styles[colour]=new OpenLayers.Style({},{stroke: false,
637     pointRadius: 2,fillColor: junction_colours[colour],
638     cursor: "pointer"});
639    
640 amb 569 var features=[];
641    
642 amb 577 for(var line=0;line<lines.length;line++)
643 amb 569 {
644 amb 572 var words=lines[line].split(' ');
645 amb 569
646     if(line == 0)
647     {
648     var lat1=words[0];
649     var lon1=words[1];
650     var lat2=words[2];
651     var lon2=words[3];
652    
653 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
654 amb 569
655     box = new OpenLayers.Marker.Box(bounds);
656    
657     layerBoxes.addMarker(box);
658     }
659     else if(words[0] != "")
660     {
661 amb 1329 var dump=words[0];
662     var lat=words[1];
663     var lon=words[2];
664     var count=words[3];
665 amb 569
666     var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
667    
668     var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
669    
670 amb 1329 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},styles[count]));
671 amb 569 }
672     }
673    
674 amb 1329 select.activate();
675    
676 amb 569 layerVectors.addFeatures(features);
677    
678 amb 936 displayStatus("data","junctions",lines.length-2);
679 amb 569 }
680    
681    
682     //
683     // Success in getting the super-node and super-segments
684     //
685    
686     function runSuperSuccess(response)
687     {
688     var lines=response.responseText.split('\n');
689    
690 amb 1329 var node_style = new OpenLayers.Style({},{stroke: false,
691     pointRadius: 3,fillColor: "#FF0000",
692     cursor: "pointer"});
693    
694     var segment_style = new OpenLayers.Style({},{fill: false,
695     strokeWidth: 2,strokeColor: "#FF0000",
696     cursor: "pointer"});
697    
698 amb 569 var features=[];
699    
700     var nodepoint;
701    
702 amb 577 for(var line=0;line<lines.length;line++)
703 amb 569 {
704 amb 572 var words=lines[line].split(' ');
705 amb 569
706     if(line == 0)
707     {
708     var lat1=words[0];
709     var lon1=words[1];
710     var lat2=words[2];
711     var lon2=words[3];
712    
713 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
714 amb 569
715     box = new OpenLayers.Marker.Box(bounds);
716    
717     layerBoxes.addMarker(box);
718     }
719     else if(words[0] != "")
720     {
721 amb 1329 var dump=words[0];
722     var lat=words[1];
723     var lon=words[2];
724 amb 569
725     var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
726    
727     var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
728    
729 amb 1329 if(dump.charAt(0) == "n")
730 amb 569 {
731     nodepoint=point;
732    
733 amb 1329 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},node_style));
734 amb 569 }
735     else
736     {
737 amb 577 var segment = new OpenLayers.Geometry.LineString([nodepoint,point]);
738 amb 569
739 amb 1329 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},segment_style));
740 amb 569 }
741     }
742     }
743    
744 amb 1329 select.activate();
745    
746 amb 569 layerVectors.addFeatures(features);
747    
748 amb 936 displayStatus("data","super",lines.length-2);
749 amb 569 }
750    
751    
752     //
753     // Success in getting the oneway data
754     //
755    
756     function runOnewaySuccess(response)
757     {
758 amb 1321 var hex={0: "00", 1: "11", 2: "22", 3: "33", 4: "44", 5: "55", 6: "66", 7: "77",
759     8: "88", 9: "99", 10: "AA", 11: "BB", 12: "CC", 13: "DD", 14: "EE", 15: "FF"};
760    
761 amb 569 var lines=response.responseText.split('\n');
762    
763     var features=[];
764    
765 amb 577 for(var line=0;line<lines.length;line++)
766 amb 569 {
767 amb 572 var words=lines[line].split(' ');
768 amb 569
769     if(line == 0)
770     {
771     var lat1=words[0];
772     var lon1=words[1];
773     var lat2=words[2];
774     var lon2=words[3];
775    
776 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
777 amb 569
778     box = new OpenLayers.Marker.Box(bounds);
779    
780     layerBoxes.addMarker(box);
781     }
782     else if(words[0] != "")
783     {
784 amb 1329 var dump=words[0];
785     var lat1=words[1];
786     var lon1=words[2];
787     var lat2=words[3];
788     var lon2=words[4];
789 amb 569
790     var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
791     var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
792    
793     //var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
794     var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
795    
796     var dlat = lonlat2.lat-lonlat1.lat;
797     var dlon = lonlat2.lon-lonlat1.lon;
798     var dist = Math.sqrt(dlat*dlat+dlon*dlon)/10;
799     var ang = Math.atan2(dlat,dlon);
800    
801     var point3 = new OpenLayers.Geometry.Point(lonlat1.lon+dlat/dist,lonlat1.lat-dlon/dist);
802     var point4 = new OpenLayers.Geometry.Point(lonlat1.lon-dlat/dist,lonlat1.lat+dlon/dist);
803    
804 amb 577 var segment = new OpenLayers.Geometry.LineString([point2,point3,point4,point2]);
805 amb 569
806     var r=Math.round(7.5+7.9*Math.cos(ang));
807     var g=Math.round(7.5+7.9*Math.cos(ang+2.0943951));
808     var b=Math.round(7.5+7.9*Math.cos(ang-2.0943951));
809     var colour = "#" + hex[r] + hex[g] + hex[b];
810    
811 amb 1329 var style=new OpenLayers.Style({},{strokeWidth: 2,strokeColor: colour, cursor: "pointer"});
812 amb 569
813 amb 1329 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
814 amb 569 }
815     }
816    
817 amb 1329 select.activate();
818    
819 amb 569 layerVectors.addFeatures(features);
820    
821 amb 936 displayStatus("data","oneway",lines.length-2);
822 amb 569 }
823    
824    
825     //
826 amb 1003 // Success in getting the highway data
827     //
828    
829     function runHighwaySuccess(response)
830     {
831     var lines=response.responseText.split('\n');
832    
833 amb 1329 var style = new OpenLayers.Style({},{fill: false,
834     strokeWidth: 2,strokeColor: "#FF0000",
835     cursor: "pointer"});
836    
837 amb 1003 var features=[];
838    
839     for(var line=0;line<lines.length;line++)
840     {
841     var words=lines[line].split(' ');
842    
843     if(line == 0)
844     {
845     var lat1=words[0];
846     var lon1=words[1];
847     var lat2=words[2];
848     var lon2=words[3];
849    
850 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
851 amb 1003
852     box = new OpenLayers.Marker.Box(bounds);
853    
854     layerBoxes.addMarker(box);
855     }
856     else if(words[0] != "")
857     {
858 amb 1329 var dump=words[0];
859     var lat1=words[1];
860     var lon1=words[2];
861     var lat2=words[3];
862     var lon2=words[4];
863 amb 1003
864     var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
865     var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
866    
867     var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
868     var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
869    
870     var segment = new OpenLayers.Geometry.LineString([point1,point2]);
871    
872 amb 1329 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
873 amb 1003 }
874     }
875    
876 amb 1329 select.activate();
877    
878 amb 1003 layerVectors.addFeatures(features);
879    
880     displayStatus("data","highway",lines.length-2);
881     }
882    
883    
884     //
885 amb 1002 // Success in getting the transport data
886     //
887    
888     function runTransportSuccess(response)
889     {
890     var lines=response.responseText.split('\n');
891    
892 amb 1329 var style = new OpenLayers.Style({},{fill: false,
893     strokeWidth: 2,strokeColor: "#FF0000",
894     cursor: "pointer"});
895    
896 amb 1002 var features=[];
897    
898     for(var line=0;line<lines.length;line++)
899     {
900     var words=lines[line].split(' ');
901    
902     if(line == 0)
903     {
904     var lat1=words[0];
905     var lon1=words[1];
906     var lat2=words[2];
907     var lon2=words[3];
908    
909 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
910 amb 1002
911     box = new OpenLayers.Marker.Box(bounds);
912    
913     layerBoxes.addMarker(box);
914     }
915     else if(words[0] != "")
916     {
917 amb 1329 var dump=words[0];
918     var lat1=words[1];
919     var lon1=words[2];
920     var lat2=words[3];
921     var lon2=words[4];
922 amb 1002
923     var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
924     var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
925    
926     var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
927     var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
928    
929     var segment = new OpenLayers.Geometry.LineString([point1,point2]);
930    
931 amb 1329 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
932 amb 1002 }
933     }
934    
935 amb 1329 select.activate();
936    
937 amb 1002 layerVectors.addFeatures(features);
938    
939 amb 1003 displayStatus("data","transport",lines.length-2);
940 amb 1002 }
941    
942    
943     //
944 amb 1077 // Success in getting the barrier data
945     //
946    
947     function runBarrierSuccess(response)
948     {
949     var lines=response.responseText.split('\n');
950    
951 amb 1329 var style = new OpenLayers.Style({},{stroke: false,
952     pointRadius: 3,fillColor: "#FF0000",
953     cursor: "pointer"});
954    
955 amb 1077 var features=[];
956    
957     for(var line=0;line<lines.length;line++)
958     {
959     var words=lines[line].split(' ');
960    
961     if(line == 0)
962     {
963     var lat1=words[0];
964     var lon1=words[1];
965     var lat2=words[2];
966     var lon2=words[3];
967    
968     var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
969    
970     box = new OpenLayers.Marker.Box(bounds);
971    
972     layerBoxes.addMarker(box);
973     }
974     else if(words[0] != "")
975     {
976 amb 1329 var dump=words[0];
977     var lat=words[1];
978     var lon=words[2];
979 amb 1077
980     var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
981    
982     var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
983    
984 amb 1329 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},style));
985 amb 1077 }
986     }
987    
988 amb 1329 select.activate();
989    
990 amb 1077 layerVectors.addFeatures(features);
991    
992     displayStatus("data","barrier",lines.length-2);
993     }
994    
995    
996     //
997 amb 623 // Success in getting the turn restrictions data
998     //
999    
1000     function runTurnsSuccess(response)
1001     {
1002     var lines=response.responseText.split('\n');
1003    
1004 amb 1329 var style = new OpenLayers.Style({},{fill: false,
1005     strokeWidth: 2,strokeColor: "#FF0000",
1006     cursor: "pointer"});
1007    
1008 amb 623 var features=[];
1009    
1010     for(var line=0;line<lines.length;line++)
1011     {
1012     var words=lines[line].split(' ');
1013    
1014     if(line == 0)
1015     {
1016     var lat1=words[0];
1017     var lon1=words[1];
1018     var lat2=words[2];
1019     var lon2=words[3];
1020    
1021 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1022 amb 623
1023     box = new OpenLayers.Marker.Box(bounds);
1024    
1025     layerBoxes.addMarker(box);
1026     }
1027     else if(words[0] != "")
1028     {
1029 amb 1329 var dump=words[0];
1030     var lat1=words[1];
1031     var lon1=words[2];
1032     var lat2=words[3];
1033     var lon2=words[4];
1034     var lat3=words[5];
1035     var lon3=words[6];
1036 amb 623
1037     var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
1038     var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
1039     var lonlat3= new OpenLayers.LonLat(lon3,lat3).transform(epsg4326,epsg900913);
1040    
1041     var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
1042     var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
1043     var point3 = new OpenLayers.Geometry.Point(lonlat3.lon,lonlat3.lat);
1044    
1045     var segments = new OpenLayers.Geometry.LineString([point1,point2,point3]);
1046    
1047 amb 1329 features.push(new OpenLayers.Feature.Vector(segments,{dump: dump},style));
1048 amb 623 }
1049     }
1050    
1051 amb 1329 select.activate();
1052    
1053 amb 623 layerVectors.addFeatures(features);
1054    
1055 amb 936 displayStatus("data","turns",lines.length-2);
1056 amb 623 }
1057    
1058    
1059     //
1060 amb 569 // Success in getting the speed/weight/height/width/length limits
1061     //
1062    
1063     function runLimitSuccess(response)
1064     {
1065     var lines=response.responseText.split('\n');
1066    
1067 amb 1329 var node_style = new OpenLayers.Style({},{stroke: false,
1068     pointRadius: 3,fillColor: "#FF0000",
1069     cursor: "pointer"});
1070    
1071     var segment_style = new OpenLayers.Style({},{fill: false,
1072     strokeWidth: 2,strokeColor: "#FF0000",
1073     cursor: "pointer"});
1074    
1075 amb 569 var features=[];
1076    
1077 amb 1329 var nodepoint;
1078 amb 569 var nodelonlat;
1079    
1080 amb 577 for(var line=0;line<lines.length;line++)
1081 amb 569 {
1082 amb 572 var words=lines[line].split(' ');
1083 amb 569
1084     if(line == 0)
1085     {
1086     var lat1=words[0];
1087     var lon1=words[1];
1088     var lat2=words[2];
1089     var lon2=words[3];
1090    
1091 amb 1009 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1092 amb 569
1093     box = new OpenLayers.Marker.Box(bounds);
1094    
1095     layerBoxes.addMarker(box);
1096     }
1097     else if(words[0] != "")
1098     {
1099 amb 1329 var dump=words[0];
1100     var lat=words[1];
1101     var lon=words[2];
1102     var number=words[3];
1103 amb 569
1104     var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
1105    
1106     if(number == undefined)
1107     {
1108     var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
1109    
1110     nodelonlat=lonlat;
1111 amb 1329 nodepoint = point;
1112 amb 569
1113 amb 1329 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},node_style));
1114 amb 569 }
1115     else
1116     {
1117 amb 1329 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
1118    
1119     var segment = new OpenLayers.Geometry.LineString([nodepoint,point]);
1120    
1121     features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},segment_style));
1122    
1123 amb 569 var dlat = lonlat.lat-nodelonlat.lat;
1124     var dlon = lonlat.lon-nodelonlat.lon;
1125 amb 1329 var dist = Math.sqrt(dlat*dlat+dlon*dlon)/120;
1126 amb 569
1127     var point = new OpenLayers.Geometry.Point(nodelonlat.lon+dlon/dist,nodelonlat.lat+dlat/dist);
1128    
1129 amb 1329 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},
1130 amb 569 new OpenLayers.Style({},{externalGraphic: 'icons/limit-' + number + '.png',
1131     graphicYOffset: -9,
1132     graphicWidth: 19,
1133     graphicHeight: 19})));
1134     }
1135     }
1136     }
1137    
1138 amb 1329 select.activate();
1139    
1140 amb 569 layerVectors.addFeatures(features);
1141    
1142 amb 936 displayStatus("data","limit",lines.length-2);
1143 amb 569 }
1144    
1145    
1146     //
1147 amb 1248 // Success in getting the property data
1148     //
1149    
1150     function runPropertySuccess(response)
1151     {
1152     var lines=response.responseText.split('\n');
1153    
1154 amb 1329 var style = new OpenLayers.Style({},{fill: false,
1155     strokeWidth: 2,strokeColor: "#FF0000",
1156     cursor: "pointer"});
1157    
1158 amb 1248 var features=[];
1159    
1160     for(var line=0;line<lines.length;line++)
1161     {
1162     var words=lines[line].split(' ');
1163    
1164     if(line == 0)
1165     {
1166     var lat1=words[0];
1167     var lon1=words[1];
1168     var lat2=words[2];
1169     var lon2=words[3];
1170    
1171     var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1172    
1173     box = new OpenLayers.Marker.Box(bounds);
1174    
1175     layerBoxes.addMarker(box);
1176     }
1177     else if(words[0] != "")
1178     {
1179 amb 1329 var dump=words[0];
1180     var lat1=words[1];
1181     var lon1=words[2];
1182     var lat2=words[3];
1183     var lon2=words[4];
1184 amb 1248
1185     var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
1186     var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
1187    
1188     var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
1189     var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
1190    
1191     var segment = new OpenLayers.Geometry.LineString([point1,point2]);
1192    
1193 amb 1329 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
1194 amb 1248 }
1195     }
1196    
1197 amb 1329 select.activate();
1198    
1199 amb 1248 layerVectors.addFeatures(features);
1200    
1201     displayStatus("data","property",lines.length-2);
1202     }
1203    
1204    
1205     //
1206 amb 1321 // Success in getting the error log data
1207     //
1208    
1209     function runErrorlogSuccess(response)
1210     {
1211     var lines=response.responseText.split('\n');
1212    
1213 amb 1329 var style = new OpenLayers.Style({},{stroke: false,
1214     pointRadius: 3,fillColor: "#FF0000",
1215     cursor: "pointer"});
1216    
1217 amb 1321 var features=[];
1218    
1219     for(var line=0;line<lines.length;line++)
1220     {
1221     var words=lines[line].split(' ');
1222    
1223     if(line == 0)
1224     {
1225     var lat1=words[0];
1226     var lon1=words[1];
1227     var lat2=words[2];
1228     var lon2=words[3];
1229    
1230     var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1231    
1232     box = new OpenLayers.Marker.Box(bounds);
1233    
1234     layerBoxes.addMarker(box);
1235     }
1236     else if(words[0] != "")
1237     {
1238 amb 1329 var dump=words[0];
1239     var lat=words[1];
1240     var lon=words[2];
1241 amb 1321
1242     var lonlat = new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
1243    
1244     var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
1245    
1246 amb 1329 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},style));
1247 amb 1321 }
1248     }
1249    
1250 amb 1326 select.activate();
1251    
1252 amb 1321 layerVectors.addFeatures(features);
1253    
1254     displayStatus("data","errorlogs",lines.length-2);
1255     }
1256    
1257    
1258     //
1259 amb 569 // Failure in getting data.
1260     //
1261    
1262     function runFailure(response)
1263     {
1264 amb 1321 displayStatus("failed");
1265 amb 569 }