You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
82 KiB
2 lines
82 KiB
var mr=Object.defineProperty,pr=Object.defineProperties;var gr=Object.getOwnPropertyDescriptors;var Sn=Object.getOwnPropertySymbols;var dr=Object.prototype.hasOwnProperty,yr=Object.prototype.propertyIsEnumerable;var _n=(m,n,r)=>n in m?mr(m,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):m[n]=r,st=(m,n)=>{for(var r in n||(n={}))dr.call(n,r)&&_n(m,r,n[r]);if(Sn)for(var r of Sn(n))yr.call(n,r)&&_n(m,r,n[r]);return m},Ct=(m,n)=>pr(m,gr(n));var mt=(m,n,r)=>new Promise((u,h)=>{var c=y=>{try{g(r.next(y))}catch(b){h(b)}},p=y=>{try{g(r.throw(y))}catch(b){h(b)}},g=y=>y.done?u(y.value):Promise.resolve(y.value).then(c,p);g((r=r.apply(m,n)).next())});import{l as xr,p as br,H as z,m as wr,q as we,h as En}from"./townshipBoundaries-a3a8b9c1-1784378651390.js";import{_ as Sr,g as _r,q as Er,h as Nr,w as Qt,A as Nn,o as Cr,c as Tr,a as Fr,d as Cn,L as Pr}from"./index-1784378651390.js";class yt{constructor(n,r){this.next=null,this.key=n,this.data=r,this.left=null,this.right=null}}function Ir(m,n){return m>n?1:m<n?-1:0}function pt(m,n,r){const u=new yt(null,null);let h=u,c=u;for(;;){const p=r(m,n.key);if(p<0){if(n.left===null)break;if(r(m,n.left.key)<0){const g=n.left;if(n.left=g.right,g.right=n,n=g,n.left===null)break}c.left=n,c=n,n=n.left}else if(p>0){if(n.right===null)break;if(r(m,n.right.key)>0){const g=n.right;if(n.right=g.left,g.left=n,n=g,n.right===null)break}h.right=n,h=n,n=n.right}else break}return h.right=n.left,c.left=n.right,n.left=u.right,n.right=u.left,n}function Se(m,n,r,u){const h=new yt(m,n);if(r===null)return h.left=h.right=null,h;r=pt(m,r,u);const c=u(m,r.key);return c<0?(h.left=r.left,h.right=r,r.left=null):c>=0&&(h.right=r.right,h.left=r,r.right=null),h}function Tn(m,n,r){let u=null,h=null;if(n){n=pt(m,n,r);const c=r(n.key,m);c===0?(u=n.left,h=n.right):c<0?(h=n.right,n.right=null,u=n):(u=n.left,n.left=null,h=n)}return{left:u,right:h}}function Mr(m,n,r){return n===null?m:(m===null||(n=pt(m.key,n,r),n.left=m),n)}function Ee(m,n,r,u,h){if(m){u(`${n}${r?"└── ":"├── "}${h(m)}
|
|
`);const c=n+(r?" ":"│ ");m.left&&Ee(m.left,c,!1,u,h),m.right&&Ee(m.right,c,!0,u,h)}}class Pe{constructor(n=Ir){this._root=null,this._size=0,this._comparator=n}insert(n,r){return this._size++,this._root=Se(n,r,this._root,this._comparator)}add(n,r){const u=new yt(n,r);this._root===null&&(u.left=u.right=null,this._size++,this._root=u);const h=this._comparator,c=pt(n,this._root,h),p=h(n,c.key);return p===0?this._root=c:(p<0?(u.left=c.left,u.right=c,c.left=null):p>0&&(u.right=c.right,u.left=c,c.right=null),this._size++,this._root=u),this._root}remove(n){this._root=this._remove(n,this._root,this._comparator)}_remove(n,r,u){let h;return r===null?null:(r=pt(n,r,u),u(n,r.key)===0?(r.left===null?h=r.right:(h=pt(n,r.left,u),h.right=r.right),this._size--,h):r)}pop(){let n=this._root;if(n){for(;n.left;)n=n.left;return this._root=pt(n.key,this._root,this._comparator),this._root=this._remove(n.key,this._root,this._comparator),{key:n.key,data:n.data}}return null}findStatic(n){let r=this._root;const u=this._comparator;for(;r;){const h=u(n,r.key);if(h===0)return r;h<0?r=r.left:r=r.right}return null}find(n){return this._root&&(this._root=pt(n,this._root,this._comparator),this._comparator(n,this._root.key)!==0)?null:this._root}contains(n){let r=this._root;const u=this._comparator;for(;r;){const h=u(n,r.key);if(h===0)return!0;h<0?r=r.left:r=r.right}return!1}forEach(n,r){let u=this._root;const h=[];let c=!1;for(;!c;)u!==null?(h.push(u),u=u.left):h.length!==0?(u=h.pop(),n.call(r,u),u=u.right):c=!0;return this}range(n,r,u,h){const c=[],p=this._comparator;let g=this._root,y;for(;c.length!==0||g;)if(g)c.push(g),g=g.left;else{if(g=c.pop(),y=p(g.key,r),y>0)break;if(p(g.key,n)>=0&&u.call(h,g))return this;g=g.right}return this}keys(){const n=[];return this.forEach(({key:r})=>{n.push(r)}),n}values(){const n=[];return this.forEach(({data:r})=>{n.push(r)}),n}min(){return this._root?this.minNode(this._root).key:null}max(){return this._root?this.maxNode(this._root).key:null}minNode(n=this._root){if(n)for(;n.left;)n=n.left;return n}maxNode(n=this._root){if(n)for(;n.right;)n=n.right;return n}at(n){let r=this._root,u=!1,h=0;const c=[];for(;!u;)if(r)c.push(r),r=r.left;else if(c.length>0){if(r=c.pop(),h===n)return r;h++,r=r.right}else u=!0;return null}next(n){let r=this._root,u=null;if(n.right){for(u=n.right;u.left;)u=u.left;return u}const h=this._comparator;for(;r;){const c=h(n.key,r.key);if(c===0)break;c<0?(u=r,r=r.left):r=r.right}return u}prev(n){let r=this._root,u=null;if(n.left!==null){for(u=n.left;u.right;)u=u.right;return u}const h=this._comparator;for(;r;){const c=h(n.key,r.key);if(c===0)break;c<0?r=r.left:(u=r,r=r.right)}return u}clear(){return this._root=null,this._size=0,this}toList(){return kr(this._root)}load(n,r=[],u=!1){let h=n.length;const c=this._comparator;if(u&&Te(n,r,0,h-1,c),this._root===null)this._root=Ne(n,r,0,h),this._size=h;else{const p=Lr(this.toList(),Rr(n,r),c);h=this._size+h,this._root=Ce({head:p},0,h)}return this}isEmpty(){return this._root===null}get size(){return this._size}get root(){return this._root}toString(n=r=>String(r.key)){const r=[];return Ee(this._root,"",!0,u=>r.push(u),n),r.join("")}update(n,r,u){const h=this._comparator;let{left:c,right:p}=Tn(n,this._root,h);h(n,r)<0?p=Se(r,u,p,h):c=Se(r,u,c,h),this._root=Mr(c,p,h)}split(n){return Tn(n,this._root,this._comparator)}*[Symbol.iterator](){let n=this._root;const r=[];let u=!1;for(;!u;)n!==null?(r.push(n),n=n.left):r.length!==0?(n=r.pop(),yield n,n=n.right):u=!0}}function Ne(m,n,r,u){const h=u-r;if(h>0){const c=r+Math.floor(h/2),p=m[c],g=n[c],y=new yt(p,g);return y.left=Ne(m,n,r,c),y.right=Ne(m,n,c+1,u),y}return null}function Rr(m,n){const r=new yt(null,null);let u=r;for(let h=0;h<m.length;h++)u=u.next=new yt(m[h],n[h]);return u.next=null,r.next}function kr(m){let n=m;const r=[];let u=!1;const h=new yt(null,null);let c=h;for(;!u;)n?(r.push(n),n=n.left):r.length>0?(n=c=c.next=r.pop(),n=n.right):u=!0;return c.next=null,h.next}function Ce(m,n,r){const u=r-n;if(u>0){const h=n+Math.floor(u/2),c=Ce(m,n,h),p=m.head;return p.left=c,m.head=m.head.next,p.right=Ce(m,h+1,r),p}return null}function Lr(m,n,r){const u=new yt(null,null);let h=u,c=m,p=n;for(;c!==null&&p!==null;)r(c.key,p.key)<0?(h.next=c,c=c.next):(h.next=p,p=p.next),h=h.next;return c!==null?h.next=c:p!==null&&(h.next=p),u.next}function Te(m,n,r,u,h){if(r>=u)return;const c=m[r+u>>1];let p=r-1,g=u+1;for(;;){do p++;while(h(m[p],c)<0);do g--;while(h(m[g],c)>0);if(p>=g)break;let y=m[p];m[p]=m[g],m[g]=y,y=n[p],n[p]=n[g],n[g]=y}Te(m,n,r,g,h),Te(m,n,g+1,u,h)}const ut=11102230246251565e-32,K=134217729,Ar=(3+8*ut)*ut;function _e(m,n,r,u,h){let c,p,g,y,b=n[0],E=u[0],o=0,x=0;E>b==E>-b?(c=b,b=n[++o]):(c=E,E=u[++x]);let _=0;if(o<m&&x<r)for(E>b==E>-b?(p=b+c,g=c-(p-b),b=n[++o]):(p=E+c,g=c-(p-E),E=u[++x]),c=p,g!==0&&(h[_++]=g);o<m&&x<r;)E>b==E>-b?(p=c+b,y=p-c,g=c-(p-y)+(b-y),b=n[++o]):(p=c+E,y=p-c,g=c-(p-y)+(E-y),E=u[++x]),c=p,g!==0&&(h[_++]=g);for(;o<m;)p=c+b,y=p-c,g=c-(p-y)+(b-y),b=n[++o],c=p,g!==0&&(h[_++]=g);for(;x<r;)p=c+E,y=p-c,g=c-(p-y)+(E-y),E=u[++x],c=p,g!==0&&(h[_++]=g);return(c!==0||_===0)&&(h[_++]=c),_}function vr(m,n){let r=n[0];for(let u=1;u<m;u++)r+=n[u];return r}function Ht(m){return new Float64Array(m)}const Br=(3+16*ut)*ut,Or=(2+12*ut)*ut,Dr=(9+64*ut)*ut*ut,Ft=Ht(4),Fn=Ht(8),Pn=Ht(12),In=Ht(16),Q=Ht(4);function Gr(m,n,r,u,h,c,p){let g,y,b,E,o,x,_,F,T,R,I,M,D,k,v,B,Y,G;const q=m-h,U=r-h,Z=n-c,H=u-c;k=q*H,x=K*q,_=x-(x-q),F=q-_,x=K*H,T=x-(x-H),R=H-T,v=F*R-(k-_*T-F*T-_*R),B=Z*U,x=K*Z,_=x-(x-Z),F=Z-_,x=K*U,T=x-(x-U),R=U-T,Y=F*R-(B-_*T-F*T-_*R),I=v-Y,o=v-I,Ft[0]=v-(I+o)+(o-Y),M=k+I,o=M-k,D=k-(M-o)+(I-o),I=D-B,o=D-I,Ft[1]=D-(I+o)+(o-B),G=M+I,o=G-M,Ft[2]=M-(G-o)+(I-o),Ft[3]=G;let j=vr(4,Ft),rt=Or*p;if(j>=rt||-j>=rt||(o=m-q,g=m-(q+o)+(o-h),o=r-U,b=r-(U+o)+(o-h),o=n-Z,y=n-(Z+o)+(o-c),o=u-H,E=u-(H+o)+(o-c),g===0&&y===0&&b===0&&E===0)||(rt=Dr*p+Ar*Math.abs(j),j+=q*E+H*g-(Z*b+U*y),j>=rt||-j>=rt))return j;k=g*H,x=K*g,_=x-(x-g),F=g-_,x=K*H,T=x-(x-H),R=H-T,v=F*R-(k-_*T-F*T-_*R),B=y*U,x=K*y,_=x-(x-y),F=y-_,x=K*U,T=x-(x-U),R=U-T,Y=F*R-(B-_*T-F*T-_*R),I=v-Y,o=v-I,Q[0]=v-(I+o)+(o-Y),M=k+I,o=M-k,D=k-(M-o)+(I-o),I=D-B,o=D-I,Q[1]=D-(I+o)+(o-B),G=M+I,o=G-M,Q[2]=M-(G-o)+(I-o),Q[3]=G;const xt=_e(4,Ft,4,Q,Fn);k=q*E,x=K*q,_=x-(x-q),F=q-_,x=K*E,T=x-(x-E),R=E-T,v=F*R-(k-_*T-F*T-_*R),B=Z*b,x=K*Z,_=x-(x-Z),F=Z-_,x=K*b,T=x-(x-b),R=b-T,Y=F*R-(B-_*T-F*T-_*R),I=v-Y,o=v-I,Q[0]=v-(I+o)+(o-Y),M=k+I,o=M-k,D=k-(M-o)+(I-o),I=D-B,o=D-I,Q[1]=D-(I+o)+(o-B),G=M+I,o=G-M,Q[2]=M-(G-o)+(I-o),Q[3]=G;const bt=_e(xt,Fn,4,Q,Pn);k=g*E,x=K*g,_=x-(x-g),F=g-_,x=K*E,T=x-(x-E),R=E-T,v=F*R-(k-_*T-F*T-_*R),B=y*b,x=K*y,_=x-(x-y),F=y-_,x=K*b,T=x-(x-b),R=b-T,Y=F*R-(B-_*T-F*T-_*R),I=v-Y,o=v-I,Q[0]=v-(I+o)+(o-Y),M=k+I,o=M-k,D=k-(M-o)+(I-o),I=D-B,o=D-I,Q[1]=D-(I+o)+(o-B),G=M+I,o=G-M,Q[2]=M-(G-o)+(I-o),Q[3]=G;const ct=_e(bt,Pn,4,Q,In);return In[ct-1]}function Hr(m,n,r,u,h,c){const p=(n-c)*(r-h),g=(m-h)*(u-c),y=p-g,b=Math.abs(p+g);return Math.abs(y)>=Br*b?y:-Gr(m,n,r,u,h,c,b)}const Dt=(m,n)=>m.ll.x<=n.x&&n.x<=m.ur.x&&m.ll.y<=n.y&&n.y<=m.ur.y,Fe=(m,n)=>{if(n.ur.x<m.ll.x||m.ur.x<n.ll.x||n.ur.y<m.ll.y||m.ur.y<n.ll.y)return null;const r=m.ll.x<n.ll.x?n.ll.x:m.ll.x,u=m.ur.x<n.ur.x?m.ur.x:n.ur.x,h=m.ll.y<n.ll.y?n.ll.y:m.ll.y,c=m.ur.y<n.ur.y?m.ur.y:n.ur.y;return{ll:{x:r,y:h},ur:{x:u,y:c}}};let gt=Number.EPSILON;gt===void 0&&(gt=Math.pow(2,-52));const Wr=gt*gt,Mn=(m,n)=>{if(-gt<m&&m<gt&&-gt<n&&n<gt)return 0;const r=m-n;return r*r<Wr*m*n?0:m<n?-1:1};class zr{constructor(){this.reset()}reset(){this.xRounder=new Rn,this.yRounder=new Rn}round(n,r){return{x:this.xRounder.round(n),y:this.yRounder.round(r)}}}class Rn{constructor(){this.tree=new Pe,this.round(0)}round(n){const r=this.tree.add(n),u=this.tree.prev(r);if(u!==null&&Mn(r.key,u.key)===0)return this.tree.remove(n),u.key;const h=this.tree.next(r);return h!==null&&Mn(r.key,h.key)===0?(this.tree.remove(n),h.key):n}}const Gt=new zr,ee=(m,n)=>m.x*n.y-m.y*n.x,Un=(m,n)=>m.x*n.x+m.y*n.y,kn=(m,n,r)=>{const u=Hr(m.x,m.y,n.x,n.y,r.x,r.y);return u>0?-1:u<0?1:0},ne=m=>Math.sqrt(Un(m,m)),Ur=(m,n,r)=>{const u={x:n.x-m.x,y:n.y-m.y},h={x:r.x-m.x,y:r.y-m.y};return ee(h,u)/ne(h)/ne(u)},Vr=(m,n,r)=>{const u={x:n.x-m.x,y:n.y-m.y},h={x:r.x-m.x,y:r.y-m.y};return Un(h,u)/ne(h)/ne(u)},Ln=(m,n,r)=>n.y===0?null:{x:m.x+n.x/n.y*(r-m.y),y:r},An=(m,n,r)=>n.x===0?null:{x:r,y:m.y+n.y/n.x*(r-m.x)},Yr=(m,n,r,u)=>{if(n.x===0)return An(r,u,m.x);if(u.x===0)return An(m,n,r.x);if(n.y===0)return Ln(r,u,m.y);if(u.y===0)return Ln(m,n,r.y);const h=ee(n,u);if(h==0)return null;const c={x:r.x-m.x,y:r.y-m.y},p=ee(c,n)/h,g=ee(c,u)/h,y=m.x+g*n.x,b=r.x+p*u.x,E=m.y+g*n.y,o=r.y+p*u.y,x=(y+b)/2,_=(E+o)/2;return{x,y:_}};class it{static compare(n,r){const u=it.comparePoints(n.point,r.point);return u!==0?u:(n.point!==r.point&&n.link(r),n.isLeft!==r.isLeft?n.isLeft?1:-1:dt.compare(n.segment,r.segment))}static comparePoints(n,r){return n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0}constructor(n,r){n.events===void 0?n.events=[this]:n.events.push(this),this.point=n,this.isLeft=r}link(n){if(n.point===this.point)throw new Error("Tried to link already linked events");const r=n.point.events;for(let u=0,h=r.length;u<h;u++){const c=r[u];this.point.events.push(c),c.point=this.point}this.checkForConsuming()}checkForConsuming(){const n=this.point.events.length;for(let r=0;r<n;r++){const u=this.point.events[r];if(u.segment.consumedBy===void 0)for(let h=r+1;h<n;h++){const c=this.point.events[h];c.consumedBy===void 0&&u.otherSE.point.events===c.otherSE.point.events&&u.segment.consume(c.segment)}}}getAvailableLinkedEvents(){const n=[];for(let r=0,u=this.point.events.length;r<u;r++){const h=this.point.events[r];h!==this&&!h.segment.ringOut&&h.segment.isInResult()&&n.push(h)}return n}getLeftmostComparator(n){const r=new Map,u=h=>{const c=h.otherSE;r.set(h,{sine:Ur(this.point,n.point,c.point),cosine:Vr(this.point,n.point,c.point)})};return(h,c)=>{r.has(h)||u(h),r.has(c)||u(c);const{sine:p,cosine:g}=r.get(h),{sine:y,cosine:b}=r.get(c);return p>=0&&y>=0?g<b?1:g>b?-1:0:p<0&&y<0?g<b?-1:g>b?1:0:y<p?-1:y>p?1:0}}}let jr=0;class dt{static compare(n,r){const u=n.leftSE.point.x,h=r.leftSE.point.x,c=n.rightSE.point.x,p=r.rightSE.point.x;if(p<u)return 1;if(c<h)return-1;const g=n.leftSE.point.y,y=r.leftSE.point.y,b=n.rightSE.point.y,E=r.rightSE.point.y;if(u<h){if(y<g&&y<b)return 1;if(y>g&&y>b)return-1;const o=n.comparePoint(r.leftSE.point);if(o<0)return 1;if(o>0)return-1;const x=r.comparePoint(n.rightSE.point);return x!==0?x:-1}if(u>h){if(g<y&&g<E)return-1;if(g>y&&g>E)return 1;const o=r.comparePoint(n.leftSE.point);if(o!==0)return o;const x=n.comparePoint(r.rightSE.point);return x<0?1:x>0?-1:1}if(g<y)return-1;if(g>y)return 1;if(c<p){const o=r.comparePoint(n.rightSE.point);if(o!==0)return o}if(c>p){const o=n.comparePoint(r.rightSE.point);if(o<0)return 1;if(o>0)return-1}if(c!==p){const o=b-g,x=c-u,_=E-y,F=p-h;if(o>x&&_<F)return 1;if(o<x&&_>F)return-1}return c>p?1:c<p||b<E?-1:b>E?1:n.id<r.id?-1:n.id>r.id?1:0}constructor(n,r,u,h){this.id=++jr,this.leftSE=n,n.segment=this,n.otherSE=r,this.rightSE=r,r.segment=this,r.otherSE=n,this.rings=u,this.windings=h}static fromRing(n,r,u){let h,c,p;const g=it.comparePoints(n,r);if(g<0)h=n,c=r,p=1;else if(g>0)h=r,c=n,p=-1;else throw new Error(`Tried to create degenerate segment at [${n.x}, ${n.y}]`);const y=new it(h,!0),b=new it(c,!1);return new dt(y,b,[u],[p])}replaceRightSE(n){this.rightSE=n,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const n=this.leftSE.point.y,r=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:n<r?n:r},ur:{x:this.rightSE.point.x,y:n>r?n:r}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(n){return n.x===this.leftSE.point.x&&n.y===this.leftSE.point.y||n.x===this.rightSE.point.x&&n.y===this.rightSE.point.y}comparePoint(n){if(this.isAnEndpoint(n))return 0;const r=this.leftSE.point,u=this.rightSE.point,h=this.vector();if(r.x===u.x)return n.x===r.x?0:n.x<r.x?1:-1;const c=(n.y-r.y)/h.y,p=r.x+c*h.x;if(n.x===p)return 0;const g=(n.x-r.x)/h.x,y=r.y+g*h.y;return n.y===y?0:n.y<y?-1:1}getIntersection(n){const r=this.bbox(),u=n.bbox(),h=Fe(r,u);if(h===null)return null;const c=this.leftSE.point,p=this.rightSE.point,g=n.leftSE.point,y=n.rightSE.point,b=Dt(r,g)&&this.comparePoint(g)===0,E=Dt(u,c)&&n.comparePoint(c)===0,o=Dt(r,y)&&this.comparePoint(y)===0,x=Dt(u,p)&&n.comparePoint(p)===0;if(E&&b)return x&&!o?p:!x&&o?y:null;if(E)return o&&c.x===y.x&&c.y===y.y?null:c;if(b)return x&&p.x===g.x&&p.y===g.y?null:g;if(x&&o)return null;if(x)return p;if(o)return y;const _=Yr(c,this.vector(),g,n.vector());return _===null||!Dt(h,_)?null:Gt.round(_.x,_.y)}split(n){const r=[],u=n.events!==void 0,h=new it(n,!0),c=new it(n,!1),p=this.rightSE;this.replaceRightSE(c),r.push(c),r.push(h);const g=new dt(h,p,this.rings.slice(),this.windings.slice());return it.comparePoints(g.leftSE.point,g.rightSE.point)>0&&g.swapEvents(),it.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),u&&(h.checkForConsuming(),c.checkForConsuming()),r}swapEvents(){const n=this.rightSE;this.rightSE=this.leftSE,this.leftSE=n,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let r=0,u=this.windings.length;r<u;r++)this.windings[r]*=-1}consume(n){let r=this,u=n;for(;r.consumedBy;)r=r.consumedBy;for(;u.consumedBy;)u=u.consumedBy;const h=dt.compare(r,u);if(h!==0){if(h>0){const c=r;r=u,u=c}if(r.prev===u){const c=r;r=u,u=c}for(let c=0,p=u.rings.length;c<p;c++){const g=u.rings[c],y=u.windings[c],b=r.rings.indexOf(g);b===-1?(r.rings.push(g),r.windings.push(y)):r.windings[b]+=y}u.rings=null,u.windings=null,u.consumedBy=r,u.leftSE.consumedBy=r.leftSE,u.rightSE.consumedBy=r.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const n=this.prev.consumedBy||this.prev;this._beforeState=n.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const n=this.beforeState();this._afterState={rings:n.rings.slice(0),windings:n.windings.slice(0),multiPolys:[]};const r=this._afterState.rings,u=this._afterState.windings,h=this._afterState.multiPolys;for(let g=0,y=this.rings.length;g<y;g++){const b=this.rings[g],E=this.windings[g],o=r.indexOf(b);o===-1?(r.push(b),u.push(E)):u[o]+=E}const c=[],p=[];for(let g=0,y=r.length;g<y;g++){if(u[g]===0)continue;const b=r[g],E=b.poly;if(p.indexOf(E)===-1)if(b.isExterior)c.push(E);else{p.indexOf(E)===-1&&p.push(E);const o=c.indexOf(b.poly);o!==-1&&c.splice(o,1)}}for(let g=0,y=c.length;g<y;g++){const b=c[g].multiPoly;h.indexOf(b)===-1&&h.push(b)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const n=this.beforeState().multiPolys,r=this.afterState().multiPolys;switch(lt.type){case"union":{const u=n.length===0,h=r.length===0;this._isInResult=u!==h;break}case"intersection":{let u,h;n.length<r.length?(u=n.length,h=r.length):(u=r.length,h=n.length),this._isInResult=h===lt.numMultiPolys&&u<h;break}case"xor":{const u=Math.abs(n.length-r.length);this._isInResult=u%2===1;break}case"difference":{const u=h=>h.length===1&&h[0].isSubject;this._isInResult=u(n)!==u(r);break}default:throw new Error(`Unrecognized operation type found ${lt.type}`)}return this._isInResult}}class vn{constructor(n,r,u){if(!Array.isArray(n)||n.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=r,this.isExterior=u,this.segments=[],typeof n[0][0]!="number"||typeof n[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const h=Gt.round(n[0][0],n[0][1]);this.bbox={ll:{x:h.x,y:h.y},ur:{x:h.x,y:h.y}};let c=h;for(let p=1,g=n.length;p<g;p++){if(typeof n[p][0]!="number"||typeof n[p][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let y=Gt.round(n[p][0],n[p][1]);y.x===c.x&&y.y===c.y||(this.segments.push(dt.fromRing(c,y,this)),y.x<this.bbox.ll.x&&(this.bbox.ll.x=y.x),y.y<this.bbox.ll.y&&(this.bbox.ll.y=y.y),y.x>this.bbox.ur.x&&(this.bbox.ur.x=y.x),y.y>this.bbox.ur.y&&(this.bbox.ur.y=y.y),c=y)}(h.x!==c.x||h.y!==c.y)&&this.segments.push(dt.fromRing(c,h,this))}getSweepEvents(){const n=[];for(let r=0,u=this.segments.length;r<u;r++){const h=this.segments[r];n.push(h.leftSE),n.push(h.rightSE)}return n}}class $r{constructor(n,r){if(!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new vn(n[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let u=1,h=n.length;u<h;u++){const c=new vn(n[u],this,!1);c.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=c.bbox.ll.x),c.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=c.bbox.ll.y),c.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=c.bbox.ur.x),c.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=c.bbox.ur.y),this.interiorRings.push(c)}this.multiPoly=r}getSweepEvents(){const n=this.exteriorRing.getSweepEvents();for(let r=0,u=this.interiorRings.length;r<u;r++){const h=this.interiorRings[r].getSweepEvents();for(let c=0,p=h.length;c<p;c++)n.push(h[c])}return n}}class Bn{constructor(n,r){if(!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof n[0][0][0]=="number"&&(n=[n])}catch(u){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let u=0,h=n.length;u<h;u++){const c=new $r(n[u],this);c.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=c.bbox.ll.x),c.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=c.bbox.ll.y),c.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=c.bbox.ur.x),c.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=c.bbox.ur.y),this.polys.push(c)}this.isSubject=r}getSweepEvents(){const n=[];for(let r=0,u=this.polys.length;r<u;r++){const h=this.polys[r].getSweepEvents();for(let c=0,p=h.length;c<p;c++)n.push(h[c])}return n}}class ie{static factory(n){const r=[];for(let u=0,h=n.length;u<h;u++){const c=n[u];if(!c.isInResult()||c.ringOut)continue;let p=null,g=c.leftSE,y=c.rightSE;const b=[g],E=g.point,o=[];for(;p=g,g=y,b.push(g),g.point!==E;)for(;;){const x=g.getAvailableLinkedEvents();if(x.length===0){const T=b[0].point,R=b[b.length-1].point;throw new Error(`Unable to complete output ring starting at [${T.x}, ${T.y}]. Last matching segment found ends at [${R.x}, ${R.y}].`)}if(x.length===1){y=x[0].otherSE;break}let _=null;for(let T=0,R=o.length;T<R;T++)if(o[T].point===g.point){_=T;break}if(_!==null){const T=o.splice(_)[0],R=b.splice(T.index);R.unshift(R[0].otherSE),r.push(new ie(R.reverse()));continue}o.push({index:b.length,point:g.point});const F=g.getLeftmostComparator(p);y=x.sort(F)[0].otherSE;break}r.push(new ie(b))}return r}constructor(n){this.events=n;for(let r=0,u=n.length;r<u;r++)n[r].segment.ringOut=this;this.poly=null}getGeom(){let n=this.events[0].point;const r=[n];for(let b=1,E=this.events.length-1;b<E;b++){const o=this.events[b].point,x=this.events[b+1].point;kn(o,n,x)!==0&&(r.push(o),n=o)}if(r.length===1)return null;const u=r[0],h=r[1];kn(u,n,h)===0&&r.shift(),r.push(r[0]);const c=this.isExteriorRing()?1:-1,p=this.isExteriorRing()?0:r.length-1,g=this.isExteriorRing()?r.length:-1,y=[];for(let b=p;b!=g;b+=c)y.push([r[b].x,r[b].y]);return y}isExteriorRing(){if(this._isExteriorRing===void 0){const n=this.enclosingRing();this._isExteriorRing=n?!n.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let n=this.events[0];for(let h=1,c=this.events.length;h<c;h++){const p=this.events[h];it.compare(n,p)>0&&(n=p)}let r=n.segment.prevInResult(),u=r?r.prevInResult():null;for(;;){if(!r)return null;if(!u)return r.ringOut;if(u.ringOut!==r.ringOut)return u.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=u.prevInResult(),u=r?r.prevInResult():null}}}class On{constructor(n){this.exteriorRing=n,n.poly=this,this.interiorRings=[]}addInterior(n){this.interiorRings.push(n),n.poly=this}getGeom(){const n=[this.exteriorRing.getGeom()];if(n[0]===null)return null;for(let r=0,u=this.interiorRings.length;r<u;r++){const h=this.interiorRings[r].getGeom();h!==null&&n.push(h)}return n}}class qr{constructor(n){this.rings=n,this.polys=this._composePolys(n)}getGeom(){const n=[];for(let r=0,u=this.polys.length;r<u;r++){const h=this.polys[r].getGeom();h!==null&&n.push(h)}return n}_composePolys(n){const r=[];for(let u=0,h=n.length;u<h;u++){const c=n[u];if(!c.poly)if(c.isExteriorRing())r.push(new On(c));else{const p=c.enclosingRing();p.poly||r.push(new On(p)),p.poly.addInterior(c)}}return r}}class Zr{constructor(n){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:dt.compare;this.queue=n,this.tree=new Pe(r),this.segments=[]}process(n){const r=n.segment,u=[];if(n.consumedBy)return n.isLeft?this.queue.remove(n.otherSE):this.tree.remove(r),u;const h=n.isLeft?this.tree.add(r):this.tree.find(r);if(!h)throw new Error(`Unable to find segment #${r.id} [${r.leftSE.point.x}, ${r.leftSE.point.y}] -> [${r.rightSE.point.x}, ${r.rightSE.point.y}] in SweepLine tree.`);let c=h,p=h,g,y;for(;g===void 0;)c=this.tree.prev(c),c===null?g=null:c.key.consumedBy===void 0&&(g=c.key);for(;y===void 0;)p=this.tree.next(p),p===null?y=null:p.key.consumedBy===void 0&&(y=p.key);if(n.isLeft){let b=null;if(g){const o=g.getIntersection(r);if(o!==null&&(r.isAnEndpoint(o)||(b=o),!g.isAnEndpoint(o))){const x=this._splitSafely(g,o);for(let _=0,F=x.length;_<F;_++)u.push(x[_])}}let E=null;if(y){const o=y.getIntersection(r);if(o!==null&&(r.isAnEndpoint(o)||(E=o),!y.isAnEndpoint(o))){const x=this._splitSafely(y,o);for(let _=0,F=x.length;_<F;_++)u.push(x[_])}}if(b!==null||E!==null){let o=null;b===null?o=E:E===null?o=b:o=it.comparePoints(b,E)<=0?b:E,this.queue.remove(r.rightSE),u.push(r.rightSE);const x=r.split(o);for(let _=0,F=x.length;_<F;_++)u.push(x[_])}u.length>0?(this.tree.remove(r),u.push(n)):(this.segments.push(r),r.prev=g)}else{if(g&&y){const b=g.getIntersection(y);if(b!==null){if(!g.isAnEndpoint(b)){const E=this._splitSafely(g,b);for(let o=0,x=E.length;o<x;o++)u.push(E[o])}if(!y.isAnEndpoint(b)){const E=this._splitSafely(y,b);for(let o=0,x=E.length;o<x;o++)u.push(E[o])}}}this.tree.remove(r)}return u}_splitSafely(n,r){this.tree.remove(n);const u=n.rightSE;this.queue.remove(u);const h=n.split(r);return h.push(u),n.consumedBy===void 0&&this.tree.add(n),h}}const Dn=typeof process!="undefined"&&{}.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,Xr=typeof process!="undefined"&&{}.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class Jr{run(n,r,u){lt.type=n,Gt.reset();const h=[new Bn(r,!0)];for(let o=0,x=u.length;o<x;o++)h.push(new Bn(u[o],!1));if(lt.numMultiPolys=h.length,lt.type==="difference"){const o=h[0];let x=1;for(;x<h.length;)Fe(h[x].bbox,o.bbox)!==null?x++:h.splice(x,1)}if(lt.type==="intersection")for(let o=0,x=h.length;o<x;o++){const _=h[o];for(let F=o+1,T=h.length;F<T;F++)if(Fe(_.bbox,h[F].bbox)===null)return[]}const c=new Pe(it.compare);for(let o=0,x=h.length;o<x;o++){const _=h[o].getSweepEvents();for(let F=0,T=_.length;F<T;F++)if(c.insert(_[F]),c.size>Dn)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const p=new Zr(c);let g=c.size,y=c.pop();for(;y;){const o=y.key;if(c.size===g){const _=o.segment;throw new Error(`Unable to pop() ${o.isLeft?"left":"right"} SweepEvent [${o.point.x}, ${o.point.y}] from segment #${_.id} [${_.leftSE.point.x}, ${_.leftSE.point.y}] -> [${_.rightSE.point.x}, ${_.rightSE.point.y}] from queue.`)}if(c.size>Dn)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(p.segments.length>Xr)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const x=p.process(o);for(let _=0,F=x.length;_<F;_++){const T=x[_];T.consumedBy===void 0&&c.insert(T)}g=c.size,y=c.pop()}Gt.reset();const b=ie.factory(p.segments);return new qr(b).getGeom()}}const lt=new Jr,Kr=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return lt.run("union",m,r)},Qr=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return lt.run("intersection",m,r)},to=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return lt.run("xor",m,r)},eo=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return lt.run("difference",m,r)};var te={union:Kr,intersection:Qr,xor:to,difference:eo};const yo="datas/geojsons/hongyuan-townships-screen.geojson",no="assets/json/hongyuan-county-outline.json",xo="assets/json/中华人民共和国.json";function io(m){return`./${m}`}const ro=21,oo=-18,so=-50,Gn=-18,Hn=-58,Wn=4.2,zn=3.2,lo=2200,ao=0,uo=2600,co=0,ho={__name:"index",props:{active:{type:Boolean,default:!0},activeLayer:{type:Object,default:null},mapRanking:{type:Object,default:null},overlayLayer:{type:Object,default:null},overlayLayers:{type:Array,default:()=>[]},tileUrlTemplate:{type:String,default:"https://qkl-map.oss-cn-chengdu.aliyuncs.com/hy-result/{z}/{x}/{y}.png"},referenceTileUrlTemplate:{type:String,default:"https://map.shuxitech.com/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}"},terrainUrl:{type:String,default:""},center:{type:Array,default:()=>[...xr]},initialZoom:{type:Number,default:br},minimumZoomDistance:{type:Number,default:1},countyViewTargetOffset:{type:Object,default:null},autoApplyLayerMapView:{type:Boolean,default:!0},maxZoom:{type:Number,default:21},adminBoundaryLineScale:{type:Number,default:1},showNationalBackdrop:{type:Boolean,default:!0},enableImageryFeaturePick:{type:Boolean,default:!0},enableTownPolygonPick:{type:Boolean,default:!0},hideTownLabelStats:{type:Boolean,default:!1}},emits:["ready","scene-mounted","feature-loading","feature-info","layer-status","tile-status","map-click","draw-boundary","view-change"],setup(m,{expose:n,emit:r}){let u=[],h=null;const c=m,p=r,g=Cn(null),y=Cn(null),b=Pr(null),E=_r(()=>c.activeLayer?[c.activeLayer,...Array.isArray(c.activeLayer.overlayLayers)?c.activeLayer.overlayLayers:[]].filter(Boolean):c.overlayLayers.length?c.overlayLayers.filter(Boolean):c.overlayLayer?[c.overlayLayer]:[]);let o=null,x=null,_=null,F=null,T=null,R=!1,I=0,M=null,D=!1,k=[],v=null,B=[],Y=[],G=[],q=[],U=[],Z=[],H=null,j=[],rt=[];const xt=new Map;let bt=null,ct=[],Vn=[];const re=new Map;Er(()=>{p("scene-mounted"),c.active&&Wt()}),Nr(()=>At()),Qt(E,()=>Oe(),{deep:!0}),Qt(()=>c.mapRanking,()=>ae(),{deep:!0}),Qt(()=>c.hideTownLabelStats,()=>ae()),Qt(()=>c.active,t=>mt(this,null,function*(){if(!t){At();return}yield Nn(),Wt()}));function Wt(){var w,S,C,N;if(o||!y.value)return!!o;const t=window.Cesium;if(!t)return p("layer-status",{type:"error",text:"Cesium 运行资源加载失败"}),!1;R=!1;const e=Yn(t),i=Me(c.tileUrlTemplate),l=Me(c.referenceTileUrlTemplate),a=jn(i),s=l&&l!==i?Ie(t,l,{maximumLevel:c.maxZoom}):null,f=i?Ie(t,i,{maximumLevel:a?Math.min(c.maxZoom,ro):c.maxZoom,rectangle:a?$n(t):null}):null;if(o=new t.Viewer(y.value,{animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,navigationHelpButton:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,scene3DOnly:!0,imageryProvider:!1,terrainProvider:e,useBrowserRecommendedResolution:!1,requestRenderMode:!0,maximumRenderTimeChange:1/0,contextOptions:{webgl:{alpha:!0,antialias:!0}}}),ve(!1),s){const P=o.imageryLayers.addImageryProvider(s);P.alpha=1,P.brightness=.68,P.contrast=1.08,P.saturation=.48,P.gamma=.9}f&&(v=o.imageryLayers.addImageryProvider(f),v.alpha=a?.88:1,v.brightness=a?.96:.9,v.contrast=a?1.12:1.1,v.saturation=a?1.08:1.05,v.gamma=a?.98:.96),o.scene.globe.terrainExaggeration=c.terrainUrl?1.5:1,o.scene.globe.depthTestAgainstTerrain=!1,o.scene.globe.baseColor=t.Color.fromCssColorString("#061821"),o.scene.backgroundColor=t.Color.fromCssColorString("#020b12"),o.scene.skyAtmosphere.show=!1,o.scene.skyBox&&(o.scene.skyBox.show=!1),o.scene.fog.enabled=!0,o.scene.fog.density=18e-5,o.resolutionScale=Math.min(Math.max(window.devicePixelRatio||1,1),1.5),o.scene.fxaa=!1,o.scene.postProcessStages.fxaa.enabled=!1,o.scene.screenSpaceCameraController.enableCollisionDetection=!0,o.scene.screenSpaceCameraController.minimumZoomDistance=Math.max(1,Number(c.minimumZoomDistance)||1),o.scene.screenSpaceCameraController.maximumZoomDistance=56e4,(w=o.cesiumWidget)!=null&&w.creditContainer&&(o.cesiumWidget.creditContainer.style.display="none"),(S=o._cesiumWidget)!=null&&S._creditContainer&&(o._cesiumWidget._creditContainer.style.display="none"),Jn(e,t),Re().then(()=>{var P;!o||(P=o.isDestroyed)!=null&&P.call(o)||(Ri(),se())}).catch(P=>{console.warn("[cesium-map] county outline load failed",P),p("layer-status",{type:"error",text:"红原县边界加载失败"})}),Fi(),Oi(),li(),ai(),ui(),se(),Oe(),ae();const d={viewer:o,clearSelectedFeature:et,focusProject:tn,focusPasture:on,focusTownByName:Qe,focusYakIndustryPoint:en,focusVectorFeature:nn,getVectorFeatureAnchorScreen:rn,getVectorFeaturesAnchorScreen:qt,getVectorFeatureScreen:Mt,getYakIndustryPointScreen:me,destroy:At};return b.value=d,(N=(C=f==null?void 0:f.errorEvent)==null?void 0:C.addEventListener)==null||N.call(C,()=>{p("tile-status",{type:"warning",text:"牧场影像底图部分瓦片加载失败"})}),p("tile-status",{type:"success",text:"牧场影像底图已加载"}),window.setTimeout(()=>{var P;o&&!((P=o.isDestroyed)!=null&&P.call(o))&&p("ready")},0),Nn(zt),!0}function Yn(t){if(!c.terrainUrl)return new t.EllipsoidTerrainProvider;try{return new t.CesiumTerrainProvider({url:c.terrainUrl,requestVertexNormals:!0,requestWaterMask:!1})}catch(e){return R=!0,new t.EllipsoidTerrainProvider}}function Ie(t,e,i={}){return e?new t.UrlTemplateImageryProvider({url:e,minimumLevel:i.minimumLevel||3,maximumLevel:i.maximumLevel||c.maxZoom,rectangle:i.rectangle||void 0,tilingScheme:new t.WebMercatorTilingScheme,credit:""}):null}function Me(t){return String(t||"").trim()}function jn(t){return/hy-result|qkl-map/i.test(String(t||""))}function $n(t){return t.Rectangle.fromDegrees(z.west-.035,z.south-.035,z.east+.035,z.north+.035)}function qn(t,e="feature"){const i=[];if(((t==null?void 0:t.features)||[]).forEach(l=>{const a=W(l==null?void 0:l.geometry);ze(a).forEach(s=>{const f=Zn(s);f&&i.push(f)})}),!i.length)return[];try{return te.union(...i)}catch(l){return console.warn(`[cesium-map] ${e} union boundary failed`,l),i.map(a=>a)}}function Re(){return mt(this,null,function*(){return u.length?u:(h||(h=Vt(no).then(t=>{const e=qn(t,"county outline");return u=e,e}).catch(t=>{throw h=null,t})),h)})}function Zn(t){if(!Array.isArray(t))return null;const e=t.map(i=>Xn((i||[]).map($).filter(Boolean))).filter(i=>i.length>=4);return e.length?e:null}function Xn(t=[]){if(!t.length)return[];const e=t[0],i=t[t.length-1];return Ue(e,i)?t:[...t,e]}function Jn(t,e){var l,a,s,f;const i=()=>{!o||R||(R=!0,o.terrainProvider=new e.EllipsoidTerrainProvider,o.scene.globe.terrainExaggeration=1,o.scene.requestRender(),p("layer-status",{type:"warning",text:"CXPT 地形服务暂不可用,已保留三维影像地图"}))};(a=(l=t==null?void 0:t.errorEvent)==null?void 0:l.addEventListener)==null||a.call(l,i),(f=(s=t==null?void 0:t.readyPromise)==null?void 0:s.catch)==null||f.call(s,i)}function Kn(){return Wt()}function Qn(){var t;return!!(o&&!((t=o.isDestroyed)!=null&&t.call(o)))}function ti(){ke()}function ke(){if(!o){Wt();return}o.useDefaultRenderLoop=!0,zt()}function ei(){At()}function zt(){var t;!o||(t=o.isDestroyed)!=null&&t.call(o)||(o.resize(),o.scene.requestRender())}function Le(){if(!(o!=null&&o.camera)||!window.Cesium)return null;const t=window.Cesium,e=o.camera;return{position:t.Cartesian3.clone(e.positionWC||e.position),direction:t.Cartesian3.clone(e.directionWC||e.direction),up:t.Cartesian3.clone(e.upWC||e.up)}}function Ut(t){var i,l,a,s,f,d;if(!(o!=null&&o.camera)||!t||!window.Cesium)return;const e=window.Cesium;(l=(i=o.camera).cancelFlight)==null||l.call(i),(s=(a=o.camera).lookAtTransform)==null||s.call(a,e.Matrix4.IDENTITY),o.camera.setView({destination:e.Cartesian3.clone(t.position),orientation:{direction:e.Cartesian3.clone(t.direction),up:e.Cartesian3.clone(t.up)}}),(d=(f=o.scene)==null?void 0:f.requestRender)==null||d.call(f)}function Ae(t){var e,i;!t||typeof window=="undefined"||((e=window.requestAnimationFrame)==null||e.call(window,()=>Ut(t)),(i=window.setTimeout)==null||i.call(window,()=>Ut(t),80))}function ni(){et(),ve(!0)}function ii(t=E.value.find(e=>(e==null?void 0:e.mapView)||(e==null?void 0:e.cameraPosition))){return!o||!t?!1:(un(t),!0)}function ve(t=!0){if(!o)return;const e=window.Cesium,i=si(),l=Be(c.initialZoom),a=ri(),s=e.Cartesian3.fromDegrees(i[0]+a.lng,i[1]+a.lat,oi()),f=new e.HeadingPitchRange(e.Math.toRadians(oo),e.Math.toRadians(so),l);t?o.camera.flyToBoundingSphere(new e.BoundingSphere(s,1),{offset:f,duration:.9}):(o.camera.lookAt(s,f),o.camera.lookAtTransform(e.Matrix4.IDENTITY)),o.scene.requestRender()}function ri(){var l,a;const t=c.countyViewTargetOffset,e=Number((l=t==null?void 0:t.lng)!=null?l:t==null?void 0:t[0]),i=Number((a=t==null?void 0:t.lat)!=null?a:t==null?void 0:t[1]);return{lng:Number.isFinite(e)?e:0,lat:Number.isFinite(i)?i:wr.lat}}function oi(){return c.terrainUrl?lo:ao}function oe(){return c.terrainUrl?uo:co}function Be(t){const e=Number.isFinite(Number(t))?Number(t):9;return Math.max(9e3,Math.min(58e4,365e3/Math.pow(1.62,e-9)))}function si(){const t=$(c.center);return t||[(z.west+z.east)/2,(z.south+z.north)/2]}function li(){!g.value||!window.ResizeObserver||(_=new ResizeObserver(()=>zt()),_.observe(g.value))}function ai(){!o||F||(F=o.camera.moveEnd.addEventListener(se))}function ui(){!o||T||(T=o.scene.postRender.addEventListener(()=>{p("view-change")}))}function se(){var l,a;if(!o||(l=o.isDestroyed)!=null&&l.call(o))return;const t=Number((a=o.camera.positionCartographic)==null?void 0:a.height)||32e4,e=Math.max(0,Math.min(1,(36e4-t)/3e5)),i={township:1.1+e*.35,countyOutline:1.9+e*.35,countyHalo:4.2+e*.65};Y.forEach(s=>{s!=null&&s.polyline&&s.__hyBoundaryRole==="township"&&(s.polyline.width=i.township)}),ct.forEach(s=>{s!=null&&s.polyline&&s.__hyBoundaryRole==="county-outline"&&(s.polyline.width=i.countyOutline),s!=null&&s.polyline&&s.__hyBoundaryRole==="county-halo"&&(s.polyline.width=i.countyHalo)}),o.scene.requestRender()}function Oe(){return mt(this,null,function*(){var i,l;if(!o)return;const t=++I;bn();const e=E.value;if(!e.length){p("layer-status",{type:"idle",text:"未选择专题图层"}),o.scene.requestRender();return}p("layer-status",{type:"loading",text:"正在加载三维专题图层"});try{if(yield Re(),t!==I||!o)return;for(const a of e){if(t!==I)return;yield ci(a,t)}if(t!==I)return;c.autoApplyLayerMapView&&un(e.find(a=>(a==null?void 0:a.mapView)||(a==null?void 0:a.cameraPosition))),p("layer-status",{type:"success",text:`${e.map(a=>a.name).filter(Boolean).join("、")}已加载`})}catch(a){if(t!==I)return;console.warn("[cesium-map] topic layer failed",a),p("layer-status",{type:"error",text:"三维专题图层加载失败"})}finally{(l=(i=o==null?void 0:o.scene)==null?void 0:i.requestRender)==null||l.call(i)}})}function ci(t,e){return mt(this,null,function*(){const i=String((t==null?void 0:t.sourceType)||"wms").toLowerCase();if(i!=="analysis"){if(["geojson","wkt-api","wfs"].includes(i)){const l=yield pi(t);if(e!==I||!l)return;xi(l,t,G);return}if(i==="wmts"){hi(t);return}mi(t)}})}function hi(t){const e=window.Cesium,i=t.tileMatrixSetID||t.tileMatrixSet||"EPSG:900913",l=Number.isFinite(Number(t.maximumLevel))?Number(t.maximumLevel):21,a=new e.WebMapTileServiceImageryProvider({url:t.url||"/geoserver/gwc/service/wmts",layer:t.layerName,style:t.style||t.styles||"",format:t.format||"image/png",tileMatrixSetID:i,tileMatrixLabels:t.tileMatrixLabels||fi(i,l),tilingScheme:/4326/i.test(i)?new e.GeographicTilingScheme:new e.WebMercatorTilingScheme,maximumLevel:l,credit:t.credit||""}),s=o.imageryLayers.addImageryProvider(a),f=String(t.layerName||"").includes("daping_yak_marks");s.alpha=f?Et(t.opacity,.94):Et(t.opacity,.86),f&&De(s,t),s.__hyLayer=t,B.push(s)}function fi(t,e=21){return Array.from({length:e+1},(i,l)=>`${t}:${l}`)}function mi(t){const e=window.Cesium,i={service:"WMS",transparent:!0,format:"image/png",version:"1.1.1",styles:t.styles||""};t.cqlFilter&&(i.cql_filter=t.cqlFilter),t.sldBody&&(i.sld_body=t.sldBody);const l=new e.WebMapServiceImageryProvider({url:t.url||"/geoserver/ne/wms",layers:t.layerName,parameters:i,getFeatureInfoParameters:Ct(st({},i),{info_format:"application/json",feature_count:10})}),a=o.imageryLayers.addImageryProvider(l),s=String(t.layerName||"").includes("daping_yak_marks");a.alpha=s?Et(t.opacity,.94):Et(t.opacity,.86),s&&De(a,t),a.__hyLayer=t,B.push(a)}function De(t,e={}){t.brightness=Number.isFinite(Number(e.brightness))?Number(e.brightness):1.08,t.contrast=Number.isFinite(Number(e.contrast))?Number(e.contrast):1.18,t.saturation=Number.isFinite(Number(e.saturation))?Number(e.saturation):1.42,t.gamma=Number.isFinite(Number(e.gamma))?Number(e.gamma):.95}function pi(t){return mt(this,null,function*(){if(t.sourceType==="wkt-api")try{const e=yield fetch(t.apiUrl,{credentials:"same-origin"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return yi(yield e.json())}catch(e){if(!t.fallbackPath)throw e;return Vt(t.fallbackPath)}if(t.sourceType==="wfs"){const e=gi(t);return Vt(e)}return Vt(t.dataPath||t.fallbackPath)})}function Vt(t){return mt(this,null,function*(){if(!t)return null;const e=/^(https?:)?\/\//.test(t)||t.startsWith("/")?t:io(t),i=yield fetch(e,{credentials:"same-origin"});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()})}function gi(t){const e=new URLSearchParams({service:"WFS",version:"1.1.0",request:"GetFeature",typeName:t.layerName,outputFormat:"application/json",srsName:"EPSG:4326"});return t.cqlFilter&&e.set("cql_filter",t.cqlFilter),t.maxFeatures&&e.set("maxFeatures",String(t.maxFeatures)),Array.isArray(t.propertyName)&&t.propertyName.length?e.set("propertyName",t.propertyName.join(",")):t.propertyName&&e.set("propertyName",t.propertyName),`${t.url||"/geoserver/ne/wfs"}?${e.toString()}`}function di(t,e={},i=null,l=null){var w,S,C;const a=((w=t==null?void 0:t.data)==null?void 0:w.type)==="Feature"?t.data:((C=(S=t==null?void 0:t.data)==null?void 0:S.features)==null?void 0:C[0])||(t==null?void 0:t.feature)||null,s=(a==null?void 0:a.properties)||e||{},f=W((a==null?void 0:a.geometry)||s.geometry||s.geom||s.the_geom||s.theGeom||s.wkt||s.shape),d=(a==null?void 0:a.id)||s.id||s.gid||s.objectid||s.OBJECTID||(t==null?void 0:t.name);return{type:"Feature",id:d,properties:s,feature:{type:"Feature",id:d,properties:s,geometry:f},geometry:f,layer:i,lngLat:l}}function yi(t){var l;const e=(l=t==null?void 0:t.data)!=null?l:t;return{type:"FeatureCollection",features:(Array.isArray(e)?e:(e==null?void 0:e.rows)||(e==null?void 0:e.list)||(e==null?void 0:e.records)||(e==null?void 0:e.data)||[]).map((a,s)=>{var f;return{type:"Feature",id:(f=a==null?void 0:a.id)!=null?f:s,properties:st({},a),geometry:W(a==null?void 0:a.geometry)||de(Ge(a))}}).filter(a=>a.geometry)}}function Ge(t={}){return t.wkt||t.WKT||t.geom||t.the_geom||t.theGeom||t.shape||t.Shape}function xi(t,e,i){((t==null?void 0:t.type)==="FeatureCollection"?t.features:(t==null?void 0:t.type)==="Feature"?[t]:[]).filter(a=>a==null?void 0:a.geometry).filter(a=>Ti(a.properties||{},e)).map(a=>bi(a,e)).filter(Boolean).forEach(a=>wt(a,e,i))}function bi(t,e){const i=W(t==null?void 0:t.geometry),l=(e==null?void 0:e.clipToHongyuanBoundary)===!0,a=wi(e);if(!i||!["Polygon","MultiPolygon"].includes(i.type)||!l&&!a)return t;let s=i.type==="Polygon"?[i.coordinates]:i.coordinates;try{l&&u.length&&(s=te.intersection(s,u)),a&&s.length&&(s=te.intersection(s,[Si(a)]))}catch(f){return console.warn("[cesium-map] vector layer clipping failed",e==null?void 0:e.key,f),t}return s.length?Ct(st({},t),{geometry:{type:"MultiPolygon",coordinates:s}}):null}function wi(t){if(!(t!=null&&t.clipBounds)||t.clipToLayerBounds===!1)return null;const e=t.clipBounds,i=Math.max(Number(e.west),z.west),l=Math.max(Number(e.south),z.south),a=Math.min(Number(e.east),z.east),s=Math.min(Number(e.north),z.north);return![i,l,a,s].every(Number.isFinite)||i>=a||l>=s?null:{west:i,south:l,east:a,north:s}}function Si(t){return[[[t.west,t.south],[t.east,t.south],[t.east,t.north],[t.west,t.north],[t.west,t.south]]]}function wt(t,e,i,l={}){const a=W(t.geometry);if(!a)return[];const s=Ni(e,t.properties||{},l),f=Yt(a,t,e,s);return i.push(...f),f}function Yt(t,e,i,l){const a=window.Cesium,s=[],f=d=>{const w=o.entities.add(d);return w.__hyFeature=e,w.__hyLayer=i,s.push(w),w};if(t.type==="Point"){const d=$(t.coordinates);return!d||i.hidePointFeatures||i.hidePointMarkers||f({position:a.Cartesian3.fromDegrees(d[0],d[1],8),point:{pixelSize:l.pointSize,color:l.fill,outlineColor:l.stroke,outlineWidth:2,heightReference:a.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY},label:i.showPointLabels?Ei(e):void 0}),s}if(t.type==="MultiPoint")return t.coordinates.forEach(d=>s.push(...Yt({type:"Point",coordinates:d},e,i,l))),s;if(t.type==="LineString"){const d=at(t.coordinates);return d.length<2||f({polyline:{positions:d,width:l.lineWidth,material:new a.PolylineGlowMaterialProperty({glowPower:.16,color:l.stroke}),clampToGround:!0}}),s}if(t.type==="MultiLineString")return t.coordinates.forEach(d=>s.push(...Yt({type:"LineString",coordinates:d},e,i,l))),s;if(t.type==="Polygon"){const d=Pt(t.coordinates);return d&&(f({polygon:{hierarchy:d,height:0,heightReference:a.HeightReference.CLAMP_TO_GROUND,perPositionHeight:!1,material:l.fill,outline:!1,classificationType:a.ClassificationType.BOTH}}),_i(t.coordinates,e,i,l,s)),s}return t.type==="MultiPolygon"&&t.coordinates.forEach(d=>s.push(...Yt({type:"Polygon",coordinates:d},e,i,l))),s}function _i(t,e,i,l,a){t.forEach(s=>{const f=at(s);if(f.length<2)return;const d=o.entities.add({polyline:{positions:f,width:l.lineWidth,material:l.stroke,depthFailMaterial:l.stroke,clampToGround:!0}});d.__hyFeature=e,d.__hyLayer=i,a.push(d)})}function Pt(t=[]){const e=window.Cesium,i=at(t[0]||[]);if(i.length<3)return null;const l=t.slice(1).map(a=>{const s=at(a);return s.length>=3?new e.PolygonHierarchy(s):null}).filter(Boolean);return new e.PolygonHierarchy(i,l)}function Ei(t,e){const i=window.Cesium,l=t.properties||{},a=l.name||l.project_name||l.title||"";if(a)return{text:String(a),font:"600 14px PingFang SC, Microsoft YaHei, sans-serif",fillColor:i.Color.WHITE,outlineColor:i.Color.fromCssColorString("#03121e"),outlineWidth:3,style:i.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new i.Cartesian2(0,-22),heightReference:i.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,distanceDisplayCondition:new i.DistanceDisplayCondition(0,15e4)}}function Ni(t,e,i={}){var N,P,L,O,A,X,tt,nt,ft;const l=window.Cesium,a=Ci(t,e),s=Et(t.opacity,.84),f=i.fillColor||(a==null?void 0:a.fillColor)||t.fillColor||t.color||"#24F6C4",d=i.strokeColor||(a==null?void 0:a.strokeColor)||t.strokeColor||t.color||"#B7FFF2",w=(L=(P=(N=i.fillAlpha)!=null?N:a==null?void 0:a.fillAlpha)!=null?P:t.fillAlpha)!=null?L:Math.min(.34,s*.34),S=(X=(A=(O=i.strokeAlpha)!=null?O:a==null?void 0:a.strokeAlpha)!=null?A:t.strokeAlpha)!=null?X:Math.max(.72,s),C=(ft=(nt=(tt=i.lineWidth)!=null?tt:a==null?void 0:a.lineWidth)!=null?nt:t.lineWidth)!=null?ft:Math.max(1.6,1.8*Number(c.adminBoundaryLineScale||1));return{fill:le(l,f,w),stroke:le(l,d,S),lineWidth:C,pointSize:i.pointSize||12}}function le(t,e,i){try{return t.Color.fromCssColorString(String(e||"#24F6C4")).withAlpha(Et(i,1))}catch(l){return t.Color.CYAN.withAlpha(Et(i,1))}}function Ci(t,e){var i;return t!=null&&t.activeLegend?t.activeLegend:((t==null?void 0:t.legends)||[]).find(l=>He(e,l))||((i=t==null?void 0:t.legends)==null?void 0:i[0])}function Ti(t,e){const i=e==null?void 0:e.activeLegend;return i?He(t,i):!0}function He(t,e={}){return e.match?We(t,e.match):Array.isArray(e.matches)?e.matches.some(i=>We(t,i)):!0}function We(t,e={}){var i,l;return String((i=t==null?void 0:t[e.field])!=null?i:"")===String((l=e.value)!=null?l:"")}function Fi(){if(!o)return;V(Y);const t=window.Cesium,e={stroke:t.Color.fromCssColorString("#B8FFF8").withAlpha(.82),fill:t.Color.TRANSPARENT,lineWidth:1.2,pointSize:0};Pi(we.features||[]).forEach(i=>{var s;const l=at(i.points);if(l.length<2)return;const a=o.entities.add({polyline:{positions:l,width:e.lineWidth,material:e.stroke,depthFailMaterial:e.stroke,clampToGround:!0,zIndex:7}});a.__hyBoundaryRole="township",a.__hyTownName=((s=i.townNames)==null?void 0:s[0])||"",Y.push(a)}),o.scene.requestRender()}function Pi(t=[]){const e=new Map;t.forEach(l=>{var f;const a=String(((f=l==null?void 0:l.properties)==null?void 0:f.name)||"").trim(),s=W(l==null?void 0:l.geometry);ze(s).forEach(d=>{const w=((d==null?void 0:d[0])||[]).map($).filter(Boolean);for(let S=0;S<w.length-1;S+=1){const C=w[S],N=w[S+1];if(!C||!N||Ue(C,N))continue;const P=Ii(C,N),L=e.get(P)||{points:[C,N],count:0,townNames:new Set};L.count+=1,a&&L.townNames.add(a),e.set(P,L)}})});const i=Array.from(e.values()).map(l=>Ct(st({},l),{townNames:Array.from(l.townNames)})).filter(l=>l.count>1&&l.townNames.length>1);return Mi(i)}function ze(t){return t!=null&&t.coordinates?t.type==="Polygon"?[t.coordinates]:t.type==="MultiPolygon"?t.coordinates:[]:[]}function Ii(t,e){const i=It(t),l=It(e);return i<l?`${i}|${l}`:`${l}|${i}`}function It(t){return`${Number(t[0]).toFixed(5)},${Number(t[1]).toFixed(5)}`}function Ue(t,e){return Math.abs(Number(t[0])-Number(e[0]))<1e-10&&Math.abs(Number(t[1])-Number(e[1]))<1e-10}function Mi(t=[]){const e=new Map;t.forEach((a,s)=>{a.points.forEach(f=>{const d=It(f),w=e.get(d)||[];w.push(s),e.set(d,w)})});const i=new Set,l=[];return t.forEach((a,s)=>{if(i.has(s))return;i.add(s);const f=[a.points[0],a.points[1]];Ve(f,e,t,i,!0),Ve(f,e,t,i,!1),l.push({points:f,townNames:a.townNames})}),l}function Ve(t,e,i,l,a){for(;t.length;){const s=a?t[0]:t[t.length-1],f=It(s),d=(e.get(f)||[]).filter(L=>!l.has(L));if(d.length!==1)return;const w=d[0],S=i[w];l.add(w);const[C,N]=S.points,P=It(C)===f?N:C;a?t.unshift(P):t.push(P)}}function Ri(){if(!o||!u.length)return;V(ct);const t=window.Cesium;ki(t),u.forEach(e=>{const l=(Array.isArray(e==null?void 0:e[0])?e[0]:[]).map($).filter(Boolean);if(l.length<3)return;const a=Pt(e);if(a){const d=o.entities.add({polygon:{hierarchy:a,material:t.Color.fromCssColorString("#20EAF2").withAlpha(.026),outline:!1,perPositionHeight:!1,heightReference:t.HeightReference.CLAMP_TO_GROUND,classificationType:t.ClassificationType.BOTH}});ct.push(d)}const s=o.entities.add({polyline:{positions:at(l),width:4.8,material:new t.PolylineGlowMaterialProperty({glowPower:.16,color:t.Color.fromCssColorString("#78FFF7").withAlpha(.48)}),depthFailMaterial:t.Color.fromCssColorString("#78FFF7").withAlpha(.32),clampToGround:!0,zIndex:8}});s.__hyBoundaryRole="county-halo";const f=o.entities.add({polyline:{positions:at(l),width:1.9,material:t.Color.fromCssColorString("#F2FFFB").withAlpha(.98),depthFailMaterial:t.Color.fromCssColorString("#F2FFFB").withAlpha(.9),clampToGround:!0,zIndex:9}});f.__hyBoundaryRole="county-outline",ct.push(s,f)}),o.scene.requestRender()}function ki(t){const e=Li();let i=[];try{i=te.difference([e],u)}catch(l){console.warn("[cesium-map] county outside mask failed",l),i=[e]}i.forEach(l=>{const a=Pt(l);if(!a)return;const s=o.entities.add({polygon:{hierarchy:a,material:t.Color.fromCssColorString("#020A10").withAlpha(.52),outline:!1,perPositionHeight:!1,heightReference:t.HeightReference.CLAMP_TO_GROUND,classificationType:t.ClassificationType.BOTH,zIndex:1}});ct.push(s)})}function Li(){const t=z.west-Wn,e=z.south-zn,i=z.east+Wn,l=z.north+zn;return[[[t,e],[i,e],[i,l],[t,l],[t,e]]]}function Ai(t,e=!1){const i=(Array.isArray(t)?t:[t]).map(Bt=>String(Bt||"").trim()).filter(Boolean).slice(0,2),l=`v15-centered-map-badge:${e?"h":"n"}:${i.join("|")}`;if(re.has(l))return re.get(l);const a=document.createElement("canvas"),s=a.getContext("2d");if(!s)return{image:"",width:1,height:1};const f=Math.min(4,Math.max(3,window.devicePixelRatio||2)),d="700 14px Microsoft YaHei, PingFang SC, sans-serif",w="700 9px Microsoft YaHei, PingFang SC, sans-serif",S="800 14px Microsoft YaHei, PingFang SC, sans-serif",C="600 9px Microsoft YaHei, PingFang SC, sans-serif",N=Bi(i[1]);s.font=d;const P=Math.ceil(s.measureText(i[0]||"").width);let L=0;N&&(s.font=w,L+=Math.ceil(s.measureText(N.metric).width),s.font=S,L+=Math.ceil(s.measureText(N.value).width),s.font=C,L+=Math.ceil(s.measureText(N.unit).width),L+=N.metric?5:0,L+=N.unit?4:0);const O=Math.min(118,Math.max(N?96:62,P+20,L+20)),A=N?40:25,X=N?5:0,tt=6,nt=O+tt*2,ft=A+X+tt*2;a.width=Math.ceil(nt*f),a.height=Math.ceil(ft*f),a.style.width=`${nt}px`,a.style.height=`${ft}px`,s.scale(f,f),s.clearRect(0,0,nt,ft);const J=tt,ot=tt,Tt=ot+A,Nt=s.createLinearGradient(J,ot,J,Tt);Nt.addColorStop(0,e?"rgba(8, 58, 70, 0.9)":"rgba(6, 45, 57, 0.78)"),Nt.addColorStop(.55,e?"rgba(4, 34, 46, 0.88)":"rgba(3, 29, 41, 0.76)"),Nt.addColorStop(1,e?"rgba(2, 22, 32, 0.88)":"rgba(2, 18, 29, 0.78)"),s.save(),s.shadowColor="rgba(48, 220, 255, 0.13)",s.shadowBlur=6,s.fillStyle=Nt,Ye(s,J,ot,O,A),s.fill(),s.restore(),s.save(),s.globalCompositeOperation="lighter";const Kt=s.createLinearGradient(J,ot,J+O,ot);Kt.addColorStop(0,"rgba(42, 210, 255, 0)"),Kt.addColorStop(.5,e?"rgba(98, 246, 255, 0.34)":"rgba(98, 246, 255, 0.26)"),Kt.addColorStop(1,"rgba(42, 210, 255, 0)"),s.strokeStyle=Kt,s.lineWidth=1,s.beginPath(),s.moveTo(J+10,ot+2),s.lineTo(J+O-10,ot+2),s.stroke(),s.restore(),s.save(),s.strokeStyle=e?"rgba(126, 251, 246, 0.58)":"rgba(126, 251, 246, 0.46)",s.lineWidth=.9,Ye(s,J+.5,ot+.5,O-1,A-1),s.stroke(),s.restore();const vt=J+O/2;X>0&&(s.save(),s.shadowColor="rgba(48, 220, 255, 0.2)",s.shadowBlur=5,s.beginPath(),s.moveTo(vt-5,Tt-1),s.lineTo(vt+5,Tt-1),s.lineTo(vt,Tt+X),s.closePath(),s.fillStyle=e?"rgba(4, 42, 52, 0.98)":"rgba(3, 31, 43, 0.96)",s.fill(),s.strokeStyle=e?"rgba(126, 251, 246, 0.48)":"rgba(126, 251, 246, 0.34)",s.lineWidth=.8,s.stroke(),s.restore()),s.save(),s.textAlign="center",s.textBaseline="alphabetic",s.fillStyle="rgba(255, 255, 255, 0.98)",s.strokeStyle="rgba(0, 8, 14, 0.98)",s.lineJoin="round",s.shadowColor="rgba(0, 8, 14, 0.72)",s.shadowBlur=0,s.font=d,s.lineWidth=1.6;const fr=ot+(N?12.5:A/2);if(jt(s,i[0]||"",vt,fr),N){const Bt=ot+29.5;let Ot=vt-L/2;s.textAlign="left",s.shadowBlur=0,s.font=w,s.lineWidth=1.2,s.fillStyle="rgba(126, 251, 246, 0.9)",N.metric&&(jt(s,N.metric,Ot,Bt,{stroke:!1}),s.font=w,Ot+=Math.ceil(s.measureText(N.metric).width)+5),s.font=S,s.lineWidth=1.4,s.fillStyle="#FFFFFF",s.shadowColor="rgba(0, 8, 14, 0.72)",s.shadowBlur=0,jt(s,N.value,Ot,Bt),s.shadowBlur=0,Ot+=Math.ceil(s.measureText(N.value).width)+(N.unit?4:0),N.unit&&(s.font=C,s.fillStyle="rgba(232, 252, 255, 0.76)",jt(s,N.unit,Ot,Bt+1,{stroke:!1}))}s.restore();const wn={image:a.toDataURL("image/png"),width:nt,height:ft};return re.set(l,wn),wn}function jt(t,e,i,l,a={}){const s=t.measureText(e),f=vi(t.font),d=Number(s.actualBoundingBoxAscent)||f*.74,w=Number(s.actualBoundingBoxDescent)||f*.18,S=l+(d-w)/2;a.stroke!==!1&&t.lineWidth>0&&t.strokeText(e,i,S),t.fillText(e,i,S)}function vi(t){const e=String(t||"").match(/(\d+(?:\.\d+)?)px/);return e?Number(e[1]):14}function Bi(t){const e=String(t||"").trim();if(!e)return null;const i=e.match(/^(.+?)\s+([+-]?\d[\d,.]*)(.*)$/u);if(i)return{metric:i[1].trim(),value:i[2].trim(),unit:i[3].trim()};const l=e.match(/^(.*?)([+-]?\d[\d,.]*)([\u4e00-\u9fa5A-Za-z/%]+)?$/u);return l?{metric:l[1].trim(),value:l[2].trim(),unit:(l[3]||"").trim()}:{metric:"",value:e,unit:""}}function Ye(t,e,i,l,a){const s=Math.min(7,l*.12,a*.34);t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+l-s,i),t.lineTo(e+l,i+s),t.lineTo(e+l,i+a-s),t.lineTo(e+l-s,i+a),t.lineTo(e+s,i+a),t.lineTo(e,i+a-s),t.lineTo(e,i+s),t.closePath()}function ae(){var f;if(!o)return;V(q);const t=window.Cesium,e=c.mapRanking||{},i=Array.isArray(e.rows)?e.rows:[],l=new Map(i.map(d=>[ht(d.name),d])),a=e.showTownNames!==!1&&e.hideTownNames!==!0,s=(f=e.hideTownLabelStats)!=null?f:c.hideTownLabelStats;a&&En.forEach(d=>{const w=l.get(ht(d.name)),S=[d.name];if(!s&&w&&e.showMapLabels!==!1){const O=e.metricLabel?`${e.metricLabel} `:"";S.push(`${O}${hr(w.value)}${w.unit||e.unit||""}`)}const C=$(d.center);if(!C)return;const N=Ai(S,!!w),P=!!(s||S.length===1),L=o.entities.add({position:t.Cartesian3.fromDegrees(C[0],C[1],18),billboard:{image:N.image,width:N.width,height:N.height,scale:1,verticalOrigin:P?t.VerticalOrigin.CENTER:t.VerticalOrigin.BOTTOM,horizontalOrigin:t.HorizontalOrigin.CENTER,pixelOffset:P?new t.Cartesian2(0,0):new t.Cartesian2(0,-4),heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new t.NearFarScalar(2e4,.94,36e4,.8),distanceDisplayCondition:new t.DistanceDisplayCondition(0,42e4)}});L.__hyTownName=d.name,L.__hyRankingRow=w||null,q.push(L)}),i.filter(d=>_t(d)).forEach(d=>{const w=_t(d),S=o.entities.add({position:t.Cartesian3.fromDegrees(w[0],w[1],16),point:{pixelSize:9,color:t.Color.fromCssColorString("#35F3FF"),outlineColor:t.Color.WHITE,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY},label:e.showPointMarkers===!1?void 0:{text:String(d.name||""),font:"600 12px PingFang SC, Microsoft YaHei, sans-serif",fillColor:t.Color.WHITE,outlineColor:t.Color.fromCssColorString("#03121e"),outlineWidth:3,style:t.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new t.Cartesian2(0,-18),heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}});S.__hyTownName=d.name,S.__hyRankingRow=d,q.push(S)}),o.scene.requestRender()}function Oi(){if(!o)return;const t=window.Cesium;x=new t.ScreenSpaceEventHandler(o.scene.canvas),x.setInputAction(e=>mt(this,null,function*(){var C,N,P;const i=Di(e.position),l=Gi(i);if(!l)return;const a=t.Cartographic.fromCartesian(l),s={lng:t.Math.toDegrees(a.longitude),lat:t.Math.toDegrees(a.latitude),height:a.height},f=je(i);if(D){Yi(s);return}p("map-click",{lngLat:s,screen:f,overlayLayer:E.value[0]||null});const d=o.scene.pick(i),w=d==null?void 0:d.id,S=er(s,f)||w;if(S!=null&&S.__hyFeature){ue(S),p("feature-info",{feature:{id:S.__hyFeature.id,properties:S.__hyFeature.properties||{},feature:S.__hyFeature,geometry:S.__hyFeature.geometry||null,layer:S.__hyLayer,lngLat:s},screen:f});return}if(!(c.enableTownPolygonPick&&(w!=null&&w.__hyTownName)&&fe(w.__hyTownName))){if(c.enableTownPolygonPick){const L=zi(s);if(L&&fe((C=L.properties)==null?void 0:C.name))return}if(c.enableImageryFeaturePick&&B.length){p("feature-loading",!0);try{const L=o.camera.getPickRay(i),O=yield o.imageryLayers.pickImageryLayerFeatures(L,o.scene),A=O==null?void 0:O[0];if(A){const X=B.find(Tt=>{var Nt;return Tt.imageryProvider===((Nt=A.imageryLayer)==null?void 0:Nt.imageryProvider)})||B[B.length-1],tt=(X==null?void 0:X.__hyLayer)||E.value[0],nt=A.properties||((N=A.data)==null?void 0:N.properties)||A.data||{},J=di(A,nt,tt,s);Je(J)||et(),p("feature-info",{feature:{id:J.id||nt.id||nt.fid||A.name,properties:J.properties||nt,feature:J.feature||A,geometry:J.geometry||((P=J.feature)==null?void 0:P.geometry)||null,layer:tt,lngLat:s},screen:f})}else et(),p("feature-info",{feature:null,screen:f})}catch(L){et(),p("feature-info",{feature:null,screen:f})}finally{p("feature-loading",!1)}}}}),t.ScreenSpaceEventType.LEFT_CLICK)}function Di(t){var P,L,O,A;if(!t||!((P=o==null?void 0:o.scene)!=null&&P.canvas))return t;const e=window.Cesium,i=o.scene.canvas,l=(L=i.getBoundingClientRect)==null?void 0:L.call(i),a=Number(l==null?void 0:l.width)||0,s=Number(l==null?void 0:l.height)||0,f=Number(i.clientWidth||((O=g.value)==null?void 0:O.clientWidth))||a||1,d=Number(i.clientHeight||((A=g.value)==null?void 0:A.clientHeight))||s||1,w=Number(t.x),S=Number(t.y);if(!Number.isFinite(w)||!Number.isFinite(S)||!a||!s)return t;const C=f/a,N=d/s;return Math.abs(C-1)<.001&&Math.abs(N-1)<.001?t:new e.Cartesian2(w*C,S*N)}function je(t){var S,C,N,P;if(!t||!((S=o==null?void 0:o.scene)!=null&&S.canvas))return null;const e=o.scene.canvas,i=(C=e.getBoundingClientRect)==null?void 0:C.call(e),l=Number(i==null?void 0:i.width)||0,a=Number(i==null?void 0:i.height)||0,s=Number(e.clientWidth||((N=g.value)==null?void 0:N.clientWidth))||l||1,f=Number(e.clientHeight||((P=g.value)==null?void 0:P.clientHeight))||a||1,d=Number(t.x),w=Number(t.y);return!Number.isFinite(d)||!Number.isFinite(w)||!i?null:{x:(Number(i.left)||0)+d*(l/s),y:(Number(i.top)||0)+w*(a/f)}}function Gi(t){if(!o)return null;const e=o.camera.getPickRay(t);return e?o.scene.globe.pick(e,o.scene):null}function ue(t){var e,i,l,a,s;et(),M=t,t.point&&(t.__hyOriginalPointSize=t.point.pixelSize,t.point.pixelSize=18),(e=t.__hyFeature)!=null&&e.geometry&&["Polygon","MultiPolygon","LineString","MultiLineString"].includes(t.__hyFeature.geometry.type)&&$t(t.__hyFeature,{townName:t.__hyTownName||((l=(i=t.__hyFeature)==null?void 0:i.properties)==null?void 0:l.name),mode:"feature"}),(s=(a=o==null?void 0:o.scene)==null?void 0:a.requestRender)==null||s.call(a)}function et(){var t,e;M!=null&&M.point&&M.__hyOriginalPointSize&&(M.point.pixelSize=M.__hyOriginalPointSize),M=null,V(Z),$e(),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function $t(t,e={}){var N,P,L,O;if(!o||!(t!=null&&t.geometry))return[];const i=Hi({append:e.append===!0});if(!i)return[];const l=window.Cesium,a=e.mode==="town",s=e.highlightTone==="white"||e.mode==="white",f=e.highlightTone==="v21",d=a?"#30DCFF":s?"#FFFFFF":f?"#FFD166":"#FF2D2D",w=a?"#F2FFFF":s?"#FFFFFF":f?"#FFF1B8":"#FF2D2D",S={fill:l.Color.fromCssColorString(d).withAlpha((N=e.fillAlpha)!=null?N:a?.16:s?.035:f?.2:.16),stroke:l.Color.fromCssColorString(w).withAlpha((P=e.strokeAlpha)!=null?P:s?.9:.98),lineWidth:(L=e.lineWidth)!=null?L:a?4.2:s?3.8:f?4.4:5.2,pointSize:a?0:(O=e.pointSize)!=null?O:14},C=Ze(t.geometry,t,i.entities,S);return C.forEach(A=>{var X;A.__hyFeature=null,A.__hyLayer=null,A.__hyTownName=e.townName||((X=t.properties)==null?void 0:X.name)||"",A.__hySelectedOverlay=!0}),Z.push(...C),qe(i),C}function Hi(t={}){return!o||!window.Cesium?null:(t.append&&H||($e(),H=new window.Cesium.CustomDataSource("selected-feature-overlay"),o.dataSources.add(H),qe(H)),H)}function $e(){var e,i;if(!(o!=null&&o.dataSources)){H=null;return}Array.from(new Set([H,...((i=(e=o.dataSources).getByName)==null?void 0:i.call(e,"selected-feature-overlay"))||[]].filter(Boolean))).forEach(l=>{try{o.dataSources.remove(l,!0)}catch(a){console.warn("[cesium-map] remove selected overlay failed",a)}}),H=null,Z=[]}function qe(t){var e,i;if(!(!(o!=null&&o.dataSources)||!t))try{if(o.dataSources.raiseToTop){o.dataSources.raiseToTop(t);return}for(;((i=(e=o.dataSources).indexOf)==null?void 0:i.call(e,t))<o.dataSources.length-1;)o.dataSources.raise(t)}catch(l){console.warn("[cesium-map] raise selected overlay failed",l)}}function Ze(t,e,i,l){const a=window.Cesium,s=[];if(!t||!i)return s;const f=d=>{const w=i.add(d);return w.__hyFeature=e,s.push(w),w};if(t.type==="Point"){const d=$(t.coordinates);return!d||l.pointSize<=0||f({position:a.Cartesian3.fromDegrees(d[0],d[1]),point:{show:!0,color:l.fill,pixelSize:l.pointSize,outlineColor:l.stroke,outlineWidth:3,heightReference:a.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),s}return t.type==="MultiPoint"?(t.coordinates.forEach(d=>{s.push(...Ze({type:"Point",coordinates:d},e,i,l))}),s):t.type==="LineString"?(ce(t.coordinates,e,i,l,s),s):t.type==="MultiLineString"?(t.coordinates.forEach(d=>{ce(d,e,i,l,s)}),s):t.type==="Polygon"?(Xe(t.coordinates,e,i,l,s),s):(t.type==="MultiPolygon"&&t.coordinates.forEach(d=>{Xe(d,e,i,l,s)}),s)}function Xe(t,e,i,l,a){const s=window.Cesium,f=Pt(t);if(!f)return;const d=i.add({polygon:{hierarchy:f,height:0,heightReference:s.HeightReference.CLAMP_TO_GROUND,perPositionHeight:!1,clampToGround:!0,material:l.fill,outline:!1,classificationType:s.ClassificationType.BOTH,zIndex:999}});d.__hyFeature=e,a.push(d),t.forEach(w=>ce(w,e,i,l,a))}function ce(t,e,i,l,a){const s=window.Cesium,f=at(t);if(f.length<2)return;const d=i.add({polyline:{positions:f,width:l.lineWidth,material:l.stroke,depthFailMaterial:l.stroke,heightReference:s.HeightReference.CLAMP_TO_GROUND,clampToGround:!0,classificationType:s.ClassificationType.BOTH,zIndex:1e3}});d.__hyFeature=e,a.push(d)}function Je(t,e={}){var s,f,d,w,S;if(!o||!t)return!1;const i=t.properties||((s=t.feature)==null?void 0:s.properties)||(typeof t=="object"?t:{}),l=W(t.geometry||((f=t.feature)==null?void 0:f.geometry)||i.geometry||i.geom||i.wkt||t);if(!l)return!1;et();const a={type:"Feature",id:t.id||((d=t.feature)==null?void 0:d.id)||i.id,properties:i,geometry:l};return $t(a,st({mode:"feature"},e)),(S=(w=o==null?void 0:o.scene)==null?void 0:w.requestRender)==null||S.call(w),Z.length>0}function Wi(t){const e=ht(t);return e&&(we.features||[]).find(i=>{var l;return ht((l=i==null?void 0:i.properties)==null?void 0:l.name)===e})||null}function he(){var t,e;return((t=c.mapRanking)==null?void 0:t.scope)==="town"&&Array.isArray((e=c.mapRanking)==null?void 0:e.rows)&&c.mapRanking.rows.length>0}function Ke(t){var i;if(!he())return!1;const e=ht(t);return(((i=c.mapRanking)==null?void 0:i.rows)||[]).some(l=>ht(l.name)===e)}function zi(t){return he()&&(we.features||[]).find(e=>{var l;const i=(l=e==null?void 0:e.properties)==null?void 0:l.name;return Ke(i)&&fn(t,W(e==null?void 0:e.geometry))})||null}function fe(t,e={}){var l,a,s,f;if(!he()||!Ke(t))return!1;const i=Wi(t);return i?(et(),$t(i,{mode:"town",townName:((l=i.properties)==null?void 0:l.name)||t}),e.emitFeatureInfo!==!1&&p("feature-info",{feature:null}),e.emitStatus!==!1&&p("layer-status",{type:"success",text:`已选中${((a=i.properties)==null?void 0:a.name)||t}`}),(f=(s=o==null?void 0:o.scene)==null?void 0:s.requestRender)==null||f.call(s),!0):!1}function Qe(t,e={}){const i=En.find(a=>ht(a.name)===ht(t)),l=$(i==null?void 0:i.center);return l?(e.select&&fe(t,{emitFeatureInfo:!1,emitStatus:!1}),an(l,42e3),{screen:St(l)}):null}function tn(t={}){var f,d;const e=nr(t),i=tr(w=>ir(w,e));if(!i.length)return null;const l=rr(i),a=or(l);et(),M=i[0],M!=null&&M.point&&(M.__hyOriginalPointSize=M.point.pixelSize,M.point.pixelSize=18),a.forEach((w,S)=>{$t(w,{mode:"feature",highlightTone:e.highlightTone,append:S>0})});const s=be(l);return s?Rt(s,.9):o.flyTo(i[0],{duration:.9,offset:kt(18e3)}),(d=(f=o==null?void 0:o.scene)==null?void 0:f.requestRender)==null||d.call(f),{entity:i[0],entities:i,feature:l[0]||i[0].__hyFeature,features:l,highlightFeatures:a,screen:qt(a.length?a:l)}}function en(t={}){const e=_t(t);let i=ge(l=>Zt(l,t));return i?(ue(i),o.flyTo(i,{duration:.9,offset:kt(16e3)})):e&&an(e,16e3),{feature:(i==null?void 0:i.__hyFeature)||null,screen:me(t)}}function nn(t={}){const e=ge(i=>Zt(i,t));return e?(ue(e),o.flyTo(e,{duration:.9,offset:kt(18e3)}),{feature:e.__hyFeature,screen:Mt(e.__hyFeature)}):null}function Mt(t){var i;const e=cr(W((t==null?void 0:t.geometry)||((i=t==null?void 0:t.feature)==null?void 0:i.geometry)));return e?St(e):null}function rn(t){return qt([t])||Mt(t)}function qt(t=[]){const e=[];if((Array.isArray(t)?t:[t]).forEach(a=>{var w,S;const s=(a==null?void 0:a.properties)||((w=a==null?void 0:a.feature)==null?void 0:w.properties)||{},f=W((a==null?void 0:a.geometry)||((S=a==null?void 0:a.feature)==null?void 0:S.geometry)||s.geometry||s.geom||s.wkt||s.geo||s.the_geom||s.geometryWkt||s.geometry_wkt||s.shape);if(!f){const C=Mt(a);C&&e.push(C);return}const d=[];Lt(f.coordinates,d),e.push(...d.map(St).filter(Boolean))}),!e.length)return null;const i=e.map(a=>Number(a.x)).filter(Number.isFinite),l=e.map(a=>Number(a.y)).filter(Number.isFinite);return!i.length||!l.length?null:{x:(Math.min(...i)+Math.max(...i))/2,y:Math.min(...l)}}function me(t={}){var a,s;const e=_t(t);if(e)return St(e);const i=ge(f=>Zt(f,t)),l=(s=(a=i==null?void 0:i.position)==null?void 0:a.getValue)==null?void 0:s.call(a,window.Cesium.JulianDate.now());return l?toLogicalScreen(window.Cesium.SceneTransforms.wgs84ToWindowCoordinates(o.scene,l)):null}function on(t={}){var f,d;sn();const e=sr(t.grasslands||t),i=t.highlightTone==="white",l=i?null:{fillColor:"#FF3B30",strokeColor:"#FF3B30",fillAlpha:.1,strokeAlpha:.68,lineWidth:12},a=i?{fillColor:"#F7FFFF",strokeColor:"#F7FFFF",fillAlpha:.025,strokeAlpha:.9,lineWidth:3.8}:{fillColor:"#FF2D2D",strokeColor:"#FFE1E1",fillAlpha:.3,strokeAlpha:1,lineWidth:6.2};t.locateOnly||(e.forEach(w=>{l&&wt(w,{key:"pasture-focus-glow",name:t.name||"牧场高亮"},U,l),wt(w,{key:"pasture-focus",name:t.name||"牧场高亮"},U,a)}),(Array.isArray(t.yakMarks)?t.yakMarks:[]).forEach((w,S)=>{const C=_t(w);C&&wt({type:"Feature",id:w.id||S,properties:st({},w),geometry:{type:"Point",coordinates:C}},{key:"pasture-focus-yak",name:"牦牛识别"},U,{fillColor:"#FFCB45",strokeColor:"#FFF4B8",pointSize:11})}));const s=be(e);return s&&Rt(s,.9),(d=(f=o==null?void 0:o.scene)==null?void 0:f.requestRender)==null||d.call(f),!!e.length}function sn(){var t,e;V(U),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function Ui(){et()}function Vi(t){D=!!t,D||(k=[]),pe(),p("draw-boundary",{status:D?"drawing":"clear",pointCount:k.length,points:k})}function Yi(t){k.push([t.lng,t.lat]),pe(),p("draw-boundary",{status:"drawing",pointCount:k.length,points:k})}function ji(){k.pop(),pe(),p("draw-boundary",{status:"drawing",pointCount:k.length,points:k})}function $i(){if(k.length<3)return null;const t=Le(),e=[...k,k[0]],i={type:"Feature",properties:{source:"drawn"},geometry:{type:"Polygon",coordinates:[e]}};return D=!1,k=[],V(j),wt(i,{key:"analysis-boundary",name:"分析边界"},j,{fillColor:"#24F6C4",strokeColor:"#B7FFF2",fillAlpha:.12,strokeAlpha:1,lineWidth:3}),p("draw-boundary",{status:"complete",pointCount:0,points:[],feature:i}),Ut(t),Ae(t),i}function qi(){var t,e;D=!1,k=[],V(j),V(rt),p("draw-boundary",{status:"clear",pointCount:0,points:[]}),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function pe(){if(!o)return;const t=window.Cesium;V(j),k.forEach(e=>{j.push(o.entities.add({position:t.Cartesian3.fromDegrees(e[0],e[1],12),point:{pixelSize:10,color:t.Color.fromCssColorString("#24F6C4"),outlineColor:t.Color.WHITE,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))}),k.length>1&&j.push(o.entities.add({polyline:{positions:at(k),width:3,material:t.Color.fromCssColorString("#24F6C4"),clampToGround:!0}})),o.scene.requestRender()}function Zi(t={}){var a,s,f,d,w,S,C;const e=((a=t.boundary)==null?void 0:a.type)==="Feature"||(s=t.boundary)!=null&&s.geometry?t.boundary:null,i=t.preserveView===!0||((f=e==null?void 0:e.properties)==null?void 0:f.source)==="drawn",l=i?Le():null;if(i&&((w=(d=o==null?void 0:o.camera)==null?void 0:d.cancelFlight)==null||w.call(d)),V(rt),e&&wt(e,{key:"analysis-result-boundary"},rt,{fillColor:"#24F6C4",strokeColor:"#B7FFF2",fillAlpha:.1,lineWidth:3}),(Array.isArray(t.matches)?t.matches:[]).forEach(N=>{const P=(N==null?void 0:N.type)==="Feature"?N:(N==null?void 0:N.feature)||null;P&&wt(P,{key:"analysis-result-feature"},rt,{fillColor:"#30DCFF",strokeColor:"#C9FBFF",fillAlpha:.1,lineWidth:2.6})}),i)Ut(l),Ae(l);else{const N=[e,...t.matches||[]].filter(Boolean),P=be(N);P&&Rt(P,.9)}(C=(S=o==null?void 0:o.scene)==null?void 0:S.requestRender)==null||C.call(S)}function Xi(t={}){if(!o||!window.Cesium)return 0;const e=Array.isArray(t.features)?t.features:[];if(!e.length)return 0;const i=window.Cesium,l=String(t.key||"engineering-suitability"),a={key:`engineering-suitability-${l}`,name:t.name||"工程适宜实施区域",sourceType:"analysis"},s=le(i,t.color||"#FFD43B",.52),f=[];if(Qi(e),e.forEach(S=>{const C=W(S==null?void 0:S.geometry);((C==null?void 0:C.type)==="Polygon"?[C.coordinates]:(C==null?void 0:C.type)==="MultiPolygon"?C.coordinates:[]).forEach((P,L)=>{var A,X;const O=Pt(P);if(O)try{const tt=Ct(st({},S),{id:S.id||`${l}-${f.length}`,properties:Ct(st({},S.properties||{}),{engineering_type:((A=S.properties)==null?void 0:A.engineering_type)||l,engineering_name:((X=S.properties)==null?void 0:X.engineering_name)||t.name})});f.push(new i.GeometryInstance({id:{__hyFeature:tt,__hyLayer:a,__hyEngineeringType:l,__hyPolygonIndex:L},geometry:new i.PolygonGeometry({polygonHierarchy:O,vertexFormat:i.PerInstanceColorAppearance.VERTEX_FORMAT}),attributes:{color:i.ColorGeometryInstanceAttribute.fromColor(s)}}))}catch(tt){console.warn("[cesium-map] engineering suitability geometry skipped",S==null?void 0:S.id,tt)}})}),!f.length)return 0;const d=o.scene.primitives.add(new i.GroundPrimitive({geometryInstances:f,appearance:new i.PerInstanceColorAppearance({translucent:!0,closed:!0,flat:!0}),classificationType:i.ClassificationType.TERRAIN,allowPicking:!0,asynchronous:!0,releaseGeometryInstances:!0}));d.__hyEngineeringType=l,d.show=!0;const w=xt.get(l)||[];return w.push(d),xt.set(l,w),o.scene.requestRender(),f.length}function Ji(t,e){var l,a;(xt.get(String(t||""))||[]).forEach(s=>{s.show=e!==!1}),(a=(l=o==null?void 0:o.scene)==null?void 0:l.requestRender)==null||a.call(l)}function Ki(){var t,e;bt&&Rt(bt,.8),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function ln(){var t,e;et(),xt.forEach(i=>{i.forEach(l=>{var a,s,f;return(f=(s=(a=o==null?void 0:o.scene)==null?void 0:a.primitives)==null?void 0:s.remove)==null?void 0:f.call(s,l)})}),xt.clear(),bt=null,(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function Qi(t=[]){const e=bt||{west:1/0,south:1/0,east:-1/0,north:-1/0};t.forEach(i=>{const l=W(i==null?void 0:i.geometry);if(!l)return;const a=[];Lt(l.coordinates,a),a.forEach(s=>{e.west=Math.min(e.west,Number(s[0])),e.south=Math.min(e.south,Number(s[1])),e.east=Math.max(e.east,Number(s[0])),e.north=Math.max(e.north,Number(s[1]))})}),[e.west,e.south,e.east,e.north].every(Number.isFinite)&&(bt=e)}function an(t,e=22e3,i=.9){if(!o||!t)return;const l=window.Cesium,a=l.Cartesian3.fromDegrees(t[0],t[1],oe());o.camera.flyToBoundingSphere(new l.BoundingSphere(a,1),{offset:kt(e),duration:i})}function Rt(t,e=.9){if(!o||!t)return;const i=window.Cesium,l=[(Number(t.west)+Number(t.east))/2,(Number(t.south)+Number(t.north))/2];if(!l.every(Number.isFinite))return;const a=Math.max(Math.abs(Number(t.east)-Number(t.west)),Math.abs(Number(t.north)-Number(t.south))),s=Math.max(18e3,Math.min(16e4,a*135e3)),f=i.Cartesian3.fromDegrees(l[0],l[1],oe());o.camera.flyToBoundingSphere(new i.BoundingSphere(f,1),{offset:kt(s),duration:e})}function un(t){if(!o||!t)return;const e=t.mapView||(t.cameraPosition?{cameraPosition:t.cameraPosition}:null);if(!e)return;const i=window.Cesium,l=Number.isFinite(Number(e.duration))?Number(e.duration):.9,a=$(e.targetLngLat);if(a){const s=Be(c.initialZoom),f=Number.isFinite(Number(e.distanceScale))?Number(e.distanceScale):1,d=Math.max(18e3,Math.min(56e4,s*f)),w=Number.isFinite(Number(e.targetHeight))?Number(e.targetHeight):oe(),S=Number.isFinite(Number(e.heading))?Number(e.heading):Gn,C=Number.isFinite(Number(e.pitch))?Number(e.pitch):Hn,N=i.Cartesian3.fromDegrees(a[0],a[1],w);o.camera.flyToBoundingSphere(new i.BoundingSphere(N,1),{offset:new i.HeadingPitchRange(i.Math.toRadians(S),i.Math.toRadians(C),d),duration:l});return}e.bounds&&Rt(e.bounds,l)}function kt(t){const e=window.Cesium;return new e.HeadingPitchRange(e.Math.toRadians(Gn),e.Math.toRadians(Hn),t)}function St(t){if(!o||!t)return null;const e=window.Cesium,i=e.Cartesian3.fromDegrees(t[0],t[1],16);return je(e.SceneTransforms.wgs84ToWindowCoordinates(o.scene,i))}function ge(t){return[...G,...U].find(e=>e.__hyFeature&&t(e.__hyFeature))||null}function tr(t){return[...G,...U].filter(e=>e.__hyFeature&&t(e.__hyFeature))}function er(t,e){if(!Number.isFinite(t==null?void 0:t.lng)||!Number.isFinite(t==null?void 0:t.lat))return null;const i=cn(G),l=i.map(s=>{var f;return{entity:s,geometry:W((f=s.__hyFeature)==null?void 0:f.geometry)}}).filter(s=>s.geometry&&fn(t,s.geometry)).sort((s,f)=>mn(s.geometry)-mn(f.geometry));if(l.length)return l[0].entity;const a=i.map(s=>{var f;return{entity:s,distance:lr(W((f=s.__hyFeature)==null?void 0:f.geometry),e)}}).filter(s=>Number.isFinite(s.distance)).sort((s,f)=>s.distance-f.distance)[0];return(a==null?void 0:a.distance)<=18?a.entity:null}function Zt(t,e={}){const i=(t==null?void 0:t.properties)||{},l=[e.id,e.key,e.featureId,e.projectId].filter(S=>S!=null&&S!=="").map(String),a=[t.id,i.id,i.key,i.feature_id,i.project_id].filter(S=>S!=null&&S!=="").map(String);if(l.some(S=>a.includes(S)))return!0;const s=[e.name,e.fullName,e.projectName].filter(Boolean).map(String),f=[i.name,i.fullName,i.project_name,i.projectName].filter(Boolean).map(String);if(s.some(S=>f.includes(S)))return!0;const d=_t(e),w=_t(Ct(st({},i),{geometry:t.geometry}));return!!(d&&w&&Math.abs(d[0]-w[0])<2e-5&&Math.abs(d[1]-w[1])<2e-5)}function nr(t={}){return t&&typeof t=="object"?t:{name:t,projectName:t,project_name:t}}function ir(t,e={}){if(Zt(t,e))return!0;const i=(t==null?void 0:t.properties)||{},l=Xt([e.id,e.key,e.featureId,e.projectId,e.project_id]),a=Xt([t==null?void 0:t.id,i.id,i.key,i.feature_id,i.project_id,i.gid]);if(l.some(d=>a.includes(d)))return!0;const s=Xt([e.name,e.fullName,e.projectName,e.project_name,e.title]),f=Xt([i.name,i.fullName,i.project_name,i.projectName,i.title]);return s.some(d=>f.includes(d))}function Xt(t=[]){const e=[];return t.forEach(i=>{if(i==null||i==="")return;const l=String(i).trim();if(!l)return;e.push(l);const a=l.replace(/\s+/g,"");a&&a!==l&&e.push(a)}),Array.from(new Set(e))}function cn(t=[]){const e=new Set;return t.filter(i=>{const l=i==null?void 0:i.__hyFeature;return!l||e.has(l)?!1:(e.add(l),!0)})}function rr(t=[]){return cn(t).map(e=>e.__hyFeature).filter(Boolean)}function or(t=[]){const e=t.filter(l=>{var s;const a=String(((s=W(l==null?void 0:l.geometry))==null?void 0:s.type)||"");return a.includes("Polygon")||a.includes("LineString")}),i=e.filter(l=>{var a;return((a=l==null?void 0:l.properties)==null?void 0:a.feature_role)==="工程范围"});return i.length?i:e}function sr(t){return(Array.isArray(t)?t:(t==null?void 0:t.grasslands)||(t==null?void 0:t.features)||(t==null?void 0:t.rows)||(t==null?void 0:t.list)||(t?[t]:[])).map((i,l)=>{var s,f;if((i==null?void 0:i.type)==="Feature")return i;const a=W(i==null?void 0:i.geometry)||de(Ge(i));return a?{type:"Feature",id:(f=(s=i==null?void 0:i.id)!=null?s:i==null?void 0:i.grasslandId)!=null?f:l,properties:st({},i),geometry:a}:null}).filter(Boolean)}function W(t){if(!t)return null;if(t.type==="Feature")return W(t.geometry);if(t.type&&Array.isArray(t.coordinates))return t;if(typeof t=="string"){const e=t.trim();if(!e)return null;if(e.startsWith("{")||e.startsWith("["))try{return W(JSON.parse(e))}catch(i){return null}return de(e)}return null}function de(t){const i=String(t||"").trim().replace(/^SRID=\d+;/i,"").match(/^([A-Z]+)(?:\s+[A-Z]+)?\s*(\(.+\))$/i);if(!i)return null;const l=i[1].toUpperCase(),a=i[2];return l==="POINT"?{type:"Point",coordinates:ye(a)}:l==="MULTIPOINT"?{type:"MultiPoint",coordinates:Jt(a).map(ye).filter(Boolean)}:l==="LINESTRING"?{type:"LineString",coordinates:xe(a)}:l==="MULTILINESTRING"?{type:"MultiLineString",coordinates:Jt(a).map(xe).filter(s=>s.length)}:l==="POLYGON"?{type:"Polygon",coordinates:hn(a)}:l==="MULTIPOLYGON"?{type:"MultiPolygon",coordinates:Jt(a).map(hn).filter(s=>s.length)}:null}function ye(t){const e=String(t||"").replace(/^\(+|\)+$/g,"").trim().split(/\s+/).slice(0,2).map(Number);return e.length===2&&e.every(Number.isFinite)?e:null}function xe(t){return String(t||"").replace(/^\(+|\)+$/g,"").split(",").map(ye).filter(Boolean)}function hn(t){return Jt(t).map(xe).filter(e=>e.length>=3)}function Jt(t){const e=String(t||"").trim(),i=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,l=[];let a=0,s=-1;return Array.from(i).forEach((f,d)=>{f==="("?(a===0&&(s=d),a+=1):f===")"&&(a-=1,a===0&&s>=0&&(l.push(i.slice(s,d+1)),s=-1))}),l.length?l:[i]}function at(t=[]){const e=window.Cesium;return t.map($).filter(Boolean).map(i=>e.Cartesian3.fromDegrees(i[0],i[1],8))}function $(t){if(!Array.isArray(t)||t.length<2)return null;const e=Number(t[0]),i=Number(t[1]);return Number.isFinite(e)&&Number.isFinite(i)?[e,i]:null}function _t(t={}){const e=W(t.geometry);return(e==null?void 0:e.type)==="Point"?$(e.coordinates):[[t.longitude,t.latitude],[t.lng,t.lat],[t.lon,t.lat],[t.x,t.y],t.point,t.center,t.centroid,t.coordinates].map($).find(Boolean)||null}function fn(t,e){return!t||!(e!=null&&e.coordinates)?!1:e.type==="Polygon"?yn(t,e.coordinates):e.type==="MultiPolygon"?e.coordinates.some(i=>yn(t,i)):!1}function mn(t){return t!=null&&t.coordinates?t.type==="Polygon"?pn(t.coordinates):t.type==="MultiPolygon"?t.coordinates.reduce((e,i)=>e+pn(i),0):Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY}function pn(t=[]){const e=t[0]||[];if(e.length<3)return Number.POSITIVE_INFINITY;let i=0;for(let l=0;l<e.length;l+=1){const a=e[l],s=e[(l+1)%e.length];i+=Number((a==null?void 0:a[0])||0)*Number((s==null?void 0:s[1])||0)-Number((s==null?void 0:s[0])||0)*Number((a==null?void 0:a[1])||0)}return Math.abs(i)}function lr(t,e){return!(t!=null&&t.coordinates)||!e?Number.POSITIVE_INFINITY:t.type==="Point"?gn(t.coordinates,e):t.type==="MultiPoint"?Math.min(...t.coordinates.map(i=>gn(i,e))):t.type==="LineString"?dn(t.coordinates,e):t.type==="MultiLineString"?Math.min(...t.coordinates.map(i=>dn(i,e))):Number.POSITIVE_INFINITY}function gn(t,e){const i=St($(t));return i?Math.hypot(Number(i.x)-Number(e.x),Number(i.y)-Number(e.y)):Number.POSITIVE_INFINITY}function dn(t=[],e){if(!Array.isArray(t)||t.length<2)return Number.POSITIVE_INFINITY;let i=Number.POSITIVE_INFINITY;for(let l=1;l<t.length;l+=1){const a=St($(t[l-1])),s=St($(t[l]));!a||!s||(i=Math.min(i,ar(e,a,s)))}return i}function ar(t,e,i){const l=Number(e.x),a=Number(e.y),s=Number(i.x)-l,f=Number(i.y)-a;if(![l,a,s,f].every(Number.isFinite))return Number.POSITIVE_INFINITY;if(!s&&!f)return Math.hypot(Number(t.x)-l,Number(t.y)-a);const d=Math.max(0,Math.min(1,((Number(t.x)-l)*s+(Number(t.y)-a)*f)/(s*s+f*f)));return Math.hypot(Number(t.x)-(l+d*s),Number(t.y)-(a+d*f))}function yn(t,e=[]){return!e.length||!xn(t,e[0])?!1:!e.slice(1).some(i=>xn(t,i))}function xn(t,e=[]){if(e.length<3)return!1;const i=Number(t.lng),l=Number(t.lat);if(!Number.isFinite(i)||!Number.isFinite(l))return!1;let a=!1;for(let s=0,f=e.length-1;s<e.length;f=s++){const d=e[s],w=e[f],S=Number(d==null?void 0:d[0]),C=Number(d==null?void 0:d[1]),N=Number(w==null?void 0:w[0]),P=Number(w==null?void 0:w[1]);if(![S,C,N,P].every(Number.isFinite))continue;if(ur(i,l,S,C,N,P))return!0;C>l!=P>l&&i<(N-S)*(l-C)/(P-C)+S&&(a=!a)}return a}function ur(t,e,i,l,a,s){const f=(t-i)*(s-l)-(e-l)*(a-i);return Math.abs(f)>1e-10?!1:(t-i)*(t-a)+(e-l)*(e-s)<=1e-10}function cr(t){if(!t)return null;if(t.type==="Point")return $(t.coordinates);const e=[];return Lt(t.coordinates,e),e.length?[e.reduce((i,l)=>i+l[0],0)/e.length,e.reduce((i,l)=>i+l[1],0)/e.length]:null}function Lt(t,e){const i=$(t);if(i&&!Array.isArray(t[0])){e.push(i);return}Array.isArray(t)&&t.forEach(l=>Lt(l,e))}function be(t=[]){const e=[];if(t.forEach(f=>{var w;const d=W((f==null?void 0:f.geometry)||((w=f==null?void 0:f.feature)==null?void 0:w.geometry)||f);d&&Lt(d.coordinates,e)}),!e.length)return null;const i=e.map(f=>f[0]),l=e.map(f=>f[1]),a=Math.max(.006,(Math.max(...i)-Math.min(...i))*.18),s=Math.max(.006,(Math.max(...l)-Math.min(...l))*.18);return{west:Math.max(z.west,Math.min(...i)-a),south:Math.max(z.south,Math.min(...l)-s),east:Math.min(z.east,Math.max(...i)+a),north:Math.min(z.north,Math.max(...l)+s)}}function V(t){if(!o){t.length=0;return}t.splice(0).forEach(e=>o.entities.remove(e))}function bn(){B.splice(0).forEach(t=>{var e,i;return(i=(e=o==null?void 0:o.imageryLayers)==null?void 0:e.remove)==null?void 0:i.call(e,t,!0)}),V(G),et()}function At(){var t,e,i;I+=1,(t=_==null?void 0:_.disconnect)==null||t.call(_),_=null,F==null||F(),F=null,T==null||T(),T=null,(e=x==null?void 0:x.destroy)==null||e.call(x),x=null,bn(),V(Vn),V(ct),V(Y),V(q),V(U),V(j),V(rt),ln(),o&&!((i=o.isDestroyed)!=null&&i.call(o))&&o.destroy(),o=null,v=null,b.value=null,y.value&&y.value.replaceChildren()}function Et(t,e=1){const i=Number(t);return Number.isFinite(i)?Math.max(0,Math.min(1,i)):e}function ht(t){return String(t||"").trim().replace(/(镇|乡)$/,"")}function hr(t){const e=Number(t);return Number.isFinite(e)?Number.isInteger(e)?String(e):String(Number(e.toFixed(2))):"--"}return n({loadMap:Kn,hasMap:Qn,play:ti,resume:ke,pause:ei,refreshView:zt,resetView:ni,focusLayerMapView:ii,destroyMap:At,highlightFeature:Je,clearSelectedFeature:et,clearFloatingOverlays:Ui,focusProject:tn,focusPasture:on,clearPastureFocus:sn,focusTown:Qe,focusYakIndustryPoint:en,focusVectorFeature:nn,getVectorFeatureAnchorScreen:rn,getVectorFeaturesAnchorScreen:qt,getVectorFeatureScreen:Mt,getYakIndustryPointScreen:me,setBoundaryDrawing:Vi,finishBoundaryDrawing:$i,undoBoundaryPoint:ji,clearAnalysisBoundary:qi,showAnalysisResult:Zi,addEngineeringSuitabilityBatch:Xi,setEngineeringSuitabilityVisibility:Ji,completeEngineeringSuitability:Ki,clearEngineeringSuitability:ln,canvasMap:b}),(t,e)=>(Cr(),Tr("div",{ref_key:"containerRef",ref:g,class:"cesium-map"},[Fr("div",{ref_key:"viewerRef",ref:y,class:"cesium-map__viewer"},null,512)],512))}},bo=Sr(ho,[["__scopeId","data-v-b250583c"]]);export{xo as C,yo as H,bo as M,no as a,io as g};
|
|
|