Routino SVN Repository Browser

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

ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1394 - (show 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 //
2 // Routino data visualiser web page Javascript
3 //
4 // Part of the Routino routing software.
5 //
6 // This file Copyright 2008-2013 Andrew M. Bishop
7 //
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 var data_types=[
28 "junctions",
29 "super",
30 "oneway",
31 "highway",
32 "transport",
33 "barrier",
34 "turns",
35 "speed",
36 "weight",
37 "height",
38 "width",
39 "length",
40 "property",
41 "errorlogs"
42 ];
43
44
45 ////////////////////////////////////////////////////////////////////////////////
46 /////////////////////////////// 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 ///////////////////////////////// Map handling /////////////////////////////////
83 ////////////////////////////////////////////////////////////////////////////////
84
85 var map;
86 var layerMap=[], layerHighlights, layerVectors, layerBoxes;
87 var epsg4326, epsg900913;
88
89 var box;
90 var select;
91
92 //
93 // Initialise the 'map' object
94 //
95
96 function map_init() // called from visualiser.html
97 {
98 lon =args["lon"];
99 lat =args["lat"];
100 zoom=args["zoom"];
101
102 // Map URLs and limits are in mapprops.js.
103
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 minZoomLevel: mapprops.zoomout,
124 numZoomLevels: mapprops.zoomin-mapprops.zoomout+1,
125 maxResolution: 156543.03390625 / Math.pow(2,mapprops.zoomout),
126
127 // These two lines are not needed with OpenLayers 2.12
128 units: "m",
129 maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
130
131 restrictedExtent: new OpenLayers.Bounds(mapprops.westedge,mapprops.southedge,mapprops.eastedge,mapprops.northedge).transform(epsg4326,epsg900913)
132 });
133
134 // Add map tile layers
135
136 for(var l=0;l < mapprops.mapdata.length;l++)
137 {
138 layerMap[l] = new OpenLayers.Layer.TMS(mapprops.mapdata[l].label,
139 mapprops.mapdata[l].tileurl,
140 {
141 getURL: limitedUrl,
142 displayOutsideMaxExtent: true,
143 buffer: 1
144 });
145 map.addLayer(layerMap[l]);
146 }
147
148 // Update the attribution if the layer changes
149
150 map.events.register("changelayer",layerMap,change_attribution_event);
151
152 function change_attribution_event(event)
153 {
154 for(var l=0;l < mapprops.mapdata.length;l++)
155 if(this[l] == event.layer)
156 change_attribution(l);
157 }
158
159 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
166 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 var res = map.getResolution();
177
178 var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
179 var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
180 var z = map.getZoom() + map.minZoomLevel;
181
182 var limit = Math.pow(2, z);
183 x = ((x % limit) + limit) % limit;
184
185 var xyz = {'x': x, 'y': y, 'z': z};
186 var url = this.url;
187
188 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 }
196
197 // Add two vectors layers (one for highlights that display behind the vectors)
198
199 layerHighlights = new OpenLayers.Layer.Vector("Highlights",{displayInLayerSwitcher: false});
200 map.addLayer(layerHighlights);
201
202 layerVectors = new OpenLayers.Layer.Vector("Markers",{displayInLayerSwitcher: false});
203 map.addLayer(layerVectors);
204
205 // Handle feature selection and popup
206
207 select = new OpenLayers.Control.SelectFeature(layerVectors,
208 {onSelect: selectFeature, onUnselect: unselectFeature});
209
210 map.addControl(select);
211 select.activate();
212
213 createPopup();
214
215 // Add a boxes layer
216
217 layerBoxes = new OpenLayers.Layer.Boxes("Boundary",{displayInLayerSwitcher: false});
218 map.addLayer(layerBoxes);
219
220 box=null;
221
222 // Set the map centre to the limited range specified
223
224 map.setCenter(map.restrictedExtent.getCenterLonLat(), map.getZoomForExtent(map.restrictedExtent,true));
225 map.maxResolution = map.getResolution();
226
227 // Move the map
228
229 if(lon != undefined && lat != undefined && zoom != undefined)
230 {
231 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 var lonlat = new OpenLayers.LonLat(lon,lat);
241 lonlat.transform(epsg4326,epsg900913);
242
243 map.moveTo(lonlat,zoom-map.minZoomLevel);
244 }
245
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 }
256
257
258 //
259 // Format a number in printf("%.5f") format.
260 //
261
262 function format5f(number)
263 {
264 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 var lonlat = map.getCenter().clone();
289 lonlat.transform(epsg900913,epsg4326);
290
291 var zoom = map.getZoom() + map.minZoomLevel;
292
293 return "lat=" + format5f(lonlat.lat) + ";lon=" + format5f(lonlat.lon) + ";zoom=" + zoom;
294 }
295
296
297 //
298 // Update a URL
299 //
300
301 function updateURL(element) // called from visualiser.html
302 {
303 if(element.id == "permalink_url")
304 element.href=location.pathname + "?" + buildMapArguments();
305
306 if(element.id == "router_url")
307 element.href="router.html" + "?" + buildMapArguments();
308
309 if(element.id == "edit_url")
310 element.href=mapprops.editurl + "?" + buildMapArguments();
311
312 if(element.id.match(/^lang_([a-zA-Z-]+)_url$/))
313 element.href="visualiser.html" + "." + RegExp.$1 + "?" + buildMapArguments();
314 }
315
316
317 ////////////////////////////////////////////////////////////////////////////////
318 ///////////////////////// Popup and selection handling /////////////////////////
319 ////////////////////////////////////////////////////////////////////////////////
320
321 var popup=null;
322
323 //
324 // Create a popup - not using OpenLayers because want it fixed on screen not fixed on map.
325 //
326
327 function createPopup()
328 {
329 popup=document.createElement('div');
330
331 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 popup.style.backgroundColor="#C0C0C0";
346 popup.style.border="4px solid #404040";
347
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 {
358 if(html==null)
359 {
360 popup.style.display="none";
361 return;
362 }
363
364 if(popup.style.display=="none")
365 {
366 var map_div=document.getElementById("map");
367
368 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
372 popup.style.display="";
373 }
374
375 popup.innerHTML=html;
376 }
377
378
379 //
380 // Select a feature
381 //
382
383 function selectFeature(feature)
384 {
385 if(feature.attributes.dump)
386 OpenLayers.Request.GET({url: "visualiser.cgi?dump=" + feature.attributes.dump, success: runDumpSuccess});
387
388 layerHighlights.destroyFeatures();
389
390 highlight_style = new OpenLayers.Style({},{strokeColor: "#F0F000",strokeWidth: 8,
391 fillColor: "#F0F000",pointRadius: 6});
392
393 highlight = new OpenLayers.Feature.Vector(feature.geometry.clone(),{},highlight_style);
394
395 layerHighlights.addFeatures([highlight]);
396 }
397
398
399 //
400 // Un-select a feature
401 //
402
403 function unselectFeature(feature)
404 {
405 layerHighlights.destroyFeatures();
406
407 drawPopup(null);
408 }
409
410
411 //
412 // Display the dump data
413 //
414
415 function runDumpSuccess(response)
416 {
417 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 }
444
445
446 ////////////////////////////////////////////////////////////////////////////////
447 /////////////////////////////// Server handling ////////////////////////////////
448 ////////////////////////////////////////////////////////////////////////////////
449
450 //
451 // Display the status
452 //
453
454 function displayStatus(type,subtype,content)
455 {
456 var child=document.getElementById("result_status").firstChild;
457
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 // Display data statistics
482 //
483
484 function displayStatistics()
485 {
486 // Use AJAX to get the statistics
487
488 OpenLayers.Request.GET({url: "statistics.cgi", success: runStatisticsSuccess});
489 }
490
491
492 //
493 // Success in running data statistics generation.
494 //
495
496 function runStatisticsSuccess(response)
497 {
498 document.getElementById("statistics_data").innerHTML="<pre>" + response.responseText + "</pre>";
499 document.getElementById("statistics_link").style.display="none";
500 }
501
502
503 //
504 // Get the requested data
505 //
506
507 function displayData(datatype) // called from visualiser.html
508 {
509 for(var data in data_types)
510 hideshow_hide(data_types[data]);
511
512 if(datatype != "")
513 hideshow_show(datatype);
514
515 // Delete the old data
516
517 unselectFeature();
518
519 select.deactivate();
520
521 layerVectors.destroyFeatures();
522 layerHighlights.destroyFeatures();
523
524 if(box != null)
525 layerBoxes.removeMarker(box);
526 box=null;
527
528 // Print the status
529
530 displayStatus("no_data");
531
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 OpenLayers.Request.GET({url: url, success: runJunctionsSuccess, failure: runFailure});
556 break;
557 case 'super':
558 OpenLayers.Request.GET({url: url, success: runSuperSuccess, faliure: runFailure});
559 break;
560 case 'oneway':
561 OpenLayers.Request.GET({url: url, success: runOnewaySuccess, failure: runFailure});
562 break;
563 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 OpenLayers.Request.GET({url: url, success: runHighwaySuccess, falure: runFailure});
570 break;
571 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 OpenLayers.Request.GET({url: url, success: runTransportSuccess, failure: runFailure});
578 break;
579 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 case 'turns':
588 OpenLayers.Request.GET({url: url, success: runTurnsSuccess, failure: runFailure});
589 break;
590 case 'speed':
591 case 'weight':
592 case 'height':
593 case 'width':
594 case 'length':
595 OpenLayers.Request.GET({url: url, success: runLimitSuccess, failure: runFailure});
596 break;
597 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 case 'errorlogs':
606 OpenLayers.Request.GET({url: url, success: runErrorlogSuccess, falure: runFailure});
607 break;
608 }
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 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 var features=[];
641
642 for(var line=0;line<lines.length;line++)
643 {
644 var words=lines[line].split(' ');
645
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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
654
655 box = new OpenLayers.Marker.Box(bounds);
656
657 layerBoxes.addMarker(box);
658 }
659 else if(words[0] != "")
660 {
661 var dump=words[0];
662 var lat=words[1];
663 var lon=words[2];
664 var count=words[3];
665
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 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},styles[count]));
671 }
672 }
673
674 select.activate();
675
676 layerVectors.addFeatures(features);
677
678 displayStatus("data","junctions",lines.length-2);
679 }
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 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 var features=[];
699
700 var nodepoint;
701
702 for(var line=0;line<lines.length;line++)
703 {
704 var words=lines[line].split(' ');
705
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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
714
715 box = new OpenLayers.Marker.Box(bounds);
716
717 layerBoxes.addMarker(box);
718 }
719 else if(words[0] != "")
720 {
721 var dump=words[0];
722 var lat=words[1];
723 var lon=words[2];
724
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 if(dump.charAt(0) == "n")
730 {
731 nodepoint=point;
732
733 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},node_style));
734 }
735 else
736 {
737 var segment = new OpenLayers.Geometry.LineString([nodepoint,point]);
738
739 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},segment_style));
740 }
741 }
742 }
743
744 select.activate();
745
746 layerVectors.addFeatures(features);
747
748 displayStatus("data","super",lines.length-2);
749 }
750
751
752 //
753 // Success in getting the oneway data
754 //
755
756 function runOnewaySuccess(response)
757 {
758 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 var lines=response.responseText.split('\n');
762
763 var features=[];
764
765 for(var line=0;line<lines.length;line++)
766 {
767 var words=lines[line].split(' ');
768
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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
777
778 box = new OpenLayers.Marker.Box(bounds);
779
780 layerBoxes.addMarker(box);
781 }
782 else if(words[0] != "")
783 {
784 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
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 var segment = new OpenLayers.Geometry.LineString([point2,point3,point4,point2]);
805
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 var style=new OpenLayers.Style({},{strokeWidth: 2,strokeColor: colour, cursor: "pointer"});
812
813 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
814 }
815 }
816
817 select.activate();
818
819 layerVectors.addFeatures(features);
820
821 displayStatus("data","oneway",lines.length-2);
822 }
823
824
825 //
826 // Success in getting the highway data
827 //
828
829 function runHighwaySuccess(response)
830 {
831 var lines=response.responseText.split('\n');
832
833 var style = new OpenLayers.Style({},{fill: false,
834 strokeWidth: 2,strokeColor: "#FF0000",
835 cursor: "pointer"});
836
837 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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
851
852 box = new OpenLayers.Marker.Box(bounds);
853
854 layerBoxes.addMarker(box);
855 }
856 else if(words[0] != "")
857 {
858 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
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 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
873 }
874 }
875
876 select.activate();
877
878 layerVectors.addFeatures(features);
879
880 displayStatus("data","highway",lines.length-2);
881 }
882
883
884 //
885 // Success in getting the transport data
886 //
887
888 function runTransportSuccess(response)
889 {
890 var lines=response.responseText.split('\n');
891
892 var style = new OpenLayers.Style({},{fill: false,
893 strokeWidth: 2,strokeColor: "#FF0000",
894 cursor: "pointer"});
895
896 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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
910
911 box = new OpenLayers.Marker.Box(bounds);
912
913 layerBoxes.addMarker(box);
914 }
915 else if(words[0] != "")
916 {
917 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
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 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
932 }
933 }
934
935 select.activate();
936
937 layerVectors.addFeatures(features);
938
939 displayStatus("data","transport",lines.length-2);
940 }
941
942
943 //
944 // Success in getting the barrier data
945 //
946
947 function runBarrierSuccess(response)
948 {
949 var lines=response.responseText.split('\n');
950
951 var style = new OpenLayers.Style({},{stroke: false,
952 pointRadius: 3,fillColor: "#FF0000",
953 cursor: "pointer"});
954
955 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 var dump=words[0];
977 var lat=words[1];
978 var lon=words[2];
979
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 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},style));
985 }
986 }
987
988 select.activate();
989
990 layerVectors.addFeatures(features);
991
992 displayStatus("data","barrier",lines.length-2);
993 }
994
995
996 //
997 // Success in getting the turn restrictions data
998 //
999
1000 function runTurnsSuccess(response)
1001 {
1002 var lines=response.responseText.split('\n');
1003
1004 var style = new OpenLayers.Style({},{fill: false,
1005 strokeWidth: 2,strokeColor: "#FF0000",
1006 cursor: "pointer"});
1007
1008 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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1022
1023 box = new OpenLayers.Marker.Box(bounds);
1024
1025 layerBoxes.addMarker(box);
1026 }
1027 else if(words[0] != "")
1028 {
1029 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
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 features.push(new OpenLayers.Feature.Vector(segments,{dump: dump},style));
1048 }
1049 }
1050
1051 select.activate();
1052
1053 layerVectors.addFeatures(features);
1054
1055 displayStatus("data","turns",lines.length-2);
1056 }
1057
1058
1059 //
1060 // 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 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 var features=[];
1076
1077 var nodepoint;
1078 var nodelonlat;
1079
1080 for(var line=0;line<lines.length;line++)
1081 {
1082 var words=lines[line].split(' ');
1083
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 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1092
1093 box = new OpenLayers.Marker.Box(bounds);
1094
1095 layerBoxes.addMarker(box);
1096 }
1097 else if(words[0] != "")
1098 {
1099 var dump=words[0];
1100 var lat=words[1];
1101 var lon=words[2];
1102 var number=words[3];
1103
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 nodepoint = point;
1112
1113 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},node_style));
1114 }
1115 else
1116 {
1117 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 var dlat = lonlat.lat-nodelonlat.lat;
1124 var dlon = lonlat.lon-nodelonlat.lon;
1125 var dist = Math.sqrt(dlat*dlat+dlon*dlon)/120;
1126
1127 var point = new OpenLayers.Geometry.Point(nodelonlat.lon+dlon/dist,nodelonlat.lat+dlat/dist);
1128
1129 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},
1130 new OpenLayers.Style({},{externalGraphic: 'icons/limit-' + number + '.png',
1131 graphicYOffset: -9,
1132 graphicWidth: 19,
1133 graphicHeight: 19})));
1134 }
1135 }
1136 }
1137
1138 select.activate();
1139
1140 layerVectors.addFeatures(features);
1141
1142 displayStatus("data","limit",lines.length-2);
1143 }
1144
1145
1146 //
1147 // Success in getting the property data
1148 //
1149
1150 function runPropertySuccess(response)
1151 {
1152 var lines=response.responseText.split('\n');
1153
1154 var style = new OpenLayers.Style({},{fill: false,
1155 strokeWidth: 2,strokeColor: "#FF0000",
1156 cursor: "pointer"});
1157
1158 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 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
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 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
1194 }
1195 }
1196
1197 select.activate();
1198
1199 layerVectors.addFeatures(features);
1200
1201 displayStatus("data","property",lines.length-2);
1202 }
1203
1204
1205 //
1206 // Success in getting the error log data
1207 //
1208
1209 function runErrorlogSuccess(response)
1210 {
1211 var lines=response.responseText.split('\n');
1212
1213 var style = new OpenLayers.Style({},{stroke: false,
1214 pointRadius: 3,fillColor: "#FF0000",
1215 cursor: "pointer"});
1216
1217 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 var dump=words[0];
1239 var lat=words[1];
1240 var lon=words[2];
1241
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 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},style));
1247 }
1248 }
1249
1250 select.activate();
1251
1252 layerVectors.addFeatures(features);
1253
1254 displayStatus("data","errorlogs",lines.length-2);
1255 }
1256
1257
1258 //
1259 // Failure in getting data.
1260 //
1261
1262 function runFailure(response)
1263 {
1264 displayStatus("failed");
1265 }