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 1484 - (show annotations) (download) (as text)
Sun Jan 5 15:42:42 2014 UTC (11 years, 2 months ago) by amb
File MIME type: application/javascript
File size: 33670 byte(s)
Replace the unescape() function with standard decodeURIComponent() function.

1 //
2 // Routino data visualiser web page Javascript
3 //
4 // Part of the Routino routing software.
5 //
6 // This file Copyright 2008-2014 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 var k=RegExp.$1;
70 var v=decodeURIComponent(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 var lon =args["lon"];
99 var lat =args["lat"];
100 var 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 = this.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 = this.map.getZoom() + this.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 var 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 var highlight_style = new OpenLayers.Style({},{strokeColor: "#F0F000",strokeWidth: 8,
391 fillColor: "#F0F000",pointRadius: 4});
392
393 var 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 var match;
432
433 while((match=string.match(regexp)) != null)
434 {
435 match=String(match);
436
437 var id=match.slice(1+type.length,match.length);
438
439 string=string.replace(regexp,Type + " <a href='" + mapprops.browseurl + "/" + type + "/" + id + "' target='" + type + id + "'>" + id + "</a>");
440 }
441 }
442 }
443
444 drawPopup(string.split("\n").join("<br>"));
445 }
446
447
448 ////////////////////////////////////////////////////////////////////////////////
449 /////////////////////////////// Server handling ////////////////////////////////
450 ////////////////////////////////////////////////////////////////////////////////
451
452 //
453 // Display the status
454 //
455
456 function displayStatus(type,subtype,content)
457 {
458 var child=document.getElementById("result_status").firstChild;
459
460 do
461 {
462 if(child.id != undefined)
463 child.style.display="none";
464
465 child=child.nextSibling;
466 }
467 while(child != undefined);
468
469 var chosen_status=document.getElementById("result_status_" + type);
470
471 chosen_status.style.display="";
472
473 if(subtype != null)
474 {
475 var format_status=document.getElementById("result_status_" + subtype).innerHTML;
476
477 chosen_status.innerHTML=format_status.replace("#",String(content));
478 }
479 }
480
481
482 //
483 // Display data statistics
484 //
485
486 function displayStatistics()
487 {
488 // Use AJAX to get the statistics
489
490 OpenLayers.Request.GET({url: "statistics.cgi", success: runStatisticsSuccess});
491 }
492
493
494 //
495 // Success in running data statistics generation.
496 //
497
498 function runStatisticsSuccess(response)
499 {
500 document.getElementById("statistics_data").innerHTML="<pre>" + response.responseText + "</pre>";
501 document.getElementById("statistics_link").style.display="none";
502 }
503
504
505 //
506 // Get the requested data
507 //
508
509 function displayData(datatype) // called from visualiser.html
510 {
511 for(var data in data_types)
512 hideshow_hide(data_types[data]);
513
514 if(datatype != "")
515 hideshow_show(datatype);
516
517 // Delete the old data
518
519 unselectFeature();
520
521 select.deactivate();
522
523 layerVectors.destroyFeatures();
524 layerHighlights.destroyFeatures();
525
526 if(box != null)
527 layerBoxes.removeMarker(box);
528 box=null;
529
530 // Print the status
531
532 displayStatus("no_data");
533
534 // Return if just here to clear the data
535
536 if(datatype == "")
537 return;
538
539 // Get the new data
540
541 var mapbounds=map.getExtent().clone();
542 mapbounds.transform(epsg900913,epsg4326);
543
544 var url="visualiser.cgi";
545
546 url=url + "?lonmin=" + mapbounds.left;
547 url=url + ";latmin=" + mapbounds.bottom;
548 url=url + ";lonmax=" + mapbounds.right;
549 url=url + ";latmax=" + mapbounds.top;
550 url=url + ";data=" + datatype;
551
552 // Use AJAX to get the data
553
554 switch(datatype)
555 {
556 case "junctions":
557 OpenLayers.Request.GET({url: url, success: runJunctionsSuccess, failure: runFailure});
558 break;
559 case "super":
560 OpenLayers.Request.GET({url: url, success: runSuperSuccess, failure: runFailure});
561 break;
562 case "oneway":
563 OpenLayers.Request.GET({url: url, success: runOnewaySuccess, failure: runFailure});
564 break;
565 case "highway":
566 var highway;
567 var highways=document.forms["highways"].elements["highway"];
568 for(var h in highways)
569 if(highways[h].checked)
570 highway=highways[h].value;
571 url+="-" + highway;
572 OpenLayers.Request.GET({url: url, success: runHighwaySuccess, failure: runFailure});
573 break;
574 case "transport":
575 var transport;
576 var transports=document.forms["transports"].elements["transport"];
577 for(var t in transports)
578 if(transports[t].checked)
579 transport=transports[t].value;
580 url+="-" + transport;
581 OpenLayers.Request.GET({url: url, success: runTransportSuccess, failure: runFailure});
582 break;
583 case "barrier":
584 var transport;
585 var transports=document.forms["barriers"].elements["barrier"];
586 for(var t in transports)
587 if(transports[t].checked)
588 transport=transports[t].value;
589 url+="-" + transport;
590 OpenLayers.Request.GET({url: url, success: runBarrierSuccess, failure: runFailure});
591 break;
592 case "turns":
593 OpenLayers.Request.GET({url: url, success: runTurnsSuccess, failure: runFailure});
594 break;
595 case "speed":
596 case "weight":
597 case "height":
598 case "width":
599 case "length":
600 OpenLayers.Request.GET({url: url, success: runLimitSuccess, failure: runFailure});
601 break;
602 case "property":
603 var property;
604 var properties=document.forms["properties"].elements["property"];
605 for(var p in properties)
606 if(properties[p].checked)
607 property=properties[p].value;
608 url+="-" + property;
609 OpenLayers.Request.GET({url: url, success: runPropertySuccess, failure: runFailure});
610 break;
611 case "errorlogs":
612 OpenLayers.Request.GET({url: url, success: runErrorlogSuccess, failure: runFailure});
613 break;
614 }
615 }
616
617
618 //
619 // Success in getting the junctions.
620 //
621
622 function runJunctionsSuccess(response)
623 {
624 var lines=response.responseText.split("\n");
625
626 var junction_colours={
627 0: "#FFFFFF",
628 1: "#FF0000",
629 2: "#FFFF00",
630 3: "#00FF00",
631 4: "#8B4513",
632 5: "#00BFFF",
633 6: "#FF69B4",
634 7: "#000000",
635 8: "#000000",
636 9: "#000000"
637 };
638
639 var styles={};
640
641 for(var colour in junction_colours)
642 styles[colour]=new OpenLayers.Style({},{stroke: false,
643 pointRadius: 2,fillColor: junction_colours[colour],
644 cursor: "pointer"});
645
646 var features=[];
647
648 for(var line=0;line<lines.length;line++)
649 {
650 var words=lines[line].split(" ");
651
652 if(line == 0)
653 {
654 var lat1=words[0];
655 var lon1=words[1];
656 var lat2=words[2];
657 var lon2=words[3];
658
659 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
660
661 box = new OpenLayers.Marker.Box(bounds);
662
663 layerBoxes.addMarker(box);
664 }
665 else if(words[0] != "")
666 {
667 var dump=words[0];
668 var lat=words[1];
669 var lon=words[2];
670 var count=words[3];
671
672 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
673
674 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
675
676 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},styles[count]));
677 }
678 }
679
680 select.activate();
681
682 layerVectors.addFeatures(features);
683
684 displayStatus("data","junctions",lines.length-2);
685 }
686
687
688 //
689 // Success in getting the super-node and super-segments
690 //
691
692 function runSuperSuccess(response)
693 {
694 var lines=response.responseText.split("\n");
695
696 var node_style = new OpenLayers.Style({},{stroke: false,
697 pointRadius: 4,fillColor: "#FF0000",
698 cursor: "pointer"});
699
700 var segment_style = new OpenLayers.Style({},{fill: false,
701 strokeWidth: 2,strokeColor: "#FF0000",
702 cursor: "pointer"});
703
704 var features=[];
705
706 var nodepoint;
707
708 for(var line=0;line<lines.length;line++)
709 {
710 var words=lines[line].split(" ");
711
712 if(line == 0)
713 {
714 var lat1=words[0];
715 var lon1=words[1];
716 var lat2=words[2];
717 var lon2=words[3];
718
719 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
720
721 box = new OpenLayers.Marker.Box(bounds);
722
723 layerBoxes.addMarker(box);
724 }
725 else if(words[0] != "")
726 {
727 var dump=words[0];
728 var lat=words[1];
729 var lon=words[2];
730
731 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
732
733 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
734
735 if(dump.charAt(0) == "n")
736 {
737 nodepoint=point;
738
739 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},node_style));
740 }
741 else
742 {
743 var segment = new OpenLayers.Geometry.LineString([nodepoint,point]);
744
745 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},segment_style));
746 }
747 }
748 }
749
750 select.activate();
751
752 layerVectors.addFeatures(features);
753
754 displayStatus("data","super",lines.length-2);
755 }
756
757
758 //
759 // Success in getting the oneway data
760 //
761
762 function runOnewaySuccess(response)
763 {
764 var hex={0: "00", 1: "11", 2: "22", 3: "33", 4: "44", 5: "55", 6: "66", 7: "77",
765 8: "88", 9: "99", 10: "AA", 11: "BB", 12: "CC", 13: "DD", 14: "EE", 15: "FF"};
766
767 var lines=response.responseText.split("\n");
768
769 var features=[];
770
771 for(var line=0;line<lines.length;line++)
772 {
773 var words=lines[line].split(" ");
774
775 if(line == 0)
776 {
777 var lat1=words[0];
778 var lon1=words[1];
779 var lat2=words[2];
780 var lon2=words[3];
781
782 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
783
784 box = new OpenLayers.Marker.Box(bounds);
785
786 layerBoxes.addMarker(box);
787 }
788 else if(words[0] != "")
789 {
790 var dump=words[0];
791 var lat1=words[1];
792 var lon1=words[2];
793 var lat2=words[3];
794 var lon2=words[4];
795
796 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
797 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
798
799 //var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
800 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
801
802 var dlat = lonlat2.lat-lonlat1.lat;
803 var dlon = lonlat2.lon-lonlat1.lon;
804 var dist = Math.sqrt(dlat*dlat+dlon*dlon)/10;
805 var ang = Math.atan2(dlat,dlon);
806
807 var point3 = new OpenLayers.Geometry.Point(lonlat1.lon+dlat/dist,lonlat1.lat-dlon/dist);
808 var point4 = new OpenLayers.Geometry.Point(lonlat1.lon-dlat/dist,lonlat1.lat+dlon/dist);
809
810 var segment = new OpenLayers.Geometry.LineString([point2,point3,point4,point2]);
811
812 var r=Math.round(7.5+7.9*Math.cos(ang));
813 var g=Math.round(7.5+7.9*Math.cos(ang+2.0943951));
814 var b=Math.round(7.5+7.9*Math.cos(ang-2.0943951));
815 var colour = "#" + hex[r] + hex[g] + hex[b];
816
817 var style=new OpenLayers.Style({},{strokeWidth: 2,strokeColor: colour, cursor: "pointer"});
818
819 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
820 }
821 }
822
823 select.activate();
824
825 layerVectors.addFeatures(features);
826
827 displayStatus("data","oneway",lines.length-2);
828 }
829
830
831 //
832 // Success in getting the highway data
833 //
834
835 function runHighwaySuccess(response)
836 {
837 var lines=response.responseText.split("\n");
838
839 var style = new OpenLayers.Style({},{fill: false,
840 strokeWidth: 2,strokeColor: "#FF0000",
841 cursor: "pointer"});
842
843 var features=[];
844
845 for(var line=0;line<lines.length;line++)
846 {
847 var words=lines[line].split(" ");
848
849 if(line == 0)
850 {
851 var lat1=words[0];
852 var lon1=words[1];
853 var lat2=words[2];
854 var lon2=words[3];
855
856 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
857
858 box = new OpenLayers.Marker.Box(bounds);
859
860 layerBoxes.addMarker(box);
861 }
862 else if(words[0] != "")
863 {
864 var dump=words[0];
865 var lat1=words[1];
866 var lon1=words[2];
867 var lat2=words[3];
868 var lon2=words[4];
869
870 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
871 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
872
873 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
874 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
875
876 var segment = new OpenLayers.Geometry.LineString([point1,point2]);
877
878 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
879 }
880 }
881
882 select.activate();
883
884 layerVectors.addFeatures(features);
885
886 displayStatus("data","highway",lines.length-2);
887 }
888
889
890 //
891 // Success in getting the transport data
892 //
893
894 function runTransportSuccess(response)
895 {
896 var lines=response.responseText.split("\n");
897
898 var style = new OpenLayers.Style({},{fill: false,
899 strokeWidth: 2,strokeColor: "#FF0000",
900 cursor: "pointer"});
901
902 var features=[];
903
904 for(var line=0;line<lines.length;line++)
905 {
906 var words=lines[line].split(" ");
907
908 if(line == 0)
909 {
910 var lat1=words[0];
911 var lon1=words[1];
912 var lat2=words[2];
913 var lon2=words[3];
914
915 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
916
917 box = new OpenLayers.Marker.Box(bounds);
918
919 layerBoxes.addMarker(box);
920 }
921 else if(words[0] != "")
922 {
923 var dump=words[0];
924 var lat1=words[1];
925 var lon1=words[2];
926 var lat2=words[3];
927 var lon2=words[4];
928
929 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
930 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
931
932 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
933 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
934
935 var segment = new OpenLayers.Geometry.LineString([point1,point2]);
936
937 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
938 }
939 }
940
941 select.activate();
942
943 layerVectors.addFeatures(features);
944
945 displayStatus("data","transport",lines.length-2);
946 }
947
948
949 //
950 // Success in getting the barrier data
951 //
952
953 function runBarrierSuccess(response)
954 {
955 var lines=response.responseText.split("\n");
956
957 var style = new OpenLayers.Style({},{stroke: false,
958 pointRadius: 3,fillColor: "#FF0000",
959 cursor: "pointer"});
960
961 var features=[];
962
963 for(var line=0;line<lines.length;line++)
964 {
965 var words=lines[line].split(" ");
966
967 if(line == 0)
968 {
969 var lat1=words[0];
970 var lon1=words[1];
971 var lat2=words[2];
972 var lon2=words[3];
973
974 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
975
976 box = new OpenLayers.Marker.Box(bounds);
977
978 layerBoxes.addMarker(box);
979 }
980 else if(words[0] != "")
981 {
982 var dump=words[0];
983 var lat=words[1];
984 var lon=words[2];
985
986 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
987
988 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
989
990 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},style));
991 }
992 }
993
994 select.activate();
995
996 layerVectors.addFeatures(features);
997
998 displayStatus("data","barrier",lines.length-2);
999 }
1000
1001
1002 //
1003 // Success in getting the turn restrictions data
1004 //
1005
1006 function runTurnsSuccess(response)
1007 {
1008 var lines=response.responseText.split("\n");
1009
1010 var style = new OpenLayers.Style({},{fill: false,
1011 strokeWidth: 2,strokeColor: "#FF0000",
1012 cursor: "pointer"});
1013
1014 var features=[];
1015
1016 for(var line=0;line<lines.length;line++)
1017 {
1018 var words=lines[line].split(" ");
1019
1020 if(line == 0)
1021 {
1022 var lat1=words[0];
1023 var lon1=words[1];
1024 var lat2=words[2];
1025 var lon2=words[3];
1026
1027 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1028
1029 box = new OpenLayers.Marker.Box(bounds);
1030
1031 layerBoxes.addMarker(box);
1032 }
1033 else if(words[0] != "")
1034 {
1035 var dump=words[0];
1036 var lat1=words[1];
1037 var lon1=words[2];
1038 var lat2=words[3];
1039 var lon2=words[4];
1040 var lat3=words[5];
1041 var lon3=words[6];
1042
1043 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
1044 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
1045 var lonlat3= new OpenLayers.LonLat(lon3,lat3).transform(epsg4326,epsg900913);
1046
1047 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
1048 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
1049 var point3 = new OpenLayers.Geometry.Point(lonlat3.lon,lonlat3.lat);
1050
1051 var segments = new OpenLayers.Geometry.LineString([point1,point2,point3]);
1052
1053 features.push(new OpenLayers.Feature.Vector(segments,{dump: dump},style));
1054 }
1055 }
1056
1057 select.activate();
1058
1059 layerVectors.addFeatures(features);
1060
1061 displayStatus("data","turns",lines.length-2);
1062 }
1063
1064
1065 //
1066 // Success in getting the speed/weight/height/width/length limits
1067 //
1068
1069 function runLimitSuccess(response)
1070 {
1071 var lines=response.responseText.split("\n");
1072
1073 var node_style = new OpenLayers.Style({},{stroke: false,
1074 pointRadius: 3,fillColor: "#FF0000",
1075 cursor: "pointer"});
1076
1077 var segment_style = new OpenLayers.Style({},{fill: false,
1078 strokeWidth: 2,strokeColor: "#FF0000",
1079 cursor: "pointer"});
1080
1081 var features=[];
1082
1083 var nodepoint;
1084 var nodelonlat;
1085
1086 for(var line=0;line<lines.length;line++)
1087 {
1088 var words=lines[line].split(" ");
1089
1090 if(line == 0)
1091 {
1092 var lat1=words[0];
1093 var lon1=words[1];
1094 var lat2=words[2];
1095 var lon2=words[3];
1096
1097 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1098
1099 box = new OpenLayers.Marker.Box(bounds);
1100
1101 layerBoxes.addMarker(box);
1102 }
1103 else if(words[0] != "")
1104 {
1105 var dump=words[0];
1106 var lat=words[1];
1107 var lon=words[2];
1108 var number=words[3];
1109
1110 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
1111
1112 if(number == undefined)
1113 {
1114 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
1115
1116 nodelonlat=lonlat;
1117 nodepoint = point;
1118
1119 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},node_style));
1120 }
1121 else
1122 {
1123 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
1124
1125 var segment = new OpenLayers.Geometry.LineString([nodepoint,point]);
1126
1127 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},segment_style));
1128
1129 var dlat = lonlat.lat-nodelonlat.lat;
1130 var dlon = lonlat.lon-nodelonlat.lon;
1131 var dist = Math.sqrt(dlat*dlat+dlon*dlon)/120;
1132
1133 point = new OpenLayers.Geometry.Point(nodelonlat.lon+dlon/dist,nodelonlat.lat+dlat/dist);
1134
1135 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},
1136 new OpenLayers.Style({},{externalGraphic: "icons/limit-" + number + ".png",
1137 graphicYOffset: -9,
1138 graphicWidth: 19,
1139 graphicHeight: 19})));
1140 }
1141 }
1142 }
1143
1144 select.activate();
1145
1146 layerVectors.addFeatures(features);
1147
1148 displayStatus("data","limit",lines.length-2);
1149 }
1150
1151
1152 //
1153 // Success in getting the property data
1154 //
1155
1156 function runPropertySuccess(response)
1157 {
1158 var lines=response.responseText.split("\n");
1159
1160 var style = new OpenLayers.Style({},{fill: false,
1161 strokeWidth: 2,strokeColor: "#FF0000",
1162 cursor: "pointer"});
1163
1164 var features=[];
1165
1166 for(var line=0;line<lines.length;line++)
1167 {
1168 var words=lines[line].split(" ");
1169
1170 if(line == 0)
1171 {
1172 var lat1=words[0];
1173 var lon1=words[1];
1174 var lat2=words[2];
1175 var lon2=words[3];
1176
1177 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1178
1179 box = new OpenLayers.Marker.Box(bounds);
1180
1181 layerBoxes.addMarker(box);
1182 }
1183 else if(words[0] != "")
1184 {
1185 var dump=words[0];
1186 var lat1=words[1];
1187 var lon1=words[2];
1188 var lat2=words[3];
1189 var lon2=words[4];
1190
1191 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
1192 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
1193
1194 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
1195 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
1196
1197 var segment = new OpenLayers.Geometry.LineString([point1,point2]);
1198
1199 features.push(new OpenLayers.Feature.Vector(segment,{dump: dump},style));
1200 }
1201 }
1202
1203 select.activate();
1204
1205 layerVectors.addFeatures(features);
1206
1207 displayStatus("data","property",lines.length-2);
1208 }
1209
1210
1211 //
1212 // Success in getting the error log data
1213 //
1214
1215 function runErrorlogSuccess(response)
1216 {
1217 var lines=response.responseText.split("\n");
1218
1219 var style = new OpenLayers.Style({},{stroke: false,
1220 pointRadius: 3,fillColor: "#FF0000",
1221 cursor: "pointer"});
1222
1223 var features=[];
1224
1225 for(var line=0;line<lines.length;line++)
1226 {
1227 var words=lines[line].split(" ");
1228
1229 if(line == 0)
1230 {
1231 var lat1=words[0];
1232 var lon1=words[1];
1233 var lat2=words[2];
1234 var lon2=words[3];
1235
1236 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
1237
1238 box = new OpenLayers.Marker.Box(bounds);
1239
1240 layerBoxes.addMarker(box);
1241 }
1242 else if(words[0] != "")
1243 {
1244 var dump=words[0];
1245 var lat=words[1];
1246 var lon=words[2];
1247
1248 var lonlat = new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
1249
1250 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
1251
1252 features.push(new OpenLayers.Feature.Vector(point,{dump: dump},style));
1253 }
1254 }
1255
1256 select.activate();
1257
1258 layerVectors.addFeatures(features);
1259
1260 displayStatus("data","errorlogs",lines.length-2);
1261 }
1262
1263
1264 //
1265 // Failure in getting data.
1266 //
1267
1268 function runFailure(response)
1269 {
1270 displayStatus("failed");
1271 }