UNPKG

mapbox-gl

Version:
30 lines 512 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mapboxgl = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ "use strict";function ArrayGroup(r){var e=r.layoutVertexArrayType;this.layoutVertexArray=new e;var t=r.elementArrayType;t&&(this.elementArray=new t);var a=r.elementArrayType2;a&&(this.elementArray2=new a),this.paintVertexArrays=util.mapObject(r.paintVertexArrayTypes,function(r){return new r})}var util=require("../util/util");module.exports=ArrayGroup,ArrayGroup.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ArrayGroup.prototype.hasCapacityFor=function(r){return this.layoutVertexArray.length+r<=ArrayGroup.MAX_VERTEX_ARRAY_LENGTH},ArrayGroup.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length},ArrayGroup.prototype.trim=function(){this.layoutVertexArray.trim(),this.elementArray&&this.elementArray.trim(),this.elementArray2&&this.elementArray2.trim();for(var r in this.paintVertexArrays)this.paintVertexArrays[r].trim()},ArrayGroup.prototype.serialize=function(){return{layoutVertexArray:this.layoutVertexArray.serialize(),elementArray:this.elementArray&&this.elementArray.serialize(),elementArray2:this.elementArray2&&this.elementArray2.serialize(),paintVertexArrays:util.mapObject(this.paintVertexArrays,function(r){return r.serialize()})}},ArrayGroup.prototype.getTransferables=function(r){r.push(this.layoutVertexArray.arrayBuffer),this.elementArray&&r.push(this.elementArray.arrayBuffer),this.elementArray2&&r.push(this.elementArray2.arrayBuffer);for(var e in this.paintVertexArrays)r.push(this.paintVertexArrays[e].arrayBuffer)}; },{"../util/util":122}],2:[function(require,module,exports){ "use strict";function Bucket(e){if(this.zoom=e.zoom,this.overscaling=e.overscaling,this.layer=e.layer,this.childLayers=e.childLayers,this.type=this.layer.type,this.features=[],this.id=this.layer.id,this.index=e.index,this.sourceLayer=this.layer.sourceLayer,this.sourceLayerIndex=e.sourceLayerIndex,this.minZoom=this.layer.minzoom,this.maxZoom=this.layer.maxzoom,this.paintAttributes=createPaintAttributes(this),e.arrays){var r=this.programInterfaces;this.bufferGroups=util.mapObject(e.arrays,function(t,a){var i=r[a],n=e.paintVertexArrayTypes[a];return t.map(function(e){return new BufferGroup(e,{layoutVertexArrayType:i.layoutVertexArrayType.serialize(),elementArrayType:i.elementArrayType&&i.elementArrayType.serialize(),elementArrayType2:i.elementArrayType2&&i.elementArrayType2.serialize(),paintVertexArrayTypes:n})})})}}function createPaintAttributes(e){var r={};for(var t in e.programInterfaces){for(var a=r[t]={},i=0;i<e.childLayers.length;i++){var n=e.childLayers[i];a[n.id]={attributes:[],uniforms:[],defines:[],vertexPragmas:{define:{},initialize:{}},fragmentPragmas:{define:{},initialize:{}}}}var o=e.programInterfaces[t];if(o.paintAttributes)for(var s="{precision}",u="{type}",l=0;l<o.paintAttributes.length;l++){var y=o.paintAttributes[l];y.multiplier=y.multiplier||1;for(var p=0;p<e.childLayers.length;p++){var c,f=e.childLayers[p],m=a[f.id],h=y.name,g=y.name.slice(2);if(m.fragmentPragmas.initialize[g]="",f.isPaintValueFeatureConstant(y.paintProperty))m.uniforms.push(y),m.fragmentPragmas.define[g]=m.vertexPragmas.define[g]=["uniform",s,u,h].join(" ")+";",m.fragmentPragmas.initialize[g]=m.vertexPragmas.initialize[g]=[s,u,g,"=",h].join(" ")+";\n";else if(f.isPaintValueZoomConstant(y.paintProperty)){m.attributes.push(util.extend({},y,{name:h})),c=["varying",s,u,g].join(" ")+";\n";var v=[m.fragmentPragmas.define[g],"attribute",s,u,h].join(" ")+";\n";m.fragmentPragmas.define[g]=c,m.vertexPragmas.define[g]=c+v,m.vertexPragmas.initialize[g]=[g,"=",h,"/",y.multiplier.toFixed(1)].join(" ")+";\n"}else{for(var d="u_"+h.slice(2)+"_t",x=f.getPaintValueStopZoomLevels(y.paintProperty),A=0;A<x.length&&x[A]<e.zoom;)A++;for(var b=Math.max(0,Math.min(x.length-4,A-2)),T=[],V=0;V<4;V++)T.push(x[Math.min(b+V,x.length-1)]);c=["varying",s,u,g].join(" ")+";\n",m.vertexPragmas.define[g]=c+["uniform","lowp","float",d].join(" ")+";\n",m.fragmentPragmas.define[g]=c,m.uniforms.push(util.extend({},y,{name:d,getValue:createGetUniform(y,b),components:1}));var P=y.components;if(1===P)m.attributes.push(util.extend({},y,{getValue:createFunctionGetValue(y,T),isFunction:!0,components:4*P})),m.vertexPragmas.define[g]+=["attribute",s,"vec4",h].join(" ")+";\n",m.vertexPragmas.initialize[g]=[g,"=","evaluate_zoom_function_1("+h+", "+d+")","/",y.multiplier.toFixed(1)].join(" ")+";\n";else{for(var k=[],z=0;z<4;z++)k.push(h+z),m.attributes.push(util.extend({},y,{getValue:createFunctionGetValue(y,[T[z]]),isFunction:!0,name:h+z})),m.vertexPragmas.define[g]+=["attribute",s,u,h+z].join(" ")+";\n";m.vertexPragmas.initialize[g]=[g," = ","evaluate_zoom_function_4("+k.join(", ")+", "+d+")","/",y.multiplier.toFixed(1)].join(" ")+";\n"}}}}}return r}function createFunctionGetValue(e,r){return function(t,a,i){if(1===r.length)return e.getValue(t,util.extend({},a,{zoom:r[0]}),i);for(var n=[],o=0;o<r.length;o++){var s=r[o];n.push(e.getValue(t,util.extend({},a,{zoom:s}),i)[0])}return n}}function createGetUniform(e,r){return function(t,a){var i=t.getPaintInterpolationT(e.paintProperty,a.zoom);return[Math.max(0,Math.min(4,i-r))]}}var ArrayGroup=require("./array_group"),BufferGroup=require("./buffer_group"),util=require("../util/util"),StructArrayType=require("../util/struct_array");module.exports=Bucket,Bucket.create=function(e){var r={fill:require("./bucket/fill_bucket"),fillextrusion:require("./bucket/fill_extrusion_bucket"),line:require("./bucket/line_bucket"),circle:require("./bucket/circle_bucket"),symbol:require("./bucket/symbol_bucket")},t=e.layer.type;return"fill"!==t||e.layer.isPaintValueFeatureConstant("fill-extrude-height")&&e.layer.isPaintValueZoomConstant("fill-extrude-height")&&0===e.layer.getPaintValue("fill-extrude-height")||(t="fillextrusion"),new r[t](e)},Bucket.EXTENT=8192,Bucket.prototype.populateArrays=function(){this.createArrays(),this.recalculateStyleLayers();for(var e=0;e<this.features.length;e++)this.addFeature(this.features[e]);this.trimArrays()},Bucket.prototype.prepareArrayGroup=function(e,r){var t=this.arrayGroups[e],a=t.length&&t[t.length-1];return a&&a.hasCapacityFor(r)||(a=new ArrayGroup({layoutVertexArrayType:this.programInterfaces[e].layoutVertexArrayType,elementArrayType:this.programInterfaces[e].elementArrayType,elementArrayType2:this.programInterfaces[e].elementArrayType2,paintVertexArrayTypes:this.paintVertexArrayTypes[e]}),a.index=t.length,t.push(a)),a},Bucket.prototype.createArrays=function(){this.arrayGroups={},this.paintVertexArrayTypes={};for(var e in this.programInterfaces){this.arrayGroups[e]=[];var r=this.paintVertexArrayTypes[e]={},t=this.paintAttributes[e];for(var a in t)r[a]=new Bucket.VertexArrayType(t[a].attributes)}},Bucket.prototype.destroy=function(){for(var e in this.bufferGroups)for(var r=this.bufferGroups[e],t=0;t<r.length;t++)r[t].destroy()},Bucket.prototype.trimArrays=function(){for(var e in this.arrayGroups)for(var r=this.arrayGroups[e],t=0;t<r.length;t++)r[t].trim()},Bucket.prototype.isEmpty=function(){for(var e in this.arrayGroups)for(var r=this.arrayGroups[e],t=0;t<r.length;t++)if(!r[t].isEmpty())return!1;return!0},Bucket.prototype.getTransferables=function(e){for(var r in this.arrayGroups)for(var t=this.arrayGroups[r],a=0;a<t.length;a++)t[a].getTransferables(e)},Bucket.prototype.setUniforms=function(e,r,t,a,i){for(var n=this.paintAttributes[r][a.id].uniforms,o=0;o<n.length;o++){var s=n[o],u=t[s.name];e["uniform"+s.components+"fv"](u,s.getValue(a,i))}},Bucket.prototype.serialize=function(){return{layerId:this.layer.id,zoom:this.zoom,arrays:util.mapObject(this.arrayGroups,function(e){return e.map(function(e){return e.serialize()})}),paintVertexArrayTypes:util.mapObject(this.paintVertexArrayTypes,function(e){return util.mapObject(e,function(e){return e.serialize()})}),childLayerIds:this.childLayers.map(function(e){return e.id})}};var FAKE_ZOOM_HISTORY={lastIntegerZoom:1/0,lastIntegerZoomTime:0,lastZoom:0};Bucket.prototype.recalculateStyleLayers=function(){for(var e=0;e<this.childLayers.length;e++)this.childLayers[e].recalculate(this.zoom,FAKE_ZOOM_HISTORY)},Bucket.prototype.populatePaintArrays=function(e,r,t,a,i){for(var n=0;n<this.childLayers.length;n++)for(var o=this.childLayers[n],s=this.arrayGroups[e],u=a.index;u<s.length;u++){var l=s[u],y=l.layoutVertexArray.length,p=l.paintVertexArrays[o.id];p.resize(y);for(var c=this.paintAttributes[e][o.id].attributes,f=0;f<c.length;f++)for(var m=c[f],h=m.getValue(o,r,t),g=m.multiplier||1,v=m.components||1,d=u===a.index?i:0,x=d;x<y;x++)for(var A=p.get(x),b=0;b<v;b++){var T=v>1?m.name+b:m.name;A[T]=h[b]*g}}},Bucket.VertexArrayType=function(e){return new StructArrayType({members:e,alignment:4})},Bucket.ElementArrayType=function(e){return new StructArrayType({members:[{type:"Uint16",name:"vertices",components:e||3}]})}; },{"../util/struct_array":120,"../util/util":122,"./array_group":1,"./bucket/circle_bucket":3,"./bucket/fill_bucket":4,"./bucket/fill_extrusion_bucket":5,"./bucket/line_bucket":6,"./bucket/symbol_bucket":7,"./buffer_group":9}],3:[function(require,module,exports){ "use strict";function CircleBucket(){Bucket.apply(this,arguments)}var Bucket=require("../bucket"),util=require("../../util/util"),loadGeometry=require("../load_geometry"),EXTENT=Bucket.EXTENT;module.exports=CircleBucket,CircleBucket.prototype=util.inherit(Bucket,{}),CircleBucket.prototype.addCircleVertex=function(e,t,r,i,a){return e.emplaceBack(2*t+(i+1)/2,2*r+(a+1)/2)},CircleBucket.prototype.programInterfaces={circle:{layoutVertexArrayType:new Bucket.VertexArrayType([{name:"a_pos",components:2,type:"Int16"}]),elementArrayType:new Bucket.ElementArrayType,paintAttributes:[{name:"a_color",components:4,type:"Uint8",getValue:function(e,t,r){return e.getPaintValue("circle-color",t,r)},multiplier:255,paintProperty:"circle-color"},{name:"a_radius",components:1,type:"Uint16",isLayerConstant:!1,getValue:function(e,t,r){return[e.getPaintValue("circle-radius",t,r)]},multiplier:10,paintProperty:"circle-radius"},{name:"a_blur",components:1,type:"Uint16",isLayerConstant:!1,getValue:function(e,t,r){return[e.getPaintValue("circle-blur",t,r)]},multiplier:10,paintProperty:"circle-blur"},{name:"a_opacity",components:1,type:"Uint16",isLayerConstant:!1,getValue:function(e,t,r){return[e.getPaintValue("circle-opacity",t,r)]},multiplier:255,paintProperty:"circle-opacity"}]}},CircleBucket.prototype.addFeature=function(e){for(var t={zoom:this.zoom},r=loadGeometry(e),i=this.prepareArrayGroup("circle",0),a=i.layoutVertexArray.length,c=0;c<r.length;c++)for(var l=0;l<r[c].length;l++){var n=r[c][l].x,o=r[c][l].y;if(!(n<0||n>=EXTENT||o<0||o>=EXTENT)){var u=this.prepareArrayGroup("circle",4),p=u.layoutVertexArray,y=this.addCircleVertex(p,n,o,-1,-1);this.addCircleVertex(p,n,o,1,-1),this.addCircleVertex(p,n,o,1,1),this.addCircleVertex(p,n,o,-1,1),u.elementArray.emplaceBack(y,y+1,y+2),u.elementArray.emplaceBack(y,y+3,y+2)}}this.populatePaintArrays("circle",t,e.properties,i,a)}; },{"../../util/util":122,"../bucket":2,"../load_geometry":11}],4:[function(require,module,exports){ "use strict";function FillBucket(){Bucket.apply(this,arguments)}function convertCoords(e){return e instanceof Point?[e.x,e.y]:e.map(convertCoords)}var Bucket=require("../bucket"),util=require("../../util/util"),loadGeometry=require("../load_geometry"),earcut=require("earcut"),classifyRings=require("../../util/classify_rings"),Point=require("point-geometry"),EARCUT_MAX_RINGS=500;module.exports=FillBucket,FillBucket.prototype=util.inherit(Bucket,{}),FillBucket.prototype.programInterfaces={fill:{layoutVertexArrayType:new Bucket.VertexArrayType([{name:"a_pos",components:2,type:"Int16"}]),elementArrayType:new Bucket.ElementArrayType(1),elementArrayType2:new Bucket.ElementArrayType(2),paintAttributes:[{name:"a_color",components:4,type:"Uint8",getValue:function(e,t,r){return e.getPaintValue("fill-color",t,r)},multiplier:255,paintProperty:"fill-color"},{name:"a_outline_color",components:4,type:"Uint8",getValue:function(e,t,r){return e.getPaintValue("fill-outline-color",t,r)},multiplier:255,paintProperty:"fill-outline-color"},{name:"a_opacity",components:1,type:"Uint8",getValue:function(e,t,r){return[e.getPaintValue("fill-opacity",t,r)]},multiplier:255,paintProperty:"fill-opacity"}]}},FillBucket.prototype.addVertex=function(e,t,r){return e.emplaceBack(t,r)},FillBucket.prototype.addFeature=function(e){var t=loadGeometry(e),r=convertCoords(classifyRings(t,EARCUT_MAX_RINGS));this.factor=Math.pow(2,13);for(var o=this.prepareArrayGroup("fill",0),l=o.layoutVertexArray.length,a=0;a<r.length;a++)this.addPolygon(r[a]);this.populatePaintArrays("fill",{zoom:this.zoom},e.properties,o,l)},FillBucket.prototype.addPolygon=function(e){for(var t=0,r=0;r<e.length;r++)t+=e[r].length;for(var o=this.prepareArrayGroup("fill",t),l=[],a=[],i=o.layoutVertexArray.length,n=[],u=0;u<e.length;u++){var p=e[u];u>0&&a.push(l.length/2);for(var c=0;c<p.length;c++){var y=p[c],s=this.addVertex(o.layoutVertexArray,y[0],y[1],0,0,1,1,0);n.push(s),c>=1&&o.elementArray2.emplaceBack(s-1,s),l.push(y[0]),l.push(y[1])}}for(var f=earcut(l,a),m=0;m<f.length;m++)o.elementArray.emplaceBack(f[m]+i)}; },{"../../util/classify_rings":108,"../../util/util":122,"../bucket":2,"../load_geometry":11,"earcut":137,"point-geometry":192}],5:[function(require,module,exports){ "use strict";function FillExtrusionBucket(){Bucket.apply(this,arguments)}function convertCoords(e){return e instanceof Point?[e.x,e.y]:e.map(convertCoords)}function isBoundaryEdge(e,t){return e.some(function(e,r){return isOutside(t[r])&&t[r]===e})}function isOutside(e){return e<0||e>Bucket.EXTENT}var Bucket=require("../bucket"),util=require("../../util/util"),loadGeometry=require("../load_geometry"),earcut=require("earcut"),classifyRings=require("../../util/classify_rings"),Point=require("point-geometry"),EARCUT_MAX_RINGS=500;module.exports=FillExtrusionBucket,FillExtrusionBucket.prototype=util.inherit(Bucket,{}),FillExtrusionBucket.prototype.programInterfaces={fillextrusion:{layoutVertexArrayType:new Bucket.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal",components:3,type:"Int16"},{name:"a_edgedistance",components:1,type:"Int16"}]),elementArrayType:new Bucket.ElementArrayType(3),paintAttributes:[{name:"a_minH",components:1,type:"Uint16",getValue:function(e,t,r){return[e.getPaintValue("fill-extrude-base",t,r)]},multiplier:1,paintProperty:"fill-extrude-base"},{name:"a_maxH",components:1,type:"Uint16",getValue:function(e,t,r){return[e.getPaintValue("fill-extrude-height",t,r)]},multiplier:1,paintProperty:"fill-extrude-height"},{name:"a_color",components:4,type:"Uint8",getValue:function(e,t,r){var o=e.getPaintValue("fill-color",t,r);return o[3]=1,o},multiplier:255,paintProperty:"fill-color"}]}},FillExtrusionBucket.prototype.addVertex=function(e,t,r,o,n,i,a,u){return e.emplaceBack(t,r,2*Math.floor(o*this.factor)+a,n*this.factor*2,i*this.factor*2,Math.round(u))},FillExtrusionBucket.prototype.addFeature=function(e){var t=loadGeometry(e),r=convertCoords(classifyRings(t,EARCUT_MAX_RINGS));this.factor=Math.pow(2,13);for(var o=this.prepareArrayGroup("fillextrusion",0),n=o.layoutVertexArray.length,i=0;i<r.length;i++)this.addPolygon(r[i]);this.populatePaintArrays("fillextrusion",{zoom:this.zoom},e.properties,o,n)},FillExtrusionBucket.prototype.addPolygon=function(e){for(var t=0,r=0;r<e.length;r++)t+=e[r].length;t*=5;for(var o=this.prepareArrayGroup("fillextrusion",t),n=[],i=[],a=[],u=0;u<e.length;u++){var l=e[u];u>0&&i.push(n.length/2);for(var s=0,p=0;p<l.length;p++){var c=l[p],y=this.addVertex(o.layoutVertexArray,c[0],c[1],0,0,1,1,0);if(a.push(y),p>=1){var d=l[p-1];if(!isBoundaryEdge(c,d)){var f=Point.convert(c)._sub(Point.convert(d))._perp()._unit(),m=this.addVertex(o.layoutVertexArray,c[0],c[1],f.x,f.y,0,0,s);this.addVertex(o.layoutVertexArray,c[0],c[1],f.x,f.y,0,1,s),s+=Point.convert(d).dist(Point.convert(c)),this.addVertex(o.layoutVertexArray,d[0],d[1],f.x,f.y,0,0,s),this.addVertex(o.layoutVertexArray,d[0],d[1],f.x,f.y,0,1,s),o.elementArray.emplaceBack(m,m+1,m+2),o.elementArray.emplaceBack(m+1,m+2,m+3)}}n.push(c[0]),n.push(c[1])}}for(var x=earcut(n,i),h=0;h<x.length-2;h+=3)o.elementArray.emplaceBack(a[x[h]],a[x[h+1]],a[x[h+2]])}; },{"../../util/classify_rings":108,"../../util/util":122,"../bucket":2,"../load_geometry":11,"earcut":137,"point-geometry":192}],6:[function(require,module,exports){ "use strict";function LineBucket(){Bucket.apply(this,arguments)}var Bucket=require("../bucket"),util=require("../../util/util"),loadGeometry=require("../load_geometry"),EXTENT=Bucket.EXTENT,EXTRUDE_SCALE=63,COS_HALF_SHARP_CORNER=Math.cos(37.5*(Math.PI/180)),SHARP_CORNER_OFFSET=15,LINE_DISTANCE_BUFFER_BITS=15,LINE_DISTANCE_SCALE=.5,MAX_LINE_DISTANCE=Math.pow(2,LINE_DISTANCE_BUFFER_BITS-1)/LINE_DISTANCE_SCALE;module.exports=LineBucket,LineBucket.prototype=util.inherit(Bucket,{}),LineBucket.prototype.addLineVertex=function(e,t,i,r,s,a,n){return e.emplaceBack(t.x<<1|r,t.y<<1|s,Math.round(EXTRUDE_SCALE*i.x)+128,Math.round(EXTRUDE_SCALE*i.y)+128,(0===a?0:a<0?-1:1)+1|(n*LINE_DISTANCE_SCALE&63)<<2,n*LINE_DISTANCE_SCALE>>6)},LineBucket.prototype.programInterfaces={line:{layoutVertexArrayType:new Bucket.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}]),paintAttributes:[{name:"a_color",components:4,type:"Uint8",getValue:function(e,t,i){return e.getPaintValue("line-color",t,i)},multiplier:255,paintProperty:"line-color"}],elementArrayType:new Bucket.ElementArrayType}},LineBucket.prototype.addFeature=function(e){for(var t=loadGeometry(e,LINE_DISTANCE_BUFFER_BITS),i=0;i<t.length;i++)this.addLine(t[i],e.properties,this.layer.layout["line-join"],this.layer.layout["line-cap"],this.layer.layout["line-miter-limit"],this.layer.layout["line-round-limit"])},LineBucket.prototype.addLine=function(e,t,i,r,s,a){for(var n=e.length;n>2&&e[n-1].equals(e[n-2]);)n--;if(!(e.length<2)){"bevel"===i&&(s=1.05);var u=SHARP_CORNER_OFFSET*(EXTENT/(512*this.overscaling)),h=e[0],d=e[n-1],l=h.equals(d),o=this.prepareArrayGroup("line",10*n),c=o.layoutVertexArray.length;if(2!==n||!l){this.distance=0;var p,_,y,E,m,x,C,A=r,L=l?"butt":r,V=!0;this.e1=this.e2=this.e3=-1,l&&(p=e[n-2],m=h.sub(p)._unit()._perp());for(var f=0;f<n;f++)if(y=l&&f===n-1?e[1]:e[f+1],!y||!e[f].equals(y)){m&&(E=m),p&&(_=p),p=e[f],m=y?y.sub(p)._unit()._perp():E,E=E||m;var S=E.add(m)._unit(),T=S.x*m.x+S.y*m.y,v=1/T,B=T<COS_HALF_SHARP_CORNER&&_&&y;if(B&&f>0){var N=p.dist(_);if(N>2*u){var I=p.sub(p.sub(_)._mult(u/N)._round());this.distance+=I.dist(_),this.addCurrentVertex(I,this.distance,E.mult(1),0,0,!1),_=I}}var k=_&&y,b=k?i:y?A:L;if(k&&"round"===b&&(v<a?b="miter":v<=2&&(b="fakeround")),"miter"===b&&v>s&&(b="bevel"),"bevel"===b&&(v>2&&(b="flipbevel"),v<s&&(b="miter")),_&&(this.distance+=p.dist(_)),"miter"===b)S._mult(v),this.addCurrentVertex(p,this.distance,S,0,0,!1);else if("flipbevel"===b){if(v>100)S=m.clone();else{var R=E.x*m.y-E.y*m.x>0?-1:1,g=v*E.add(m).mag()/E.sub(m).mag();S._perp()._mult(g*R)}this.addCurrentVertex(p,this.distance,S,0,0,!1),this.addCurrentVertex(p,this.distance,S.mult(-1),0,0,!1)}else if("bevel"===b||"fakeround"===b){var F=E.x*m.y-E.y*m.x>0,D=-Math.sqrt(v*v-1);if(F?(C=0,x=D):(x=0,C=D),V||this.addCurrentVertex(p,this.distance,E,x,C,!1),"fakeround"===b){for(var P,M=Math.floor(8*(.5-(T-.5))),q=0;q<M;q++)P=m.mult((q+1)/(M+1))._add(E)._unit(),this.addPieSliceVertex(p,this.distance,P,F);this.addPieSliceVertex(p,this.distance,S,F);for(var O=M-1;O>=0;O--)P=E.mult((O+1)/(M+1))._add(m)._unit(),this.addPieSliceVertex(p,this.distance,P,F)}y&&this.addCurrentVertex(p,this.distance,m,-x,-C,!1)}else"butt"===b?(V||this.addCurrentVertex(p,this.distance,E,0,0,!1),y&&this.addCurrentVertex(p,this.distance,m,0,0,!1)):"square"===b?(V||(this.addCurrentVertex(p,this.distance,E,1,1,!1),this.e1=this.e2=-1),y&&this.addCurrentVertex(p,this.distance,m,-1,-1,!1)):"round"===b&&(V||(this.addCurrentVertex(p,this.distance,E,0,0,!1),this.addCurrentVertex(p,this.distance,E,1,1,!0),this.e1=this.e2=-1),y&&(this.addCurrentVertex(p,this.distance,m,-1,-1,!0),this.addCurrentVertex(p,this.distance,m,0,0,!1)));if(B&&f<n-1){var U=p.dist(y);if(U>2*u){var X=p.add(y.sub(p)._mult(u/U)._round());this.distance+=X.dist(p),this.addCurrentVertex(X,this.distance,m.mult(1),0,0,!1),p=X}}V=!1}this.populatePaintArrays("line",{zoom:this.zoom},t,o,c)}}},LineBucket.prototype.addCurrentVertex=function(e,t,i,r,s,a){var n,u=a?1:0,h=this.arrayGroups.line[this.arrayGroups.line.length-1],d=h.layoutVertexArray,l=h.elementArray;n=i.clone(),r&&n._sub(i.perp()._mult(r)),this.e3=this.addLineVertex(d,e,n,u,0,r,t),this.e1>=0&&this.e2>=0&&l.emplaceBack(this.e1,this.e2,this.e3),this.e1=this.e2,this.e2=this.e3,n=i.mult(-1),s&&n._sub(i.perp()._mult(s)),this.e3=this.addLineVertex(d,e,n,u,1,-s,t),this.e1>=0&&this.e2>=0&&l.emplaceBack(this.e1,this.e2,this.e3),this.e1=this.e2,this.e2=this.e3,t>MAX_LINE_DISTANCE/2&&(this.distance=0,this.addCurrentVertex(e,this.distance,i,r,s,a))},LineBucket.prototype.addPieSliceVertex=function(e,t,i,r){var s=r?1:0;i=i.mult(r?-1:1);var a=this.arrayGroups.line[this.arrayGroups.line.length-1],n=a.layoutVertexArray,u=a.elementArray;this.e3=this.addLineVertex(n,e,i,0,s,0,t),this.e1>=0&&this.e2>=0&&u.emplaceBack(this.e1,this.e2,this.e3),r?this.e2=this.e3:this.e1=this.e3}; },{"../../util/util":122,"../bucket":2,"../load_geometry":11}],7:[function(require,module,exports){ "use strict";function SymbolBucket(e){Bucket.apply(this,arguments),this.showCollisionBoxes=e.showCollisionBoxes,this.overscaling=e.overscaling,this.collisionBoxArray=e.collisionBoxArray,this.symbolQuadsArray=e.symbolQuadsArray,this.symbolInstancesArray=e.symbolInstancesArray,this.sdfIcons=e.sdfIcons,this.iconsNeedLinear=e.iconsNeedLinear,this.adjustedTextSize=e.adjustedTextSize,this.adjustedIconSize=e.adjustedIconSize,this.fontstack=e.fontstack}function addVertex(e,t,o,a,n,i,s,r,l,y,c){return e.emplaceBack(t,o,Math.round(64*a),Math.round(64*n),i/4,s/4,10*(y||0),c,10*(r||0),10*Math.min(l||25,25))}var Point=require("point-geometry"),Bucket=require("../bucket"),Anchor=require("../../symbol/anchor"),getAnchors=require("../../symbol/get_anchors"),resolveTokens=require("../../util/token"),Quads=require("../../symbol/quads"),Shaping=require("../../symbol/shaping"),resolveText=require("../../symbol/resolve_text"),mergeLines=require("../../symbol/mergelines"),clipLine=require("../../symbol/clip_line"),util=require("../../util/util"),loadGeometry=require("../load_geometry"),CollisionFeature=require("../../symbol/collision_feature"),findPoleOfInaccessibility=require("../../util/find_pole_of_inaccessibility"),classifyRings=require("../../util/classify_rings"),shapeText=Shaping.shapeText,shapeIcon=Shaping.shapeIcon,getGlyphQuads=Quads.getGlyphQuads,getIconQuads=Quads.getIconQuads,EXTENT=Bucket.EXTENT;module.exports=SymbolBucket,SymbolBucket.MAX_QUADS=65535,SymbolBucket.prototype=util.inherit(Bucket,{}),SymbolBucket.prototype.serialize=function(){var e=Bucket.prototype.serialize.apply(this);return e.sdfIcons=this.sdfIcons,e.iconsNeedLinear=this.iconsNeedLinear,e.adjustedTextSize=this.adjustedTextSize,e.adjustedIconSize=this.adjustedIconSize,e.fontstack=this.fontstack,e};var layoutVertexArrayType=new Bucket.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_offset",components:2,type:"Int16"},{name:"a_texture_pos",components:2,type:"Uint16"},{name:"a_data",components:4,type:"Uint8"}]),elementArrayType=new Bucket.ElementArrayType;SymbolBucket.prototype.addCollisionBoxVertex=function(e,t,o,a,n){return e.emplaceBack(t.x,t.y,Math.round(o.x),Math.round(o.y),10*a,10*n)},SymbolBucket.prototype.programInterfaces={glyph:{layoutVertexArrayType:layoutVertexArrayType,elementArrayType:elementArrayType},icon:{layoutVertexArrayType:layoutVertexArrayType,elementArrayType:elementArrayType},collisionBox:{layoutVertexArrayType:new Bucket.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},{name:"a_data",components:2,type:"Uint8"}])}},SymbolBucket.prototype.populateArrays=function(e,t,o){var a={lastIntegerZoom:1/0,lastIntegerZoomTime:0,lastZoom:0};this.adjustedTextMaxSize=this.layer.getLayoutValue("text-size",{zoom:18,zoomHistory:a}),this.adjustedTextSize=this.layer.getLayoutValue("text-size",{zoom:this.zoom+1,zoomHistory:a}),this.adjustedIconMaxSize=this.layer.getLayoutValue("icon-size",{zoom:18,zoomHistory:a}),this.adjustedIconSize=this.layer.getLayoutValue("icon-size",{zoom:this.zoom+1,zoomHistory:a});var n=512*this.overscaling;this.tilePixelRatio=EXTENT/n,this.compareText={},this.iconsNeedLinear=!1,this.symbolInstancesStartIndex=this.symbolInstancesArray.length;var i=this.layer.layout,s=this.features,r=this.textFeatures,l=.5,y=.5;switch(i["text-anchor"]){case"right":case"top-right":case"bottom-right":l=1;break;case"left":case"top-left":case"bottom-left":l=0}switch(i["text-anchor"]){case"bottom":case"bottom-right":case"bottom-left":y=1;break;case"top":case"top-right":case"top-left":y=0}for(var c="right"===i["text-justify"]?1:"left"===i["text-justify"]?0:.5,h=24,x=i["text-line-height"]*h,d="line"!==i["symbol-placement"]?i["text-max-width"]*h:0,u=i["text-letter-spacing"]*h,m=[i["text-offset"][0]*h,i["text-offset"][1]*h],p=this.fontstack=i["text-font"].join(","),g=[],b=0;b<s.length;b++)g.push(loadGeometry(s[b]));if("line"===i["symbol-placement"]){var I=mergeLines(s,r,g);g=I.geometries,s=I.features,r=I.textFeatures}for(var f,S,B=0;B<s.length;B++)if(g[B]){if(f=r[B]?shapeText(r[B],t[p],d,x,l,y,c,u,m):null,i["icon-image"]){var v=resolveTokens(s[B].properties,i["icon-image"]),A=o[v];S=shapeIcon(A,i),A&&(void 0===this.sdfIcons?this.sdfIcons=A.sdf:this.sdfIcons!==A.sdf&&util.warnOnce("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),1!==A.pixelRatio?this.iconsNeedLinear=!0:0===i["icon-rotate"]&&this.layer.isLayoutValueFeatureConstant("icon-rotate")||(this.iconsNeedLinear=!0))}else S=null;(f||S)&&this.addFeature(g[B],f,S,s[B])}this.symbolInstancesEndIndex=this.symbolInstancesArray.length,this.placeFeatures(e,this.showCollisionBoxes),this.trimArrays()},SymbolBucket.prototype.addFeature=function(e,t,o,a){var n=this.layer.layout,i=24,s=this.adjustedTextSize/i,r=void 0!==this.adjustedTextMaxSize?this.adjustedTextMaxSize:this.adjustedTextSize,l=this.tilePixelRatio*s,y=this.tilePixelRatio*r/i,c=this.tilePixelRatio*this.adjustedIconSize,h=this.tilePixelRatio*n["symbol-spacing"],x=n["symbol-avoid-edges"],d=n["text-padding"]*this.tilePixelRatio,u=n["icon-padding"]*this.tilePixelRatio,m=n["text-max-angle"]/180*Math.PI,p="map"===n["text-rotation-alignment"]&&"line"===n["symbol-placement"],g="map"===n["icon-rotation-alignment"]&&"line"===n["symbol-placement"],b=n["text-allow-overlap"]||n["icon-allow-overlap"]||n["text-ignore-placement"]||n["icon-ignore-placement"],I=n["symbol-placement"],f="line"===I,S=h/2,B=null;B=f?clipLine(e,0,0,EXTENT,EXTENT):classifyRings(e,0);for(var v=0;v<B.length;v++){var A=null,T=B[v],k=null;f?(k=T,A=getAnchors(k,h,m,t,o,i,y,this.overscaling,EXTENT)):(k=T[0],A=this.findPolygonAnchors(T));for(var M=0,z=A.length;M<z;M++){var E=A[M];if(!(t&&f&&this.anchorIsTooClose(t.text,S,E))){var P=!(E.x<0||E.x>EXTENT||E.y<0||E.y>EXTENT);if(!x||P){var w=P||b;this.addSymbolInstance(E,k,t,o,this.layer,w,this.symbolInstancesArray.length,this.collisionBoxArray,a.index,this.sourceLayerIndex,this.index,l,d,p,c,u,g,{zoom:this.zoom},a.properties)}}}}},SymbolBucket.prototype.findPolygonAnchors=function(e){var t=e[0];if(0===t.length)return[];if(t.length<3||!util.isClosedPolygon(t))return[new Anchor(t[0].x,t[0].y,0)];var o=null,a=findPoleOfInaccessibility(e,16);return o=[new Anchor(a.x,a.y,0)]},SymbolBucket.prototype.anchorIsTooClose=function(e,t,o){var a=this.compareText;if(e in a){for(var n=a[e],i=n.length-1;i>=0;i--)if(o.dist(n[i])<t)return!0}else a[e]=[];return a[e].push(o),!1},SymbolBucket.prototype.placeFeatures=function(e,t){this.recalculateStyleLayers(),this.createArrays();var o=this.layer.layout,a=e.maxScale,n="map"===o["text-rotation-alignment"]&&"line"===o["symbol-placement"],i="map"===o["icon-rotation-alignment"]&&"line"===o["symbol-placement"],s=o["text-allow-overlap"]||o["icon-allow-overlap"]||o["text-ignore-placement"]||o["icon-ignore-placement"];if(s){var r=this.symbolInstancesArray.toArray(this.symbolInstancesStartIndex,this.symbolInstancesEndIndex),l=e.angle,y=Math.sin(l),c=Math.cos(l);this.sortedSymbolInstances=r.sort(function(e,t){var o=y*e.anchorPointX+c*e.anchorPointY|0,a=y*t.anchorPointX+c*t.anchorPointY|0;return o-a||t.index-e.index})}for(var h=this.symbolInstancesStartIndex;h<this.symbolInstancesEndIndex;h++){var x=this.sortedSymbolInstances?this.sortedSymbolInstances[h-this.symbolInstancesStartIndex]:this.symbolInstancesArray.get(h),d={boxStartIndex:x.textBoxStartIndex,boxEndIndex:x.textBoxEndIndex},u={boxStartIndex:x.iconBoxStartIndex,boxEndIndex:x.iconBoxEndIndex},m=!(x.textBoxStartIndex===x.textBoxEndIndex),p=!(x.iconBoxStartIndex===x.iconBoxEndIndex),g=o["text-optional"]||!m,b=o["icon-optional"]||!p,I=m?e.placeCollisionFeature(d,o["text-allow-overlap"],o["symbol-avoid-edges"]):e.minScale,f=p?e.placeCollisionFeature(u,o["icon-allow-overlap"],o["symbol-avoid-edges"]):e.minScale;g||b?!b&&I?I=Math.max(f,I):!g&&f&&(f=Math.max(f,I)):f=I=Math.max(f,I),m&&(e.insertCollisionFeature(d,I,o["text-ignore-placement"]),I<=a&&this.addSymbols("glyph",x.glyphQuadStartIndex,x.glyphQuadEndIndex,I,o["text-keep-upright"],n,e.angle)),p&&(e.insertCollisionFeature(u,f,o["icon-ignore-placement"]),f<=a&&this.addSymbols("icon",x.iconQuadStartIndex,x.iconQuadEndIndex,f,o["icon-keep-upright"],i,e.angle))}t&&this.addToDebugBuffers(e)},SymbolBucket.prototype.addSymbols=function(e,t,o,a,n,i,s){for(var r=this.prepareArrayGroup(e,4*(o-t)),l=r.elementArray,y=r.layoutVertexArray,c=this.zoom,h=Math.max(Math.log(a)/Math.LN2+c,0),x=t;x<o;x++){var d=this.symbolQuadsArray.get(x).SymbolQuad,u=(d.anchorAngle+s+Math.PI)%(2*Math.PI);if(!(n&&i&&(u<=Math.PI/2||u>3*Math.PI/2))){var m=d.tl,p=d.tr,g=d.bl,b=d.br,I=d.tex,f=d.anchorPoint,S=Math.max(c+Math.log(d.minScale)/Math.LN2,h),B=Math.min(c+Math.log(d.maxScale)/Math.LN2,25);if(!(B<=S)){S===h&&(S=0);var v=Math.round(d.glyphAngle/(2*Math.PI)*256),A=addVertex(y,f.x,f.y,m.x,m.y,I.x,I.y,S,B,h,v);addVertex(y,f.x,f.y,p.x,p.y,I.x+I.w,I.y,S,B,h,v),addVertex(y,f.x,f.y,g.x,g.y,I.x,I.y+I.h,S,B,h,v),addVertex(y,f.x,f.y,b.x,b.y,I.x+I.w,I.y+I.h,S,B,h,v),l.emplaceBack(A,A+1,A+2),l.emplaceBack(A+1,A+2,A+3)}}}},SymbolBucket.prototype.updateIcons=function(e){this.recalculateStyleLayers();var t=this.layer.layout["icon-image"];if(t)for(var o=0;o<this.features.length;o++){var a=resolveTokens(this.features[o].properties,t);a&&(e[a]=!0)}},SymbolBucket.prototype.updateFont=function(e){this.recalculateStyleLayers();var t=this.layer.layout["text-font"],o=e[t]=e[t]||{};this.textFeatures=resolveText(this.features,this.layer.layout,o)},SymbolBucket.prototype.addToDebugBuffers=function(e){for(var t=this.prepareArrayGroup("collisionBox",0),o=t.layoutVertexArray,a=-e.angle,n=e.yStretch,i=this.symbolInstancesStartIndex;i<this.symbolInstancesEndIndex;i++){var s=this.symbolInstancesArray.get(i);s.textCollisionFeature={boxStartIndex:s.textBoxStartIndex,boxEndIndex:s.textBoxEndIndex},s.iconCollisionFeature={boxStartIndex:s.iconBoxStartIndex,boxEndIndex:s.iconBoxEndIndex};for(var r=0;r<2;r++){var l=s[0===r?"textCollisionFeature":"iconCollisionFeature"];if(l)for(var y=l.boxStartIndex;y<l.boxEndIndex;y++){var c=this.collisionBoxArray.get(y),h=c.anchorPoint,x=new Point(c.x1,c.y1*n)._rotate(a),d=new Point(c.x2,c.y1*n)._rotate(a),u=new Point(c.x1,c.y2*n)._rotate(a),m=new Point(c.x2,c.y2*n)._rotate(a),p=Math.max(0,Math.min(25,this.zoom+Math.log(c.maxScale)/Math.LN2)),g=Math.max(0,Math.min(25,this.zoom+Math.log(c.placementScale)/Math.LN2));this.addCollisionBoxVertex(o,h,x,p,g),this.addCollisionBoxVertex(o,h,d,p,g),this.addCollisionBoxVertex(o,h,d,p,g),this.addCollisionBoxVertex(o,h,m,p,g),this.addCollisionBoxVertex(o,h,m,p,g),this.addCollisionBoxVertex(o,h,u,p,g),this.addCollisionBoxVertex(o,h,u,p,g),this.addCollisionBoxVertex(o,h,x,p,g)}}}},SymbolBucket.prototype.addSymbolInstance=function(e,t,o,a,n,i,s,r,l,y,c,h,x,d,u,m,p,g,b){var I,f,S,B,v,A,T,k;if(o&&(T=i?getGlyphQuads(e,o,h,t,n,d):[],v=new CollisionFeature(r,t,e,l,y,c,o,h,x,d,!1)),I=this.symbolQuadsArray.length,T&&T.length)for(var M=0;M<T.length;M++)this.addSymbolQuad(T[M]);f=this.symbolQuadsArray.length;var z=v?v.boxStartIndex:this.collisionBoxArray.length,E=v?v.boxEndIndex:this.collisionBoxArray.length;a&&(k=i?getIconQuads(e,a,u,t,n,p,o,g,b):[],A=new CollisionFeature(r,t,e,l,y,c,a,u,m,p,!0)),S=this.symbolQuadsArray.length,k&&1===k.length&&this.addSymbolQuad(k[0]),B=this.symbolQuadsArray.length;var P=A?A.boxStartIndex:this.collisionBoxArray.length,w=A?A.boxEndIndex:this.collisionBoxArray.length;return B>SymbolBucket.MAX_QUADS&&util.warnOnce("Too many symbols being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),f>SymbolBucket.MAX_QUADS&&util.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),this.symbolInstancesArray.emplaceBack(z,E,P,w,I,f,S,B,e.x,e.y,s)},SymbolBucket.prototype.addSymbolQuad=function(e){return this.symbolQuadsArray.emplaceBack(e.anchorPoint.x,e.anchorPoint.y,e.tl.x,e.tl.y,e.tr.x,e.tr.y,e.bl.x,e.bl.y,e.br.x,e.br.y,e.tex.h,e.tex.w,e.tex.x,e.tex.y,e.anchorAngle,e.glyphAngle,e.maxScale,e.minScale)}; },{"../../symbol/anchor":69,"../../symbol/clip_line":71,"../../symbol/collision_feature":73,"../../symbol/get_anchors":75,"../../symbol/mergelines":78,"../../symbol/quads":79,"../../symbol/resolve_text":80,"../../symbol/shaping":81,"../../util/classify_rings":108,"../../util/find_pole_of_inaccessibility":114,"../../util/token":121,"../../util/util":122,"../bucket":2,"../load_geometry":11,"point-geometry":192}],8:[function(require,module,exports){ "use strict";function Buffer(t,e,r){this.arrayBuffer=t.arrayBuffer,this.length=t.length,this.attributes=e.members,this.itemSize=e.bytesPerElement,this.type=r,this.arrayType=e}module.exports=Buffer,Buffer.prototype.bind=function(t){var e=t[this.type];this.buffer?t.bindBuffer(e,this.buffer):(this.gl=t,this.buffer=t.createBuffer(),t.bindBuffer(e,this.buffer),t.bufferData(e,this.arrayBuffer,t.STATIC_DRAW),this.arrayBuffer=null)};var AttributeType={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT"};Buffer.prototype.setVertexAttribPointers=function(t,e){for(var r=0;r<this.attributes.length;r++){var f=this.attributes[r],i=e[f.name];void 0!==i&&t.vertexAttribPointer(i,f.components,t[AttributeType[f.type]],!1,this.arrayType.bytesPerElement,f.offset)}},Buffer.prototype.destroy=function(){this.buffer&&this.gl.deleteBuffer(this.buffer)},Buffer.BufferType={VERTEX:"ARRAY_BUFFER",ELEMENT:"ELEMENT_ARRAY_BUFFER"}; },{}],9:[function(require,module,exports){ "use strict";function BufferGroup(e,r){this.layoutVertexBuffer=new Buffer(e.layoutVertexArray,r.layoutVertexArrayType,Buffer.BufferType.VERTEX),e.elementArray&&(this.elementBuffer=new Buffer(e.elementArray,r.elementArrayType,Buffer.BufferType.ELEMENT));var t,f=this.vaos={};e.elementArray2&&(this.elementBuffer2=new Buffer(e.elementArray2,r.elementArrayType2,Buffer.BufferType.ELEMENT),t=this.secondVaos={}),this.paintVertexBuffers=util.mapObject(e.paintVertexArrays,function(u,s){return f[s]=new VertexArrayObject,e.elementArray2&&(t[s]=new VertexArrayObject),new Buffer(u,r.paintVertexArrayTypes[s],Buffer.BufferType.VERTEX)})}var util=require("../util/util"),Buffer=require("./buffer"),VertexArrayObject=require("../render/vertex_array_object");module.exports=BufferGroup,BufferGroup.prototype.destroy=function(){this.layoutVertexBuffer.destroy(),this.elementBuffer&&this.elementBuffer.destroy(),this.elementBuffer2&&this.elementBuffer2.destroy();for(var e in this.paintVertexBuffers)this.paintVertexBuffers[e].destroy();for(var r in this.vaos)this.vaos[r].destroy();for(var t in this.secondVaos)this.secondVaos[t].destroy()}; },{"../render/vertex_array_object":34,"../util/util":122,"./buffer":8}],10:[function(require,module,exports){ "use strict";function FeatureIndex(e,t,r){if(e.grid){var i=e,n=t;e=i.coord,t=i.overscaling,this.grid=new Grid(i.grid),this.featureIndexArray=new FeatureIndexArray(i.featureIndexArray),this.rawTileData=n,this.bucketLayerIDs=i.bucketLayerIDs}else this.grid=new Grid(EXTENT,16,0),this.featureIndexArray=new FeatureIndexArray;this.coord=e,this.overscaling=t,this.x=e.x,this.y=e.y,this.z=e.z-Math.log(t)/Math.LN2,this.setCollisionTile(r)}function translateDistance(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function topDownFeatureComparator(e,t){return t-e}function getLineWidth(e){return e["line-gap-width"]>0?e["line-gap-width"]+2*e["line-width"]:e["line-width"]}function translate(e,t,r,i,n){if(!t[0]&&!t[1])return e;t=Point.convert(t),"viewport"===r&&t._rotate(-i);for(var a=[],o=0;o<e.length;o++){for(var s=e[o],l=[],u=0;u<s.length;u++)l.push(s[u].sub(t._mult(n)));a.push(l)}return a}function offsetLine(e,t){for(var r=[],i=new Point(0,0),n=0;n<e.length;n++){for(var a=e[n],o=[],s=0;s<a.length;s++){var l=a[s-1],u=a[s],c=a[s+1],f=0===s?i:u.sub(l)._unit()._perp(),y=s===a.length-1?i:c.sub(u)._unit()._perp(),h=f._add(y)._unit(),d=h.x*y.x+h.y*y.y;h._mult(1/d),o.push(h._mult(t)._add(u))}r.push(o)}return r}var Point=require("point-geometry"),loadGeometry=require("./load_geometry"),EXTENT=require("./bucket").EXTENT,featureFilter=require("feature-filter"),StructArrayType=require("../util/struct_array"),Grid=require("grid-index"),DictionaryCoder=require("../util/dictionary_coder"),vt=require("vector-tile"),Protobuf=require("pbf"),GeoJSONFeature=require("../util/vectortile_to_geojson"),arraysIntersect=require("../util/util").arraysIntersect,intersection=require("../util/intersection_tests"),multiPolygonIntersectsBufferedMultiPoint=intersection.multiPolygonIntersectsBufferedMultiPoint,multiPolygonIntersectsMultiPolygon=intersection.multiPolygonIntersectsMultiPolygon,multiPolygonIntersectsBufferedMultiLine=intersection.multiPolygonIntersectsBufferedMultiLine,FeatureIndexArray=new StructArrayType({members:[{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]});module.exports=FeatureIndex,FeatureIndex.prototype.insert=function(e,t,r,i){var n=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(t,r,i);for(var a=loadGeometry(e),o=0;o<a.length;o++){for(var s=a[o],l=[1/0,1/0,-(1/0),-(1/0)],u=0;u<s.length;u++){var c=s[u];l[0]=Math.min(l[0],c.x),l[1]=Math.min(l[1],c.y),l[2]=Math.max(l[2],c.x),l[3]=Math.max(l[3],c.y)}this.grid.insert(n,l[0],l[1],l[2],l[3])}},FeatureIndex.prototype.setCollisionTile=function(e){this.collisionTile=e},FeatureIndex.prototype.serialize=function(){var e={coord:this.coord,overscaling:this.overscaling,grid:this.grid.toArrayBuffer(),featureIndexArray:this.featureIndexArray.serialize(),bucketLayerIDs:this.bucketLayerIDs};return{data:e,transferables:[e.grid,e.featureIndexArray.arrayBuffer]}},FeatureIndex.prototype.query=function(e,t){this.vtLayers||(this.vtLayers=new vt.VectorTile(new Protobuf(this.rawTileData)).layers,this.sourceLayerCoder=new DictionaryCoder(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]));var r={},i=e.params||{},n=EXTENT/e.tileSize/e.scale,a=featureFilter(i.filter),o=0;for(var s in t){var l=t[s],u=l.paint,c=0;"line"===l.type?c=getLineWidth(u)/2+Math.abs(u["line-offset"])+translateDistance(u["line-translate"]):"fill"===l.type?c=translateDistance(u["fill-translate"]):"circle"===l.type&&(c=u["circle-radius"]+translateDistance(u["circle-translate"])),o=Math.max(o,c*n)}for(var f=e.queryGeometry.map(function(e){return e.map(function(e){return new Point(e.x,e.y)})}),y=1/0,h=1/0,d=-(1/0),g=-(1/0),v=0;v<f.length;v++)for(var p=f[v],x=0;x<p.length;x++){var I=p[x];y=Math.min(y,I.x),h=Math.min(h,I.y),d=Math.max(d,I.x),g=Math.max(g,I.y)}var m=this.grid.query(y-o,h-o,d+o,g+o);m.sort(topDownFeatureComparator),this.filterMatching(r,m,this.featureIndexArray,f,a,i.layers,t,e.bearing,n);var M=this.collisionTile.queryRenderedSymbols(y,h,d,g,e.scale);return M.sort(),this.filterMatching(r,M,this.collisionTile.collisionBoxArray,f,a,i.layers,t,e.bearing,n),r},FeatureIndex.prototype.filterMatching=function(e,t,r,i,n,a,o,s,l){for(var u,c=0;c<t.length;c++){var f=t[c];if(f!==u){u=f;var y=r.get(f),h=this.bucketLayerIDs[y.bucketIndex];if(!a||arraysIntersect(a,h)){var d=this.sourceLayerCoder.decode(y.sourceLayerIndex),g=this.vtLayers[d],v=g.feature(y.featureIndex);if(n(v))for(var p=null,x=0;x<h.length;x++){var I=h[x];if(!(a&&a.indexOf(I)<0)){var m=o[I];if(m){var M;if("symbol"!==m.type){p||(p=loadGeometry(v));var L=m.paint;if("line"===m.type){M=translate(i,L["line-translate"],L["line-translate-anchor"],s,l);var b=getLineWidth(L)/2*l;if(L["line-offset"]&&(p=offsetLine(p,L["line-offset"]*l)),!multiPolygonIntersectsBufferedMultiLine(M,p,b))continue}else if("fill"===m.type){if(M=translate(i,L["fill-translate"],L["fill-translate-anchor"],s,l),!multiPolygonIntersectsMultiPolygon(M,p))continue}else if("circle"===m.type){M=translate(i,L["circle-translate"],L["circle-translate-anchor"],s,l);var P=L["circle-radius"]*l;if(!multiPolygonIntersectsBufferedMultiPoint(M,p,P))continue}}var w=new GeoJSONFeature(v,this.z,this.x,this.y);w.layer=m.serialize({includeRefProperties:!0});var T=e[I];void 0===T&&(T=e[I]=[]),T.push(w)}}}}}}}; },{"../util/dictionary_coder":110,"../util/intersection_tests":117,"../util/struct_array":120,"../util/util":122,"../util/vectortile_to_geojson":123,"./bucket":2,"./load_geometry":11,"feature-filter":138,"grid-index":160,"pbf":190,"point-geometry":192,"vector-tile":202}],11:[function(require,module,exports){ "use strict";function createBounds(e){return{min:-1*Math.pow(2,e-1),max:Math.pow(2,e-1)-1}}var util=require("../util/util"),EXTENT=require("./bucket").EXTENT,boundsLookup={15:createBounds(15),16:createBounds(16)};module.exports=function(e,t){for(var r=boundsLookup[t||16],o=EXTENT/e.extent,u=e.loadGeometry(),n=0;n<u.length;n++)for(var a=u[n],i=0;i<a.length;i++){var d=a[i];d.x=Math.round(d.x*o),d.y=Math.round(d.y*o),(d.x<r.min||d.x>r.max||d.y<r.min||d.y>r.max)&&util.warnOnce("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return u}; },{"../util/util":122,"./bucket":2}],12:[function(require,module,exports){ "use strict";function Coordinate(o,t,n){this.column=o,this.row=t,this.zoom=n}module.exports=Coordinate,Coordinate.prototype={clone:function(){return new Coordinate(this.column,this.row,this.zoom)},zoomTo:function(o){return this.clone()._zoomTo(o)},sub:function(o){return this.clone()._sub(o)},_zoomTo:function(o){var t=Math.pow(2,o-this.zoom);return this.column*=t,this.row*=t,this.zoom=o,this},_sub:function(o){return o=o.zoomTo(this.zoom),this.column-=o.column,this.row-=o.row,this}}; },{}],13:[function(require,module,exports){ "use strict";function LngLat(t,n){if(isNaN(t)||isNaN(n))throw new Error("Invalid LngLat object: ("+t+", "+n+")");if(this.lng=+t,this.lat=+n,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}module.exports=LngLat;var wrap=require("../util/util").wrap;LngLat.prototype.wrap=function(){return new LngLat(wrap(this.lng,-180,180),this.lat)},LngLat.prototype.toArray=function(){return[this.lng,this.lat]},LngLat.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},LngLat.convert=function(t){if(t instanceof LngLat)return t;if(t&&t.hasOwnProperty("lng")&&t.hasOwnProperty("lat"))return new LngLat(t.lng,t.lat);if(Array.isArray(t)&&2===t.length)return new LngLat(t[0],t[1]);throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}; },{"../util/util":122}],14:[function(require,module,exports){ "use strict";function LngLatBounds(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}module.exports=LngLatBounds;var LngLat=require("./lng_lat");LngLatBounds.prototype={setNorthEast:function(t){return this._ne=LngLat.convert(t),this},setSouthWest:function(t){return this._sw=LngLat.convert(t),this},extend:function(t){var n,e,s=this._sw,r=this._ne;if(t instanceof LngLat)n=t,e=t;else{if(!(t instanceof LngLatBounds))return Array.isArray(t)?t.every(Array.isArray)?this.extend(LngLatBounds.convert(t)):this.extend(LngLat.convert(t)):this;if(n=t._sw,e=t._ne,!n||!e)return this}return s||r?(s.lng=Math.min(n.lng,s.lng),s.lat=Math.min(n.lat,s.lat),r.lng=Math.max(e.lng,r.lng),r.lat=Math.max(e.lat,r.lat)):(this._sw=new LngLat(n.lng,n.lat),this._ne=new LngLat(e.lng,e.lat)),this},getCenter:function(){return new LngLat((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},getSouthWest:function(){return this._sw},getNorthEast:function(){return this._ne},getNorthWest:function(){return new LngLat(this.getWest(),this.getNorth())},getSouthEast:function(){return new LngLat(this.getEast(),this.getSouth())},getWest:function(){return this._sw.lng},getSouth:function(){return this._sw.lat},getEast:function(){return this._ne.lng},getNorth:function(){return this._ne.lat},toArray:function(){return[this._sw.toArray(),this._ne.toArray()]},toString:function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"}},LngLatBounds.convert=function(t){return!t||t instanceof LngLatBounds?t:new LngLatBounds(t)}; },{"./lng_lat":13}],15:[function(require,module,exports){ "use strict";function Transform(t,i){this.tileSize=512,this._minZoom=t||0,this._maxZoom=i||22,this.latRange=[-85.05113,85.05113],this.width=0,this.height=0,this._center=new LngLat(0,0),this.zoom=0,this.angle=0,this._altitude=1.5,this._pitch=0,this._unmodified=!0}var LngLat=require("./lng_lat"),Point=require("point-geometry"),Coordinate=require("./coordinate"),util=require("../util/util"),interp=require("../util/interpolate"),TileCoord=require("../source/tile_coord"),EXTENT=require("../data/bucket").EXTENT,glmatrix=require("gl-matrix"),vec4=glmatrix.vec4,mat4=glmatrix.mat4,mat2=glmatrix.mat2;module.exports=Transform,Transform.prototype={get minZoom(){return this._minZoom},set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},get maxZoom(){return this._maxZoom},set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},get worldSize(){return this.tileSize*this.scale},get centerPoint(){return this.size._div(2)},get size(){return new Point(this.width,this.height)},get bearing(){return-this.angle/Math.PI*180},set bearing(t){var i=-util.wrap(t,-180,180)*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=mat2.create(),mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},get pitch(){return this._pitch/Math.PI*180},set pitch(t){var i=util.clamp(t,0,60)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())},get altitude(){return this._altitude},set altitude(t){var i=Math.max(.75,t);this._altitude!==i&&(this._unmodified=!1,this._altitude=i,this._calcMatrices())},get zoom(){return this._zoom},set zoom(t){var i=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this.scale=this.zoomScale(i),this.tileZoom=Math.floor(i),this.zoomFraction=i-this.tileZoom,this._calcMatrices(),this._constrain())},get center(){return this._center},set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._calcMatrices(),this._constrain())},coveringZoomLevel:function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},coveringTiles:function(t){var i=this.coveringZoomLevel(t),o=i;if(i<t.minzoom)return[];i>t.maxzoom&&(i=t.maxzoom);var e=this,n=e.locationCoordinate(e.center)._zoomTo(i),a=new Point(n.column-.5,n.row-.5);return TileCoord.cover(i,[e.pointCoordinate(new Point(0,0))._zoomTo(i),e.pointCoordinate(new Point(e.width,0))._zoomTo(i),e.pointCoordinate(new Point(e.width,e.height))._zoomTo(i),e.pointCoordinate(new Point(0,e.height))._zoomTo(i)],t.reparseOverscaled?o:i).sort(function(t,i){return a.dist(t)-a.dist(i)})},resize:function(t,i){this.width=t,this.height=i,this.pixelsToGLUnits=[2/t,-2/i],this._calcMatrices(),this._constrain()},get unmodified(){return this._unmodified},zoomScale:function(t){return Math.pow(2,t)},scaleZoom:function(t){return Math.log(t)/Math.LN2},project:function(t,i){return new Point(this.lngX(t.lng,i),this.latY(t.lat,i))},unproject:function(t,i){return new LngLat(this.xLng(t.x,i),this.yLat(t.y,i))},get x(){return this.lngX(this.center.lng)},get y(){return this.latY(this.center.lat)},get point(){return new Point(this.x,this.y)},lngX:function(t,i){return(180+t)*(i||this.worldSize)/360},latY:function(t,i){var o=180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360));return(180-o)*(i||this.worldSize)/360},xLng:function(t,i){return 360*t/(i||this.worldSize)-180},yLat:function(t,i){var o=180-360*t/(i||this.worldSize);return 360/Math.PI*Math.atan(Math.exp(o*Math.PI/180))-90},panBy:function(t){var i=this.centerPoint._add(t);this.center=this.pointLocation(i)},setLocationAtPoint:function(t,i){var o=this.locationCoordinate(t),e=this.pointCoordinate(i),n=this.pointCoordinate(this.centerPoint),a=e