@equinor/videx-map
Advanced tools
Comparing version 1.1.14 to 1.1.15
@@ -15,2 +15,2 @@ import{Container,Graphics,Point,Geometry,Shader,Mesh as Mesh$1,TextMetrics,Text,TextStyle}from"pixi.js";import Vector2 from"@equinor/videx-vector2";import{flatten,mix}from"@equinor/videx-linear-algebra";import earcut from"earcut";import{clamp}from"@equinor/videx-math";var ModuleInterface=function(){function ModuleInterface(){this.visibility=!0,this.root=new Container,this.root.sortableChildren=!0}return ModuleInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},ModuleInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},ModuleInterface}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)}; | ||
and limitations under the License. | ||
***************************************************************************** */function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds())+")","\n background-color: DimGrey;\n color: GhostWhite;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,outlineWidth:.125},config?(config.color&&"number"==typeof config.color&&(_this.config.color=config.color),config.outlineWidth&&"number"==typeof config.outlineWidth&&(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule}(ModuleInterface);function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}function removeDuplicates(points,epsilon){for(var reduced=[points[0]],prev=points[0],i=1;i<points.length;i++){var cur=points[i];Vector2.equals(cur,prev,epsilon)||(reduced.push(cur),prev=cur)}return reduced}function Intersection(p1,d1,p2,d2){var c=Vector2.sub(p1,p2),len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return d1.scale(len).mutable.add(p1).immutable}var Mesh=function(){function Mesh(){}return Mesh.Line=function(points,thickness,callback){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],_thickness=.5*thickness,segment0=points[0],first=segment0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness),upper0=from0.rotate90().mutable.add(first).immutable,lower0=from0.rotate270().mutable.add(first).immutable;vertices.push(upper0.x,upper0.y,lower0.x,lower0.y),callback&&callback(segment0);for(var i=1;i<points.length-1;i++){var segment=points[i],prev=points[i-1].position,cur=segment.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=segment.direction.rotate90().mutable.rescale(_thickness).add(cur).immutable,inner=segment.direction.rotate270().mutable.rescale(_thickness).add(cur).immutable;if(vertices.push(upper.x,upper.y,inner.x,inner.y),callback&&callback(segment),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var segmentN=points[points.length-1],last=segmentN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness),upperN=Vector2.add(last,toN.rotate90()),lowerN=Vector2.add(last,toN.rotate270());vertices.push(upperN.x,upperN.y,lowerN.x,lowerN.y),callback&&callback(segmentN);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=Shader.from(vertexShader,fragmentShader,uniforms);return new Mesh$1(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetNormal(index){if(0===index)return Vector2.sub(reduced[1],reduced[0]).mutable.rotate90().rescale(1);if(index===reduced.length-1)return Vector2.sub(reduced[reduced.length-1],reduced[reduced.length-2]).mutable.rotate90().rescale(1);var prev=reduced[index-1],cur=reduced[index],next=reduced[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length-1;i++){var cur=reduced[i],next=reduced[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetIndex(index){var r=index%reduced.length;return r<0&&(r+=reduced.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length;i++){var prev=reduced[GetIndex(i-1)],cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],next2=reduced[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===reduced.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={lineWidth:.125},config?(config.lineWidth&&"number"==typeof config.lineWidth&&(_this.config.lineWidth=config.lineWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:0,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.lineWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.lineWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(scale){var _this=this,clampedOutlineWidth=scale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0),Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].width=clampedOutlineWidth}))},OutlineModule}(ModuleInterface);OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++){if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArrays(group.consumed,[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length;j++){if("break"===_loop_1(j))break}}var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=clamp(this.config.initialHash),this.fields=[];var textStyle=new TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=function(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(outlineScale,hashScale,labelScale){var clampedHashWidth=clamp(hashScale,this.config.minHash,this.config.maxHash),clampedOutlineWidth=outlineScale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0);for(var i=0;i<this.fields.length;i++){var d=this.fields[i];d.fill.uniform.hashWidth=clampedHashWidth,d.outline.uniform.width=clampedOutlineWidth}labelScale>20?this.labelManager.visible&&this.labelManager.hideLabels():(this.labelManager.visible||this.labelManager.showLabels(),this.labelManager.resize(labelScale))},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field,!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);function generateCircle(center,radius){var geometry=new Geometry;geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]);var uniforms={circleColor:[.2,.2,.2]},shader=Shader.from("\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n ","\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor;\n\n void main() {\n vec2 dir = vec2(UVs.x - 0.5, UVs.y - 0.5) * 2.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n float light = 0.8 + dot(dir, vec2(1.0, -1.0)) * 0.5;\n vec3 col = circleColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",uniforms);return{mesh:new Mesh$1(geometry,shader),uniforms:uniforms}}FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var PointDictionary=function(){function PointDictionary(distThreshold,decimals){void 0===decimals&&(decimals=0),this.distThreshold=distThreshold,this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.pointValues=[]}return PointDictionary.prototype.add=function(point,value){var pointID=this.pointValues.length;this.pointValues.push({value:value,position:point,id:pointID});var key=Math.floor(point[0]*this.resolution)+"."+Math.floor(point[1]*this.resolution);return this.tiles.has(key)?this.tiles.get(key).push(pointID):this.tiles.set(key,[pointID]),pointID},PointDictionary.prototype.getOverlapping=function(target){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID];if(Vector2.distance(target,point.position)<this.distThreshold)return point}}return null},PointDictionary.prototype.getClosestUnder=function(target,pointRadius){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),minDist=1/0,closest=null,x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID],distance=Vector2.distance(target,point.position);distance<pointRadius&&distance<minDist&&(minDist=distance,closest=point)}}return closest},PointDictionary}(),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3);this.root.addChild(well.mesh),this.pointDict.add(pos,{mesh:well.mesh,uniforms:well.uniforms})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace,5*this.prevScale);if(circleUnder){var point=circleUnder.value;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);var LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var amount=points.length,path=new Array(amount),root=points[0];path[0]={point:root,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0)return{position:this.path[0].point,direction:this.GetDirection(0),distance:0};if(relative>=1)return{position:this.path[this.amount-1].point,direction:this.GetDirection(this.amount-1),distance:this.length};var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);return{position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path.length-1;return[{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length},{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);points.push({position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var prev_1=this.path[i-1],dist_1=cur_1.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1,prevDir_1=this.GetDirection(i-1),curDir_1=this.GetDirection(i);points.push({position:mix(prev_1.point,cur_1.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prevDir_1,curDir_1,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_1.distance*frac_1});break}points.push({position:cur_1.point,direction:this.GetDirection(i),distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(range/2);range>1;)relative<this.path[idx].relative?(range=Math.floor(range/2),idx=base+Math.floor(range/2)):(base+=Math.floor(range/2),range=Math.ceil(range/2),idx=base+Math.floor(range/2));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(idx){var end=this.amount-1;if(0===idx)return Vector2.sub(this.path[1].point,this.path[0].point).normalize();if(idx===end)return Vector2.sub(this.path[end].point,this.path[end-1].point).normalize();var cur=this.path[idx].point,to=Vector2.sub(cur,this.path[idx-1].point),from=Vector2.sub(this.path[idx+1].point,cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),ComparableArray=function(){function ComparableArray(a,sort,selector){if(void 0===sort&&(sort=!1),"number"!=typeof a){if(a.length<=0)throw"Array has no length.";for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(selector(temp))}sort&&tempNumbers.sort(),this.numbers=tempNumbers,this.selector=selector}else this.numbers=[a]}return ComparableArray.prototype.compare=function(a,sort){if(void 0===sort&&(sort=!0),"number"==typeof a&&(a=[a]),this.numbers.length!=a.length)return!1;for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(this.selector(temp))}sort&&tempNumbers.sort();for(i=0;i<tempNumbers.length;i++)if(this.numbers[i]!==tempNumbers[i])return!1;return!0},ComparableArray.prototype.toString=function(){return"["+this.numbers.toString()+"]"},ComparableArray}(),WellboreMesh=function(){function WellboreMesh(interp,thickness){this.interp=interp,this.thickness=thickness,this.baseTris=0}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(_this.thickness,p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(_this.thickness,p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.Line(section,this.thickness,(function(point){var v1Norm=point.direction.rotate90().mutable;vertexData.push(point.distance,1,v1Norm[0],v1Norm[1]);var v2Norm=point.direction.rotate270();vertexData.push(point.distance,0,v2Norm[0],v2Norm[1]),extraData.push(type,type)}));vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(thickness,p,vertices,triangles,vertexData,extraData){var pos=p.position,dir=p.direction.rescale(.15*thickness),pNorm=dir.rotate90().mutable.rescale(1.5*thickness).immutable,ll=pos.sub(dir).mutable.sub(pNorm);vertices.push(ll.x,ll.y);var lr=ll.set(pos).add(dir).sub(pNorm);vertices.push(lr.x,lr.y);var ul=ll.set(pos).sub(dir).add(pNorm);vertices.push(ul.x,ul.y);var ur=ll.set(pos).add(dir).add(pNorm);vertices.push(ur.x,ur.y),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2),vertexData.push(p.distance,0,0,0,p.distance,0,0,0,p.distance,1,0,0,p.distance,1,0,0),this.baseTris+=4},WellboreMesh}(),LineDictionary=function(){function LineDictionary(decimals){void 0===decimals&&(decimals=0),this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.lineValues=new Map,this.lineSegments=[]}return LineDictionary.prototype.add=function(lineID,line,value){this.lineValues.set(lineID,{value:value,enabled:!0});for(var i=1;i<line.length;i++){var p1=line[i-1],p2=line[i],segmentID=this.lineSegments.length;this.lineSegments.push({lineID:lineID,geometry:{x1:p1[0],y1:p1[1],x2:p2[0],y2:p2[1]}}),this.addSegment(p1[0],p1[1],p2[0],p2[1],segmentID)}},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,segmentID){var downwards,xMin,xMax,yMin,yMax,m,y0,unique={};x1<x2?(xMin=Math.floor(x1*this.resolution),xMax=Math.floor(x2*this.resolution),m=(y2-y1)/(x2-x1),y0=this.resolution*(y1-x1*m),downwards=y2<y1,unique[key=Math.floor(x1*this.resolution)+"."+Math.floor(y1*this.resolution)]=!0):(xMin=Math.floor(x2*this.resolution),xMax=Math.floor(x1*this.resolution),m=(y1-y2)/(x1-x2),y0=this.resolution*(y2-x2*m),downwards=y1<y2,unique[key=Math.floor(x2*this.resolution)+"."+Math.floor(y2*this.resolution)]=!0);y1<y2?(yMin=Math.floor(y1*this.resolution),yMax=Math.floor(y2*this.resolution)):(yMin=Math.floor(y2*this.resolution),yMax=Math.floor(y1*this.resolution));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;unique[x+"."+Math.floor(y)]=!0}for(y=yMin+1;y<=yMax;y++){x=(y-y0)/m;unique[Math.floor(x)+"."+Math.floor(downwards?y-1:y)]=!0}for(var _i=0,_a=Object.keys(unique);_i<_a.length;_i++){var key=_a[_i];this.tiles.has(key)?this.tiles.get(key).push(segmentID):this.tiles.set(key,[segmentID])}},LineDictionary.prototype.getClosest=function(target,maxDist){var _this=this;void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.length){var minDist=1/0,minLineID=-1;if(segments.forEach((function(d){var seg=_this.lineSegments[d],dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist/this.resolution))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.length)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(d){var seg=_this.lineSegments[d],distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist/this.resolution)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArrays([minT],extraT)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,unique={},lines=[],keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(val){if(!unique.hasOwnProperty(val)){var lineID=_this.lineSegments[val].lineID;_this.lineValues.get(lineID).enabled&&lines.push(val),unique[val]=!0}}))}return lines},LineDictionary}();function generateBackground(width,height){var background=new Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-.04,.5*-height-.01,width+.08,height+.02),background.pivot.set(0,.5*-height),background.alpha=.75,background.tint=0,background}var WellboreLayer=function(_super){function WellboreLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.lineDict=new LineDictionary(2.5),_this.circleRadius=.4,_this.pointDict=new PointDictionary(.25,-1.5),_this.selection=null,_this}return __extends(WellboreLayer,_super),WellboreLayer.prototype.appendWellbores=function(wells){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint,zINdex=0,textStyle=new TextStyle({fontFamily:"Arial",fontSize:24,fill:16777215,align:"center"}),drawWell=function(well){var longLat=well.coordinates.map((function(coord){return new Vector2(coord[1],coord[0])})),points=well.coordinates.map((function(coord){var p=project([coord[1],coord[0]]);return new Vector2(p.x,p.y)})),intervals=well.intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));intervals.length>0&&(intervals=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=function(wellLabel,textStyle){var label=new Text(wellLabel,textStyle);label.resolution=2;var textMetrics=TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height;return label.scale.set(.011),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}(well.label,textStyle);var verticalIndex=0;if(overlapping=_this.pointDict.getOverlapping(first))first=overlapping.position,verticalIndex=overlapping.value.labels.length,overlapping.value.labels.push(label);else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),_this.pointDict.add(first,{lineIDs:[],point:circle,labels:[label]});var labelPosition=Vector2.up.mutable.scale(_this.circleRadius+.05+.35*verticalIndex).add(first).immutable;label.text.position.set(labelPosition[0],labelPosition[1]),label.text.zIndex=1000001,_this.root.addChild(label.text),label.background.position.set(labelPosition[0],labelPosition[1]),label.background.zIndex=1e6,_this.root.addChild(label.background)}else{var _a=new WellboreMesh(interp,.15).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var label,uniforms={wellboreColor:[.2,.2,.2],visible:!0,enabled:!0},lineShader=Shader.from(WellboreLayer.vertexShader,WellboreLayer.fragmentShader,uniforms),lineMesh=new Mesh$1(geometry,lineShader);lineMesh.zIndex=zINdex++,_this.root.addChild(lineMesh),(label=function(wellLabel,interp,textStyle){var label=new Text(wellLabel,textStyle);label.resolution=2;var textMetrics=TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(.011);var targetPos,background=generateBackground(width,height);return dir.x<0?(label.anchor.set(0,0),background.pivot.set(.5*width,.5*height),background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.left,dir),targetPos=dir.rotate270().mutable.rescale(.1).add(end.position)):(label.anchor.set(1,0),background.pivot.x=.5*width,background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.right,dir),targetPos=dir.rotate90().mutable.rescale(.1).add(end.position)),label.position.set(targetPos[0],targetPos[1]),background.position.set(targetPos[0],targetPos[1]),{text:label,background:background}}(well.label,interp,textStyle)).text.zIndex=1000001,_this.root.addChild(label.text),label.background.zIndex=1e6,_this.root.addChild(label.background);var callback={line:lineMesh,label:label,uniforms:uniforms,data:well,zIndex:lineMesh.zIndex,pointID:-1};_this.lineDict.add(well.id,longLat,callback);var overlapping,circle,first=points[0];if(overlapping=_this.pointDict.getOverlapping(first))overlapping.value.lineIDs.push(well.id),callback.pointID=overlapping.id;else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),callback.pointID=_this.pointDict.add(first,{lineIDs:[well.id],point:circle,labels:[]})}};wells.forEach((function(well){return drawWell(well)}))},WellboreLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.06*scale;return targetScale>1&&(targetScale=1),targetScale},WellboreLayer.prototype.showIntersection=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.uniforms.visible=visible}))},WellboreLayer.prototype.showLabels=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.label.text.visible=visible}))},WellboreLayer.prototype.get=function(filter){if(void 0===filter&&(filter=null),!filter){var output_1=[];return this.lineDict.lineValues.forEach((function(d){return output_1.push(d.value)})),output_1}var output=[];return this.lineDict.lineValues.forEach((function(d){filter(d.value.data)&&output.push(d.value)})),output},WellboreLayer.prototype.enableWellbores=function(filter){this.lineDict.lineValues.forEach((function(v,k){filter(v.value.data)?(v.value.uniforms.enabled=!0,v.value.label.text.alpha=1,v.value.label.background.alpha=1,v.enabled=!0):(v.value.uniforms.enabled=!1,v.value.label.text.alpha=0,v.value.label.background.alpha=0,v.enabled=!1)}))},WellboreLayer.prototype.tryUnselect=function(){if(null!=this.selection){this.selection.lines.forEach((function(sel){sel.uniforms.wellboreColor=[.2,.2,.2],sel.line.zIndex=sel.zIndex,sel.label.background.tint=0,sel.label.text.zIndex=1000001,sel.label.background.zIndex=1e6,sel.label.background.alpha=.7}));var root=this.selection.root;return root&&(root.point.uniforms.circleColor=[.2,.2,.2],root.point.mesh.zIndex=2e4,root.labels.forEach((function(label){label.background.tint=0,label.text.zIndex=1000001,label.background.zIndex=1e6,label.background.alpha=.7}))),this.selection=null,!0}return!1},WellboreLayer.prototype.highlight=function(lat,long){var _this=this,_a=(0,this.pixiOverlay.utils.latLngToLayerPoint)([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y);function highlighLine(line,wellboreColor,labelBg){line.uniforms.wellboreColor=wellboreColor,line.label.background.tint=labelBg,line.label.background.zIndex=1000002,line.label.background.alpha=1,line.label.text.zIndex=1000003,line.line.zIndex=1e4}var circleUnder=this.pointDict.getClosestUnder(worldSpace,this.circleRadius);if(circleUnder){if(this.selection&&this.selection.multiSelect&&this.selection.ID.compare(circleUnder.id))return!0;this.tryUnselect();var pointData_1=circleUnder.value;pointData_1.point.uniforms.circleColor=[.7,.1,.4],pointData_1.point.mesh.zIndex=20001;var multiSelection_1=[];return circleUnder.value.lineIDs.forEach((function(d){var newSelection=_this.lineDict.lineValues.get(d).value;highlighLine(newSelection,[.7,.1,.4],10685014),multiSelection_1.push(newSelection)})),circleUnder.value.labels.forEach((function(label){label.text.zIndex=1000003,label.background.tint=10685014,label.background.zIndex=1000002,label.background.alpha=1})),this.selection={lines:multiSelection_1,root:pointData_1,multiSelect:!0,ID:new ComparableArray(circleUnder.id)},!0}var latLong=new Vector2(lat,long),newSelection=this.lineDict.getAllClosest(latLong,1e-4,.2,(function(min,d){return min.pointID===d.pointID}));if(newSelection.length<=0)return!1;if(this.selection&&!this.selection.multiSelect&&this.selection.ID.compare(newSelection))return!0;this.tryUnselect();var pointData=this.pointDict.pointValues[newSelection[0].pointID].value;return pointData.point.uniforms.circleColor=newSelection.length>1?[.7,.1,.4]:[.7,.1,.7],pointData.point.mesh.zIndex=20001,newSelection.forEach((function(line){newSelection.length>1?highlighLine(line,[.7,.1,.4],10685014):highlighLine(line,[.7,.1,.7],10685091)})),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){},WellboreLayer}(ModuleInterface);WellboreLayer.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n",WellboreLayer.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor;\n uniform bool visible;\n uniform bool enabled;\n\n void main() {\n if (!enabled) {\n if (type == 2.0) discard;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.025);\n return;\n }\n\n if (visible && type == 1.0) {\n if(mod(vCol.x, 0.1) > 0.05) discard;\n }\n\n if (!visible && type == 2.0) discard;\n\n float light = 0.8 + dot(vCol.zw, vec2(1.0, -1.0)) * 0.5;\n vec3 col = wellboreColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n";export{ExplorationLayer,FaultlineModule,FieldModule,ModuleInterface,OutlineModule,WellboreLayer}; | ||
***************************************************************************** */function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds())+")","\n background: #555;\n color: #eee;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,outlineWidth:.125},config?(config.color&&"number"==typeof config.color&&(_this.config.color=config.color),config.outlineWidth&&"number"==typeof config.outlineWidth&&(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule}(ModuleInterface);function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}function removeDuplicates(points,epsilon){for(var reduced=[points[0]],prev=points[0],i=1;i<points.length;i++){var cur=points[i];Vector2.equals(cur,prev,epsilon)||(reduced.push(cur),prev=cur)}return reduced}function Intersection(p1,d1,p2,d2){var c=Vector2.sub(p1,p2),len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return d1.scale(len).mutable.add(p1).immutable}var Mesh=function(){function Mesh(){}return Mesh.Line=function(points,thickness,callback){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],_thickness=.5*thickness,segment0=points[0],first=segment0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness),upper0=from0.rotate90().mutable.add(first).immutable,lower0=from0.rotate270().mutable.add(first).immutable;vertices.push(upper0.x,upper0.y,lower0.x,lower0.y),callback&&callback(segment0);for(var i=1;i<points.length-1;i++){var segment=points[i],prev=points[i-1].position,cur=segment.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=segment.direction.rotate90().mutable.rescale(_thickness).add(cur).immutable,inner=segment.direction.rotate270().mutable.rescale(_thickness).add(cur).immutable;if(vertices.push(upper.x,upper.y,inner.x,inner.y),callback&&callback(segment),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var segmentN=points[points.length-1],last=segmentN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness),upperN=Vector2.add(last,toN.rotate90()),lowerN=Vector2.add(last,toN.rotate270());vertices.push(upperN.x,upperN.y,lowerN.x,lowerN.y),callback&&callback(segmentN);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=Shader.from(vertexShader,fragmentShader,uniforms);return new Mesh$1(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetNormal(index){if(0===index)return Vector2.sub(reduced[1],reduced[0]).mutable.rotate90().rescale(1);if(index===reduced.length-1)return Vector2.sub(reduced[reduced.length-1],reduced[reduced.length-2]).mutable.rotate90().rescale(1);var prev=reduced[index-1],cur=reduced[index],next=reduced[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length-1;i++){var cur=reduced[i],next=reduced[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetIndex(index){var r=index%reduced.length;return r<0&&(r+=reduced.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length;i++){var prev=reduced[GetIndex(i-1)],cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],next2=reduced[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===reduced.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={lineWidth:.125},config?(config.lineWidth&&"number"==typeof config.lineWidth&&(_this.config.lineWidth=config.lineWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:0,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.lineWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.lineWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(scale){var _this=this,clampedOutlineWidth=scale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0),Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].width=clampedOutlineWidth}))},OutlineModule}(ModuleInterface);OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++){if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArrays(group.consumed,[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length;j++){if("break"===_loop_1(j))break}}var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=clamp(this.config.initialHash),this.fields=[];var textStyle=new TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=function(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(outlineScale,hashScale,labelScale){var clampedHashWidth=clamp(hashScale,this.config.minHash,this.config.maxHash),clampedOutlineWidth=outlineScale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0);for(var i=0;i<this.fields.length;i++){var d=this.fields[i];d.fill.uniform.hashWidth=clampedHashWidth,d.outline.uniform.width=clampedOutlineWidth}labelScale>20?this.labelManager.visible&&this.labelManager.hideLabels():(this.labelManager.visible||this.labelManager.showLabels(),this.labelManager.resize(labelScale))},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field,!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);function generateCircle(center,radius){var geometry=new Geometry;geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]);var uniforms={circleColor:[.2,.2,.2]},shader=Shader.from("\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n ","\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor;\n\n void main() {\n vec2 dir = vec2(UVs.x - 0.5, UVs.y - 0.5) * 2.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n float light = 0.8 + dot(dir, vec2(1.0, -1.0)) * 0.5;\n vec3 col = circleColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",uniforms);return{mesh:new Mesh$1(geometry,shader),uniforms:uniforms}}FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var PointDictionary=function(){function PointDictionary(distThreshold,decimals){void 0===decimals&&(decimals=0),this.distThreshold=distThreshold,this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.pointValues=[]}return PointDictionary.prototype.add=function(point,value){var pointID=this.pointValues.length;this.pointValues.push({value:value,position:point,id:pointID});var key=Math.floor(point[0]*this.resolution)+"."+Math.floor(point[1]*this.resolution);return this.tiles.has(key)?this.tiles.get(key).push(pointID):this.tiles.set(key,[pointID]),pointID},PointDictionary.prototype.getOverlapping=function(target){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID];if(Vector2.distance(target,point.position)<this.distThreshold)return point}}return null},PointDictionary.prototype.getClosestUnder=function(target,pointRadius){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),minDist=1/0,closest=null,x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID],distance=Vector2.distance(target,point.position);distance<pointRadius&&distance<minDist&&(minDist=distance,closest=point)}}return closest},PointDictionary}(),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3);this.root.addChild(well.mesh),this.pointDict.add(pos,{mesh:well.mesh,uniforms:well.uniforms})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace,5*this.prevScale);if(circleUnder){var point=circleUnder.value;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);var LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var amount=points.length,path=new Array(amount),root=points[0];path[0]={point:root,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0)return{position:this.path[0].point,direction:this.GetDirection(0),distance:0};if(relative>=1)return{position:this.path[this.amount-1].point,direction:this.GetDirection(this.amount-1),distance:this.length};var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);return{position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path.length-1;return[{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length},{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);points.push({position:mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var prev_1=this.path[i-1],dist_1=cur_1.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1,prevDir_1=this.GetDirection(i-1),curDir_1=this.GetDirection(i);points.push({position:mix(prev_1.point,cur_1.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prevDir_1,curDir_1,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_1.distance*frac_1});break}points.push({position:cur_1.point,direction:this.GetDirection(i),distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(range/2);range>1;)relative<this.path[idx].relative?(range=Math.floor(range/2),idx=base+Math.floor(range/2)):(base+=Math.floor(range/2),range=Math.ceil(range/2),idx=base+Math.floor(range/2));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(idx){var end=this.amount-1;if(0===idx)return Vector2.sub(this.path[1].point,this.path[0].point).normalize();if(idx===end)return Vector2.sub(this.path[end].point,this.path[end-1].point).normalize();var cur=this.path[idx].point,to=Vector2.sub(cur,this.path[idx-1].point),from=Vector2.sub(this.path[idx+1].point,cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),ComparableArray=function(){function ComparableArray(a,sort,selector){if(void 0===sort&&(sort=!1),"number"!=typeof a){if(a.length<=0)throw"Array has no length.";for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(selector(temp))}sort&&tempNumbers.sort(),this.numbers=tempNumbers,this.selector=selector}else this.numbers=[a]}return ComparableArray.prototype.compare=function(a,sort){if(void 0===sort&&(sort=!0),"number"==typeof a&&(a=[a]),this.numbers.length!=a.length)return!1;for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(this.selector(temp))}sort&&tempNumbers.sort();for(i=0;i<tempNumbers.length;i++)if(this.numbers[i]!==tempNumbers[i])return!1;return!0},ComparableArray.prototype.toString=function(){return"["+this.numbers.toString()+"]"},ComparableArray}(),WellboreMesh=function(){function WellboreMesh(interp,thickness){this.interp=interp,this.thickness=thickness,this.baseTris=0}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(_this.thickness,p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(_this.thickness,p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.Line(section,this.thickness,(function(point){var v1Norm=point.direction.rotate90().mutable;vertexData.push(point.distance,1,v1Norm[0],v1Norm[1]);var v2Norm=point.direction.rotate270();vertexData.push(point.distance,0,v2Norm[0],v2Norm[1]),extraData.push(type,type)}));vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(thickness,p,vertices,triangles,vertexData,extraData){var pos=p.position,dir=p.direction.rescale(.15*thickness),pNorm=dir.rotate90().mutable.rescale(1.5*thickness).immutable,ll=pos.sub(dir).mutable.sub(pNorm);vertices.push(ll.x,ll.y);var lr=ll.set(pos).add(dir).sub(pNorm);vertices.push(lr.x,lr.y);var ul=ll.set(pos).sub(dir).add(pNorm);vertices.push(ul.x,ul.y);var ur=ll.set(pos).add(dir).add(pNorm);vertices.push(ur.x,ur.y),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2),vertexData.push(p.distance,0,0,0,p.distance,0,0,0,p.distance,1,0,0,p.distance,1,0,0),this.baseTris+=4},WellboreMesh}(),LineDictionary=function(){function LineDictionary(decimals){void 0===decimals&&(decimals=0),this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.lineValues=new Map,this.lineSegments=[]}return LineDictionary.prototype.add=function(lineID,line,value){this.lineValues.set(lineID,{value:value,enabled:!0});for(var i=1;i<line.length;i++){var p1=line[i-1],p2=line[i],segmentID=this.lineSegments.length;this.lineSegments.push({lineID:lineID,geometry:{x1:p1[0],y1:p1[1],x2:p2[0],y2:p2[1]}}),this.addSegment(p1[0],p1[1],p2[0],p2[1],segmentID)}},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,segmentID){var downwards,xMin,xMax,yMin,yMax,m,y0,unique={};x1<x2?(xMin=Math.floor(x1*this.resolution),xMax=Math.floor(x2*this.resolution),m=(y2-y1)/(x2-x1),y0=this.resolution*(y1-x1*m),downwards=y2<y1,unique[key=Math.floor(x1*this.resolution)+"."+Math.floor(y1*this.resolution)]=!0):(xMin=Math.floor(x2*this.resolution),xMax=Math.floor(x1*this.resolution),m=(y1-y2)/(x1-x2),y0=this.resolution*(y2-x2*m),downwards=y1<y2,unique[key=Math.floor(x2*this.resolution)+"."+Math.floor(y2*this.resolution)]=!0);y1<y2?(yMin=Math.floor(y1*this.resolution),yMax=Math.floor(y2*this.resolution)):(yMin=Math.floor(y2*this.resolution),yMax=Math.floor(y1*this.resolution));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;unique[x+"."+Math.floor(y)]=!0}for(y=yMin+1;y<=yMax;y++){x=(y-y0)/m;unique[Math.floor(x)+"."+Math.floor(downwards?y-1:y)]=!0}for(var _i=0,_a=Object.keys(unique);_i<_a.length;_i++){var key=_a[_i];this.tiles.has(key)?this.tiles.get(key).push(segmentID):this.tiles.set(key,[segmentID])}},LineDictionary.prototype.getClosest=function(target,maxDist){var _this=this;void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.length){var minDist=1/0,minLineID=-1;if(segments.forEach((function(d){var seg=_this.lineSegments[d],dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist/this.resolution))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.length)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(d){var seg=_this.lineSegments[d],distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist/this.resolution)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArrays([minT],extraT)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,unique={},lines=[],keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(val){if(!unique.hasOwnProperty(val)){var lineID=_this.lineSegments[val].lineID;_this.lineValues.get(lineID).enabled&&lines.push(val),unique[val]=!0}}))}return lines},LineDictionary}();function generateBackground(width,height){var background=new Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-.04,.5*-height-.01,width+.08,height+.02),background.pivot.set(0,.5*-height),background.alpha=.75,background.tint=0,background}var WellboreLayer=function(_super){function WellboreLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.lineDict=new LineDictionary(2.5),_this.circleRadius=.4,_this.pointDict=new PointDictionary(.25,-1.5),_this.selection=null,_this}return __extends(WellboreLayer,_super),WellboreLayer.prototype.appendWellbores=function(wells){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint,zINdex=0,textStyle=new TextStyle({fontFamily:"Arial",fontSize:24,fill:16777215,align:"center"}),drawWell=function(well){var longLat=well.coordinates.map((function(coord){return new Vector2(coord[1],coord[0])})),points=well.coordinates.map((function(coord){var p=project([coord[1],coord[0]]);return new Vector2(p.x,p.y)})),intervals=well.intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));intervals.length>0&&(intervals=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=function(wellLabel,textStyle){var label=new Text(wellLabel,textStyle);label.resolution=2;var textMetrics=TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height;return label.scale.set(.011),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}(well.label,textStyle);var verticalIndex=0;if(overlapping=_this.pointDict.getOverlapping(first))first=overlapping.position,verticalIndex=overlapping.value.labels.length,overlapping.value.labels.push(label);else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),_this.pointDict.add(first,{lineIDs:[],point:circle,labels:[label]});var labelPosition=Vector2.up.mutable.scale(_this.circleRadius+.05+.35*verticalIndex).add(first).immutable;label.text.position.set(labelPosition[0],labelPosition[1]),label.text.zIndex=1000001,_this.root.addChild(label.text),label.background.position.set(labelPosition[0],labelPosition[1]),label.background.zIndex=1e6,_this.root.addChild(label.background)}else{var _a=new WellboreMesh(interp,.15).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var label,uniforms={wellboreColor:[.2,.2,.2],visible:!0,enabled:!0},lineShader=Shader.from(WellboreLayer.vertexShader,WellboreLayer.fragmentShader,uniforms),lineMesh=new Mesh$1(geometry,lineShader);lineMesh.zIndex=zINdex++,_this.root.addChild(lineMesh),(label=function(wellLabel,interp,textStyle){var label=new Text(wellLabel,textStyle);label.resolution=2;var textMetrics=TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(.011);var targetPos,background=generateBackground(width,height);return dir.x<0?(label.anchor.set(0,0),background.pivot.set(.5*width,.5*height),background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.left,dir),targetPos=dir.rotate270().mutable.rescale(.1).add(end.position)):(label.anchor.set(1,0),background.pivot.x=.5*width,background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.right,dir),targetPos=dir.rotate90().mutable.rescale(.1).add(end.position)),label.position.set(targetPos[0],targetPos[1]),background.position.set(targetPos[0],targetPos[1]),{text:label,background:background}}(well.label,interp,textStyle)).text.zIndex=1000001,_this.root.addChild(label.text),label.background.zIndex=1e6,_this.root.addChild(label.background);var callback={line:lineMesh,label:label,uniforms:uniforms,data:well,zIndex:lineMesh.zIndex,pointID:-1};_this.lineDict.add(well.id,longLat,callback);var overlapping,circle,first=points[0];if(overlapping=_this.pointDict.getOverlapping(first))overlapping.value.lineIDs.push(well.id),callback.pointID=overlapping.id;else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),callback.pointID=_this.pointDict.add(first,{lineIDs:[well.id],point:circle,labels:[]})}};wells.forEach((function(well){return drawWell(well)}))},WellboreLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.06*scale;return targetScale>1&&(targetScale=1),targetScale},WellboreLayer.prototype.showIntersection=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.uniforms.visible=visible}))},WellboreLayer.prototype.showLabels=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.label.text.visible=visible}))},WellboreLayer.prototype.get=function(filter){if(void 0===filter&&(filter=null),!filter){var output_1=[];return this.lineDict.lineValues.forEach((function(d){return output_1.push(d.value)})),output_1}var output=[];return this.lineDict.lineValues.forEach((function(d){filter(d.value.data)&&output.push(d.value)})),output},WellboreLayer.prototype.enableWellbores=function(filter){this.lineDict.lineValues.forEach((function(v,k){filter(v.value.data)?(v.value.uniforms.enabled=!0,v.value.label.text.alpha=1,v.value.label.background.alpha=1,v.enabled=!0):(v.value.uniforms.enabled=!1,v.value.label.text.alpha=0,v.value.label.background.alpha=0,v.enabled=!1)}))},WellboreLayer.prototype.tryUnselect=function(){if(null!=this.selection){this.selection.lines.forEach((function(sel){sel.uniforms.wellboreColor=[.2,.2,.2],sel.line.zIndex=sel.zIndex,sel.label.background.tint=0,sel.label.text.zIndex=1000001,sel.label.background.zIndex=1e6,sel.label.background.alpha=.7}));var root=this.selection.root;return root&&(root.point.uniforms.circleColor=[.2,.2,.2],root.point.mesh.zIndex=2e4,root.labels.forEach((function(label){label.background.tint=0,label.text.zIndex=1000001,label.background.zIndex=1e6,label.background.alpha=.7}))),this.selection=null,!0}return!1},WellboreLayer.prototype.highlight=function(lat,long){var _this=this,_a=(0,this.pixiOverlay.utils.latLngToLayerPoint)([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y);function highlighLine(line,wellboreColor,labelBg){line.uniforms.wellboreColor=wellboreColor,line.label.background.tint=labelBg,line.label.background.zIndex=1000002,line.label.background.alpha=1,line.label.text.zIndex=1000003,line.line.zIndex=1e4}var circleUnder=this.pointDict.getClosestUnder(worldSpace,this.circleRadius);if(circleUnder){if(this.selection&&this.selection.multiSelect&&this.selection.ID.compare(circleUnder.id))return!0;this.tryUnselect();var pointData_1=circleUnder.value;pointData_1.point.uniforms.circleColor=[.7,.1,.4],pointData_1.point.mesh.zIndex=20001;var multiSelection_1=[];return circleUnder.value.lineIDs.forEach((function(d){var newSelection=_this.lineDict.lineValues.get(d).value;highlighLine(newSelection,[.7,.1,.4],10685014),multiSelection_1.push(newSelection)})),circleUnder.value.labels.forEach((function(label){label.text.zIndex=1000003,label.background.tint=10685014,label.background.zIndex=1000002,label.background.alpha=1})),this.selection={lines:multiSelection_1,root:pointData_1,multiSelect:!0,ID:new ComparableArray(circleUnder.id)},!0}var latLong=new Vector2(lat,long),newSelection=this.lineDict.getAllClosest(latLong,1e-4,.2,(function(min,d){return min.pointID===d.pointID}));if(newSelection.length<=0)return!1;if(this.selection&&!this.selection.multiSelect&&this.selection.ID.compare(newSelection))return!0;this.tryUnselect();var pointData=this.pointDict.pointValues[newSelection[0].pointID].value;return pointData.point.uniforms.circleColor=newSelection.length>1?[.7,.1,.4]:[.7,.1,.7],pointData.point.mesh.zIndex=20001,newSelection.forEach((function(line){newSelection.length>1?highlighLine(line,[.7,.1,.4],10685014):highlighLine(line,[.7,.1,.7],10685091)})),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){},WellboreLayer}(ModuleInterface);WellboreLayer.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n",WellboreLayer.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor;\n uniform bool visible;\n uniform bool enabled;\n\n void main() {\n if (!enabled) {\n if (type == 2.0) discard;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.025);\n return;\n }\n\n if (visible && type == 1.0) {\n if(mod(vCol.x, 0.1) > 0.05) discard;\n }\n\n if (!visible && type == 2.0) discard;\n\n float light = 0.8 + dot(vCol.zw, vec2(1.0, -1.0)) * 0.5;\n vec3 col = wellboreColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n";export{ExplorationLayer,FaultlineModule,FieldModule,ModuleInterface,OutlineModule,WellboreLayer}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(ex){return ex&&"object"==typeof ex&&"default"in ex?ex.default:ex}Object.defineProperty(exports,"__esModule",{value:!0});var PIXI=require("pixi.js"),Vector2=_interopDefault(require("@equinor/videx-vector2")),videxLinearAlgebra=require("@equinor/videx-linear-algebra"),earcut=_interopDefault(require("earcut")),videxMath=require("@equinor/videx-math"),ModuleInterface=function(){function ModuleInterface(){this.visibility=!0,this.root=new PIXI.Container,this.root.sortableChildren=!0}return ModuleInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},ModuleInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},ModuleInterface}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds())+")","\n background-color: DimGrey;\n color: GhostWhite;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,outlineWidth:.125},config?(config.color&&"number"==typeof config.color&&(_this.config.color=config.color),config.outlineWidth&&"number"==typeof config.outlineWidth&&(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new PIXI.Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule}(ModuleInterface);function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}function removeDuplicates(points,epsilon){for(var reduced=[points[0]],prev=points[0],i=1;i<points.length;i++){var cur=points[i];Vector2.equals(cur,prev,epsilon)||(reduced.push(cur),prev=cur)}return reduced}function Intersection(p1,d1,p2,d2){var c=Vector2.sub(p1,p2),len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return d1.scale(len).mutable.add(p1).immutable}var Mesh=function(){function Mesh(){}return Mesh.Line=function(points,thickness,callback){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],_thickness=.5*thickness,segment0=points[0],first=segment0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness),upper0=from0.rotate90().mutable.add(first).immutable,lower0=from0.rotate270().mutable.add(first).immutable;vertices.push(upper0.x,upper0.y,lower0.x,lower0.y),callback&&callback(segment0);for(var i=1;i<points.length-1;i++){var segment=points[i],prev=points[i-1].position,cur=segment.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=segment.direction.rotate90().mutable.rescale(_thickness).add(cur).immutable,inner=segment.direction.rotate270().mutable.rescale(_thickness).add(cur).immutable;if(vertices.push(upper.x,upper.y,inner.x,inner.y),callback&&callback(segment),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var segmentN=points[points.length-1],last=segmentN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness),upperN=Vector2.add(last,toN.rotate90()),lowerN=Vector2.add(last,toN.rotate270());vertices.push(upperN.x,upperN.y,lowerN.x,lowerN.y),callback&&callback(segmentN);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniforms);return new PIXI.Mesh(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetNormal(index){if(0===index)return Vector2.sub(reduced[1],reduced[0]).mutable.rotate90().rescale(1);if(index===reduced.length-1)return Vector2.sub(reduced[reduced.length-1],reduced[reduced.length-2]).mutable.rotate90().rescale(1);var prev=reduced[index-1],cur=reduced[index],next=reduced[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length-1;i++){var cur=reduced[i],next=reduced[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=videxLinearAlgebra.flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetIndex(index){var r=index%reduced.length;return r<0&&(r+=reduced.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length;i++){var prev=reduced[GetIndex(i-1)],cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],next2=reduced[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===reduced.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={lineWidth:.125},config?(config.lineWidth&&"number"==typeof config.lineWidth&&(_this.config.lineWidth=config.lineWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:0,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.lineWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.lineWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(scale){var _this=this,clampedOutlineWidth=scale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0),Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].width=clampedOutlineWidth}))},OutlineModule}(ModuleInterface);OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=PIXI.TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new PIXI.Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++){if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArrays(group.consumed,[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length;j++){if("break"===_loop_1(j))break}}var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=videxMath.clamp(this.config.initialHash),this.fields=[];var textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=function(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(outlineScale,hashScale,labelScale){var clampedHashWidth=videxMath.clamp(hashScale,this.config.minHash,this.config.maxHash),clampedOutlineWidth=outlineScale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0);for(var i=0;i<this.fields.length;i++){var d=this.fields[i];d.fill.uniform.hashWidth=clampedHashWidth,d.outline.uniform.width=clampedOutlineWidth}labelScale>20?this.labelManager.visible&&this.labelManager.hideLabels():(this.labelManager.visible||this.labelManager.showLabels(),this.labelManager.resize(labelScale))},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field,!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);function generateCircle(center,radius){var geometry=new PIXI.Geometry;geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]);var uniforms={circleColor:[.2,.2,.2]},shader=PIXI.Shader.from("\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n ","\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor;\n\n void main() {\n vec2 dir = vec2(UVs.x - 0.5, UVs.y - 0.5) * 2.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n float light = 0.8 + dot(dir, vec2(1.0, -1.0)) * 0.5;\n vec3 col = circleColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",uniforms);return{mesh:new PIXI.Mesh(geometry,shader),uniforms:uniforms}}FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var PointDictionary=function(){function PointDictionary(distThreshold,decimals){void 0===decimals&&(decimals=0),this.distThreshold=distThreshold,this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.pointValues=[]}return PointDictionary.prototype.add=function(point,value){var pointID=this.pointValues.length;this.pointValues.push({value:value,position:point,id:pointID});var key=Math.floor(point[0]*this.resolution)+"."+Math.floor(point[1]*this.resolution);return this.tiles.has(key)?this.tiles.get(key).push(pointID):this.tiles.set(key,[pointID]),pointID},PointDictionary.prototype.getOverlapping=function(target){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID];if(Vector2.distance(target,point.position)<this.distThreshold)return point}}return null},PointDictionary.prototype.getClosestUnder=function(target,pointRadius){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),minDist=1/0,closest=null,x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID],distance=Vector2.distance(target,point.position);distance<pointRadius&&distance<minDist&&(minDist=distance,closest=point)}}return closest},PointDictionary}(),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3);this.root.addChild(well.mesh),this.pointDict.add(pos,{mesh:well.mesh,uniforms:well.uniforms})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace,5*this.prevScale);if(circleUnder){var point=circleUnder.value;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);var LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var amount=points.length,path=new Array(amount),root=points[0];path[0]={point:root,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0)return{position:this.path[0].point,direction:this.GetDirection(0),distance:0};if(relative>=1)return{position:this.path[this.amount-1].point,direction:this.GetDirection(this.amount-1),distance:this.length};var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);return{position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path.length-1;return[{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length},{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);points.push({position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var prev_1=this.path[i-1],dist_1=cur_1.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1,prevDir_1=this.GetDirection(i-1),curDir_1=this.GetDirection(i);points.push({position:videxLinearAlgebra.mix(prev_1.point,cur_1.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prevDir_1,curDir_1,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_1.distance*frac_1});break}points.push({position:cur_1.point,direction:this.GetDirection(i),distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(range/2);range>1;)relative<this.path[idx].relative?(range=Math.floor(range/2),idx=base+Math.floor(range/2)):(base+=Math.floor(range/2),range=Math.ceil(range/2),idx=base+Math.floor(range/2));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(idx){var end=this.amount-1;if(0===idx)return Vector2.sub(this.path[1].point,this.path[0].point).normalize();if(idx===end)return Vector2.sub(this.path[end].point,this.path[end-1].point).normalize();var cur=this.path[idx].point,to=Vector2.sub(cur,this.path[idx-1].point),from=Vector2.sub(this.path[idx+1].point,cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),ComparableArray=function(){function ComparableArray(a,sort,selector){if(void 0===sort&&(sort=!1),"number"!=typeof a){if(a.length<=0)throw"Array has no length.";for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(selector(temp))}sort&&tempNumbers.sort(),this.numbers=tempNumbers,this.selector=selector}else this.numbers=[a]}return ComparableArray.prototype.compare=function(a,sort){if(void 0===sort&&(sort=!0),"number"==typeof a&&(a=[a]),this.numbers.length!=a.length)return!1;for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(this.selector(temp))}sort&&tempNumbers.sort();for(i=0;i<tempNumbers.length;i++)if(this.numbers[i]!==tempNumbers[i])return!1;return!0},ComparableArray.prototype.toString=function(){return"["+this.numbers.toString()+"]"},ComparableArray}(),WellboreMesh=function(){function WellboreMesh(interp,thickness){this.interp=interp,this.thickness=thickness,this.baseTris=0}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(_this.thickness,p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(_this.thickness,p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.Line(section,this.thickness,(function(point){var v1Norm=point.direction.rotate90().mutable;vertexData.push(point.distance,1,v1Norm[0],v1Norm[1]);var v2Norm=point.direction.rotate270();vertexData.push(point.distance,0,v2Norm[0],v2Norm[1]),extraData.push(type,type)}));vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(thickness,p,vertices,triangles,vertexData,extraData){var pos=p.position,dir=p.direction.rescale(.15*thickness),pNorm=dir.rotate90().mutable.rescale(1.5*thickness).immutable,ll=pos.sub(dir).mutable.sub(pNorm);vertices.push(ll.x,ll.y);var lr=ll.set(pos).add(dir).sub(pNorm);vertices.push(lr.x,lr.y);var ul=ll.set(pos).sub(dir).add(pNorm);vertices.push(ul.x,ul.y);var ur=ll.set(pos).add(dir).add(pNorm);vertices.push(ur.x,ur.y),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2),vertexData.push(p.distance,0,0,0,p.distance,0,0,0,p.distance,1,0,0,p.distance,1,0,0),this.baseTris+=4},WellboreMesh}(),LineDictionary=function(){function LineDictionary(decimals){void 0===decimals&&(decimals=0),this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.lineValues=new Map,this.lineSegments=[]}return LineDictionary.prototype.add=function(lineID,line,value){this.lineValues.set(lineID,{value:value,enabled:!0});for(var i=1;i<line.length;i++){var p1=line[i-1],p2=line[i],segmentID=this.lineSegments.length;this.lineSegments.push({lineID:lineID,geometry:{x1:p1[0],y1:p1[1],x2:p2[0],y2:p2[1]}}),this.addSegment(p1[0],p1[1],p2[0],p2[1],segmentID)}},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,segmentID){var downwards,xMin,xMax,yMin,yMax,m,y0,unique={};x1<x2?(xMin=Math.floor(x1*this.resolution),xMax=Math.floor(x2*this.resolution),m=(y2-y1)/(x2-x1),y0=this.resolution*(y1-x1*m),downwards=y2<y1,unique[key=Math.floor(x1*this.resolution)+"."+Math.floor(y1*this.resolution)]=!0):(xMin=Math.floor(x2*this.resolution),xMax=Math.floor(x1*this.resolution),m=(y1-y2)/(x1-x2),y0=this.resolution*(y2-x2*m),downwards=y1<y2,unique[key=Math.floor(x2*this.resolution)+"."+Math.floor(y2*this.resolution)]=!0);y1<y2?(yMin=Math.floor(y1*this.resolution),yMax=Math.floor(y2*this.resolution)):(yMin=Math.floor(y2*this.resolution),yMax=Math.floor(y1*this.resolution));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;unique[x+"."+Math.floor(y)]=!0}for(y=yMin+1;y<=yMax;y++){x=(y-y0)/m;unique[Math.floor(x)+"."+Math.floor(downwards?y-1:y)]=!0}for(var _i=0,_a=Object.keys(unique);_i<_a.length;_i++){var key=_a[_i];this.tiles.has(key)?this.tiles.get(key).push(segmentID):this.tiles.set(key,[segmentID])}},LineDictionary.prototype.getClosest=function(target,maxDist){var _this=this;void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.length){var minDist=1/0,minLineID=-1;if(segments.forEach((function(d){var seg=_this.lineSegments[d],dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist/this.resolution))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.length)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(d){var seg=_this.lineSegments[d],distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist/this.resolution)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArrays([minT],extraT)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,unique={},lines=[],keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(val){if(!unique.hasOwnProperty(val)){var lineID=_this.lineSegments[val].lineID;_this.lineValues.get(lineID).enabled&&lines.push(val),unique[val]=!0}}))}return lines},LineDictionary}();function generateBackground(width,height){var background=new PIXI.Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-.04,.5*-height-.01,width+.08,height+.02),background.pivot.set(0,.5*-height),background.alpha=.75,background.tint=0,background}var WellboreLayer=function(_super){function WellboreLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.lineDict=new LineDictionary(2.5),_this.circleRadius=.4,_this.pointDict=new PointDictionary(.25,-1.5),_this.selection=null,_this}return __extends(WellboreLayer,_super),WellboreLayer.prototype.appendWellbores=function(wells){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint,zINdex=0,textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:24,fill:16777215,align:"center"}),drawWell=function(well){var longLat=well.coordinates.map((function(coord){return new Vector2(coord[1],coord[0])})),points=well.coordinates.map((function(coord){var p=project([coord[1],coord[0]]);return new Vector2(p.x,p.y)})),intervals=well.intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));intervals.length>0&&(intervals=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=function(wellLabel,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height;return label.scale.set(.011),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}(well.label,textStyle);var verticalIndex=0;if(overlapping=_this.pointDict.getOverlapping(first))first=overlapping.position,verticalIndex=overlapping.value.labels.length,overlapping.value.labels.push(label);else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),_this.pointDict.add(first,{lineIDs:[],point:circle,labels:[label]});var labelPosition=Vector2.up.mutable.scale(_this.circleRadius+.05+.35*verticalIndex).add(first).immutable;label.text.position.set(labelPosition[0],labelPosition[1]),label.text.zIndex=1000001,_this.root.addChild(label.text),label.background.position.set(labelPosition[0],labelPosition[1]),label.background.zIndex=1e6,_this.root.addChild(label.background)}else{var _a=new WellboreMesh(interp,.15).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new PIXI.Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var label,uniforms={wellboreColor:[.2,.2,.2],visible:!0,enabled:!0},lineShader=PIXI.Shader.from(WellboreLayer.vertexShader,WellboreLayer.fragmentShader,uniforms),lineMesh=new PIXI.Mesh(geometry,lineShader);lineMesh.zIndex=zINdex++,_this.root.addChild(lineMesh),(label=function(wellLabel,interp,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(.011);var targetPos,background=generateBackground(width,height);return dir.x<0?(label.anchor.set(0,0),background.pivot.set(.5*width,.5*height),background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.left,dir),targetPos=dir.rotate270().mutable.rescale(.1).add(end.position)):(label.anchor.set(1,0),background.pivot.x=.5*width,background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.right,dir),targetPos=dir.rotate90().mutable.rescale(.1).add(end.position)),label.position.set(targetPos[0],targetPos[1]),background.position.set(targetPos[0],targetPos[1]),{text:label,background:background}}(well.label,interp,textStyle)).text.zIndex=1000001,_this.root.addChild(label.text),label.background.zIndex=1e6,_this.root.addChild(label.background);var callback={line:lineMesh,label:label,uniforms:uniforms,data:well,zIndex:lineMesh.zIndex,pointID:-1};_this.lineDict.add(well.id,longLat,callback);var overlapping,circle,first=points[0];if(overlapping=_this.pointDict.getOverlapping(first))overlapping.value.lineIDs.push(well.id),callback.pointID=overlapping.id;else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),callback.pointID=_this.pointDict.add(first,{lineIDs:[well.id],point:circle,labels:[]})}};wells.forEach((function(well){return drawWell(well)}))},WellboreLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.06*scale;return targetScale>1&&(targetScale=1),targetScale},WellboreLayer.prototype.showIntersection=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.uniforms.visible=visible}))},WellboreLayer.prototype.showLabels=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.label.text.visible=visible}))},WellboreLayer.prototype.get=function(filter){if(void 0===filter&&(filter=null),!filter){var output_1=[];return this.lineDict.lineValues.forEach((function(d){return output_1.push(d.value)})),output_1}var output=[];return this.lineDict.lineValues.forEach((function(d){filter(d.value.data)&&output.push(d.value)})),output},WellboreLayer.prototype.enableWellbores=function(filter){this.lineDict.lineValues.forEach((function(v,k){filter(v.value.data)?(v.value.uniforms.enabled=!0,v.value.label.text.alpha=1,v.value.label.background.alpha=1,v.enabled=!0):(v.value.uniforms.enabled=!1,v.value.label.text.alpha=0,v.value.label.background.alpha=0,v.enabled=!1)}))},WellboreLayer.prototype.tryUnselect=function(){if(null!=this.selection){this.selection.lines.forEach((function(sel){sel.uniforms.wellboreColor=[.2,.2,.2],sel.line.zIndex=sel.zIndex,sel.label.background.tint=0,sel.label.text.zIndex=1000001,sel.label.background.zIndex=1e6,sel.label.background.alpha=.7}));var root=this.selection.root;return root&&(root.point.uniforms.circleColor=[.2,.2,.2],root.point.mesh.zIndex=2e4,root.labels.forEach((function(label){label.background.tint=0,label.text.zIndex=1000001,label.background.zIndex=1e6,label.background.alpha=.7}))),this.selection=null,!0}return!1},WellboreLayer.prototype.highlight=function(lat,long){var _this=this,_a=(0,this.pixiOverlay.utils.latLngToLayerPoint)([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y);function highlighLine(line,wellboreColor,labelBg){line.uniforms.wellboreColor=wellboreColor,line.label.background.tint=labelBg,line.label.background.zIndex=1000002,line.label.background.alpha=1,line.label.text.zIndex=1000003,line.line.zIndex=1e4}var circleUnder=this.pointDict.getClosestUnder(worldSpace,this.circleRadius);if(circleUnder){if(this.selection&&this.selection.multiSelect&&this.selection.ID.compare(circleUnder.id))return!0;this.tryUnselect();var pointData_1=circleUnder.value;pointData_1.point.uniforms.circleColor=[.7,.1,.4],pointData_1.point.mesh.zIndex=20001;var multiSelection_1=[];return circleUnder.value.lineIDs.forEach((function(d){var newSelection=_this.lineDict.lineValues.get(d).value;highlighLine(newSelection,[.7,.1,.4],10685014),multiSelection_1.push(newSelection)})),circleUnder.value.labels.forEach((function(label){label.text.zIndex=1000003,label.background.tint=10685014,label.background.zIndex=1000002,label.background.alpha=1})),this.selection={lines:multiSelection_1,root:pointData_1,multiSelect:!0,ID:new ComparableArray(circleUnder.id)},!0}var latLong=new Vector2(lat,long),newSelection=this.lineDict.getAllClosest(latLong,1e-4,.2,(function(min,d){return min.pointID===d.pointID}));if(newSelection.length<=0)return!1;if(this.selection&&!this.selection.multiSelect&&this.selection.ID.compare(newSelection))return!0;this.tryUnselect();var pointData=this.pointDict.pointValues[newSelection[0].pointID].value;return pointData.point.uniforms.circleColor=newSelection.length>1?[.7,.1,.4]:[.7,.1,.7],pointData.point.mesh.zIndex=20001,newSelection.forEach((function(line){newSelection.length>1?highlighLine(line,[.7,.1,.4],10685014):highlighLine(line,[.7,.1,.7],10685091)})),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){},WellboreLayer}(ModuleInterface);WellboreLayer.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n",WellboreLayer.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor;\n uniform bool visible;\n uniform bool enabled;\n\n void main() {\n if (!enabled) {\n if (type == 2.0) discard;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.025);\n return;\n }\n\n if (visible && type == 1.0) {\n if(mod(vCol.x, 0.1) > 0.05) discard;\n }\n\n if (!visible && type == 2.0) discard;\n\n float light = 0.8 + dot(vCol.zw, vec2(1.0, -1.0)) * 0.5;\n vec3 col = wellboreColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n",exports.ExplorationLayer=ExplorationLayer,exports.FaultlineModule=FaultlineModule,exports.FieldModule=FieldModule,exports.ModuleInterface=ModuleInterface,exports.OutlineModule=OutlineModule,exports.WellboreLayer=WellboreLayer; | ||
"use strict";function _interopDefault(ex){return ex&&"object"==typeof ex&&"default"in ex?ex.default:ex}Object.defineProperty(exports,"__esModule",{value:!0});var PIXI=require("pixi.js"),Vector2=_interopDefault(require("@equinor/videx-vector2")),videxLinearAlgebra=require("@equinor/videx-linear-algebra"),earcut=_interopDefault(require("earcut")),videxMath=require("@equinor/videx-math"),ModuleInterface=function(){function ModuleInterface(){this.visibility=!0,this.root=new PIXI.Container,this.root.sortableChildren=!0}return ModuleInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},ModuleInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},ModuleInterface}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds())+")","\n background: #555;\n color: #eee;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,outlineWidth:.125},config?(config.color&&"number"==typeof config.color&&(_this.config.color=config.color),config.outlineWidth&&"number"==typeof config.outlineWidth&&(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new PIXI.Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule}(ModuleInterface);function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}function removeDuplicates(points,epsilon){for(var reduced=[points[0]],prev=points[0],i=1;i<points.length;i++){var cur=points[i];Vector2.equals(cur,prev,epsilon)||(reduced.push(cur),prev=cur)}return reduced}function Intersection(p1,d1,p2,d2){var c=Vector2.sub(p1,p2),len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return d1.scale(len).mutable.add(p1).immutable}var Mesh=function(){function Mesh(){}return Mesh.Line=function(points,thickness,callback){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],_thickness=.5*thickness,segment0=points[0],first=segment0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness),upper0=from0.rotate90().mutable.add(first).immutable,lower0=from0.rotate270().mutable.add(first).immutable;vertices.push(upper0.x,upper0.y,lower0.x,lower0.y),callback&&callback(segment0);for(var i=1;i<points.length-1;i++){var segment=points[i],prev=points[i-1].position,cur=segment.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=segment.direction.rotate90().mutable.rescale(_thickness).add(cur).immutable,inner=segment.direction.rotate270().mutable.rescale(_thickness).add(cur).immutable;if(vertices.push(upper.x,upper.y,inner.x,inner.y),callback&&callback(segment),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var segmentN=points[points.length-1],last=segmentN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness),upperN=Vector2.add(last,toN.rotate90()),lowerN=Vector2.add(last,toN.rotate270());vertices.push(upperN.x,upperN.y,lowerN.x,lowerN.y),callback&&callback(segmentN);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniforms);return new PIXI.Mesh(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetNormal(index){if(0===index)return Vector2.sub(reduced[1],reduced[0]).mutable.rotate90().rescale(1);if(index===reduced.length-1)return Vector2.sub(reduced[reduced.length-1],reduced[reduced.length-2]).mutable.rotate90().rescale(1);var prev=reduced[index-1],cur=reduced[index],next=reduced[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length-1;i++){var cur=reduced[i],next=reduced[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=videxLinearAlgebra.flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetIndex(index){var r=index%reduced.length;return r<0&&(r+=reduced.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length;i++){var prev=reduced[GetIndex(i-1)],cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],next2=reduced[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===reduced.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={lineWidth:.125},config?(config.lineWidth&&"number"==typeof config.lineWidth&&(_this.config.lineWidth=config.lineWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:0,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.lineWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.lineWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(scale){var _this=this,clampedOutlineWidth=scale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0),Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].width=clampedOutlineWidth}))},OutlineModule}(ModuleInterface);OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=PIXI.TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new PIXI.Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++){if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArrays(group.consumed,[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length;j++){if("break"===_loop_1(j))break}}var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=videxMath.clamp(this.config.initialHash),this.fields=[];var textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=function(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(outlineScale,hashScale,labelScale){var clampedHashWidth=videxMath.clamp(hashScale,this.config.minHash,this.config.maxHash),clampedOutlineWidth=outlineScale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0);for(var i=0;i<this.fields.length;i++){var d=this.fields[i];d.fill.uniform.hashWidth=clampedHashWidth,d.outline.uniform.width=clampedOutlineWidth}labelScale>20?this.labelManager.visible&&this.labelManager.hideLabels():(this.labelManager.visible||this.labelManager.showLabels(),this.labelManager.resize(labelScale))},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field,!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);function generateCircle(center,radius){var geometry=new PIXI.Geometry;geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]);var uniforms={circleColor:[.2,.2,.2]},shader=PIXI.Shader.from("\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n ","\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor;\n\n void main() {\n vec2 dir = vec2(UVs.x - 0.5, UVs.y - 0.5) * 2.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n float light = 0.8 + dot(dir, vec2(1.0, -1.0)) * 0.5;\n vec3 col = circleColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",uniforms);return{mesh:new PIXI.Mesh(geometry,shader),uniforms:uniforms}}FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var PointDictionary=function(){function PointDictionary(distThreshold,decimals){void 0===decimals&&(decimals=0),this.distThreshold=distThreshold,this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.pointValues=[]}return PointDictionary.prototype.add=function(point,value){var pointID=this.pointValues.length;this.pointValues.push({value:value,position:point,id:pointID});var key=Math.floor(point[0]*this.resolution)+"."+Math.floor(point[1]*this.resolution);return this.tiles.has(key)?this.tiles.get(key).push(pointID):this.tiles.set(key,[pointID]),pointID},PointDictionary.prototype.getOverlapping=function(target){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID];if(Vector2.distance(target,point.position)<this.distThreshold)return point}}return null},PointDictionary.prototype.getClosestUnder=function(target,pointRadius){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),minDist=1/0,closest=null,x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID],distance=Vector2.distance(target,point.position);distance<pointRadius&&distance<minDist&&(minDist=distance,closest=point)}}return closest},PointDictionary}(),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3);this.root.addChild(well.mesh),this.pointDict.add(pos,{mesh:well.mesh,uniforms:well.uniforms})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace,5*this.prevScale);if(circleUnder){var point=circleUnder.value;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);var LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var amount=points.length,path=new Array(amount),root=points[0];path[0]={point:root,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0)return{position:this.path[0].point,direction:this.GetDirection(0),distance:0};if(relative>=1)return{position:this.path[this.amount-1].point,direction:this.GetDirection(this.amount-1),distance:this.length};var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);return{position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path.length-1;return[{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length},{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);points.push({position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var prev_1=this.path[i-1],dist_1=cur_1.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1,prevDir_1=this.GetDirection(i-1),curDir_1=this.GetDirection(i);points.push({position:videxLinearAlgebra.mix(prev_1.point,cur_1.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prevDir_1,curDir_1,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_1.distance*frac_1});break}points.push({position:cur_1.point,direction:this.GetDirection(i),distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(range/2);range>1;)relative<this.path[idx].relative?(range=Math.floor(range/2),idx=base+Math.floor(range/2)):(base+=Math.floor(range/2),range=Math.ceil(range/2),idx=base+Math.floor(range/2));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(idx){var end=this.amount-1;if(0===idx)return Vector2.sub(this.path[1].point,this.path[0].point).normalize();if(idx===end)return Vector2.sub(this.path[end].point,this.path[end-1].point).normalize();var cur=this.path[idx].point,to=Vector2.sub(cur,this.path[idx-1].point),from=Vector2.sub(this.path[idx+1].point,cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),ComparableArray=function(){function ComparableArray(a,sort,selector){if(void 0===sort&&(sort=!1),"number"!=typeof a){if(a.length<=0)throw"Array has no length.";for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(selector(temp))}sort&&tempNumbers.sort(),this.numbers=tempNumbers,this.selector=selector}else this.numbers=[a]}return ComparableArray.prototype.compare=function(a,sort){if(void 0===sort&&(sort=!0),"number"==typeof a&&(a=[a]),this.numbers.length!=a.length)return!1;for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(this.selector(temp))}sort&&tempNumbers.sort();for(i=0;i<tempNumbers.length;i++)if(this.numbers[i]!==tempNumbers[i])return!1;return!0},ComparableArray.prototype.toString=function(){return"["+this.numbers.toString()+"]"},ComparableArray}(),WellboreMesh=function(){function WellboreMesh(interp,thickness){this.interp=interp,this.thickness=thickness,this.baseTris=0}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(_this.thickness,p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(_this.thickness,p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.Line(section,this.thickness,(function(point){var v1Norm=point.direction.rotate90().mutable;vertexData.push(point.distance,1,v1Norm[0],v1Norm[1]);var v2Norm=point.direction.rotate270();vertexData.push(point.distance,0,v2Norm[0],v2Norm[1]),extraData.push(type,type)}));vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(thickness,p,vertices,triangles,vertexData,extraData){var pos=p.position,dir=p.direction.rescale(.15*thickness),pNorm=dir.rotate90().mutable.rescale(1.5*thickness).immutable,ll=pos.sub(dir).mutable.sub(pNorm);vertices.push(ll.x,ll.y);var lr=ll.set(pos).add(dir).sub(pNorm);vertices.push(lr.x,lr.y);var ul=ll.set(pos).sub(dir).add(pNorm);vertices.push(ul.x,ul.y);var ur=ll.set(pos).add(dir).add(pNorm);vertices.push(ur.x,ur.y),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2),vertexData.push(p.distance,0,0,0,p.distance,0,0,0,p.distance,1,0,0,p.distance,1,0,0),this.baseTris+=4},WellboreMesh}(),LineDictionary=function(){function LineDictionary(decimals){void 0===decimals&&(decimals=0),this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.lineValues=new Map,this.lineSegments=[]}return LineDictionary.prototype.add=function(lineID,line,value){this.lineValues.set(lineID,{value:value,enabled:!0});for(var i=1;i<line.length;i++){var p1=line[i-1],p2=line[i],segmentID=this.lineSegments.length;this.lineSegments.push({lineID:lineID,geometry:{x1:p1[0],y1:p1[1],x2:p2[0],y2:p2[1]}}),this.addSegment(p1[0],p1[1],p2[0],p2[1],segmentID)}},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,segmentID){var downwards,xMin,xMax,yMin,yMax,m,y0,unique={};x1<x2?(xMin=Math.floor(x1*this.resolution),xMax=Math.floor(x2*this.resolution),m=(y2-y1)/(x2-x1),y0=this.resolution*(y1-x1*m),downwards=y2<y1,unique[key=Math.floor(x1*this.resolution)+"."+Math.floor(y1*this.resolution)]=!0):(xMin=Math.floor(x2*this.resolution),xMax=Math.floor(x1*this.resolution),m=(y1-y2)/(x1-x2),y0=this.resolution*(y2-x2*m),downwards=y1<y2,unique[key=Math.floor(x2*this.resolution)+"."+Math.floor(y2*this.resolution)]=!0);y1<y2?(yMin=Math.floor(y1*this.resolution),yMax=Math.floor(y2*this.resolution)):(yMin=Math.floor(y2*this.resolution),yMax=Math.floor(y1*this.resolution));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;unique[x+"."+Math.floor(y)]=!0}for(y=yMin+1;y<=yMax;y++){x=(y-y0)/m;unique[Math.floor(x)+"."+Math.floor(downwards?y-1:y)]=!0}for(var _i=0,_a=Object.keys(unique);_i<_a.length;_i++){var key=_a[_i];this.tiles.has(key)?this.tiles.get(key).push(segmentID):this.tiles.set(key,[segmentID])}},LineDictionary.prototype.getClosest=function(target,maxDist){var _this=this;void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.length){var minDist=1/0,minLineID=-1;if(segments.forEach((function(d){var seg=_this.lineSegments[d],dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist/this.resolution))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.length)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(d){var seg=_this.lineSegments[d],distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist/this.resolution)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArrays([minT],extraT)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,unique={},lines=[],keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(val){if(!unique.hasOwnProperty(val)){var lineID=_this.lineSegments[val].lineID;_this.lineValues.get(lineID).enabled&&lines.push(val),unique[val]=!0}}))}return lines},LineDictionary}();function generateBackground(width,height){var background=new PIXI.Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-.04,.5*-height-.01,width+.08,height+.02),background.pivot.set(0,.5*-height),background.alpha=.75,background.tint=0,background}var WellboreLayer=function(_super){function WellboreLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.lineDict=new LineDictionary(2.5),_this.circleRadius=.4,_this.pointDict=new PointDictionary(.25,-1.5),_this.selection=null,_this}return __extends(WellboreLayer,_super),WellboreLayer.prototype.appendWellbores=function(wells){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint,zINdex=0,textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:24,fill:16777215,align:"center"}),drawWell=function(well){var longLat=well.coordinates.map((function(coord){return new Vector2(coord[1],coord[0])})),points=well.coordinates.map((function(coord){var p=project([coord[1],coord[0]]);return new Vector2(p.x,p.y)})),intervals=well.intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));intervals.length>0&&(intervals=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=function(wellLabel,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height;return label.scale.set(.011),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}(well.label,textStyle);var verticalIndex=0;if(overlapping=_this.pointDict.getOverlapping(first))first=overlapping.position,verticalIndex=overlapping.value.labels.length,overlapping.value.labels.push(label);else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),_this.pointDict.add(first,{lineIDs:[],point:circle,labels:[label]});var labelPosition=Vector2.up.mutable.scale(_this.circleRadius+.05+.35*verticalIndex).add(first).immutable;label.text.position.set(labelPosition[0],labelPosition[1]),label.text.zIndex=1000001,_this.root.addChild(label.text),label.background.position.set(labelPosition[0],labelPosition[1]),label.background.zIndex=1e6,_this.root.addChild(label.background)}else{var _a=new WellboreMesh(interp,.15).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new PIXI.Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var label,uniforms={wellboreColor:[.2,.2,.2],visible:!0,enabled:!0},lineShader=PIXI.Shader.from(WellboreLayer.vertexShader,WellboreLayer.fragmentShader,uniforms),lineMesh=new PIXI.Mesh(geometry,lineShader);lineMesh.zIndex=zINdex++,_this.root.addChild(lineMesh),(label=function(wellLabel,interp,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(.011);var targetPos,background=generateBackground(width,height);return dir.x<0?(label.anchor.set(0,0),background.pivot.set(.5*width,.5*height),background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.left,dir),targetPos=dir.rotate270().mutable.rescale(.1).add(end.position)):(label.anchor.set(1,0),background.pivot.x=.5*width,background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.right,dir),targetPos=dir.rotate90().mutable.rescale(.1).add(end.position)),label.position.set(targetPos[0],targetPos[1]),background.position.set(targetPos[0],targetPos[1]),{text:label,background:background}}(well.label,interp,textStyle)).text.zIndex=1000001,_this.root.addChild(label.text),label.background.zIndex=1e6,_this.root.addChild(label.background);var callback={line:lineMesh,label:label,uniforms:uniforms,data:well,zIndex:lineMesh.zIndex,pointID:-1};_this.lineDict.add(well.id,longLat,callback);var overlapping,circle,first=points[0];if(overlapping=_this.pointDict.getOverlapping(first))overlapping.value.lineIDs.push(well.id),callback.pointID=overlapping.id;else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),callback.pointID=_this.pointDict.add(first,{lineIDs:[well.id],point:circle,labels:[]})}};wells.forEach((function(well){return drawWell(well)}))},WellboreLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.06*scale;return targetScale>1&&(targetScale=1),targetScale},WellboreLayer.prototype.showIntersection=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.uniforms.visible=visible}))},WellboreLayer.prototype.showLabels=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.label.text.visible=visible}))},WellboreLayer.prototype.get=function(filter){if(void 0===filter&&(filter=null),!filter){var output_1=[];return this.lineDict.lineValues.forEach((function(d){return output_1.push(d.value)})),output_1}var output=[];return this.lineDict.lineValues.forEach((function(d){filter(d.value.data)&&output.push(d.value)})),output},WellboreLayer.prototype.enableWellbores=function(filter){this.lineDict.lineValues.forEach((function(v,k){filter(v.value.data)?(v.value.uniforms.enabled=!0,v.value.label.text.alpha=1,v.value.label.background.alpha=1,v.enabled=!0):(v.value.uniforms.enabled=!1,v.value.label.text.alpha=0,v.value.label.background.alpha=0,v.enabled=!1)}))},WellboreLayer.prototype.tryUnselect=function(){if(null!=this.selection){this.selection.lines.forEach((function(sel){sel.uniforms.wellboreColor=[.2,.2,.2],sel.line.zIndex=sel.zIndex,sel.label.background.tint=0,sel.label.text.zIndex=1000001,sel.label.background.zIndex=1e6,sel.label.background.alpha=.7}));var root=this.selection.root;return root&&(root.point.uniforms.circleColor=[.2,.2,.2],root.point.mesh.zIndex=2e4,root.labels.forEach((function(label){label.background.tint=0,label.text.zIndex=1000001,label.background.zIndex=1e6,label.background.alpha=.7}))),this.selection=null,!0}return!1},WellboreLayer.prototype.highlight=function(lat,long){var _this=this,_a=(0,this.pixiOverlay.utils.latLngToLayerPoint)([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y);function highlighLine(line,wellboreColor,labelBg){line.uniforms.wellboreColor=wellboreColor,line.label.background.tint=labelBg,line.label.background.zIndex=1000002,line.label.background.alpha=1,line.label.text.zIndex=1000003,line.line.zIndex=1e4}var circleUnder=this.pointDict.getClosestUnder(worldSpace,this.circleRadius);if(circleUnder){if(this.selection&&this.selection.multiSelect&&this.selection.ID.compare(circleUnder.id))return!0;this.tryUnselect();var pointData_1=circleUnder.value;pointData_1.point.uniforms.circleColor=[.7,.1,.4],pointData_1.point.mesh.zIndex=20001;var multiSelection_1=[];return circleUnder.value.lineIDs.forEach((function(d){var newSelection=_this.lineDict.lineValues.get(d).value;highlighLine(newSelection,[.7,.1,.4],10685014),multiSelection_1.push(newSelection)})),circleUnder.value.labels.forEach((function(label){label.text.zIndex=1000003,label.background.tint=10685014,label.background.zIndex=1000002,label.background.alpha=1})),this.selection={lines:multiSelection_1,root:pointData_1,multiSelect:!0,ID:new ComparableArray(circleUnder.id)},!0}var latLong=new Vector2(lat,long),newSelection=this.lineDict.getAllClosest(latLong,1e-4,.2,(function(min,d){return min.pointID===d.pointID}));if(newSelection.length<=0)return!1;if(this.selection&&!this.selection.multiSelect&&this.selection.ID.compare(newSelection))return!0;this.tryUnselect();var pointData=this.pointDict.pointValues[newSelection[0].pointID].value;return pointData.point.uniforms.circleColor=newSelection.length>1?[.7,.1,.4]:[.7,.1,.7],pointData.point.mesh.zIndex=20001,newSelection.forEach((function(line){newSelection.length>1?highlighLine(line,[.7,.1,.4],10685014):highlighLine(line,[.7,.1,.7],10685091)})),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){},WellboreLayer}(ModuleInterface);WellboreLayer.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n",WellboreLayer.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor;\n uniform bool visible;\n uniform bool enabled;\n\n void main() {\n if (!enabled) {\n if (type == 2.0) discard;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.025);\n return;\n }\n\n if (visible && type == 1.0) {\n if(mod(vCol.x, 0.1) > 0.05) discard;\n }\n\n if (!visible && type == 2.0) discard;\n\n float light = 0.8 + dot(vCol.zw, vec2(1.0, -1.0)) * 0.5;\n vec3 col = wellboreColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n",exports.ExplorationLayer=ExplorationLayer,exports.FaultlineModule=FaultlineModule,exports.FieldModule=FieldModule,exports.ModuleInterface=ModuleInterface,exports.OutlineModule=OutlineModule,exports.WellboreLayer=WellboreLayer; |
@@ -15,2 +15,2 @@ !function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("pixi.js"),require("@equinor/videx-vector2"),require("@equinor/videx-linear-algebra"),require("earcut"),require("@equinor/videx-math")):"function"==typeof define&&define.amd?define(["exports","pixi.js","@equinor/videx-vector2","@equinor/videx-linear-algebra","earcut","@equinor/videx-math"],factory):factory((global=global||self).Vector2={},global.PIXI,global.Vector2,global.videxLinearAlgebra,global.earcut,global.videxMath)}(this,(function(exports,PIXI,Vector2,videxLinearAlgebra,earcut,videxMath){"use strict";Vector2=Vector2&&Vector2.hasOwnProperty("default")?Vector2.default:Vector2,earcut=earcut&&earcut.hasOwnProperty("default")?earcut.default:earcut;var ModuleInterface=function(){function ModuleInterface(){this.visibility=!0,this.root=new PIXI.Container,this.root.sortableChildren=!0}return ModuleInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},ModuleInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},ModuleInterface}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)}; | ||
and limitations under the License. | ||
***************************************************************************** */function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds())+")","\n background-color: DimGrey;\n color: GhostWhite;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,outlineWidth:.125},config?(config.color&&"number"==typeof config.color&&(_this.config.color=config.color),config.outlineWidth&&"number"==typeof config.outlineWidth&&(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new PIXI.Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule}(ModuleInterface);function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}function removeDuplicates(points,epsilon){for(var reduced=[points[0]],prev=points[0],i=1;i<points.length;i++){var cur=points[i];Vector2.equals(cur,prev,epsilon)||(reduced.push(cur),prev=cur)}return reduced}function Intersection(p1,d1,p2,d2){var c=Vector2.sub(p1,p2),len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return d1.scale(len).mutable.add(p1).immutable}var Mesh=function(){function Mesh(){}return Mesh.Line=function(points,thickness,callback){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],_thickness=.5*thickness,segment0=points[0],first=segment0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness),upper0=from0.rotate90().mutable.add(first).immutable,lower0=from0.rotate270().mutable.add(first).immutable;vertices.push(upper0.x,upper0.y,lower0.x,lower0.y),callback&&callback(segment0);for(var i=1;i<points.length-1;i++){var segment=points[i],prev=points[i-1].position,cur=segment.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=segment.direction.rotate90().mutable.rescale(_thickness).add(cur).immutable,inner=segment.direction.rotate270().mutable.rescale(_thickness).add(cur).immutable;if(vertices.push(upper.x,upper.y,inner.x,inner.y),callback&&callback(segment),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var segmentN=points[points.length-1],last=segmentN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness),upperN=Vector2.add(last,toN.rotate90()),lowerN=Vector2.add(last,toN.rotate270());vertices.push(upperN.x,upperN.y,lowerN.x,lowerN.y),callback&&callback(segmentN);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniforms);return new PIXI.Mesh(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetNormal(index){if(0===index)return Vector2.sub(reduced[1],reduced[0]).mutable.rotate90().rescale(1);if(index===reduced.length-1)return Vector2.sub(reduced[reduced.length-1],reduced[reduced.length-2]).mutable.rotate90().rescale(1);var prev=reduced[index-1],cur=reduced[index],next=reduced[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length-1;i++){var cur=reduced[i],next=reduced[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=videxLinearAlgebra.flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetIndex(index){var r=index%reduced.length;return r<0&&(r+=reduced.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length;i++){var prev=reduced[GetIndex(i-1)],cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],next2=reduced[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===reduced.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={lineWidth:.125},config?(config.lineWidth&&"number"==typeof config.lineWidth&&(_this.config.lineWidth=config.lineWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:0,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.lineWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.lineWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(scale){var _this=this,clampedOutlineWidth=scale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0),Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].width=clampedOutlineWidth}))},OutlineModule}(ModuleInterface);OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=PIXI.TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new PIXI.Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++){if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArrays(group.consumed,[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length;j++){if("break"===_loop_1(j))break}}var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=videxMath.clamp(this.config.initialHash),this.fields=[];var textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=function(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(outlineScale,hashScale,labelScale){var clampedHashWidth=videxMath.clamp(hashScale,this.config.minHash,this.config.maxHash),clampedOutlineWidth=outlineScale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0);for(var i=0;i<this.fields.length;i++){var d=this.fields[i];d.fill.uniform.hashWidth=clampedHashWidth,d.outline.uniform.width=clampedOutlineWidth}labelScale>20?this.labelManager.visible&&this.labelManager.hideLabels():(this.labelManager.visible||this.labelManager.showLabels(),this.labelManager.resize(labelScale))},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field,!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);function generateCircle(center,radius){var geometry=new PIXI.Geometry;geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]);var uniforms={circleColor:[.2,.2,.2]},shader=PIXI.Shader.from("\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n ","\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor;\n\n void main() {\n vec2 dir = vec2(UVs.x - 0.5, UVs.y - 0.5) * 2.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n float light = 0.8 + dot(dir, vec2(1.0, -1.0)) * 0.5;\n vec3 col = circleColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",uniforms);return{mesh:new PIXI.Mesh(geometry,shader),uniforms:uniforms}}FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var PointDictionary=function(){function PointDictionary(distThreshold,decimals){void 0===decimals&&(decimals=0),this.distThreshold=distThreshold,this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.pointValues=[]}return PointDictionary.prototype.add=function(point,value){var pointID=this.pointValues.length;this.pointValues.push({value:value,position:point,id:pointID});var key=Math.floor(point[0]*this.resolution)+"."+Math.floor(point[1]*this.resolution);return this.tiles.has(key)?this.tiles.get(key).push(pointID):this.tiles.set(key,[pointID]),pointID},PointDictionary.prototype.getOverlapping=function(target){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID];if(Vector2.distance(target,point.position)<this.distThreshold)return point}}return null},PointDictionary.prototype.getClosestUnder=function(target,pointRadius){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),minDist=1/0,closest=null,x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID],distance=Vector2.distance(target,point.position);distance<pointRadius&&distance<minDist&&(minDist=distance,closest=point)}}return closest},PointDictionary}(),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3);this.root.addChild(well.mesh),this.pointDict.add(pos,{mesh:well.mesh,uniforms:well.uniforms})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace,5*this.prevScale);if(circleUnder){var point=circleUnder.value;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);var LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var amount=points.length,path=new Array(amount),root=points[0];path[0]={point:root,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0)return{position:this.path[0].point,direction:this.GetDirection(0),distance:0};if(relative>=1)return{position:this.path[this.amount-1].point,direction:this.GetDirection(this.amount-1),distance:this.length};var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);return{position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path.length-1;return[{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length},{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);points.push({position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var prev_1=this.path[i-1],dist_1=cur_1.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1,prevDir_1=this.GetDirection(i-1),curDir_1=this.GetDirection(i);points.push({position:videxLinearAlgebra.mix(prev_1.point,cur_1.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prevDir_1,curDir_1,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_1.distance*frac_1});break}points.push({position:cur_1.point,direction:this.GetDirection(i),distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(range/2);range>1;)relative<this.path[idx].relative?(range=Math.floor(range/2),idx=base+Math.floor(range/2)):(base+=Math.floor(range/2),range=Math.ceil(range/2),idx=base+Math.floor(range/2));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(idx){var end=this.amount-1;if(0===idx)return Vector2.sub(this.path[1].point,this.path[0].point).normalize();if(idx===end)return Vector2.sub(this.path[end].point,this.path[end-1].point).normalize();var cur=this.path[idx].point,to=Vector2.sub(cur,this.path[idx-1].point),from=Vector2.sub(this.path[idx+1].point,cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),ComparableArray=function(){function ComparableArray(a,sort,selector){if(void 0===sort&&(sort=!1),"number"!=typeof a){if(a.length<=0)throw"Array has no length.";for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(selector(temp))}sort&&tempNumbers.sort(),this.numbers=tempNumbers,this.selector=selector}else this.numbers=[a]}return ComparableArray.prototype.compare=function(a,sort){if(void 0===sort&&(sort=!0),"number"==typeof a&&(a=[a]),this.numbers.length!=a.length)return!1;for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(this.selector(temp))}sort&&tempNumbers.sort();for(i=0;i<tempNumbers.length;i++)if(this.numbers[i]!==tempNumbers[i])return!1;return!0},ComparableArray.prototype.toString=function(){return"["+this.numbers.toString()+"]"},ComparableArray}(),WellboreMesh=function(){function WellboreMesh(interp,thickness){this.interp=interp,this.thickness=thickness,this.baseTris=0}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(_this.thickness,p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(_this.thickness,p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.Line(section,this.thickness,(function(point){var v1Norm=point.direction.rotate90().mutable;vertexData.push(point.distance,1,v1Norm[0],v1Norm[1]);var v2Norm=point.direction.rotate270();vertexData.push(point.distance,0,v2Norm[0],v2Norm[1]),extraData.push(type,type)}));vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(thickness,p,vertices,triangles,vertexData,extraData){var pos=p.position,dir=p.direction.rescale(.15*thickness),pNorm=dir.rotate90().mutable.rescale(1.5*thickness).immutable,ll=pos.sub(dir).mutable.sub(pNorm);vertices.push(ll.x,ll.y);var lr=ll.set(pos).add(dir).sub(pNorm);vertices.push(lr.x,lr.y);var ul=ll.set(pos).sub(dir).add(pNorm);vertices.push(ul.x,ul.y);var ur=ll.set(pos).add(dir).add(pNorm);vertices.push(ur.x,ur.y),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2),vertexData.push(p.distance,0,0,0,p.distance,0,0,0,p.distance,1,0,0,p.distance,1,0,0),this.baseTris+=4},WellboreMesh}(),LineDictionary=function(){function LineDictionary(decimals){void 0===decimals&&(decimals=0),this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.lineValues=new Map,this.lineSegments=[]}return LineDictionary.prototype.add=function(lineID,line,value){this.lineValues.set(lineID,{value:value,enabled:!0});for(var i=1;i<line.length;i++){var p1=line[i-1],p2=line[i],segmentID=this.lineSegments.length;this.lineSegments.push({lineID:lineID,geometry:{x1:p1[0],y1:p1[1],x2:p2[0],y2:p2[1]}}),this.addSegment(p1[0],p1[1],p2[0],p2[1],segmentID)}},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,segmentID){var downwards,xMin,xMax,yMin,yMax,m,y0,unique={};x1<x2?(xMin=Math.floor(x1*this.resolution),xMax=Math.floor(x2*this.resolution),m=(y2-y1)/(x2-x1),y0=this.resolution*(y1-x1*m),downwards=y2<y1,unique[key=Math.floor(x1*this.resolution)+"."+Math.floor(y1*this.resolution)]=!0):(xMin=Math.floor(x2*this.resolution),xMax=Math.floor(x1*this.resolution),m=(y1-y2)/(x1-x2),y0=this.resolution*(y2-x2*m),downwards=y1<y2,unique[key=Math.floor(x2*this.resolution)+"."+Math.floor(y2*this.resolution)]=!0);y1<y2?(yMin=Math.floor(y1*this.resolution),yMax=Math.floor(y2*this.resolution)):(yMin=Math.floor(y2*this.resolution),yMax=Math.floor(y1*this.resolution));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;unique[x+"."+Math.floor(y)]=!0}for(y=yMin+1;y<=yMax;y++){x=(y-y0)/m;unique[Math.floor(x)+"."+Math.floor(downwards?y-1:y)]=!0}for(var _i=0,_a=Object.keys(unique);_i<_a.length;_i++){var key=_a[_i];this.tiles.has(key)?this.tiles.get(key).push(segmentID):this.tiles.set(key,[segmentID])}},LineDictionary.prototype.getClosest=function(target,maxDist){var _this=this;void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.length){var minDist=1/0,minLineID=-1;if(segments.forEach((function(d){var seg=_this.lineSegments[d],dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist/this.resolution))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.length)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(d){var seg=_this.lineSegments[d],distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist/this.resolution)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArrays([minT],extraT)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,unique={},lines=[],keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(val){if(!unique.hasOwnProperty(val)){var lineID=_this.lineSegments[val].lineID;_this.lineValues.get(lineID).enabled&&lines.push(val),unique[val]=!0}}))}return lines},LineDictionary}();function generateBackground(width,height){var background=new PIXI.Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-.04,.5*-height-.01,width+.08,height+.02),background.pivot.set(0,.5*-height),background.alpha=.75,background.tint=0,background}var WellboreLayer=function(_super){function WellboreLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.lineDict=new LineDictionary(2.5),_this.circleRadius=.4,_this.pointDict=new PointDictionary(.25,-1.5),_this.selection=null,_this}return __extends(WellboreLayer,_super),WellboreLayer.prototype.appendWellbores=function(wells){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint,zINdex=0,textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:24,fill:16777215,align:"center"}),drawWell=function(well){var longLat=well.coordinates.map((function(coord){return new Vector2(coord[1],coord[0])})),points=well.coordinates.map((function(coord){var p=project([coord[1],coord[0]]);return new Vector2(p.x,p.y)})),intervals=well.intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));intervals.length>0&&(intervals=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=function(wellLabel,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height;return label.scale.set(.011),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}(well.label,textStyle);var verticalIndex=0;if(overlapping=_this.pointDict.getOverlapping(first))first=overlapping.position,verticalIndex=overlapping.value.labels.length,overlapping.value.labels.push(label);else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),_this.pointDict.add(first,{lineIDs:[],point:circle,labels:[label]});var labelPosition=Vector2.up.mutable.scale(_this.circleRadius+.05+.35*verticalIndex).add(first).immutable;label.text.position.set(labelPosition[0],labelPosition[1]),label.text.zIndex=1000001,_this.root.addChild(label.text),label.background.position.set(labelPosition[0],labelPosition[1]),label.background.zIndex=1e6,_this.root.addChild(label.background)}else{var _a=new WellboreMesh(interp,.15).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new PIXI.Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var label,uniforms={wellboreColor:[.2,.2,.2],visible:!0,enabled:!0},lineShader=PIXI.Shader.from(WellboreLayer.vertexShader,WellboreLayer.fragmentShader,uniforms),lineMesh=new PIXI.Mesh(geometry,lineShader);lineMesh.zIndex=zINdex++,_this.root.addChild(lineMesh),(label=function(wellLabel,interp,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(.011);var targetPos,background=generateBackground(width,height);return dir.x<0?(label.anchor.set(0,0),background.pivot.set(.5*width,.5*height),background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.left,dir),targetPos=dir.rotate270().mutable.rescale(.1).add(end.position)):(label.anchor.set(1,0),background.pivot.x=.5*width,background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.right,dir),targetPos=dir.rotate90().mutable.rescale(.1).add(end.position)),label.position.set(targetPos[0],targetPos[1]),background.position.set(targetPos[0],targetPos[1]),{text:label,background:background}}(well.label,interp,textStyle)).text.zIndex=1000001,_this.root.addChild(label.text),label.background.zIndex=1e6,_this.root.addChild(label.background);var callback={line:lineMesh,label:label,uniforms:uniforms,data:well,zIndex:lineMesh.zIndex,pointID:-1};_this.lineDict.add(well.id,longLat,callback);var overlapping,circle,first=points[0];if(overlapping=_this.pointDict.getOverlapping(first))overlapping.value.lineIDs.push(well.id),callback.pointID=overlapping.id;else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),callback.pointID=_this.pointDict.add(first,{lineIDs:[well.id],point:circle,labels:[]})}};wells.forEach((function(well){return drawWell(well)}))},WellboreLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.06*scale;return targetScale>1&&(targetScale=1),targetScale},WellboreLayer.prototype.showIntersection=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.uniforms.visible=visible}))},WellboreLayer.prototype.showLabels=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.label.text.visible=visible}))},WellboreLayer.prototype.get=function(filter){if(void 0===filter&&(filter=null),!filter){var output_1=[];return this.lineDict.lineValues.forEach((function(d){return output_1.push(d.value)})),output_1}var output=[];return this.lineDict.lineValues.forEach((function(d){filter(d.value.data)&&output.push(d.value)})),output},WellboreLayer.prototype.enableWellbores=function(filter){this.lineDict.lineValues.forEach((function(v,k){filter(v.value.data)?(v.value.uniforms.enabled=!0,v.value.label.text.alpha=1,v.value.label.background.alpha=1,v.enabled=!0):(v.value.uniforms.enabled=!1,v.value.label.text.alpha=0,v.value.label.background.alpha=0,v.enabled=!1)}))},WellboreLayer.prototype.tryUnselect=function(){if(null!=this.selection){this.selection.lines.forEach((function(sel){sel.uniforms.wellboreColor=[.2,.2,.2],sel.line.zIndex=sel.zIndex,sel.label.background.tint=0,sel.label.text.zIndex=1000001,sel.label.background.zIndex=1e6,sel.label.background.alpha=.7}));var root=this.selection.root;return root&&(root.point.uniforms.circleColor=[.2,.2,.2],root.point.mesh.zIndex=2e4,root.labels.forEach((function(label){label.background.tint=0,label.text.zIndex=1000001,label.background.zIndex=1e6,label.background.alpha=.7}))),this.selection=null,!0}return!1},WellboreLayer.prototype.highlight=function(lat,long){var _this=this,_a=(0,this.pixiOverlay.utils.latLngToLayerPoint)([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y);function highlighLine(line,wellboreColor,labelBg){line.uniforms.wellboreColor=wellboreColor,line.label.background.tint=labelBg,line.label.background.zIndex=1000002,line.label.background.alpha=1,line.label.text.zIndex=1000003,line.line.zIndex=1e4}var circleUnder=this.pointDict.getClosestUnder(worldSpace,this.circleRadius);if(circleUnder){if(this.selection&&this.selection.multiSelect&&this.selection.ID.compare(circleUnder.id))return!0;this.tryUnselect();var pointData_1=circleUnder.value;pointData_1.point.uniforms.circleColor=[.7,.1,.4],pointData_1.point.mesh.zIndex=20001;var multiSelection_1=[];return circleUnder.value.lineIDs.forEach((function(d){var newSelection=_this.lineDict.lineValues.get(d).value;highlighLine(newSelection,[.7,.1,.4],10685014),multiSelection_1.push(newSelection)})),circleUnder.value.labels.forEach((function(label){label.text.zIndex=1000003,label.background.tint=10685014,label.background.zIndex=1000002,label.background.alpha=1})),this.selection={lines:multiSelection_1,root:pointData_1,multiSelect:!0,ID:new ComparableArray(circleUnder.id)},!0}var latLong=new Vector2(lat,long),newSelection=this.lineDict.getAllClosest(latLong,1e-4,.2,(function(min,d){return min.pointID===d.pointID}));if(newSelection.length<=0)return!1;if(this.selection&&!this.selection.multiSelect&&this.selection.ID.compare(newSelection))return!0;this.tryUnselect();var pointData=this.pointDict.pointValues[newSelection[0].pointID].value;return pointData.point.uniforms.circleColor=newSelection.length>1?[.7,.1,.4]:[.7,.1,.7],pointData.point.mesh.zIndex=20001,newSelection.forEach((function(line){newSelection.length>1?highlighLine(line,[.7,.1,.4],10685014):highlighLine(line,[.7,.1,.7],10685091)})),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){},WellboreLayer}(ModuleInterface);WellboreLayer.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n",WellboreLayer.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor;\n uniform bool visible;\n uniform bool enabled;\n\n void main() {\n if (!enabled) {\n if (type == 2.0) discard;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.025);\n return;\n }\n\n if (visible && type == 1.0) {\n if(mod(vCol.x, 0.1) > 0.05) discard;\n }\n\n if (!visible && type == 2.0) discard;\n\n float light = 0.8 + dot(vCol.zw, vec2(1.0, -1.0)) * 0.5;\n vec3 col = wellboreColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n",exports.ExplorationLayer=ExplorationLayer,exports.FaultlineModule=FaultlineModule,exports.FieldModule=FieldModule,exports.ModuleInterface=ModuleInterface,exports.OutlineModule=OutlineModule,exports.WellboreLayer=WellboreLayer,Object.defineProperty(exports,"__esModule",{value:!0})})); | ||
***************************************************************************** */function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}function log(text){var date,out="%cVIDEX-MAP%c "+text;console.log(out+" ("+((date=new Date).getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds())+")","\n background: #555;\n color: #eee;\n padding: 0 6px 0 6px;\n border-radius: 2px;\n ",null)}var FaultlineModule=function(_super){function FaultlineModule(config){var _this=_super.call(this)||this;return _this.spawned=[],_this.pool=[],_this.config={color:7503240,outlineWidth:.125},config?(config.color&&"number"==typeof config.color&&(_this.config.color=config.color),config.outlineWidth&&"number"==typeof config.outlineWidth&&(_this.config.outlineWidth=config.outlineWidth),_this):_this}return __extends(FaultlineModule,_super),FaultlineModule.prototype.set=function(data){var _this=this;this.clear();var project=this.pixiOverlay.utils.latLngToLayerPoint,lineCount=0;data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),_this.spawned.push(faultline);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new PIXI.Point(coord.x,coord.y)})),first=projected[0],last=projected[projected.length-1];if(Vector2.equals([first.x,first.y],[last.x,last.y],1e-6))faultline.beginFill(_this.config.color),faultline.lineStyle(_this.config.outlineWidth,_this.config.color),faultline.drawPolygon(projected),faultline.endFill();else{lineCount++,faultline.lineStyle(_this.config.outlineWidth,_this.config.color).moveTo(first.x,first.y);for(var i=1;i<projected.length;i++)faultline.lineTo(projected[i].x,projected[i].y)}})),lineCount>0&&log("Drawing "+lineCount+" faultline polygons as lines.")},FaultlineModule.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineModule}(ModuleInterface);function distanceToLine(point,lineStart,lineEnd){var lineDir=Vector2.sub(lineEnd,lineStart),lineAngle=Vector2.angleRight(lineDir),len=lineDir.magnitude,dir=Vector2.sub(point,lineStart).mutable.rotate(-lineAngle);return dir[0]<0?dir.magnitude:dir[0]>len?Vector2.distance(point,lineEnd):Math.abs(dir.y)}function removeDuplicates(points,epsilon){for(var reduced=[points[0]],prev=points[0],i=1;i<points.length;i++){var cur=points[i];Vector2.equals(cur,prev,epsilon)||(reduced.push(cur),prev=cur)}return reduced}function Intersection(p1,d1,p2,d2){var c=Vector2.sub(p1,p2),len=(c[0]*d2[1]-c[1]*d2[0])/(d1[1]*d2[0]-d1[0]*d2[1]);return d1.scale(len).mutable.add(p1).immutable}var Mesh=function(){function Mesh(){}return Mesh.Line=function(points,thickness,callback){void 0===thickness&&(thickness=1);var vertices=[],triangles=[],_thickness=.5*thickness,segment0=points[0],first=segment0.position,from0=Vector2.sub(points[1].position,first).rescale(_thickness),upper0=from0.rotate90().mutable.add(first).immutable,lower0=from0.rotate270().mutable.add(first).immutable;vertices.push(upper0.x,upper0.y,lower0.x,lower0.y),callback&&callback(segment0);for(var i=1;i<points.length-1;i++){var segment=points[i],prev=points[i-1].position,cur=segment.position,next=points[i+1].position,to=Vector2.sub(cur,prev),from=Vector2.sub(next,cur),upper=null,inner=null;if(Vector2.angleDeg(to,from)<90){var toU=to.rotate90().mutable.rescale(_thickness).add(prev).immutable,fromU=from.rotate90().mutable.rescale(_thickness).add(next).immutable,toI=to.rotate270().mutable.rescale(_thickness).add(prev).immutable,fromI=from.rotate270().mutable.rescale(_thickness).add(next).immutable;upper=Intersection(toU,to,fromU,from),inner=Intersection(toI,to,fromI,from)}else upper=segment.direction.rotate90().mutable.rescale(_thickness).add(cur).immutable,inner=segment.direction.rotate270().mutable.rescale(_thickness).add(cur).immutable;if(vertices.push(upper.x,upper.y,inner.x,inner.y),callback&&callback(segment),0!=i){var n_1=2*i;triangles.push(n_1-1,n_1-2,n_1,n_1-1,n_1,n_1+1)}}var segmentN=points[points.length-1],last=segmentN.position,toN=Vector2.sub(last,points[points.length-2].position).rescale(_thickness),upperN=Vector2.add(last,toN.rotate90()),lowerN=Vector2.add(last,toN.rotate270());vertices.push(upperN.x,upperN.y,lowerN.x,lowerN.y),callback&&callback(segmentN);var n=2*points.length-2;return triangles.push(n-1,n-2,n,n-1,n,n+1),{vertices:vertices,triangles:triangles}},Mesh.from=function(vertices,triangles,vertexShader,fragmentShader,uniforms,normals){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,2),normals&&geometry.addAttribute("inputNormals",normals,2),geometry.addIndex(triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniforms);return new PIXI.Mesh(geometry,shader)},Mesh.SimpleLine=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetNormal(index){if(0===index)return Vector2.sub(reduced[1],reduced[0]).mutable.rotate90().rescale(1);if(index===reduced.length-1)return Vector2.sub(reduced[reduced.length-1],reduced[reduced.length-2]).mutable.rotate90().rescale(1);var prev=reduced[index-1],cur=reduced[index],next=reduced[index+1];return Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1)}for(var prevUpperRight,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length-1;i++){var cur=reduced[i],next=reduced[i+1],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=GetNormal(i),rightNormal=GetNormal(i+1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh.Polygon=function(points){var vertices=videxLinearAlgebra.flatten(points);return{vertices:vertices,triangles:earcut(vertices)}},Mesh.PolygonOutline=function(points,thickness){void 0===thickness&&(thickness=1);var linethickness=.5*thickness,reduced=removeDuplicates(points,.001);function GetIndex(index){var r=index%reduced.length;return r<0&&(r+=reduced.length),r}for(var prevUpperRight,firstUpperLeft,firstDirN,vertices=[],triangles=[],normals=[],baseTris=0,i=0;i<reduced.length;i++){var prev=reduced[GetIndex(i-1)],cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],next2=reduced[GetIndex(i+2)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,leftNormal=Vector2.lerpRot(Vector2.sub(cur,prev),Vector2.sub(next,cur),.5).mutable.rotate90().rescale(1),rightNormal=Vector2.lerpRot(Vector2.sub(next,cur),Vector2.sub(next2,next),.5).mutable.rotate90().rescale(1),lowerLeft=Vector2.sub(cur,dirN),upperLeft=Vector2.add(cur,dirN),lowerRight=Vector2.sub(next,dirN),upperRight=Vector2.add(next,dirN);if(vertices.push(lowerLeft[0],lowerLeft[1],upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1],upperRight[0],upperRight[1]),normals.push(-leftNormal[0],-leftNormal[1],leftNormal[0],leftNormal[1],-rightNormal[0],-rightNormal[1],rightNormal[0],rightNormal[1]),triangles.push(baseTris,baseTris+1,baseTris+3,baseTris,baseTris+3,baseTris+2),0!==i){var toPrevUpper=Vector2.sub(prevUpperRight,upperLeft);Vector2.signedAngle(dirN,toPrevUpper)<0?triangles.push(baseTris,baseTris-2,baseTris+1):triangles.push(baseTris,baseTris-1,baseTris+1)}else firstUpperLeft=upperLeft,firstDirN=dirN;if(i===reduced.length-1){var toLastUpper=Vector2.sub(upperRight,firstUpperLeft);Vector2.signedAngle(firstDirN,toLastUpper)<0?triangles.push(0,baseTris-2,1):triangles.push(0,baseTris-1,1)}prevUpperRight=upperRight,baseTris+=4}return{vertices:vertices,triangles:triangles,normals:normals}},Mesh}(),OutlineModule=function(_super){function OutlineModule(config){var _this=_super.call(this)||this;return _this.outlineDict={},_this.spawned=[],_this.config={lineWidth:.125},config?(config.lineWidth&&"number"==typeof config.lineWidth&&(_this.config.lineWidth=config.lineWidth),_this):_this}return __extends(OutlineModule,_super),OutlineModule.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,width:0,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms;for(var coordinates=outlineCollection.coordinates,n=0;n<coordinates.length;n++){for(var polygon=coordinates[n],projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}var outlineData=void 0;if(Vector2.equals(projected[0],projected[projected.length-1],1e-6)){if(projected.pop(),projected.length<=2){log("Skipping outline (Polygon) with "+projected.length+" points.");continue}outlineData=Mesh.PolygonOutline(projected,_this.config.lineWidth)}else{if(projected.length<=1){log("Skipping outline (Line) with "+projected.length+" points.");continue}outlineData=Mesh.SimpleLine(projected,_this.config.lineWidth)}var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineModule.vertexShader,OutlineModule.fragmentShader,uniforms,outlineData.normals);_this.root.addChild(outline),_this.spawned.push(outline)}}))},OutlineModule.prototype.setVisibleLayers=function(names){var _this=this;Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].visible=!1})),names.forEach((function(name){var uniforms=_this.outlineDict[name];uniforms&&(uniforms.visible=!0)}))},OutlineModule.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineModule.prototype.resize=function(scale){var _this=this,clampedOutlineWidth=scale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0),Object.keys(this.outlineDict).forEach((function(key){return _this.outlineDict[key].width=clampedOutlineWidth}))},OutlineModule}(ModuleInterface);OutlineModule.vertexShader="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineModule.fragmentShader="\n precision mediump float;\n\n uniform vec3 color;\n uniform bool visible;\n\n void main() {\n if (!visible) discard;\n gl_FragColor = vec4(color, 1.0);\n }\n";var Hightlighter=function(){function Hightlighter(fillColor1,fillColor2,outlineColor){this.fields=[],this.cached=[],this.fillColor1=fillColor1,this.fillColor2=fillColor2,this.outlineColor=outlineColor}return Hightlighter.prototype.add=function(group){this.fields.push(group)},Hightlighter.prototype.highlight=function(index){var target=this.fields[index];this.cached&&this.revert(),this.cached=new Array(target.length);for(var i=0;i<target.length;i++){var field=target[i];this.cached[i]={fillCol1:field.fill.uniform.col1,fillCol2:field.fill.uniform.col2,outlineCol:field.outline.uniform.color,baseZIndex:field.fill.mesh.zIndex,field:field},field.fill.uniform.col1=this.fillColor1,field.fill.uniform.col2=this.fillColor2,field.fill.mesh.zIndex+=1e4,field.outline.uniform.color=this.outlineColor,field.outline.mesh.zIndex+=1e4}},Hightlighter.prototype.revert=function(){return!!this.cached&&(this.cached.forEach((function(d){d.field.fill.uniform.col1=d.fillCol1,d.field.fill.uniform.col2=d.fillCol2,d.field.fill.mesh.zIndex=d.baseZIndex,d.field.outline.uniform.color=d.outlineCol,d.field.outline.mesh.zIndex=d.baseZIndex+1})),this.cached=void 0,!0)},Hightlighter}();function recalculatePosition(labels,selfIndex,targetIndiced){var self=labels[selfIndex],comX=self.mass*self.position[0],comY=self.mass*self.position[1],totalMass=self.mass;return targetIndiced.forEach((function(idx){var target=labels[idx];comX+=target.mass*target.position[0],comY+=target.mass*target.position[1],totalMass+=target.mass})),[comX/totalMass,comY/totalMass]}var LabelManager=function(){function LabelManager(textStyle,baseScale){this.fields=[],this.multiFields=[],this.prevScale=1,this.visible=!0,this.textStyle=textStyle,this.baseScale=baseScale}return LabelManager.prototype.addField=function(name,entries){if(entries.length<=1)this.fields.push({name:name,position:entries[0].position,instance:null});else{var textMetrics=PIXI.TextMetrics.measureText(name,this.textStyle),width=textMetrics.width*this.baseScale,height=textMetrics.height*this.baseScale,labels=entries.map((function(entry){return{position:entry.position,mass:entry.mass,instance:null,active:!0,consumed:[],consumer:-1}}));this.multiFields.push({name:name,labels:labels,width:width,height:height})}},LabelManager.prototype.draw=function(root){var _this=this,drawLabel=function(name,position){var instance=new PIXI.Text(name,_this.textStyle);return instance.resolution=2,instance.position.set(position[0],position[1]),instance.scale.set(_this.baseScale),instance.anchor.set(.5),instance.zIndex=1e5,root.addChild(instance),instance};this.fields.forEach((function(field){field.instance=drawLabel(field.name,field.position)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance=drawLabel(field.name,label.position)}))}))},LabelManager.prototype.resize=function(scale){var _this=this;this.fields.forEach((function(field){field.instance.scale.set(scale*_this.baseScale)})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.scale.set(scale*_this.baseScale)}));for(var centers=function(field,scale){for(var labels=field.labels,groups=[],i=0;i<labels.length;i++)groups.push({index:i,consumed:[],consumer:-1});for(i=0;i<labels.length;i++){if(!((group=groups[i]).consumer>=0))for(var label=labels[i],_loop_1=function(j){var _a;if(i===j)return"continue";var a,b,dist,compLabel=labels[j];if(a=label,b=compLabel,dist=Vector2.sub(a.position,b.position),Math.abs(dist[0])<field.width*scale&&Math.abs(dist[1])<field.height*scale){var compIndex_1=j,compGroup=groups[j];if(compGroup.consumer>=0){if((compIndex_1=compGroup.consumer)===i)return"continue";compGroup=groups[compGroup.consumer]}return(_a=compGroup.consumed).push.apply(_a,__spreadArrays(group.consumed,[i])),group.consumed.forEach((function(d){return groups[d].consumer=compIndex_1})),group.consumed=[],group.consumer=compIndex_1,"break"}},j=0;j<labels.length;j++){if("break"===_loop_1(j))break}}var output=[];for(i=0;i<groups.length;i++){var group;(group=groups[i]).consumer>=0||output.push(recalculatePosition(labels,group.index,group.consumed))}return output}(field,scale),i=0;i<centers.length;i++){var label=field.labels[i],pos=centers[i];label.instance.visible=!0,label.instance.position.set(pos[0],pos[1])}for(i=centers.length;i<field.labels.length;i++){(label=field.labels[i]).instance.visible=!1}})),this.prevScale=scale},LabelManager.prototype.hideLabels=function(){this.fields.forEach((function(field){field.instance.visible=!1})),this.multiFields.forEach((function(field){field.labels.forEach((function(label){label.instance.visible=!1}))})),this.visible=!1},LabelManager.prototype.showLabels=function(){this.fields.forEach((function(field){field.instance.visible=!0})),this.visible=!0},LabelManager}();var TriangleDictionary=function(){function TriangleDictionary(decimals){void 0===decimals&&(decimals=0),this.tiles=new Map,this.triangles=[],this.polygonValues=[],this.resolution=Math.pow(10,decimals)}return TriangleDictionary.prototype.add=function(vertices,triangles,value){var v1,v2,v3,polygonID=this.polygonValues.length;this.polygonValues.push(value);for(var i=0;i<triangles.length;i+=3){var triangleID=this.triangles.length;v1=vertices[triangles[i]],v2=vertices[triangles[i+1]],v3=vertices[triangles[i+2]],this.triangles.push({v1:v1,v2:v2,v3:v3,polygonID:polygonID});for(var minX=Math.min(v1[0],v2[0],v3[0]),maxX=Math.max(v1[0],v2[0],v3[0]),minY=Math.min(v1[1],v2[1],v3[1]),maxY=Math.max(v1[1],v2[1],v3[1]),tileMinX=Math.floor(minX*this.resolution),tileMaxX=Math.floor(maxX*this.resolution),tileMinY=Math.floor(minY*this.resolution),tileMaxY=Math.floor(maxY*this.resolution),x=tileMinX;x<=tileMaxX;x++)for(var y=tileMinY;y<=tileMaxY;y++){var key=x+"."+y;this.tiles.has(key)?this.tiles.get(key).push(triangleID):this.tiles.set(key,[triangleID])}}},TriangleDictionary.prototype.getPolygonAt=function(target){var key=Math.floor(target[0]*this.resolution)+"."+Math.floor(target[1]*this.resolution);if(!this.tiles.has(key))return null;for(var p,v1,v2,v3,k1,k2,k3,triangles=this.tiles.get(key),i=0;i<triangles.length;i++){var triangle=this.triangles[triangles[i]];if(p=target,v1=triangle.v1,v2=triangle.v2,v3=triangle.v3,k1=void 0,k2=void 0,k3=void 0,k1=(p[0]-v1[0])*(v2[1]-v1[1])-(p[1]-v1[1])*(v2[0]-v1[0]),k2=(p[0]-v2[0])*(v3[1]-v2[1])-(p[1]-v2[1])*(v3[0]-v2[0]),k3=(p[0]-v3[0])*(v1[1]-v3[1])-(p[1]-v3[1])*(v1[0]-v3[0]),k1<0?k2<0&&k3<0:k2>=0&&k3>=0)return this.polygonValues[triangle.polygonID]}return null},TriangleDictionary}(),red=[.8,0,0],green=[.133,.6,.133],pink=[1,.753,.796],gray=[.6,.6,.6],outlineRed=[.6,0,0],outlineGray=[.5,.5,.5],FieldModule=function(_super){function FieldModule(config){var _this=_super.call(this)||this;return _this.fields=[],_this.config={initialHash:1,minHash:0,maxHash:1/0},_this.dict=new TriangleDictionary(1.2),_this.prevField=-1,config?(config.initialHash&&"number"==typeof config.initialHash&&(_this.config.initialHash=config.initialHash),config.minHash&&"number"==typeof config.minHash&&(_this.config.minHash=config.minHash),config.maxHash&&"number"==typeof config.maxHash&&(_this.config.maxHash=config.maxHash),_this):_this}return __extends(FieldModule,_super),FieldModule.prototype.set=function(data){var _this=this;this.config.initialHash=videxMath.clamp(this.config.initialHash),this.fields=[];var textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:64,fontWeight:"600",fill:4539717,align:"center"});this.labelManager=new LabelManager(textStyle,.029),this.highlighter=new Hightlighter([.5,0,.5],[.25,0,.25],[.35,0,.35]);var preprocessedData=function(data){var unique={};return data.forEach((function(field){var fieldName=field.properties.label,coordinates=[],geometry=field.geometry;if("Polygon"===geometry.type)coordinates=geometry.coordinates;else for(var multipolygons=geometry.coordinates,i=0;i<multipolygons.length;i++)coordinates.push.apply(coordinates,multipolygons[i]);function appendIndex(index){unique[fieldName].geometry.push({coordinates:coordinates[index],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}})}if(unique.hasOwnProperty(fieldName))for(i=0;i<coordinates.length;i++)appendIndex(i);else if(unique[fieldName]={type:field.type,geometry:[{coordinates:coordinates[0],properties:{discname:field.properties.discname,hctype:field.properties.hctype,polygonId:field.properties.polygonId,status:field.properties.status}}],properties:{group:field.properties.group,guid:field.properties.guid,label:field.properties.label,lat:field.properties.lat,long:field.properties.long}},coordinates.length>1)for(i=1;i<coordinates.length;i++)appendIndex(i)})),Object.values(unique)}(data),fieldID=0,baseZIndex=0;preprocessedData.forEach((function(field){var _a,name=field.properties.label;if("Troll"!==name){var guid=field.properties.guid,entries=[],meshes=[];field.geometry.forEach((function(polygon){var fieldStyle=_this.getFieldStyle(guid,polygon.properties.hctype),projected=_this.projectPolygons(polygon.coordinates);projected.pop();var meshData=Mesh.Polygon(projected);_this.dict.add(polygon.coordinates,meshData.triangles,fieldID);var outlineData=Mesh.PolygonOutline(projected,.15),_a=function(vertices,triangles){for(var comX=0,comY=0,totalMass=0,i=0;i<triangles.length;i+=3){var a=vertices[triangles[i]],b=vertices[triangles[i+1]],c=vertices[triangles[i+2]],ab=Vector2.sub(b,a),ac=Vector2.sub(c,a),mass=.5*Vector2.cross(ab,ac);comX+=mass*(a.x+b.x+c.x)/3,comY+=mass*(a.y+b.y+c.y)/3,totalMass+=mass}return[new Vector2(comX/totalMass,comY/totalMass),totalMass]}(projected,meshData.triangles),position=_a[0],mass=_a[1];meshes.push(_this.drawPolygons(meshData,outlineData,fieldStyle,baseZIndex)),baseZIndex+=2,entries.push({position:position,mass:mass})})),fieldID++,_this.labelManager.addField(name,entries),(_a=_this.fields).push.apply(_a,meshes),_this.highlighter.add(meshes)}})),this.labelManager.draw(this.root)},FieldModule.prototype.drawPolygons=function(meshData,outlineData,fieldStyle,zIndex){var fillUniform={col1:fieldStyle.fillColor1,col2:fieldStyle.fillColor2,opacity:fieldStyle.fillOpacity,hashed:fieldStyle.hashed,hashDisp:10*Math.random(),hashWidth:this.config.initialHash},outlineUniform={color:fieldStyle.outlineColor,width:0},polygonMesh=Mesh.from(meshData.vertices,meshData.triangles,FieldModule.vertexShaderFill,FieldModule.fragmentShaderFill,fillUniform);polygonMesh.zIndex=zIndex,this.root.addChild(polygonMesh);var polygonOutlineMesh=Mesh.from(outlineData.vertices,outlineData.triangles,FieldModule.vertexShaderOutline,FieldModule.fragmentShaderOutline,outlineUniform,outlineData.normals);return polygonOutlineMesh.zIndex=zIndex+1,this.root.addChild(polygonOutlineMesh),{fill:{mesh:polygonMesh,uniform:fillUniform},outline:{mesh:polygonOutlineMesh,uniform:outlineUniform}}},FieldModule.prototype.getFieldStyle=function(guid,hctype){if(!guid)return{fillColor1:gray,fillColor2:gray,outlineColor:outlineGray,fillOpacity:.15,hashed:!1};var fill={fillColor1:green,fillColor2:green,outlineColor:green,fillOpacity:.6,hashed:!1};switch(hctype){case"GAS":fill.fillColor1=red,fill.fillColor2=red,fill.outlineColor=outlineRed;break;case"GAS/CONDENSATE":fill.fillColor1=pink,fill.fillColor2=red,fill.outlineColor=outlineRed,fill.hashed=!0;break;case"OIL/GAS":fill.fillColor1=red,fill.hashed=!0}return fill},FieldModule.prototype.projectPolygons=function(points){var project=this.pixiOverlay.utils.latLngToLayerPoint;return points.map((function(c){var coord=project([c[1],c[0]]);return new Vector2(coord.x,coord.y)}))},FieldModule.prototype.resize=function(outlineScale,hashScale,labelScale){var clampedHashWidth=videxMath.clamp(hashScale,this.config.minHash,this.config.maxHash),clampedOutlineWidth=outlineScale-1;clampedOutlineWidth<0&&(clampedOutlineWidth=0);for(var i=0;i<this.fields.length;i++){var d=this.fields[i];d.fill.uniform.hashWidth=clampedHashWidth,d.outline.uniform.width=clampedOutlineWidth}labelScale>20?this.labelManager.visible&&this.labelManager.hideLabels():(this.labelManager.visible||this.labelManager.showLabels(),this.labelManager.resize(labelScale))},FieldModule.prototype.highlight=function(lat,long){var field=this.dict.getPolygonAt([long,lat]);return field?this.prevField===field||(this.highlighter.highlight(field),this.pixiOverlay.redraw(),this.prevField=field,!0):(this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1,!1)},FieldModule.prototype.tryUnselect=function(){this.highlighter.revert()&&this.pixiOverlay.redraw(),this.prevField=-1},FieldModule}(ModuleInterface);function generateCircle(center,radius){var geometry=new PIXI.Geometry;geometry.addAttribute("verts",[center[0]-radius,center[1]-radius,center[0]+radius,center[1]-radius,center[0]-radius,center[1]+radius,center[0]+radius,center[1]+radius],2),geometry.addAttribute("inputUVs",[0,0,1,0,0,1,1,1],2),geometry.addIndex([0,2,3,0,3,1]);var uniforms={circleColor:[.2,.2,.2]},shader=PIXI.Shader.from("\n attribute vec2 verts;\n attribute vec2 inputUVs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 UVs;\n\n void main() {\n UVs = inputUVs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n ","\n precision mediump float;\n\n varying vec2 UVs;\n\n uniform vec3 circleColor;\n\n void main() {\n vec2 dir = vec2(UVs.x - 0.5, UVs.y - 0.5) * 2.0;\n float dist = dir.x * dir.x + dir.y * dir.y;\n if (dist > 1.0) discard;\n\n float light = 0.8 + dot(dir, vec2(1.0, -1.0)) * 0.5;\n vec3 col = circleColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n ",uniforms);return{mesh:new PIXI.Mesh(geometry,shader),uniforms:uniforms}}FieldModule.vertexShaderFill="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec2 verts;\n\n void main() {\n verts = inputVerts;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform vec3 col1;\n uniform vec3 col2;\n uniform float opacity;\n\n uniform bool hashed;\n uniform float hashDisp;\n uniform float hashWidth;\n\n void main() {\n if(hashed && mod(verts.y + hashDisp, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(col2, 1.0) * opacity;\n }\n else {\n gl_FragColor = vec4(col1, 1.0) * opacity;\n }\n }\n",FieldModule.vertexShaderOutline="\n attribute vec2 inputVerts;\n attribute vec2 inputNormals;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n uniform float width;\n\n void main() {\n vec2 pos = inputVerts + inputNormals * width;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);\n }\n",FieldModule.fragmentShaderOutline="\n precision mediump float;\n\n uniform vec3 color;\n\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n";var PointDictionary=function(){function PointDictionary(distThreshold,decimals){void 0===decimals&&(decimals=0),this.distThreshold=distThreshold,this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.pointValues=[]}return PointDictionary.prototype.add=function(point,value){var pointID=this.pointValues.length;this.pointValues.push({value:value,position:point,id:pointID});var key=Math.floor(point[0]*this.resolution)+"."+Math.floor(point[1]*this.resolution);return this.tiles.has(key)?this.tiles.get(key).push(pointID):this.tiles.set(key,[pointID]),pointID},PointDictionary.prototype.getOverlapping=function(target){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID];if(Vector2.distance(target,point.position)<this.distThreshold)return point}}return null},PointDictionary.prototype.getClosestUnder=function(target,pointRadius){for(var keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),minDist=1/0,closest=null,x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);if(this.tiles.has(key))for(var pointsIDs=this.tiles.get(key),n=0;n<pointsIDs.length;n++){var pointID=pointsIDs[n],point=this.pointValues[pointID],distance=Vector2.distance(target,point.position);distance<pointRadius&&distance<minDist&&(minDist=distance,closest=point)}}return closest},PointDictionary}(),ExplorationLayer=function(_super){function ExplorationLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.pointDict=new PointDictionary(.25,-2),_this}return __extends(ExplorationLayer,_super),ExplorationLayer.prototype.appendExploration=function(scale){void 0===scale&&(scale=1);var project=this.pixiOverlay.utils.latLngToLayerPoint,targetScale=this.clampScale(scale);this.prevScale=targetScale;for(var i=0;i<null.length;i++){var projected=project([null[i].latitude,null[i].longitude]),pos=new Vector2(projected.x,projected.y),well=generateCircle(pos,.3);this.root.addChild(well.mesh),this.pointDict.add(pos,{mesh:well.mesh,uniforms:well.uniforms})}},ExplorationLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.05*scale;return targetScale>1&&(targetScale=1),targetScale},ExplorationLayer.prototype.highlight=function(lat,long){var project=this.pixiOverlay.utils.latLngToLayerPoint;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null);var _a=project([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y),circleUnder=this.pointDict.getClosestUnder(worldSpace,5*this.prevScale);if(circleUnder){var point=circleUnder.value;return this.selection={point:point,zIndex:point.mesh.zIndex},point.uniforms.circleColor=[.2,.6,.7],point.mesh.zIndex=1/0,!0}return!1},ExplorationLayer}(ModuleInterface);var LineInterpolator=function(){function LineInterpolator(points,radius){this.singlePoint=!0;var amount=points.length,path=new Array(amount),root=points[0];path[0]={point:root,distance:0,relative:0};for(var length=0,i=1;i<amount;i++){var point=points[i];length+=Vector2.distance(point,path[i-1].point),path[i]={point:point,distance:length,relative:0},Vector2.distance(point,root)>radius&&(this.singlePoint=!1)}for(i=1;i<amount;i++){var p=path[i];p.relative=0===length?0:p.distance/length}this.amount=amount,this.length=length,this.path=path}return LineInterpolator.prototype.GetPoint=function(relative){if(this.singlePoint)return{position:this.path[0].point,direction:Vector2.up,distance:0};if(relative<0)return{position:this.path[0].point,direction:this.GetDirection(0),distance:0};if(relative>=1)return{position:this.path[this.amount-1].point,direction:this.GetDirection(this.amount-1),distance:this.length};var base=this.GetClosestPointBelow(relative),prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relative-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);return{position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac}},LineInterpolator.prototype.GetSection=function(relativeStart,relativeEnd){if(this.singlePoint)return[{position:this.path[0].point,direction:Vector2.up,distance:0},{position:this.path[0].point,direction:Vector2.up,distance:0}];if(relativeStart>=1){var last=this.path.length-1;return[{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length},{position:this.path[last].point,direction:this.GetDirection(last),distance:this.length}]}var base=this.GetClosestPointBelow(relativeStart),points=[],prev=this.path[base],cur=this.path[base+1],dist=cur.relative-prev.relative,frac=(relativeStart-prev.relative)/dist,prevDir=this.GetDirection(base),curDir=this.GetDirection(base+1);points.push({position:videxLinearAlgebra.mix(prev.point,cur.point,frac,Vector2.zero),direction:Vector2.lerpRot(prevDir,curDir,frac).normalize(),distance:prev.distance*(1-frac)+cur.distance*frac});for(var i=base+1;i<this.amount;i++){var cur_1=this.path[i];if(cur_1.relative>=relativeEnd){var prev_1=this.path[i-1],dist_1=cur_1.relative-prev_1.relative,frac_1=(relativeEnd-prev_1.relative)/dist_1,prevDir_1=this.GetDirection(i-1),curDir_1=this.GetDirection(i);points.push({position:videxLinearAlgebra.mix(prev_1.point,cur_1.point,frac_1,Vector2.zero),direction:Vector2.lerpRot(prevDir_1,curDir_1,frac_1).normalize(),distance:prev_1.distance*(1-frac_1)+cur_1.distance*frac_1});break}points.push({position:cur_1.point,direction:this.GetDirection(i),distance:cur_1.distance})}return points},LineInterpolator.prototype.GetClosestPointBelow=function(relative){for(var base=0,range=this.amount,idx=Math.floor(range/2);range>1;)relative<this.path[idx].relative?(range=Math.floor(range/2),idx=base+Math.floor(range/2)):(base+=Math.floor(range/2),range=Math.ceil(range/2),idx=base+Math.floor(range/2));return base},LineInterpolator.prototype.GetPointFromStart=function(distance){var relative=distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetPointFromEnd=function(distance){var relative=1-distance/this.length;return videxMath.clamp(relative),this.GetPoint(relative)},LineInterpolator.prototype.GetRangeFromStart=function(relative,width,resolution){void 0===resolution&&(resolution=10);for(var relativeDisp=(relative+width/this.length-relative)/resolution,points=[],i=0;i<=resolution;i++)points.push(this.GetPoint(relative+relativeDisp*i));return points},LineInterpolator.prototype.GetDirection=function(idx){var end=this.amount-1;if(0===idx)return Vector2.sub(this.path[1].point,this.path[0].point).normalize();if(idx===end)return Vector2.sub(this.path[end].point,this.path[end-1].point).normalize();var cur=this.path[idx].point,to=Vector2.sub(cur,this.path[idx-1].point),from=Vector2.sub(this.path[idx+1].point,cur);return Vector2.lerpRot(to,from,.5).normalize()},LineInterpolator}(),ComparableArray=function(){function ComparableArray(a,sort,selector){if(void 0===sort&&(sort=!1),"number"!=typeof a){if(a.length<=0)throw"Array has no length.";for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(selector(temp))}sort&&tempNumbers.sort(),this.numbers=tempNumbers,this.selector=selector}else this.numbers=[a]}return ComparableArray.prototype.compare=function(a,sort){if(void 0===sort&&(sort=!0),"number"==typeof a&&(a=[a]),this.numbers.length!=a.length)return!1;for(var tempNumbers=[],i=0;i<a.length;i++){var temp=a[i];"number"==typeof temp?tempNumbers.push(temp):tempNumbers.push(this.selector(temp))}sort&&tempNumbers.sort();for(i=0;i<tempNumbers.length;i++)if(this.numbers[i]!==tempNumbers[i])return!1;return!0},ComparableArray.prototype.toString=function(){return"["+this.numbers.toString()+"]"},ComparableArray}(),WellboreMesh=function(){function WellboreMesh(interp,thickness){this.interp=interp,this.thickness=thickness,this.baseTris=0}return WellboreMesh.prototype.generate=function(intervals){var _this=this;void 0===intervals&&(intervals=[]);var vertices=[],triangles=[],vertexData=[],extraData=[];if(intervals.length<=0){var path=this.interp.GetSection(0,1);this.appendSegment(path,0,vertices,triangles,vertexData,extraData)}else if(intervals.length>0){var p_1=0;intervals.forEach((function(i){var path1=_this.interp.GetSection(p_1,i[0]);_this.appendSegment(path1,0,vertices,triangles,vertexData,extraData);var path2=_this.interp.GetSection(i[0],i[1]);_this.appendSegment(path2,1,vertices,triangles,vertexData,extraData),p_1=i[1]}));var end=intervals[intervals.length-1][1];if(end<1){var lastPath=this.interp.GetSection(end,1);this.appendSegment(lastPath,0,vertices,triangles,vertexData,extraData)}}return intervals.forEach((function(i){var p1=_this.interp.GetPoint(i[0]);if(_this.generateCrossline(_this.thickness,p1,vertices,triangles,vertexData,extraData),!(Math.abs(i[0]-i[1])<.001)){var p2=_this.interp.GetPoint(i[1]);_this.generateCrossline(_this.thickness,p2,vertices,triangles,vertexData,extraData)}})),{vertices:vertices,triangles:triangles,vertexData:vertexData,extraData:extraData}},WellboreMesh.prototype.appendSegment=function(section,type,vertices,triangles,vertexData,extraData){var _this=this,mesh=Mesh.Line(section,this.thickness,(function(point){var v1Norm=point.direction.rotate90().mutable;vertexData.push(point.distance,1,v1Norm[0],v1Norm[1]);var v2Norm=point.direction.rotate270();vertexData.push(point.distance,0,v2Norm[0],v2Norm[1]),extraData.push(type,type)}));vertices.push.apply(vertices,mesh.vertices),mesh.triangles.forEach((function(d){return triangles.push(d+_this.baseTris)})),this.baseTris+=mesh.vertices.length/2},WellboreMesh.prototype.generateCrossline=function(thickness,p,vertices,triangles,vertexData,extraData){var pos=p.position,dir=p.direction.rescale(.15*thickness),pNorm=dir.rotate90().mutable.rescale(1.5*thickness).immutable,ll=pos.sub(dir).mutable.sub(pNorm);vertices.push(ll.x,ll.y);var lr=ll.set(pos).add(dir).sub(pNorm);vertices.push(lr.x,lr.y);var ul=ll.set(pos).sub(dir).add(pNorm);vertices.push(ul.x,ul.y);var ur=ll.set(pos).add(dir).add(pNorm);vertices.push(ur.x,ur.y),triangles.push(this.baseTris,this.baseTris+2,this.baseTris+3,this.baseTris,this.baseTris+3,this.baseTris+1),extraData.push(2,2,2,2),vertexData.push(p.distance,0,0,0,p.distance,0,0,0,p.distance,1,0,0,p.distance,1,0,0),this.baseTris+=4},WellboreMesh}(),LineDictionary=function(){function LineDictionary(decimals){void 0===decimals&&(decimals=0),this.resolution=Math.pow(10,decimals),this.tiles=new Map,this.lineValues=new Map,this.lineSegments=[]}return LineDictionary.prototype.add=function(lineID,line,value){this.lineValues.set(lineID,{value:value,enabled:!0});for(var i=1;i<line.length;i++){var p1=line[i-1],p2=line[i],segmentID=this.lineSegments.length;this.lineSegments.push({lineID:lineID,geometry:{x1:p1[0],y1:p1[1],x2:p2[0],y2:p2[1]}}),this.addSegment(p1[0],p1[1],p2[0],p2[1],segmentID)}},LineDictionary.prototype.addSegment=function(x1,y1,x2,y2,segmentID){var downwards,xMin,xMax,yMin,yMax,m,y0,unique={};x1<x2?(xMin=Math.floor(x1*this.resolution),xMax=Math.floor(x2*this.resolution),m=(y2-y1)/(x2-x1),y0=this.resolution*(y1-x1*m),downwards=y2<y1,unique[key=Math.floor(x1*this.resolution)+"."+Math.floor(y1*this.resolution)]=!0):(xMin=Math.floor(x2*this.resolution),xMax=Math.floor(x1*this.resolution),m=(y1-y2)/(x1-x2),y0=this.resolution*(y2-x2*m),downwards=y1<y2,unique[key=Math.floor(x2*this.resolution)+"."+Math.floor(y2*this.resolution)]=!0);y1<y2?(yMin=Math.floor(y1*this.resolution),yMax=Math.floor(y2*this.resolution)):(yMin=Math.floor(y2*this.resolution),yMax=Math.floor(y1*this.resolution));for(var x=xMin+1;x<=xMax;x++){var y=y0+x*m;unique[x+"."+Math.floor(y)]=!0}for(y=yMin+1;y<=yMax;y++){x=(y-y0)/m;unique[Math.floor(x)+"."+Math.floor(downwards?y-1:y)]=!0}for(var _i=0,_a=Object.keys(unique);_i<_a.length;_i++){var key=_a[_i];this.tiles.has(key)?this.tiles.get(key).push(segmentID):this.tiles.set(key,[segmentID])}},LineDictionary.prototype.getClosest=function(target,maxDist){var _this=this;void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0!==segments.length){var minDist=1/0,minLineID=-1;if(segments.forEach((function(d){var seg=_this.lineSegments[d],dist=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));dist<minDist&&(minDist=dist,minLineID=seg.lineID)})),!(minDist>maxDist/this.resolution))return this.lineValues.get(minLineID).value}},LineDictionary.prototype.getAllClosest=function(target,epsilon,maxDist,filter){var _a,_this=this;void 0===epsilon&&(epsilon=0),void 0===maxDist&&(maxDist=1);var segments=this.getSegmentsOn3Grid(target);if(0===segments.length)return[];var minDist=1/0,minID=-1,extraLines=[];if(segments.forEach((function(d){var seg=_this.lineSegments[d],distance=distanceToLine(target,new Vector2(seg.geometry.x1,seg.geometry.y1),new Vector2(seg.geometry.x2,seg.geometry.y2));if(distance<minDist+epsilon)if(distance<minDist){var upperLimit_1=distance+epsilon,newLines_1=[];minDist<=upperLimit_1&&newLines_1.push({ID:minID,distance:minDist}),extraLines.forEach((function(d){d.distance<=upperLimit_1&&newLines_1.push(d)})),extraLines=newLines_1,minDist=distance,minID=seg.lineID}else extraLines.push({ID:seg.lineID,distance:distance})})),minDist>maxDist/this.resolution)return[];var unique=((_a={})[minID]=!0,_a),uniqueLines=[];extraLines.forEach((function(d){unique.hasOwnProperty(d.ID)||(unique[d.ID]=!0,uniqueLines.push(d))}));var minT=this.lineValues.get(minID).value,extraT=uniqueLines.map((function(d){return _this.lineValues.get(d.ID).value}));if(filter){var filtered_1=[];extraT.forEach((function(curT){filter(minT,curT)&&filtered_1.push(curT)})),extraT=filtered_1}return __spreadArrays([minT],extraT)},LineDictionary.prototype.getSegmentsOn3Grid=function(target){for(var _this=this,unique={},lines=[],keyX=Math.floor(target[0]*this.resolution),keyY=Math.floor(target[1]*this.resolution),x=-1;x<=1;x++)for(var y=-1;y<=1;y++){var key=keyX+x+"."+(keyY+y);this.tiles.has(key)&&this.tiles.get(key).forEach((function(val){if(!unique.hasOwnProperty(val)){var lineID=_this.lineSegments[val].lineID;_this.lineValues.get(lineID).enabled&&lines.push(val),unique[val]=!0}}))}return lines},LineDictionary}();function generateBackground(width,height){var background=new PIXI.Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-.04,.5*-height-.01,width+.08,height+.02),background.pivot.set(0,.5*-height),background.alpha=.75,background.tint=0,background}var WellboreLayer=function(_super){function WellboreLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.lineDict=new LineDictionary(2.5),_this.circleRadius=.4,_this.pointDict=new PointDictionary(.25,-1.5),_this.selection=null,_this}return __extends(WellboreLayer,_super),WellboreLayer.prototype.appendWellbores=function(wells){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint,zINdex=0,textStyle=new PIXI.TextStyle({fontFamily:"Arial",fontSize:24,fill:16777215,align:"center"}),drawWell=function(well){var longLat=well.coordinates.map((function(coord){return new Vector2(coord[1],coord[0])})),points=well.coordinates.map((function(coord){var p=project([coord[1],coord[0]]);return new Vector2(p.x,p.y)})),intervals=well.intervals.map((function(i){return[i.l1,i.l2]})).sort((function(a,b){return a[0]<b[0]?-1:a[0]>b[0]?1:0}));intervals.length>0&&(intervals=function(intervals){for(var output=[],prev=intervals[0].slice(0),i=1;i<intervals.length;i++){var cur=intervals[i].slice(0);cur[0]<prev[1]?cur[1]>prev[1]&&(prev[1]=cur[1]):(output.push(prev),prev=cur)}return output.push(prev),output}(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=function(wellLabel,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height;return label.scale.set(.011),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}(well.label,textStyle);var verticalIndex=0;if(overlapping=_this.pointDict.getOverlapping(first))first=overlapping.position,verticalIndex=overlapping.value.labels.length,overlapping.value.labels.push(label);else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),_this.pointDict.add(first,{lineIDs:[],point:circle,labels:[label]});var labelPosition=Vector2.up.mutable.scale(_this.circleRadius+.05+.35*verticalIndex).add(first).immutable;label.text.position.set(labelPosition[0],labelPosition[1]),label.text.zIndex=1000001,_this.root.addChild(label.text),label.background.position.set(labelPosition[0],labelPosition[1]),label.background.zIndex=1e6,_this.root.addChild(label.background)}else{var _a=new WellboreMesh(interp,.15).generate(intervals),vertices=_a.vertices,triangles=_a.triangles,vertexData=_a.vertexData,extraData=_a.extraData,geometry=new PIXI.Geometry;geometry.addAttribute("verts",vertices,2),geometry.addAttribute("vertCol",vertexData,4),geometry.addAttribute("typeData",extraData,1),geometry.addIndex(triangles);var label,uniforms={wellboreColor:[.2,.2,.2],visible:!0,enabled:!0},lineShader=PIXI.Shader.from(WellboreLayer.vertexShader,WellboreLayer.fragmentShader,uniforms),lineMesh=new PIXI.Mesh(geometry,lineShader);lineMesh.zIndex=zINdex++,_this.root.addChild(lineMesh),(label=function(wellLabel,interp,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=.011*textMetrics.width,height=.011*textMetrics.height,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(.011);var targetPos,background=generateBackground(width,height);return dir.x<0?(label.anchor.set(0,0),background.pivot.set(.5*width,.5*height),background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.left,dir),targetPos=dir.rotate270().mutable.rescale(.1).add(end.position)):(label.anchor.set(1,0),background.pivot.x=.5*width,background.rotation=Vector2.signedAngle(Vector2.right,dir),label.rotation=Vector2.signedAngle(Vector2.right,dir),targetPos=dir.rotate90().mutable.rescale(.1).add(end.position)),label.position.set(targetPos[0],targetPos[1]),background.position.set(targetPos[0],targetPos[1]),{text:label,background:background}}(well.label,interp,textStyle)).text.zIndex=1000001,_this.root.addChild(label.text),label.background.zIndex=1e6,_this.root.addChild(label.background);var callback={line:lineMesh,label:label,uniforms:uniforms,data:well,zIndex:lineMesh.zIndex,pointID:-1};_this.lineDict.add(well.id,longLat,callback);var overlapping,circle,first=points[0];if(overlapping=_this.pointDict.getOverlapping(first))overlapping.value.lineIDs.push(well.id),callback.pointID=overlapping.id;else(circle=generateCircle(first,_this.circleRadius)).mesh.zIndex=2e4,_this.root.addChild(circle.mesh),callback.pointID=_this.pointDict.add(first,{lineIDs:[well.id],point:circle,labels:[]})}};wells.forEach((function(well){return drawWell(well)}))},WellboreLayer.prototype.clampScale=function(scale){scale<1&&(scale=1);var targetScale=.06*scale;return targetScale>1&&(targetScale=1),targetScale},WellboreLayer.prototype.showIntersection=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.uniforms.visible=visible}))},WellboreLayer.prototype.showLabels=function(visible){void 0===visible&&(visible=!0),this.lineDict.lineValues.forEach((function(d){d.value.label.text.visible=visible}))},WellboreLayer.prototype.get=function(filter){if(void 0===filter&&(filter=null),!filter){var output_1=[];return this.lineDict.lineValues.forEach((function(d){return output_1.push(d.value)})),output_1}var output=[];return this.lineDict.lineValues.forEach((function(d){filter(d.value.data)&&output.push(d.value)})),output},WellboreLayer.prototype.enableWellbores=function(filter){this.lineDict.lineValues.forEach((function(v,k){filter(v.value.data)?(v.value.uniforms.enabled=!0,v.value.label.text.alpha=1,v.value.label.background.alpha=1,v.enabled=!0):(v.value.uniforms.enabled=!1,v.value.label.text.alpha=0,v.value.label.background.alpha=0,v.enabled=!1)}))},WellboreLayer.prototype.tryUnselect=function(){if(null!=this.selection){this.selection.lines.forEach((function(sel){sel.uniforms.wellboreColor=[.2,.2,.2],sel.line.zIndex=sel.zIndex,sel.label.background.tint=0,sel.label.text.zIndex=1000001,sel.label.background.zIndex=1e6,sel.label.background.alpha=.7}));var root=this.selection.root;return root&&(root.point.uniforms.circleColor=[.2,.2,.2],root.point.mesh.zIndex=2e4,root.labels.forEach((function(label){label.background.tint=0,label.text.zIndex=1000001,label.background.zIndex=1e6,label.background.alpha=.7}))),this.selection=null,!0}return!1},WellboreLayer.prototype.highlight=function(lat,long){var _this=this,_a=(0,this.pixiOverlay.utils.latLngToLayerPoint)([lat,long]),x=_a.x,y=_a.y,worldSpace=new Vector2(x,y);function highlighLine(line,wellboreColor,labelBg){line.uniforms.wellboreColor=wellboreColor,line.label.background.tint=labelBg,line.label.background.zIndex=1000002,line.label.background.alpha=1,line.label.text.zIndex=1000003,line.line.zIndex=1e4}var circleUnder=this.pointDict.getClosestUnder(worldSpace,this.circleRadius);if(circleUnder){if(this.selection&&this.selection.multiSelect&&this.selection.ID.compare(circleUnder.id))return!0;this.tryUnselect();var pointData_1=circleUnder.value;pointData_1.point.uniforms.circleColor=[.7,.1,.4],pointData_1.point.mesh.zIndex=20001;var multiSelection_1=[];return circleUnder.value.lineIDs.forEach((function(d){var newSelection=_this.lineDict.lineValues.get(d).value;highlighLine(newSelection,[.7,.1,.4],10685014),multiSelection_1.push(newSelection)})),circleUnder.value.labels.forEach((function(label){label.text.zIndex=1000003,label.background.tint=10685014,label.background.zIndex=1000002,label.background.alpha=1})),this.selection={lines:multiSelection_1,root:pointData_1,multiSelect:!0,ID:new ComparableArray(circleUnder.id)},!0}var latLong=new Vector2(lat,long),newSelection=this.lineDict.getAllClosest(latLong,1e-4,.2,(function(min,d){return min.pointID===d.pointID}));if(newSelection.length<=0)return!1;if(this.selection&&!this.selection.multiSelect&&this.selection.ID.compare(newSelection))return!0;this.tryUnselect();var pointData=this.pointDict.pointValues[newSelection[0].pointID].value;return pointData.point.uniforms.circleColor=newSelection.length>1?[.7,.1,.4]:[.7,.1,.7],pointData.point.mesh.zIndex=20001,newSelection.forEach((function(line){newSelection.length>1?highlighLine(line,[.7,.1,.4],10685014):highlighLine(line,[.7,.1,.7],10685091)})),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){},WellboreLayer}(ModuleInterface);WellboreLayer.vertexShader="\n attribute vec2 verts;\n attribute vec4 vertCol;\n attribute float typeData;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n varying vec4 vCol;\n varying float type;\n\n void main() {\n vCol = vertCol;\n type = typeData;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(verts, 1.0)).xy, 0.0, 1.0);\n }\n",WellboreLayer.fragmentShader="\n precision mediump float;\n\n varying vec4 vCol;\n varying float type;\n\n uniform vec3 wellboreColor;\n uniform bool visible;\n uniform bool enabled;\n\n void main() {\n if (!enabled) {\n if (type == 2.0) discard;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.025);\n return;\n }\n\n if (visible && type == 1.0) {\n if(mod(vCol.x, 0.1) > 0.05) discard;\n }\n\n if (!visible && type == 2.0) discard;\n\n float light = 0.8 + dot(vCol.zw, vec2(1.0, -1.0)) * 0.5;\n vec3 col = wellboreColor * light;\n\n gl_FragColor = vec4(col, 1.0);\n }\n",exports.ExplorationLayer=ExplorationLayer,exports.FaultlineModule=FaultlineModule,exports.FieldModule=FieldModule,exports.ModuleInterface=ModuleInterface,exports.OutlineModule=OutlineModule,exports.WellboreLayer=WellboreLayer,Object.defineProperty(exports,"__esModule",{value:!0})})); |
{ | ||
"name": "@equinor/videx-map", | ||
"version": "1.1.14", | ||
"version": "1.1.15", | ||
"description": "Component for Pixi-overlay in Leaflet.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
199682