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