!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.rastertools=e.rastertools||{})}(this,function(e){"use strict";function t(e,t,o){return(e-t)/(o-t)}function o(e){for(var t=[],o=e.rows,r=e.cols,h=[],l=0;l0){var f=e.cells[l][a],n=(f.cval,p(f)),i=null,c=a,b=l;null!==n&&h.push([n.p[0]+c,n.p[1]+b]);do{if(i=u(e.cells[b][c],n.x,n.y,n.o),null===i)break;if(h.push([i.p[0]+c,i.p[1]+b]),c+=i.x,b+=i.y,n=i,b<0||b>=o||c<0||c>=r||"undefined"==typeof e.cells[b][c]){c-=i.x,b-=i.y;var g=s(e,c,b,i.x,i.y,i.o);if(null===g)break;g.path.forEach(function(e){h.push(e)}),c=g.i,b=g.j,n=g}}while("undefined"!=typeof e.cells[b][c]&&e.cells[b][c].edges.length>0);t.push(h),h=[],e.cells[l][a].edges.length>0&&a--}return t}function s(e,t,o,s,r,p){for(var u=e.cells[o][t],h=u.cval_real,l=t+s,a=o+r,f=[],n=(e.rows,e.cols,!1);!n;){if("undefined"==typeof e.cells[a]||"undefined"==typeof e.cells[a][l])if(a-=r,l-=s,u=e.cells[a][l],h=u.cval_real,r===-1)if(0===p)if(h&w)f.push([l,a]),s=-1,r=0,p=0;else{if(!(h&x)){f.push([l+u.bottomright,a]),s=0,r=1,p=1,n=!0;break}f.push([l+1,a]),s=1,r=0,p=0}else{if(!(h&w)){if(h&x){f.push([l+u.bottomright,a]),s=0,r=1,p=1,n=!0;break}f.push([l+u.bottomleft,a]),s=0,r=1,p=0,n=!0;break}f.push([l,a]),s=-1,r=0,p=0}else if(1===r)if(0===p){if(!(h&k)){if(h&v){f.push([l+u.topleft,a+1]),s=0,r=-1,p=0,n=!0;break}f.push([l+u.topright,a+1]),s=0,r=-1,p=1,n=!0;break}f.push([l+1,a+1]),s=1,r=0,p=1}else h&k?(f.push([l+1,a+1]),s=1,r=0,p=1):(f.push([l+1,a+1]),s=1,r=0,p=1);else if(s===-1)if(0===p){if(!(h&v)){if(h&w){f.push([l,a+u.leftbottom]),s=1,r=0,p=0,n=!0;break}f.push([l,a+u.lefttop]),s=1,r=0,p=1,n=!0;break}f.push([l,a+1]),s=0,r=1,p=0}else{if(!(h&v)){console.log("wtf");break}f.push([l,a+1]),s=0,r=1,p=0}else{if(1!==s){console.log("we came from nowhere!");break}if(0===p){if(!(h&x)){f.push([l+1,a+u.rightbottom]),s=-1,r=0,p=0,n=!0;break}f.push([l+1,a]),s=0,r=-1,p=1}else{if(!(h&x)){if(h&k){f.push([l+1,a+u.righttop]),s=-1,r=0,p=1;break}f.push([l+1,a+u.rightbottom]),s=-1,r=0,p=0,n=!0;break}f.push([l+1,a]),s=0,r=-1,p=1}}else if(u=e.cells[a][l],h=u.cval_real,s===-1)if(0===p)if("undefined"!=typeof e.cells[a-1]&&"undefined"!=typeof e.cells[a-1][l])s=0,r=-1,p=1;else{if(!(h&w)){f.push([l+u.bottomright,a]),s=0,r=1,p=1,n=!0;break}f.push([l,a])}else{if(!(h&v)){console.log("found entry from top at "+l+","+a);break}console.log("proceeding in x-direction!")}else if(1===s){if(0===p){console.log("wtf");break}if("undefined"!=typeof e.cells[a+1]&&"undefined"!=typeof e.cells[a+1][l])s=0,r=1,p=0;else{if(!(h&k)){f.push([l+u.topleft,a+1]),s=0,r=-1,p=0,n=!0;break}f.push([l+1,a+1]),s=1,r=0,p=1}}else if(r===-1){if(1!==p){console.log("wtf");break}if("undefined"!=typeof e.cells[a][l+1])s=1,r=0,p=1;else{if(!(h&x)){f.push([l+1,a+u.righttop]),s=-1,r=0,p=1,n=!0;break}f.push([l+1,a]),s=0,r=-1,p=1}}else{if(1!==r){console.log("where did we came from???");break}if(0!==p){console.log("wtf");break}if("undefined"!=typeof e.cells[a][l-1])s=-1,r=0,p=0;else{if(!(h&v)){f.push([l,a+u.leftbottom]),s=1,r=0,p=0,n=!0;break}f.push([l,a+1]),s=0,r=1,p=0}}if(l+=s,a+=r,l===t&&a===o)break}return{path:f,i:l,j:a,x:s,y:r,o:p}}function r(e,t){delete e.edges[t];for(var o=t+1;o0){var t=e.edges[e.edges.length-1],o=e.cval_real;switch(t){case 0:return o&k?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.topleft,1],x:0,y:-1,o:0};case 1:return o&x?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 2:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[e.topleft,1],x:0,y:-1,o:0};case 3:return o&w?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 4:return o&k?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};case 5:return o&x?{p:[e.topright,1],x:0,y:-1,o:1}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 6:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};case 7:return o&w?{p:[e.topright,1],x:0,y:-1,o:1}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 8:return o&x?{p:[e.bottomright],x:0,y:1,o:1}:{p:[1,e.righttop],x:-1,y:0,o:1};case 9:return o&w?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 10:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[1,e.righttop],x:-1,y:0,o:1};case 11:return o&v?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[0,e.lefttop],x:1,y:0,o:1};case 12:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 13:return o&w?{p:[1,e.rightbottom],x:-1,y:0,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 14:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 15:return o&v?{p:[1,e.rightbottom],x:-1,y:0,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 16:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[0,e.leftbottom],x:1,y:0,o:0};case 17:return o&v?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[0,e.lefttop],x:1,y:0,o:1};case 18:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 19:return o&v?{p:[e.bottomleft,0],x:0,y:1,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 20:return o&v?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[0,e.leftbottom],x:1,y:0,o:0};case 21:return o&k?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[e.topright,1],x:0,y:-1,o:1};case 22:return o&v?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 23:return o&k?{p:[0,e.lefttop],x:1,y:0,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};default:console.log("edge index out of range!"),console.log(e)}}return null}function u(e,t,o,s){var p,u,t,o,h,l,a,f=e.cval;switch(t){case-1:switch(s){case 0:p=U[f],h=A[f],l=G[f],a=P[f];break;default:p=R[f],h=F[f],l=O[f],a=I[f]}break;case 1:switch(s){case 0:p=Y[f],h=J[f],l=K[f],a=Q[f];break;default:p=Z[f],h=B[f],l=D[f],a=H[f]}break;default:switch(o){case-1:switch(s){case 0:p=$[f],h=N[f],l=j[f],a=C[f];break;default:p=ee[f],h=_[f],l=E[f],a=M[f]}break;case 1:switch(s){case 0:p=X[f],h=T[f],l=V[f],a=L[f];break;default:p=W[f],h=S[f],l=q[f],a=z[f]}}}if(u=e.edges.indexOf(p),"undefined"==typeof e.edges[u])return null;switch(r(e,u),f=e.cval_real,p){case 0:f&k?(t=e.topleft,o=1):(t=1,o=e.righttop);break;case 1:f&x?(t=1,o=e.rightbottom):(t=e.topleft,o=1);break;case 2:f&x?(t=e.topleft,o=1):(t=e.bottomright,o=0);break;case 3:f&w?(t=e.bottomleft,o=0):(t=e.topleft,o=1);break;case 4:f&k?(t=e.topright,o=1):(t=1,o=e.righttop);break;case 5:f&x?(t=1,o=e.rightbottom):(t=e.topright,o=1);break;case 6:f&x?(t=e.topright,o=1):(t=e.bottomright,o=0);break;case 7:f&w?(t=e.bottomleft,o=0):(t=e.topright,o=1);break;case 8:f&x?(t=1,o=e.righttop):(t=e.bottomright,o=0);break;case 9:f&w?(t=e.bottomleft,o=0):(t=1,o=e.righttop);break;case 10:f&w?(t=1,o=e.righttop):(t=0,o=e.leftbottom);break;case 11:f&v?(t=0,o=e.lefttop):(t=1,o=e.righttop);break;case 12:f&x?(t=1,o=e.rightbottom):(t=e.bottomright,o=0);break;case 13:f&w?(t=e.bottomleft,o=0):(t=1,o=e.rightbottom);break;case 14:f&w?(t=1,o=e.rightbottom):(t=0,o=e.leftbottom);break;case 15:f&v?(t=0,o=e.lefttop):(t=1,o=e.rightbottom);break;case 16:f&x?(t=0,o=e.leftbottom):(t=e.bottomright,o=0);break;case 17:f&v?(t=0,o=e.lefttop):(t=e.bottomright,o=0);break;case 18:f&w?(t=e.bottomleft,o=0):(t=0,o=e.leftbottom);break;case 19:f&v?(t=0,o=e.lefttop):(t=e.bottomleft,o=0);break;case 20:f&v?(t=0,o=e.leftbottom):(t=e.topleft,o=1);break;case 21:f&k?(t=e.topright,o=1):(t=0,o=e.leftbottom);break;case 22:f&v?(t=0,o=e.lefttop):(t=e.topleft,o=1);break;case 23:f&k?(t=e.topright,o=1):(t=0,o=e.lefttop);break;default:return console.log("edge index out of range!"),console.log(e),null}return"undefined"!=typeof t&&"undefined"!=typeof o&&"undefined"!=typeof h&&"undefined"!=typeof l&&"undefined"!=typeof a||(console.log("undefined value!"),console.log(e),console.log(t+" "+o+" "+h+" "+l+" "+a)),{p:[t,o],x:h,y:l,o:a}}function h(e,t,o){return(e-t)/(o-t)}function l(e,t){for(var o=e.length-1,s=e[0].length-1,r={rows:o,cols:s,cells:[]},p=0;p=t?8:0,l|=f>=t?4:0,l|=n>=t?2:0,l|=i>=t?1:0;var c=!1;if(5==l||10==l){var b=(a+f+n+i)/4;5==l&&b=0;c--)if(Math.abs(t[c][0][0]-n)<=s&&Math.abs(t[c][0][1]-i)<=s){for(var g=h.path.length-2;g>=0;--g)t[c].unshift(h.path[g]);l=!0;break}l||(t[o++]=h.path)}})}),t}function b(e,t,o){var s,r,p=e.length,u=[],h=[0,0,1,1,0,0,0,0,-1,0,1,1,-1,0,-1,0],l=[0,-1,0,0,1,1,1,1,0,-1,0,0,0,-1,0,0],a=["none","left","bottom","left","right","none","bottom","left","top","top","none","top","right","right","bottom","none"],f=["none","bottom","right","right","top","top","top","top","left","bottom","right","right","left","bottom","left","none"],c=(e[t][o],e[t][o]),b=c.cval,g=a[b],d=i(c,g);u.push([o+d[0],t+d[1]]),g=f[b],d=i(c,g),u.push([o+d[0],t+d[1]]),n(c);for(var y=o+h[b],m=t+l[b],v=b;y>=0&&m>=0&&mh?128:64,f|=ih?32:16,f|=ch?8:4,f|=bh?2:1;var g=+f,d=0;if(17==f||18==f||33==f||34==f||38==f||68==f||72==f||98==f||102==f||132==f||136==f||137==f||152==f||153==f){var y=(n+i+c+b)/4;d=y>h?2:y0?(f=156,d=4):f=152:33===f?d>0?(f=139,d=4):f=137:72===f?d>0?(f=99,d=4):f=98:132===f&&(d>0?(f=39,d=4):f=38)}if(0!=f&&170!=f){var m,v,k,x,w,N,j,C;m=v=k=x=w=N=j=C=.5;var _=[];1===f?(k=1-t(o,c,b),C=1-t(o,n,b),_.push(X[f])):169===f?(k=t(h,b,c),C=t(h,b,n),_.push(X[f])):4===f?(N=1-t(o,i,c),x=t(o,b,c),_.push(U[f])):166===f?(N=t(h,c,i),x=1-t(h,c,b),_.push(U[f])):16===f?(w=t(o,c,i),v=t(o,n,i),_.push(R[f])):154===f?(w=1-t(h,i,c),v=1-t(h,i,n),_.push(R[f])):64===f?(j=t(o,b,n),m=1-t(o,i,n),_.push(Z[f])):106===f?(j=1-t(h,n,b),m=t(h,n,i),_.push(Z[f])):168===f?(x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),_.push(W[f]),_.push(X[f])):2===f?(x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),_.push(W[f]),_.push(X[f])):162===f?(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),_.push(W[f]),_.push(X[f])):8===f?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),_.push(R[f]),_.push(U[f])):138===f?(w=1-t(o,i,c),N=1-t(h,i,c),m=1-t(h,i,n),v=1-t(o,i,n),_.push(R[f]),_.push(U[f])):32===f?(w=t(h,c,i),N=t(o,c,i),m=t(o,n,i),v=t(h,n,i),_.push(R[f]),_.push(U[f])):42===f?(C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i),_.push(Y[f]),_.push(Z[f])):128===f&&(C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n),_.push(Y[f]),_.push(Z[f])),5===f?(N=1-t(o,i,c),C=1-t(o,n,b),_.push(U[f])):165===f?(N=t(h,c,i),C=t(h,b,n),_.push(U[f])):20===f?(x=t(o,b,c),v=t(o,n,i),_.push(W[f])):150===f?(x=1-t(h,c,b),v=1-t(h,i,n),_.push(W[f])):80===f?(w=t(o,c,i),j=t(o,b,n),_.push(R[f])):90===f?(w=1-t(h,i,c),j=1-t(h,n,b),_.push(R[f])):65===f?(k=1-t(o,c,b),m=1-t(o,i,n),_.push(X[f])):105===f?(k=t(h,b,c),m=t(h,n,i),_.push(X[f])):160===f?(w=t(h,c,i),N=t(o,c,i),C=t(o,b,n),j=t(h,b,n),_.push(R[f]),_.push(U[f])):10===f?(w=1-t(o,i,c),N=1-t(h,i,c),C=1-t(h,n,b),j=1-t(o,n,b),_.push(R[f]),_.push(U[f])):130===f?(x=1-t(o,c,b),k=1-t(h,c,b),m=1-t(h,i,n),v=1-t(o,i,n),_.push(W[f]),_.push(X[f])):40===f?(x=t(h,b,c),k=t(o,b,c),m=t(o,n,i),v=t(h,n,i),_.push(W[f]),_.push(X[f])):101===f?(N=t(h,c,i),m=t(h,n,i),_.push(U[f])):69===f?(N=1-t(o,i,c),m=1-t(o,i,n),_.push(U[f])):149===f?(C=t(h,b,n),v=1-t(h,i,n),_.push(Y[f])):21===f?(C=1-t(o,n,b),v=t(o,n,i),_.push(Y[f])):86===f?(x=1-t(h,c,b),j=1-t(h,n,b),_.push(W[f])):84===f?(x=t(o,b,c),j=t(o,b,n),_.push(W[f])):89===f?(w=1-t(h,i,c),k=t(h,b,c),_.push(X[f])):81===f?(w=t(o,c,i),k=1-t(o,c,b),_.push(X[f])):96===f?(w=t(h,c,i),N=t(o,c,i),j=t(o,b,n),m=t(h,n,i),_.push(R[f]),_.push(U[f])):74===f?(w=1-t(o,i,c),N=1-t(h,i,c),j=1-t(h,n,b),m=1-t(o,i,n),_.push(R[f]),_.push(U[f])):24===f?(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),v=t(o,n,i),_.push(R[f]),_.push(X[f])):146===f?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),v=1-t(h,i,n),_.push(R[f]),_.push(X[f])):6===f?(N=1-t(o,i,c),x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),_.push(U[f]),_.push(W[f])):164===f?(N=t(h,c,i),x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),_.push(U[f]),_.push(W[f])):129===f?(k=1-t(o,c,b),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n),_.push(X[f]),_.push(Y[f])):41===f?(k=t(h,b,c),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i),_.push(X[f]),_.push(Y[f])):66===f?(x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),m=1-t(o,i,n),_.push(W[f]),_.push(X[f])):104===f?(x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),m=t(h,n,i),_.push(X[f]),_.push($[f])):144===f?(w=t(o,c,i),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n),_.push(R[f]),_.push(Z[f])):26===f?(w=1-t(h,i,c),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i),_.push(R[f]),_.push(Z[f])):36===f?(N=t(h,c,i),x=t(o,b,c),m=t(o,n,i),v=t(h,n,i),_.push(U[f]),_.push(W[f])):134===f?(N=1-t(o,i,c),x=1-t(h,c,b),m=1-t(h,i,n),v=1-t(o,i,n),_.push(U[f]),_.push(W[f])):9===f?(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),C=1-t(o,n,b),_.push(R[f]),_.push(U[f])):161===f?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),C=t(h,b,n),_.push(R[f]),_.push(U[f])):37===f?(N=t(h,c,i),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i),_.push(U[f]),_.push(Y[f])):133===f?(N=1-t(o,i,c),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n),_.push(U[f]),_.push(Y[f])):148===f?(x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n),_.push(W[f]),_.push(Z[f])):22===f?(x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i),_.push(W[f]),_.push(Z[f])):82===f?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),_.push(R[f]),_.push(X[f])):88===f?(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),_.push(R[f]),_.push(X[f])):73===f?(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),m=1-t(o,i,n),_.push(R[f]),_.push(U[f])):97===f?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),m=t(h,n,i),_.push(R[f]),_.push(U[f])):145===f?(w=t(o,c,i),k=1-t(o,c,b),C=t(h,b,n),v=1-t(h,i,n),_.push(R[f]),_.push(Y[f])):25===f?(w=1-t(h,i,c),k=t(h,b,c),C=1-t(o,n,b),v=t(o,n,i),_.push(R[f]),_.push(Y[f])):70===f?(N=1-t(o,i,c),x=1-t(h,c,b),j=1-t(h,n,b),m=1-t(o,i,n),_.push(U[f]),_.push(W[f])):100===f?(N=t(h,c,i),x=t(o,b,c),j=t(o,b,n),m=t(h,n,i),_.push(U[f]),_.push(W[f])):34===f?(0===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(Y[f]),_.push(Z[f])):35===f?(4===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(X[f]),_.push(Z[f])):136===f?(0===d?(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)):(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)),_.push(R[f]),_.push(U[f]),_.push(Y[f]),_.push(Z[f])):153===f?(0===d?(w=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(X[f])):102===f?(0===d?(N=1-t(o,i,c),x=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(U[f]),_.push(Z[f])):155===f?(4===d?(w=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(Y[f])):103===f?(4===d?(N=1-t(o,i,c),x=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(U[f]),_.push(W[f])):152===f?(0===d?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(W[f]),_.push(X[f])):156===f?(4===d?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(X[f]),_.push(Z[f])):137===f?(0===d?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)):(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)),_.push(R[f]),_.push(U[f]),_.push(X[f])):139===f?(4===d?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)):(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)),_.push(R[f]),_.push(U[f]),_.push(Y[f])):98===f?(0===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(Z[f])):99===f?(4===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(X[f])):38===f?(0===d?(N=1-t(o,i,c),x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(U[f]),_.push(Y[f]),_.push(Z[f])):39===f?(4===d?(N=1-t(o,i,c),x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(U[f]),_.push(W[f]),_.push(Z[f])):85===f&&(w=1,N=0,x=1,k=0,C=0,j=1,m=0,v=1),(m<0||m>1||v<0||v>1||w<0||w>1||x<0||x>1||C<0||C>1||j<0||j>1)&&console.log(f+" "+g+" "+n+","+i+","+c+","+b+" "+d+" "+m+" "+v+" "+w+" "+N+" "+x+" "+k+" "+C+" "+j),u.cells[l][a]={cval:f,cval_real:g,flipped:d,topleft:m,topright:v,righttop:w,rightbottom:N,bottomright:x,bottomleft:k,leftbottom:C,lefttop:j,edges:_}}}}}return u},oe=function(e,t,o){for(var s={type:"FeatureCollection",features:[]},r=0;r