@equinor/videx-map
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -32,2 +32,6 @@ import * as PIXI from 'pixi.js'; | ||
lineWidth: number; | ||
/** | ||
* Set collection of faultlines to display. Clears previous content on execution. | ||
* @param data Faultlines to draw | ||
*/ | ||
set(data: FaultlineData[]): void; | ||
@@ -34,0 +38,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import{Container,Graphics,Point,Geometry,Shader,Mesh as Mesh$1,Text,TextMetrics,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 MultiLayer=function(){function MultiLayer(L,map){var _this=this,root=new Container;root.sortableChildren=!0;var pixiOverlay=L.pixiOverlay((function(utils){var zoom=map.getZoom(),container=utils.getContainer(),renderer=utils.getRenderer();_this.prevZoom!==zoom&&(_this.onZoom&&_this.onZoom(zoom),_this.prevZoom=zoom),renderer.render(container)}),root);pixiOverlay.addTo(map),this.L=L,this.map=map,this.pixiOverlay=pixiOverlay,this.root=root}return MultiLayer.prototype.addLayer=function(Class){var layer=new Class(this.L,this.map,!0);return layer.pixiOverlay=this.pixiOverlay,this.root.addChild(layer.root),layer},MultiLayer.prototype.redraw=function(){this.pixiOverlay.redraw()},MultiLayer}(),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)}; | ||
import{Container,Graphics,Point,Geometry,Shader,Mesh as Mesh$1,Text,TextMetrics,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 MultiLayer=function(){function MultiLayer(L,map,options){var _this=this,root=new Container;root.sortableChildren=!0;var pixiOverlay=L.pixiOverlay((function(utils){var zoom=map.getZoom(),container=utils.getContainer(),renderer=utils.getRenderer();_this.prevZoom!==zoom&&(_this.onZoom&&_this.onZoom(zoom),_this.prevZoom=zoom),renderer.render(container)}),root,options);pixiOverlay.addTo(map),this.L=L,this.map=map,this.pixiOverlay=pixiOverlay,this.root=root}return MultiLayer.prototype.addLayer=function(Class){var layer=new Class(this.L,this.map,!0);return layer.pixiOverlay=this.pixiOverlay,this.root.addChild(layer.root),layer},MultiLayer.prototype.redraw=function(){this.pixiOverlay.redraw()},MultiLayer}(),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)}; | ||
/*! ***************************************************************************** | ||
@@ -3,0 +3,0 @@ Copyright (c) Microsoft Corporation. All rights reserved. |
@@ -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"),MultiLayer=function(){function MultiLayer(L,map){var _this=this,root=new PIXI.Container;root.sortableChildren=!0;var pixiOverlay=L.pixiOverlay((function(utils){var zoom=map.getZoom(),container=utils.getContainer(),renderer=utils.getRenderer();_this.prevZoom!==zoom&&(_this.onZoom&&_this.onZoom(zoom),_this.prevZoom=zoom),renderer.render(container)}),root);pixiOverlay.addTo(map),this.L=L,this.map=map,this.pixiOverlay=pixiOverlay,this.root=root}return MultiLayer.prototype.addLayer=function(Class){var layer=new Class(this.L,this.map,!0);return layer.pixiOverlay=this.pixiOverlay,this.root.addChild(layer.root),layer},MultiLayer.prototype.redraw=function(){this.pixiOverlay.redraw()},MultiLayer}(),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}var MapLayerInterface=function(){function MapLayerInterface(L,map,multilayer){void 0===multilayer&&(multilayer=!1),this.visibility=!0;var root=new PIXI.Container;if(root.sortableChildren=!0,!multilayer){var pixiOverlay=L.pixiOverlay((function(utils){var container=utils.getContainer();utils.getRenderer().render(container)}),root);pixiOverlay.addTo(map),this.pixiOverlay=pixiOverlay}this.map=map,this.root=root}return MapLayerInterface.prototype.redraw=function(){this.pixiOverlay.redraw()},MapLayerInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},MapLayerInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},MapLayerInterface}(),FaultlineLayer=function(_super){function FaultlineLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.spawned=[],_this.pool=[],_this.lineWidth=.125,_this}return __extends(FaultlineLayer,_super),FaultlineLayer.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),faultline.beginFill(7503240),faultline.lineStyle(_this.lineWidth,7503240);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new PIXI.Point(coord.x,coord.y)}));faultline.drawPolygon(projected),faultline.endFill(),_this.spawned.push(faultline)}))},FaultlineLayer.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineLayer}(MapLayerInterface);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){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,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);for(var prevUpperRight,linethickness=.5*thickness,reduced=removeDuplicates(points,.001),vertices=[],triangles=[],UVs=[],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,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]),UVs.push(0,1,0,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,UVs:UVs}},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=[],UVs=[],baseTris=0,i=0;i<reduced.length;i++){var cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,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]),UVs.push(0,1,0,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,UVs:UVs}},Mesh}(),OutlineLayer=function(_super){function OutlineLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.outlineDict={},_this.spawned=[],_this.lineWidth=.125,_this}return __extends(OutlineLayer,_super),OutlineLayer.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms,outlineCollection.coordinates.forEach((function(polygon){for(var outlineData,projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}Vector2.equals(projected[0],projected[projected.length-1],1e-6)?(projected.pop(),outlineData=Mesh.PolygonOutline(projected,_this.lineWidth)):outlineData=Mesh.SimpleLine(projected,_this.lineWidth);var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineLayer.vertexShader,OutlineLayer.fragmentShader,uniforms);_this.root.addChild(outline),_this.spawned.push(outline)}))}))},OutlineLayer.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)}))},OutlineLayer.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineLayer}(MapLayerInterface);OutlineLayer.vertexShader="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n void main() {\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineLayer.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 FieldLayer=function(_super){function FieldLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.fields=[],_this.settings={initialScale:1,minScale:0,maxScale:1/0},_this}return __extends(FieldLayer,_super),FieldLayer.prototype.appendFields=function(data){var _this=this;data.forEach((function(field){if("Troll"!==field.properties.label){field.properties.guid;var geometry=field.geometry;"Polygon"===geometry.type?_this.drawPolygons(geometry.coordinates):_this.drawMultiPolygons(geometry.coordinates)}}))},FieldLayer.prototype.drawMultiPolygons=function(multiPolygons){var _this=this;multiPolygons.forEach((function(polygons){_this.drawPolygons(polygons)}))},FieldLayer.prototype.drawPolygons=function(polygons){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;polygons.forEach((function(d){var points=d.map((function(p){var coord=project([p[1],p[0]]);return new Vector2(coord.x,coord.y)})),meshData=Mesh.Polygon(points),outlineData=Mesh.PolygonOutline(points,.25),fillUniform={hashWidth:_this.clampScale(_this.settings.initialScale)},polygonOutlineMesh=_this.createMesh(meshData,FieldLayer.vertexShaderFill,FieldLayer.fragmentShaderFill,fillUniform);_this.root.addChild(polygonOutlineMesh);var polygonMesh=_this.createMesh(outlineData,FieldLayer.vertexShaderOutline,FieldLayer.fragmentShaderOutline);_this.root.addChild(polygonMesh),_this.fields.push({fill:polygonMesh,outline:polygonOutlineMesh,fillUniform:fillUniform})}))},FieldLayer.prototype.createMesh=function(data,vertexShader,fragmentShader,uniform){void 0===uniform&&(uniform=null);var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",data.vertices,2),geometry.addIndex(data.triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniform);return new PIXI.Mesh(geometry,shader)},FieldLayer.prototype.clampScale=function(scale){var newScale=scale;return newScale<this.settings.minScale&&(newScale=this.settings.minScale),newScale>this.settings.maxScale&&(newScale=this.settings.maxScale),newScale},FieldLayer.prototype.resize=function(scale){scale=this.clampScale(scale),this.fields.forEach((function(field){field.fillUniform.hashWidth=scale}))},FieldLayer}(MapLayerInterface);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}}FieldLayer.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",FieldLayer.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform float hashWidth;\n\n void main() {\n if(mod(verts.y, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(1.0, 0.2, 0.3, 1.0);\n }\n else {\n gl_FragColor = vec4(1.0, 0.2, 0.3, 1.0);\n // gl_FragColor = vec4(0.2, 1.0, 0.3, 1.0);\n }\n }\n",FieldLayer.vertexShaderOutline="\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",FieldLayer.fragmentShaderOutline="\n precision mediump float;\n\n varying vec2 verts;\n\n void main() {\n gl_FragColor = vec4(0.3, 0.05, 0.05, 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}(),sample=null,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<sample.length;i++){var projected=project([sample[i].latitude,sample[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})}console.log(this.pointDict.tiles)},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 unselected=!1;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null,unselected=!0);var _a=this.pixiOverlay.utils.latLngToLayerPoint([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,this.redraw(),!0}return unselected&&this.redraw(),!1},ExplorationLayer}(MapLayerInterface);function compressInterval(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}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}(),labelScale=.011,bgMargin=.01;function generateLabel(wellLabel,interp,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=textMetrics.width*labelScale,height=textMetrics.height*labelScale,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(labelScale);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}}function generatePointLabel(wellLabel,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=textMetrics.width*labelScale,height=textMetrics.height*labelScale;return label.scale.set(labelScale),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}function generateBackground(width,height){var background=new PIXI.Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-4*bgMargin,.5*-height-bgMargin,width+8*bgMargin,height+2*bgMargin),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"});wells.forEach((function(well){return 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=compressInterval(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=generatePointLabel(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=generateLabel(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:[]})}}(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=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.redraw(),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 this.tryUnselect()&&this.redraw(),!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.redraw(),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){this.tryUnselect()&&this.redraw()},WellboreLayer}(MapLayerInterface);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.FaultlineLayer=FaultlineLayer,exports.FieldLayer=FieldLayer,exports.MultiLayer=MultiLayer,exports.OutlineLayer=OutlineLayer,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"),MultiLayer=function(){function MultiLayer(L,map,options){var _this=this,root=new PIXI.Container;root.sortableChildren=!0;var pixiOverlay=L.pixiOverlay((function(utils){var zoom=map.getZoom(),container=utils.getContainer(),renderer=utils.getRenderer();_this.prevZoom!==zoom&&(_this.onZoom&&_this.onZoom(zoom),_this.prevZoom=zoom),renderer.render(container)}),root,options);pixiOverlay.addTo(map),this.L=L,this.map=map,this.pixiOverlay=pixiOverlay,this.root=root}return MultiLayer.prototype.addLayer=function(Class){var layer=new Class(this.L,this.map,!0);return layer.pixiOverlay=this.pixiOverlay,this.root.addChild(layer.root),layer},MultiLayer.prototype.redraw=function(){this.pixiOverlay.redraw()},MultiLayer}(),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}var MapLayerInterface=function(){function MapLayerInterface(L,map,multilayer){void 0===multilayer&&(multilayer=!1),this.visibility=!0;var root=new PIXI.Container;if(root.sortableChildren=!0,!multilayer){var pixiOverlay=L.pixiOverlay((function(utils){var container=utils.getContainer();utils.getRenderer().render(container)}),root);pixiOverlay.addTo(map),this.pixiOverlay=pixiOverlay}this.map=map,this.root=root}return MapLayerInterface.prototype.redraw=function(){this.pixiOverlay.redraw()},MapLayerInterface.prototype.toggle=function(){this.root.visible=!this.root.visible},MapLayerInterface.prototype.setVisibility=function(visible){return visible!=this.visibility&&(this.root.visible=visible,this.visibility=visible,!0)},MapLayerInterface}(),FaultlineLayer=function(_super){function FaultlineLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.spawned=[],_this.pool=[],_this.lineWidth=.125,_this}return __extends(FaultlineLayer,_super),FaultlineLayer.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(d){var faultline;_this.pool.length>0?faultline=_this.pool.pop():(faultline=new PIXI.Graphics,_this.root.addChild(faultline)),faultline.beginFill(7503240),faultline.lineStyle(_this.lineWidth,7503240);var projected=d.coordinates.map((function(p){var coord=project([p[1],p[0]]);return new PIXI.Point(coord.x,coord.y)}));faultline.drawPolygon(projected),faultline.endFill(),_this.spawned.push(faultline)}))},FaultlineLayer.prototype.clear=function(){for(;this.spawned.length>0;){var temp=this.spawned.pop();temp.clear(),this.pool.push(temp)}},FaultlineLayer}(MapLayerInterface);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){var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",vertices,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);for(var prevUpperRight,linethickness=.5*thickness,reduced=removeDuplicates(points,.001),vertices=[],triangles=[],UVs=[],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,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]),UVs.push(0,1,0,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,UVs:UVs}},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=[],UVs=[],baseTris=0,i=0;i<reduced.length;i++){var cur=reduced[GetIndex(i)],next=reduced[GetIndex(i+1)],dirN=Vector2.sub(next,cur).rotate90().mutable.rescale(linethickness).immutable,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]),UVs.push(0,1,0,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,UVs:UVs}},Mesh}(),OutlineLayer=function(_super){function OutlineLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.outlineDict={},_this.spawned=[],_this.lineWidth=.125,_this}return __extends(OutlineLayer,_super),OutlineLayer.prototype.set=function(data){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;this.clear(),data.forEach((function(outlineCollection){var uniforms={color:outlineCollection.meta.stroke,visible:!0};_this.outlineDict[outlineCollection.meta.name]=uniforms,outlineCollection.coordinates.forEach((function(polygon){for(var outlineData,projected=[],i=0;i<polygon.length;i++){var p=polygon[i],pos=project([p[1],p[0]]);projected.push([pos.x,pos.y])}Vector2.equals(projected[0],projected[projected.length-1],1e-6)?(projected.pop(),outlineData=Mesh.PolygonOutline(projected,_this.lineWidth)):outlineData=Mesh.SimpleLine(projected,_this.lineWidth);var outline=Mesh.from(outlineData.vertices,outlineData.triangles,OutlineLayer.vertexShader,OutlineLayer.fragmentShader,uniforms);_this.root.addChild(outline),_this.spawned.push(outline)}))}))},OutlineLayer.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)}))},OutlineLayer.prototype.clear=function(){for(;this.spawned.length>0;){this.spawned.pop().destroy()}this.outlineDict={}},OutlineLayer}(MapLayerInterface);OutlineLayer.vertexShader="\n attribute vec2 inputVerts;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n\n void main() {\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(inputVerts, 1.0)).xy, 0.0, 1.0);\n }\n",OutlineLayer.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 FieldLayer=function(_super){function FieldLayer(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.fields=[],_this.settings={initialScale:1,minScale:0,maxScale:1/0},_this}return __extends(FieldLayer,_super),FieldLayer.prototype.appendFields=function(data){var _this=this;data.forEach((function(field){if("Troll"!==field.properties.label){field.properties.guid;var geometry=field.geometry;"Polygon"===geometry.type?_this.drawPolygons(geometry.coordinates):_this.drawMultiPolygons(geometry.coordinates)}}))},FieldLayer.prototype.drawMultiPolygons=function(multiPolygons){var _this=this;multiPolygons.forEach((function(polygons){_this.drawPolygons(polygons)}))},FieldLayer.prototype.drawPolygons=function(polygons){var _this=this,project=this.pixiOverlay.utils.latLngToLayerPoint;polygons.forEach((function(d){var points=d.map((function(p){var coord=project([p[1],p[0]]);return new Vector2(coord.x,coord.y)})),meshData=Mesh.Polygon(points),outlineData=Mesh.PolygonOutline(points,.25),fillUniform={hashWidth:_this.clampScale(_this.settings.initialScale)},polygonOutlineMesh=_this.createMesh(meshData,FieldLayer.vertexShaderFill,FieldLayer.fragmentShaderFill,fillUniform);_this.root.addChild(polygonOutlineMesh);var polygonMesh=_this.createMesh(outlineData,FieldLayer.vertexShaderOutline,FieldLayer.fragmentShaderOutline);_this.root.addChild(polygonMesh),_this.fields.push({fill:polygonMesh,outline:polygonOutlineMesh,fillUniform:fillUniform})}))},FieldLayer.prototype.createMesh=function(data,vertexShader,fragmentShader,uniform){void 0===uniform&&(uniform=null);var geometry=new PIXI.Geometry;geometry.addAttribute("inputVerts",data.vertices,2),geometry.addIndex(data.triangles);var shader=PIXI.Shader.from(vertexShader,fragmentShader,uniform);return new PIXI.Mesh(geometry,shader)},FieldLayer.prototype.clampScale=function(scale){var newScale=scale;return newScale<this.settings.minScale&&(newScale=this.settings.minScale),newScale>this.settings.maxScale&&(newScale=this.settings.maxScale),newScale},FieldLayer.prototype.resize=function(scale){scale=this.clampScale(scale),this.fields.forEach((function(field){field.fillUniform.hashWidth=scale}))},FieldLayer}(MapLayerInterface);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}}FieldLayer.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",FieldLayer.fragmentShaderFill="\n precision mediump float;\n\n varying vec2 verts;\n\n uniform float hashWidth;\n\n void main() {\n if(mod(verts.y, hashWidth * 2.0) > hashWidth) {\n gl_FragColor = vec4(1.0, 0.2, 0.3, 1.0);\n }\n else {\n gl_FragColor = vec4(1.0, 0.2, 0.3, 1.0);\n // gl_FragColor = vec4(0.2, 1.0, 0.3, 1.0);\n }\n }\n",FieldLayer.vertexShaderOutline="\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",FieldLayer.fragmentShaderOutline="\n precision mediump float;\n\n varying vec2 verts;\n\n void main() {\n gl_FragColor = vec4(0.3, 0.05, 0.05, 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}(),sample=null,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<sample.length;i++){var projected=project([sample[i].latitude,sample[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})}console.log(this.pointDict.tiles)},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 unselected=!1;this.selection&&((point=this.selection.point).uniforms.circleColor=[.2,.2,.2],point.mesh.zIndex=this.selection.zIndex,this.selection=null,unselected=!0);var _a=this.pixiOverlay.utils.latLngToLayerPoint([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,this.redraw(),!0}return unselected&&this.redraw(),!1},ExplorationLayer}(MapLayerInterface);function compressInterval(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}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}(),labelScale=.011,bgMargin=.01;function generateLabel(wellLabel,interp,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=textMetrics.width*labelScale,height=textMetrics.height*labelScale,end=interp.GetPoint(1),start=interp.GetPointFromEnd(width),dir=Vector2.sub(end.position,start.position);label.scale.set(labelScale);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}}function generatePointLabel(wellLabel,textStyle){var label=new PIXI.Text(wellLabel,textStyle);label.resolution=2;var textMetrics=PIXI.TextMetrics.measureText(wellLabel,textStyle),width=textMetrics.width*labelScale,height=textMetrics.height*labelScale;return label.scale.set(labelScale),label.anchor.set(.5,0),{text:label,background:generateBackground(width,height)}}function generateBackground(width,height){var background=new PIXI.Graphics;return background.beginFill(16777215),background.drawRect(.5*-width-4*bgMargin,.5*-height-bgMargin,width+8*bgMargin,height+2*bgMargin),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"});wells.forEach((function(well){return 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=compressInterval(intervals));var interp=new LineInterpolator(points,.5);if(interp.singlePoint){first=points[0],label=generatePointLabel(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=generateLabel(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:[]})}}(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=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.redraw(),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 this.tryUnselect()&&this.redraw(),!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.redraw(),this.selection={lines:newSelection,root:pointData,multiSelect:!1,ID:new ComparableArray(newSelection,!0,(function(d){return d.data.id}))},!0},WellboreLayer.prototype.removeHighlight=function(){this.tryUnselect()&&this.redraw()},WellboreLayer}(MapLayerInterface);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.FaultlineLayer=FaultlineLayer,exports.FieldLayer=FieldLayer,exports.MultiLayer=MultiLayer,exports.OutlineLayer=OutlineLayer,exports.WellboreLayer=WellboreLayer; |
@@ -1,2 +0,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 MultiLayer=function(){function MultiLayer(L,map){var _this=this,root=new PIXI.Container;root.sortableChildren=!0;var pixiOverlay=L.pixiOverlay((function(utils){var zoom=map.getZoom(),container=utils.getContainer(),renderer=utils.getRenderer();_this.prevZoom!==zoom&&(_this.onZoom&&_this.onZoom(zoom),_this.prevZoom=zoom),renderer.render(container)}),root);pixiOverlay.addTo(map),this.L=L,this.map=map,this.pixiOverlay=pixiOverlay,this.root=root}return MultiLayer.prototype.addLayer=function(Class){var layer=new Class(this.L,this.map,!0);return layer.pixiOverlay=this.pixiOverlay,this.root.addChild(layer.root),layer},MultiLayer.prototype.redraw=function(){this.pixiOverlay.redraw()},MultiLayer}(),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(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 MultiLayer=function(){function MultiLayer(L,map,options){var _this=this,root=new PIXI.Container;root.sortableChildren=!0;var pixiOverlay=L.pixiOverlay((function(utils){var zoom=map.getZoom(),container=utils.getContainer(),renderer=utils.getRenderer();_this.prevZoom!==zoom&&(_this.onZoom&&_this.onZoom(zoom),_this.prevZoom=zoom),renderer.render(container)}),root,options);pixiOverlay.addTo(map),this.L=L,this.map=map,this.pixiOverlay=pixiOverlay,this.root=root}return MultiLayer.prototype.addLayer=function(Class){var layer=new Class(this.L,this.map,!0);return layer.pixiOverlay=this.pixiOverlay,this.root.addChild(layer.root),layer},MultiLayer.prototype.redraw=function(){this.pixiOverlay.redraw()},MultiLayer}(),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)}; | ||
/*! ***************************************************************************** | ||
@@ -3,0 +3,0 @@ Copyright (c) Microsoft Corporation. All rights reserved. |
@@ -38,4 +38,5 @@ import * as PIXI from 'pixi.js'; | ||
* @param map Reference to map object | ||
* @param options Options used when creating the layer | ||
*/ | ||
constructor(L: any, map: L.Map); | ||
constructor(L: any, map: L.Map, options?: {}); | ||
/** | ||
@@ -42,0 +43,0 @@ * Adds a new layer to the multi-layer. |
{ | ||
"name": "@equinor/videx-map", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Component for Pixi-overlay in Leaflet.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
160712
1571