/*! * Copyright© 2017 OSM Buildings, Jan Marsch * @osmbuildings, http://osmbuildings.org * * OSMBuildings-OL3.js * github: https://github.com/kekscom/osmbuildings * license: BSD 2-clause * * version 0.2.2b * */ (function(Z){function L(b,a){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d}function pa(b){var a=b.length;if(16>a)return!1;var c,d=Infinity,e=-Infinity,g=Infinity,f=-Infinity;for(c=0;ce||1.15f/g||1.2=a?90:1<=a?-90:(2*qa(ra(B*(1- 2*a)))-G)/B*180;c.latitude=d;c.longitude=360*(1===b?1:(b%1+1)%1)-180;return c}function aa(b,a){var c=N(1,H(0,.5-sa(ga(ta+G*b/180))/B/2));return{x:(a/360+.5)*M<<0,y:c*M<<0}}function O(b){for(var a=y+n,c=z+q,d=0,e=b.length-3;dn&&b[d]q&&b[d+1]b[c].scale&&(b[c].scale+=.1,1c&&(c+=1);1c?b:c<2/3?a+(b-a)*(2/3-c)*6:a}function a(a, b){if(void 0!==a)return Math.min(b,Math.max(0,a||0))}var c={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b", darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22", fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90", lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970", mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513", salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},d=function(b,c,d,k){this.r=a(b,1);this.g=a(c,1);this.b=a(d,1); this.a=a(k,1)||1};d.parse=function(a){if("string"===typeof a){a=a.toLowerCase();a=c[a]||a;var b;if(b=a.match(/^#?(\w{2})(\w{2})(\w{2})$/))return new d(parseInt(b[1],16)/255,parseInt(b[2],16)/255,parseInt(b[3],16)/255);if(b=a.match(/rgba?\((\d+)\D+(\d+)\D+(\d+)(\D+([\d.]+))?\)/))return new d(parseFloat(b[1])/255,parseFloat(b[2])/255,parseFloat(b[3])/255,b[4]?parseFloat(b[5]):1)}return new d};d.fromHSL=function(a,c,f,k){if(0===c)return new d(f,f,f,k);c=.5>f?f*(1+c):f+c-f*c;f=2*f-c;a/=360;return new d(b(f, c,a+1/3),b(f,c,a),b(f,c,a-1/3),k)};d.prototype={toHSL:function(){if(void 0!==this.r&&void 0!==this.g&&void 0!==this.b){var a=Math.max(this.r,this.g,this.b),b=Math.min(this.r,this.g,this.b),c,d=(a+b)/2,h=a-b;if(h){b=.5f.status||299f&&(h=g,f=k)}2a.length))return a},resetItems:function(){this.items=[];this.loadedItems= {};T.reset()},addRenderItems:function(b,a){for(var c,d,e,g=Ba.read(b),f=0,k=g.length;fca)&&(a.footprint=this.getPixelFootprint(b.footprint),a.footprint)){for(var d=a.footprint, e=Infinity,g=-Infinity,f=Infinity,k=-Infinity,h=0,l=d.length-3;hx))if(this.isStatic&&this._staticData)this.addRenderItems(this._staticData);else if(this.src){var a=16>16-x,c=n/a<<0,d=q/a<<0,e=ia((n+y)/a),a=ia((q+z)/a),g,f=this;for(g=d;g<=a;g++)for(d=c;d<=e;d++)this.loadTile(d,g,16,b)}},loadTile:function(b,a,c,d){b=this.src.replace("{s}","abcd"[(b+a)%4]).replace("{x}",b).replace("{y}",a).replace("{z}",c);return Ca.loadJSON(b,d)}},U={draw:function(b, a,c,d,e,g,f,k){var h,l=this._extrude(b,a,d,e,g,f),m=[];if(c)for(a=0,h=c.length;a(l.x-k.x)*(h.y-k.y)&&(b.fillStyle=k.xh.x&&k.y>h.y?g:e,b.beginPath(),this._ring(b,[h.x,h.y,k.x,k.y,l.x,l.y,m.x,m.y]),b.closePath(),b.fill()),p[r]=l.x,p[r+1]=l.y;return p},_ring:function(b,a){b.moveTo(a[0],a[1]);for(var c=2,d=a.length-1;c(h.x-f.x)*(k.y-f.y)?(1===g&&b.lineTo(f.x,f.y),g=0,m||b.moveTo(f.x,f.y),b.lineTo(k.x,k.y)):(0===g&&b.lineTo(h.x,h.y),g=1,m||b.moveTo(h.x,h.y),b.lineTo(l.x,l.y));if(c)for(m=0,p=c.length;m(g.x-f.x)*(k.y-f.y)?(1===c&&b.lineTo(f.x,f.y),c=0,m||b.moveTo(f.x,f.y),b.lineTo(k.x, k.y)):(0===c&&b.lineTo(g.x,g.y),c=1,m||b.moveTo(g.x,g.y),b.lineTo(l.x,l.y));b.closePath();b.fill()}},t={draw:function(b,a,c,d,e,g,f,k,h){a={x:a.x-n,y:a.y-q};var l=450/(450-e),m=450/(450-g);e=u.project(a,l);d*=l;g&&(a=u.project(a,m),c*=m);(l=this._tangents(a,c,e,d))?(g=I(l[0].y1-a.y,l[0].x1-a.x),l=I(l[1].y1-a.y,l[1].x1-a.x)):(g=1.5*B,l=1.5*B);b.fillStyle=f;b.beginPath();b.arc(e.x,e.y,d,G,g,!0);b.arc(a.x,a.y,c,g,G);b.closePath();b.fill();b.fillStyle=k;b.beginPath();b.arc(e.x,e.y,d,l,G,!0);b.arc(a.x, a.y,c,G,l);b.closePath();b.fill();b.fillStyle=h;this._circle(b,e,d)},simplified:function(b,a,c){this._circle(b,{x:a.x-n,y:a.y-q},c)},shadow:function(b,a,c,d,e,g){a={x:a.x-n,y:a.y-q};e=v.project(a,e);var f;g&&(a=v.project(a,g));var k=this._tangents(a,c,e,d);k?(g=I(k[0].y1-a.y,k[0].x1-a.x),f=I(k[1].y1-a.y,k[1].x1-a.x),b.moveTo(k[1].x2,k[1].y2),b.arc(e.x,e.y,d,f,g),b.arc(a.x,a.y,c,g,f)):(b.moveTo(a.x+c,a.y),b.arc(a.x,a.y,c,0,2*B))},shadowMask:function(b,a,c){var d=a.x-n;a=a.y-q;b.moveTo(d+c,a);b.arc(d, a,c,0,2*B)},hitArea:function(b,a,c,d,e,g,f){a={x:a.x-n,y:a.y-q};var k=450/(450-e),h=450/(450-g);e=u.project(a,k);d*=k;g&&(a=u.project(a,h),c*=h);g=this._tangents(a,c,e,d);b.fillStyle=f;b.beginPath();g?(f=I(g[0].y1-a.y,g[0].x1-a.x),k=I(g[1].y1-a.y,g[1].x1-a.x),b.moveTo(g[1].x2,g[1].y2),b.arc(e.x,e.y,d,k,f),b.arc(a.x,a.y,c,f,k)):(b.moveTo(a.x+c,a.y),b.arc(a.x,a.y,c,0,2*B));b.closePath();b.fill()},_circle:function(b,a,c){b.beginPath();b.arc(a.x,a.y,c,0,2*B);b.stroke();b.fill()},_tangents:function(b, a,c,d){var e=b.x-c.x,g=b.y-c.y,f=a-d,k=e*e+g*g;if(!(k<=f*f)){var k=ha(k),e=-e/k,g=-g/k,f=f/k,k=[],h,l,m;h=ha(H(0,1-f*f));for(var p=1;-1<=p;p-=2)l=e*f-p*h*g,m=g*f+p*h*e,k.push({x1:b.x+a*l<<0,y1:b.y+a*m<<0,x2:c.x+d*l<<0,y2:c.y+d*m<<0});return k}}},K={draw:function(b,a,c,d,e,g,f){var k=450/(450-e);c=u.project({x:c.x-n,y:c.y-q},450/(450-d));d={x:0,y:0};for(var h={x:0,y:0},l=0,m=a.length-3;l(c.x-d.x)*(h.y-d.y)&&(b.fillStyle=d.xh.x&&d.y>h.y?f:g,b.beginPath(),this._triangle(b,d,h,c),b.closePath(),b.fill())},_triangle:function(b,a,c,d){b.moveTo(a.x,a.y);b.lineTo(c.x,c.y);b.lineTo(d.x,d.y)},_ring:function(b,a){b.moveTo(a[0]-n,a[1]-q);for(var c=2,d=a.length-1;c(c.x-g.x)*(f.y-g.y)&&this._triangle(b,g,f,c)},shadowMask:function(b,a){this._ring(b,a)},hitArea:function(b,a,c,d,e,g){var f=450/(450-e);c=u.project({x:c.x-n,y:c.y-q},450/(450-d));d={x:0,y:0};var k={x:0,y:0};b.fillStyle=g;b.beginPath();g=0;for(var h=a.length-3;g(c.x-d.x)*(k.y-d.y)&&this._triangle(b,d,k,c);b.closePath();b.fill()}}, u={project:function(b,a){return{x:(b.x-Q)*a+Q<<0,y:(b.y-R)*a+R<<0}},render:function(){var b=this.context;b.clearRect(0,0,y,z);if(!(15>x)){var a,c,d,e={x:Q+n,y:R+q},g,f,k,h,l=D.items;l.sort(function(a,b){return a.minHeight-b.minHeight||L(b.center,e)-L(a.center,e)||b.height-a.height});for(var m=0,p=l.length;ma.scale?a.height*a.scale:a.height;d=0;a.minHeight&&(d=1>a.scale?a.minHeight*a.scale:a.minHeight);f=a.wallColor||da;k=a.altColor||Y;h= a.roofColor||S;b.strokeStyle=k;switch(a.shape){case "cylinder":t.draw(b,a.center,a.radius,a.radius,c,d,f,k,h);break;case "cone":t.draw(b,a.center,a.radius,0,c,d,f,k);break;case "dome":t.draw(b,a.center,a.radius,a.radius/2,c,d,f,k);break;case "sphere":t.draw(b,a.center,a.radius,a.radius,c,d,f,k,h);break;case "pyramid":K.draw(b,g,a.center,c,d,f,k);break;default:U.draw(b,g,a.holes,c,d,f,k,h)}switch(a.roofShape){case "cone":t.draw(b,a.center,a.radius,0,c+a.roofHeight,c,h,""+E.parse(h).lightness(.9)); break;case "dome":t.draw(b,a.center,a.radius,a.radius/2,c+a.roofHeight,c,h,""+E.parse(h).lightness(.9));break;case "pyramid":K.draw(b,g,a.center,c+a.roofHeight,c,h,E.parse(h).lightness(.9))}}}}},ea={maxZoom:17,maxHeight:5,isSimple:function(b){return x<=this.maxZoom&&b.height+b.roofHeightx||x>this.maxZoom))for(var a,c,d=D.items,e=0,g=d.length;e=this.maxHeight)&&(c=a.footprint,O(c)))switch(b.strokeStyle= a.altColor||Y,b.fillStyle=a.roofColor||S,a.shape){case "cylinder":case "cone":case "dome":case "sphere":t.simplified(b,a.center,a.radius);break;default:U.simplified(b,c,a.holes)}}},v={enabled:!0,color:"#666666",blurColor:"#000000",blurSize:15,date:new Date,direction:{x:0,y:0},project:function(b,a){return{x:b.x+this.direction.x*a,y:b.y+this.direction.y*a}},render:function(){var b=this.context,a,c,d;b.clearRect(0,0,y,z);if(!(!this.enabled||15>x||(a=fa(W+n,ba+q),a=za(this.date,a.latitude,a.longitude), 0>=a.altitude))){c=1/ga(a.altitude);d=5>c?.75:1/c*5;this.direction.x=xa(a.azimuth)*c;this.direction.y=wa(a.azimuth)*c;var e,g,f,k;a=D.items;b.canvas.style.opacity=d/(2*A);b.shadowColor=this.blurColor;b.shadowBlur=A/2*this.blurSize;b.fillStyle=this.color;b.beginPath();d=0;for(c=a.length;de.scale?e.height*e.scale:e.height;f=0;e.minHeight&&(f=1>e.scale?e.minHeight*e.scale:e.minHeight);switch(e.shape){case "cylinder":t.shadow(b,e.center,e.radius,e.radius,g,f); break;case "cone":t.shadow(b,e.center,e.radius,0,g,f);break;case "dome":t.shadow(b,e.center,e.radius,e.radius/2,g,f);break;case "sphere":t.shadow(b,e.center,e.radius,e.radius,g,f);break;case "pyramid":K.shadow(b,k,e.center,g,f);break;default:U.shadow(b,k,e.holes,g,f)}switch(e.roofShape){case "cone":t.shadow(b,e.center,e.radius,0,g+e.roofHeight,g);break;case "dome":t.shadow(b,e.center,e.radius,e.radius/2,g+e.roofHeight,g);break;case "pyramid":K.shadow(b,k,e.center,g+e.roofHeight,g)}}b.closePath(); b.fill();b.shadowBlur=null;b.globalCompositeOperation="destination-out";b.beginPath();d=0;for(c=a.length;dx)){var a,c,d,e={x:Q+n,y:R+q},g,f,k=D.items;k.sort(function(a,b){return a.minHeight-b.minHeight||L(b.center,e)-L(a.center,e)||b.height-a.height});for(var h=0,l=k.length;h>8&255,a>>16&255].join()+")"}},V,P={container:document.createElement("DIV"),items:[],init:function(){this.container.style.pointerEvents="none";this.container.style.position="absolute";this.container.style.left=0;this.container.style.top=0;v.context=this.createContext(this.container); ea.context=this.createContext(this.container);u.context=this.createContext(this.container);T.context=this.createContext()},render:function(b){ya(function(){b||(v.render(),ea.render(),T.render());u.render()})},createContext:function(b){var a=document.createElement("CANVAS");a.style.transform="translate3d(0, 0, 0)";a.style.imageRendering="optimizeSpeed";a.style.position="absolute";a.style.left=0;a.style.top=0;var c=a.getContext("2d");c.lineCap="round";c.lineJoin="round";c.lineWidth=1;c.imageSmoothingEnabled= !1;this.items.push(a);b&&b.appendChild(a);return c},appendTo:function(b){b.appendChild(this.container)},remove:function(){this.container.parentNode.removeChild(this.container)},setSize:function(b,a){for(var c=0,d=this.items.length;c