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 1260 - (show annotations) (download) (as text)
Tue Feb 26 18:27:14 2013 UTC (12 years ago) by amb
File MIME type: application/javascript
File size: 26391 byte(s)
Clarify comment.

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 ];
42
43
44 //
45 // Junction styles
46 //
47
48 var junction_colours={
49 0: "#FFFFFF",
50 1: "#FF0000",
51 2: "#FFFF00",
52 3: "#00FF00",
53 4: "#8B4513",
54 5: "#00BFFF",
55 6: "#FF69B4",
56 7: "#000000",
57 8: "#000000",
58 9: "#000000"
59 };
60
61 var junction_styles={};
62
63
64 //
65 // Super styles
66 //
67
68 var super_node_style,super_segment_style;
69
70
71 //
72 // Oneway and turn restriction styles
73 //
74
75 var hex={0: "00", 1: "11", 2: "22", 3: "33", 4: "44", 5: "55", 6: "66", 7: "77",
76 8: "88", 9: "99", 10: "AA", 11: "BB", 12: "CC", 13: "DD", 14: "EE", 15: "FF"};
77
78 var turn_restriction_style;
79
80
81 ////////////////////////////////////////////////////////////////////////////////
82 /////////////////////////////// Initialisation /////////////////////////////////
83 ////////////////////////////////////////////////////////////////////////////////
84
85 // Process the URL query string and extract the arguments
86
87 var legal={"^lon" : "^[-0-9.]+$",
88 "^lat" : "^[-0-9.]+$",
89 "^zoom" : "^[0-9]+$"};
90
91 var args={};
92
93 if(location.search.length>1)
94 {
95 var query,queries;
96
97 query=location.search.replace(/^\?/,"");
98 query=query.replace(/;/g,'&');
99 queries=query.split('&');
100
101 for(var i=0;i<queries.length;i++)
102 {
103 queries[i].match(/^([^=]+)(=(.*))?$/);
104
105 k=RegExp.$1;
106 v=unescape(RegExp.$3);
107
108 for(var l in legal)
109 {
110 if(k.match(RegExp(l)) && v.match(RegExp(legal[l])))
111 args[k]=v;
112 }
113 }
114 }
115
116
117 ////////////////////////////////////////////////////////////////////////////////
118 ///////////////////////////////// Map handling /////////////////////////////////
119 ////////////////////////////////////////////////////////////////////////////////
120
121 var map;
122 var layerMap=[], layerVectors, layerBoxes;
123 var epsg4326, epsg900913;
124
125 var box;
126
127 //
128 // Initialise the 'map' object
129 //
130
131 function map_init() // called from visualiser.html
132 {
133 lon =args["lon"];
134 lat =args["lat"];
135 zoom=args["zoom"];
136
137 // Map URLs and limits are in mapprops.js.
138
139 //
140 // Create the map
141 //
142
143 epsg4326=new OpenLayers.Projection("EPSG:4326");
144 epsg900913=new OpenLayers.Projection("EPSG:900913");
145
146 map = new OpenLayers.Map ("map",
147 {
148 controls:[
149 new OpenLayers.Control.Navigation(),
150 new OpenLayers.Control.PanZoomBar(),
151 new OpenLayers.Control.ScaleLine(),
152 new OpenLayers.Control.LayerSwitcher()
153 ],
154
155 projection: epsg900913,
156 displayProjection: epsg4326,
157
158 minZoomLevel: mapprops.zoomout,
159 numZoomLevels: mapprops.zoomin-mapprops.zoomout+1,
160 maxResolution: 156543.03390625 / Math.pow(2,mapprops.zoomout),
161
162 // These two lines are not needed with OpenLayers 2.12
163 units: "m",
164 maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
165
166 restrictedExtent: new OpenLayers.Bounds(mapprops.westedge,mapprops.southedge,mapprops.eastedge,mapprops.northedge).transform(epsg4326,epsg900913)
167 });
168
169 // Add map tile layers
170
171 for(var l=0;l < mapprops.mapdata.length;l++)
172 {
173 layerMap[l] = new OpenLayers.Layer.TMS(mapprops.mapdata[l].label,
174 mapprops.mapdata[l].tileurl,
175 {
176 getURL: limitedUrl,
177 displayOutsideMaxExtent: true,
178 buffer: 1
179 });
180 map.addLayer(layerMap[l]);
181 }
182
183 // Update the attribution if the layer changes
184
185 map.events.register("changelayer",layerMap,change_attribution_event);
186
187 function change_attribution_event(event)
188 {
189 for(var l=0;l < mapprops.mapdata.length;l++)
190 if(this[l] == event.layer)
191 change_attribution(l);
192 }
193
194 function change_attribution(l)
195 {
196 var data_url =mapprops.mapdata[l].attribution.data_url;
197 var data_text=mapprops.mapdata[l].attribution.data_text;
198 var tile_url =mapprops.mapdata[l].attribution.tile_url;
199 var tile_text=mapprops.mapdata[l].attribution.tile_text;
200
201 document.getElementById("attribution_data").innerHTML="<a href=\"" + data_url + "\" target=\"data_attribution\">" + data_text + "</a>";
202 document.getElementById("attribution_tile").innerHTML="<a href=\"" + tile_url + "\" target=\"tile_attribution\">" + tile_text + "</a>";
203 }
204
205 change_attribution(0);
206
207 // Get a URL for the tile (mostly copied from OpenLayers/Layer/XYZ.js).
208
209 function limitedUrl(bounds)
210 {
211 var res = map.getResolution();
212 var res = this.getServerResolution();
213
214 var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
215 var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
216 var z = map.getZoom() + map.minZoomLevel;
217
218 var limit = Math.pow(2, z);
219 x = ((x % limit) + limit) % limit;
220
221 var xyz = {'x': x, 'y': y, 'z': z};
222 var url = this.url;
223
224 if (OpenLayers.Util.isArray(url))
225 {
226 var s = '' + xyz.x + xyz.y + xyz.z;
227 url = this.selectUrl(s, url);
228 }
229
230 return OpenLayers.String.format(url, xyz);
231 }
232
233 // Add a vectors layer
234
235 layerVectors = new OpenLayers.Layer.Vector("Markers");
236 map.addLayer(layerVectors);
237
238 for(var colour in junction_colours)
239 junction_styles[colour]=new OpenLayers.Style({},{stroke: false, pointRadius: 2,fillColor: junction_colours[colour]});
240
241 super_node_style =new OpenLayers.Style({},{stroke: false, pointRadius: 3,fillColor : "#FF0000"});
242 super_segment_style=new OpenLayers.Style({},{fill: false , strokeWidth: 2,strokeColor: "#FF0000"});
243
244 turn_restriction_style=new OpenLayers.Style({},{fill: false, strokeWidth: 2,strokeColor: "#FF0000"});
245
246 // Add a boxes layer
247
248 layerBoxes = new OpenLayers.Layer.Boxes("Boundary");
249 map.addLayer(layerBoxes);
250
251 box=null;
252
253 // Set the map centre to the limited range specified
254
255 map.setCenter(map.restrictedExtent.getCenterLonLat(), map.getZoomForExtent(map.restrictedExtent,true));
256 map.maxResolution = map.getResolution();
257
258 // Move the map
259
260 if(lon != undefined && lat != undefined && zoom != undefined)
261 {
262 if(lon<mapprops.westedge) lon=mapprops.westedge;
263 if(lon>mapprops.eastedge) lon=mapprops.eastedge;
264
265 if(lat<mapprops.southedge) lat=mapprops.southedge;
266 if(lat>mapprops.northedge) lat=mapprops.northedge;
267
268 if(zoom<mapprops.zoomout) zoom=mapprops.zoomout;
269 if(zoom>mapprops.zoomin) zoom=mapprops.zoomin;
270
271 var lonlat = new OpenLayers.LonLat(lon,lat);
272 lonlat.transform(epsg4326,epsg900913);
273
274 map.moveTo(lonlat,zoom-map.minZoomLevel);
275 }
276 }
277
278
279 //
280 // Format a number in printf("%.5f") format.
281 //
282
283 function format5f(number)
284 {
285 var newnumber=Math.floor(number*100000+0.5);
286 var delta=0;
287
288 if(newnumber>=0 && newnumber<100000) delta= 100000;
289 if(newnumber<0 && newnumber>-100000) delta=-100000;
290
291 var string=String(newnumber+delta);
292
293 var intpart =string.substring(0,string.length-5);
294 var fracpart=string.substring(string.length-5,string.length);
295
296 if(delta>0) intpart="0";
297 if(delta<0) intpart="-0";
298
299 return(intpart + "." + fracpart);
300 }
301
302
303 //
304 // Build a set of URL arguments for the map location
305 //
306
307 function buildMapArguments()
308 {
309 var lonlat = map.getCenter().clone();
310 lonlat.transform(epsg900913,epsg4326);
311
312 var zoom = map.getZoom() + map.minZoomLevel;
313
314 return "lat=" + format5f(lonlat.lat) + ";lon=" + format5f(lonlat.lon) + ";zoom=" + zoom;
315 }
316
317
318 //
319 // Update a URL
320 //
321
322 function updateURL(element) // called from visualiser.html
323 {
324 if(element.id == "permalink_url")
325 element.href=location.pathname + "?" + buildMapArguments();
326
327 if(element.id == "router_url")
328 element.href="router.html" + "?" + buildMapArguments();
329
330 if(element.id == "edit_url")
331 element.href="http://www.openstreetmap.org/edit" + "?" + buildMapArguments();
332
333 if(element.id.match(/^lang_([a-zA-Z-]+)_url$/))
334 element.href="visualiser.html" + "." + RegExp.$1 + "?" + buildMapArguments();
335 }
336
337
338 ////////////////////////////////////////////////////////////////////////////////
339 /////////////////////////////// Server handling ////////////////////////////////
340 ////////////////////////////////////////////////////////////////////////////////
341
342 //
343 // Display the status
344 //
345
346 function displayStatus(type,subtype,content)
347 {
348 var child=document.getElementById("result_status").firstChild;
349
350 do
351 {
352 if(child.id != undefined)
353 child.style.display="none";
354
355 child=child.nextSibling;
356 }
357 while(child != undefined);
358
359 var chosen_status=document.getElementById("result_status_" + type);
360
361 chosen_status.style.display="";
362
363 if(subtype != null)
364 {
365 var format_status=document.getElementById("result_status_" + subtype).innerHTML;
366
367 chosen_status.innerHTML=format_status.replace('#',String(content));
368 }
369 }
370
371
372 //
373 // Display data statistics
374 //
375
376 function displayStatistics()
377 {
378 // Use AJAX to get the statistics
379
380 OpenLayers.Request.GET({url: "statistics.cgi", success: runStatisticsSuccess});
381 }
382
383
384 //
385 // Success in running data statistics generation.
386 //
387
388 function runStatisticsSuccess(response)
389 {
390 document.getElementById("statistics_data").innerHTML="<pre>" + response.responseText + "</pre>";
391 document.getElementById("statistics_link").style.display="none";
392 }
393
394
395 //
396 // Get the requested data
397 //
398
399 function displayData(datatype) // called from visualiser.html
400 {
401 for(var data in data_types)
402 hideshow_hide(data_types[data]);
403
404 if(datatype != "")
405 hideshow_show(datatype);
406
407 // Delete the old data
408
409 layerVectors.destroyFeatures();
410
411 if(box != null)
412 layerBoxes.removeMarker(box);
413 box=null;
414
415 // Print the status
416
417 displayStatus("no_data");
418
419 // Return if just here to clear the data
420
421 if(datatype == "")
422 return;
423
424 // Get the new data
425
426 var mapbounds=map.getExtent().clone();
427 mapbounds.transform(epsg900913,epsg4326);
428
429 var url="visualiser.cgi";
430
431 url=url + "?lonmin=" + mapbounds.left;
432 url=url + ";latmin=" + mapbounds.bottom;
433 url=url + ";lonmax=" + mapbounds.right;
434 url=url + ";latmax=" + mapbounds.top;
435 url=url + ";data=" + datatype;
436
437 // Use AJAX to get the data
438
439 switch(datatype)
440 {
441 case 'junctions':
442 OpenLayers.Request.GET({url: url, success: runJunctionsSuccess, failure: runFailure});
443 break;
444 case 'super':
445 OpenLayers.Request.GET({url: url, success: runSuperSuccess, faliure: runFailure});
446 break;
447 case 'oneway':
448 OpenLayers.Request.GET({url: url, success: runOnewaySuccess, failure: runFailure});
449 break;
450 case 'highway':
451 var highways=document.forms["highways"].elements["highway"];
452 for(var h in highways)
453 if(highways[h].checked)
454 highway=highways[h].value;
455 url+="-" + highway;
456 OpenLayers.Request.GET({url: url, success: runHighwaySuccess, falure: runFailure});
457 break;
458 case 'transport':
459 var transports=document.forms["transports"].elements["transport"];
460 for(var t in transports)
461 if(transports[t].checked)
462 transport=transports[t].value;
463 url+="-" + transport;
464 OpenLayers.Request.GET({url: url, success: runTransportSuccess, failure: runFailure});
465 break;
466 case 'barrier':
467 var transports=document.forms["barriers"].elements["barrier"];
468 for(var t in transports)
469 if(transports[t].checked)
470 transport=transports[t].value;
471 url+="-" + transport;
472 OpenLayers.Request.GET({url: url, success: runBarrierSuccess, failure: runFailure});
473 break;
474 case 'turns':
475 OpenLayers.Request.GET({url: url, success: runTurnsSuccess, failure: runFailure});
476 break;
477 case 'speed':
478 case 'weight':
479 case 'height':
480 case 'width':
481 case 'length':
482 OpenLayers.Request.GET({url: url, success: runLimitSuccess, failure: runFailure});
483 break;
484 case 'property':
485 var properties=document.forms["properties"].elements["property"];
486 for(var p in properties)
487 if(properties[p].checked)
488 property=properties[p].value;
489 url+="-" + property;
490 OpenLayers.Request.GET({url: url, success: runPropertySuccess, falure: runFailure});
491 break;
492 }
493 }
494
495
496 //
497 // Success in getting the junctions.
498 //
499
500 function runJunctionsSuccess(response)
501 {
502 var lines=response.responseText.split('\n');
503
504 var features=[];
505
506 for(var line=0;line<lines.length;line++)
507 {
508 var words=lines[line].split(' ');
509
510 if(line == 0)
511 {
512 var lat1=words[0];
513 var lon1=words[1];
514 var lat2=words[2];
515 var lon2=words[3];
516
517 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
518
519 box = new OpenLayers.Marker.Box(bounds);
520
521 layerBoxes.addMarker(box);
522 }
523 else if(words[0] != "")
524 {
525 var lat=words[0];
526 var lon=words[1];
527 var count=words[2];
528
529 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
530
531 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
532
533 features.push(new OpenLayers.Feature.Vector(point,{},junction_styles[count]));
534 }
535 }
536
537 layerVectors.addFeatures(features);
538
539 displayStatus("data","junctions",lines.length-2);
540 }
541
542
543 //
544 // Success in getting the super-node and super-segments
545 //
546
547 function runSuperSuccess(response)
548 {
549 var lines=response.responseText.split('\n');
550
551 var features=[];
552
553 var nodepoint;
554
555 for(var line=0;line<lines.length;line++)
556 {
557 var words=lines[line].split(' ');
558
559 if(line == 0)
560 {
561 var lat1=words[0];
562 var lon1=words[1];
563 var lat2=words[2];
564 var lon2=words[3];
565
566 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
567
568 box = new OpenLayers.Marker.Box(bounds);
569
570 layerBoxes.addMarker(box);
571 }
572 else if(words[0] != "")
573 {
574 var lat=words[0];
575 var lon=words[1];
576 var type=words[2];
577
578 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
579
580 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
581
582 if(type == "n")
583 {
584 nodepoint=point;
585
586 features.push(new OpenLayers.Feature.Vector(point,{},super_node_style));
587 }
588 else
589 {
590 var segment = new OpenLayers.Geometry.LineString([nodepoint,point]);
591
592 features.push(new OpenLayers.Feature.Vector(segment,{},super_segment_style));
593 }
594 }
595 }
596
597 layerVectors.addFeatures(features);
598
599 displayStatus("data","super",lines.length-2);
600 }
601
602
603 //
604 // Success in getting the oneway data
605 //
606
607 function runOnewaySuccess(response)
608 {
609 var lines=response.responseText.split('\n');
610
611 var features=[];
612
613 for(var line=0;line<lines.length;line++)
614 {
615 var words=lines[line].split(' ');
616
617 if(line == 0)
618 {
619 var lat1=words[0];
620 var lon1=words[1];
621 var lat2=words[2];
622 var lon2=words[3];
623
624 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
625
626 box = new OpenLayers.Marker.Box(bounds);
627
628 layerBoxes.addMarker(box);
629 }
630 else if(words[0] != "")
631 {
632 var lat1=words[0];
633 var lon1=words[1];
634 var lat2=words[2];
635 var lon2=words[3];
636
637 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
638 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
639
640 //var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
641 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
642
643 var dlat = lonlat2.lat-lonlat1.lat;
644 var dlon = lonlat2.lon-lonlat1.lon;
645 var dist = Math.sqrt(dlat*dlat+dlon*dlon)/10;
646 var ang = Math.atan2(dlat,dlon);
647
648 var point3 = new OpenLayers.Geometry.Point(lonlat1.lon+dlat/dist,lonlat1.lat-dlon/dist);
649 var point4 = new OpenLayers.Geometry.Point(lonlat1.lon-dlat/dist,lonlat1.lat+dlon/dist);
650
651 var segment = new OpenLayers.Geometry.LineString([point2,point3,point4,point2]);
652
653 var r=Math.round(7.5+7.9*Math.cos(ang));
654 var g=Math.round(7.5+7.9*Math.cos(ang+2.0943951));
655 var b=Math.round(7.5+7.9*Math.cos(ang-2.0943951));
656 var colour = "#" + hex[r] + hex[g] + hex[b];
657
658 var style=new OpenLayers.Style({},{strokeWidth: 2,strokeColor: colour});
659
660 features.push(new OpenLayers.Feature.Vector(segment,{},style));
661 }
662 }
663
664 layerVectors.addFeatures(features);
665
666 displayStatus("data","oneway",lines.length-2);
667 }
668
669
670 //
671 // Success in getting the highway data
672 //
673
674 function runHighwaySuccess(response)
675 {
676 var lines=response.responseText.split('\n');
677
678 var features=[];
679
680 for(var line=0;line<lines.length;line++)
681 {
682 var words=lines[line].split(' ');
683
684 if(line == 0)
685 {
686 var lat1=words[0];
687 var lon1=words[1];
688 var lat2=words[2];
689 var lon2=words[3];
690
691 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
692
693 box = new OpenLayers.Marker.Box(bounds);
694
695 layerBoxes.addMarker(box);
696 }
697 else if(words[0] != "")
698 {
699 var lat1=words[0];
700 var lon1=words[1];
701 var lat2=words[2];
702 var lon2=words[3];
703
704 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
705 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
706
707 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
708 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
709
710 var segment = new OpenLayers.Geometry.LineString([point1,point2]);
711
712 features.push(new OpenLayers.Feature.Vector(segment,{},super_segment_style));
713 }
714 }
715
716 layerVectors.addFeatures(features);
717
718 displayStatus("data","highway",lines.length-2);
719 }
720
721
722 //
723 // Success in getting the transport data
724 //
725
726 function runTransportSuccess(response)
727 {
728 var lines=response.responseText.split('\n');
729
730 var features=[];
731
732 for(var line=0;line<lines.length;line++)
733 {
734 var words=lines[line].split(' ');
735
736 if(line == 0)
737 {
738 var lat1=words[0];
739 var lon1=words[1];
740 var lat2=words[2];
741 var lon2=words[3];
742
743 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
744
745 box = new OpenLayers.Marker.Box(bounds);
746
747 layerBoxes.addMarker(box);
748 }
749 else if(words[0] != "")
750 {
751 var lat1=words[0];
752 var lon1=words[1];
753 var lat2=words[2];
754 var lon2=words[3];
755
756 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
757 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
758
759 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
760 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
761
762 var segment = new OpenLayers.Geometry.LineString([point1,point2]);
763
764 features.push(new OpenLayers.Feature.Vector(segment,{},super_segment_style));
765 }
766 }
767
768 layerVectors.addFeatures(features);
769
770 displayStatus("data","transport",lines.length-2);
771 }
772
773
774 //
775 // Success in getting the barrier data
776 //
777
778 function runBarrierSuccess(response)
779 {
780 var lines=response.responseText.split('\n');
781
782 var features=[];
783
784 for(var line=0;line<lines.length;line++)
785 {
786 var words=lines[line].split(' ');
787
788 if(line == 0)
789 {
790 var lat1=words[0];
791 var lon1=words[1];
792 var lat2=words[2];
793 var lon2=words[3];
794
795 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
796
797 box = new OpenLayers.Marker.Box(bounds);
798
799 layerBoxes.addMarker(box);
800 }
801 else if(words[0] != "")
802 {
803 var lat=words[0];
804 var lon=words[1];
805
806 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
807
808 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
809
810 features.push(new OpenLayers.Feature.Vector(point,{},super_node_style));
811 }
812 }
813
814 layerVectors.addFeatures(features);
815
816 displayStatus("data","barrier",lines.length-2);
817 }
818
819
820 //
821 // Success in getting the turn restrictions data
822 //
823
824 function runTurnsSuccess(response)
825 {
826 var lines=response.responseText.split('\n');
827
828 var features=[];
829
830 for(var line=0;line<lines.length;line++)
831 {
832 var words=lines[line].split(' ');
833
834 if(line == 0)
835 {
836 var lat1=words[0];
837 var lon1=words[1];
838 var lat2=words[2];
839 var lon2=words[3];
840
841 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
842
843 box = new OpenLayers.Marker.Box(bounds);
844
845 layerBoxes.addMarker(box);
846 }
847 else if(words[0] != "")
848 {
849 var lat1=words[0];
850 var lon1=words[1];
851 var lat2=words[2];
852 var lon2=words[3];
853 var lat3=words[4];
854 var lon3=words[5];
855
856 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
857 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
858 var lonlat3= new OpenLayers.LonLat(lon3,lat3).transform(epsg4326,epsg900913);
859
860 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
861 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
862 var point3 = new OpenLayers.Geometry.Point(lonlat3.lon,lonlat3.lat);
863
864 var segments = new OpenLayers.Geometry.LineString([point1,point2,point3]);
865
866 features.push(new OpenLayers.Feature.Vector(segments,{},turn_restriction_style));
867 }
868 }
869
870 layerVectors.addFeatures(features);
871
872 displayStatus("data","turns",lines.length-2);
873 }
874
875
876 //
877 // Success in getting the speed/weight/height/width/length limits
878 //
879
880 function runLimitSuccess(response)
881 {
882 var lines=response.responseText.split('\n');
883
884 var features=[];
885
886 var nodelonlat;
887
888 for(var line=0;line<lines.length;line++)
889 {
890 var words=lines[line].split(' ');
891
892 if(line == 0)
893 {
894 var lat1=words[0];
895 var lon1=words[1];
896 var lat2=words[2];
897 var lon2=words[3];
898
899 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
900
901 box = new OpenLayers.Marker.Box(bounds);
902
903 layerBoxes.addMarker(box);
904 }
905 else if(words[0] != "")
906 {
907 var lat=words[0];
908 var lon=words[1];
909 var number=words[2];
910
911 var lonlat= new OpenLayers.LonLat(lon,lat).transform(epsg4326,epsg900913);
912
913 if(number == undefined)
914 {
915 var point = new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat);
916
917 nodelonlat=lonlat;
918
919 features.push(new OpenLayers.Feature.Vector(point,{},junction_styles[1]));
920 }
921 else
922 {
923 var dlat = lonlat.lat-nodelonlat.lat;
924 var dlon = lonlat.lon-nodelonlat.lon;
925 var dist = Math.sqrt(dlat*dlat+dlon*dlon)/60;
926
927 var point = new OpenLayers.Geometry.Point(nodelonlat.lon+dlon/dist,nodelonlat.lat+dlat/dist);
928
929 features.push(new OpenLayers.Feature.Vector(point,{},
930 new OpenLayers.Style({},{externalGraphic: 'icons/limit-' + number + '.png',
931 graphicYOffset: -9,
932 graphicWidth: 19,
933 graphicHeight: 19})));
934 }
935 }
936 }
937
938 layerVectors.addFeatures(features);
939
940 displayStatus("data","limit",lines.length-2);
941 }
942
943
944 //
945 // Success in getting the property data
946 //
947
948 function runPropertySuccess(response)
949 {
950 var lines=response.responseText.split('\n');
951
952 var features=[];
953
954 for(var line=0;line<lines.length;line++)
955 {
956 var words=lines[line].split(' ');
957
958 if(line == 0)
959 {
960 var lat1=words[0];
961 var lon1=words[1];
962 var lat2=words[2];
963 var lon2=words[3];
964
965 var bounds = new OpenLayers.Bounds(lon1,lat1,lon2,lat2).transform(epsg4326,epsg900913);
966
967 box = new OpenLayers.Marker.Box(bounds);
968
969 layerBoxes.addMarker(box);
970 }
971 else if(words[0] != "")
972 {
973 var lat1=words[0];
974 var lon1=words[1];
975 var lat2=words[2];
976 var lon2=words[3];
977
978 var lonlat1= new OpenLayers.LonLat(lon1,lat1).transform(epsg4326,epsg900913);
979 var lonlat2= new OpenLayers.LonLat(lon2,lat2).transform(epsg4326,epsg900913);
980
981 var point1 = new OpenLayers.Geometry.Point(lonlat1.lon,lonlat1.lat);
982 var point2 = new OpenLayers.Geometry.Point(lonlat2.lon,lonlat2.lat);
983
984 var segment = new OpenLayers.Geometry.LineString([point1,point2]);
985
986 features.push(new OpenLayers.Feature.Vector(segment,{},super_segment_style));
987 }
988 }
989
990 layerVectors.addFeatures(features);
991
992 displayStatus("data","property",lines.length-2);
993 }
994
995
996 //
997 // Failure in getting data.
998 //
999
1000 function runFailure(response)
1001 {
1002 displayStatus("error");
1003 }