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 1248 - (show annotations) (download) (as text)
Thu Jan 24 19:35:05 2013 UTC (12 years, 1 month ago) by amb
File MIME type: application/javascript
File size: 26483 byte(s)
Add the ability for the visualiser to display highways that have a particular
property.

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