ow-eengine-power 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/OW_EEngine_Power.js
CHANGED
|
@@ -2395,7 +2395,7 @@ class ai {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
//设置显隐
|
|
2397
2397
|
setLineVisible(o) {
|
|
2398
|
-
this.Keym == "OW_JPS_EEngin_001" && (this.entityCollection2.show = o);
|
|
2398
|
+
this.Keym == "OW_JPS_EEngin_001" && (this.entityCollection2.show = o, this.LineentityCollection2.show = o);
|
|
2399
2399
|
}
|
|
2400
2400
|
//移除渲染电力线路
|
|
2401
2401
|
RemoveLineModel() {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
material.alpha = 1.0 - fract(st.s * 2.0 + time);
|
|
11
11
|
return material;
|
|
12
12
|
}
|
|
13
|
-
`},translucent:function(){return!0}})}setLineVisible(o){this.Keym=="OW_JPS_EEngin_001"&&(this.entityCollection2.show=o)}RemoveLineModel(){this.Keym=="OW_JPS_EEngin_001"&&(this.viewer.dataSources.remove(this.dataSource2),this.entityCollection2.show=!1,this.viewer.dataSources.remove(this.LinedataSource2),this.LineentityCollection2.show=!1,this.cameraMoveHandler&&(this.cameraMoveHandler(),this.cameraMoveHandler=null),this.loadedTowerIndices.clear(),this.modelCache.clear())}}class ii{constructor(){p(this,"id","");p(this,"name","");p(this,"towerFZinfo","");p(this,"towerDisFile","");p(this,"stressFileContent","");p(this,"streesistrue",0);p(this,"TowerMemberColor","#FFFFFF");p(this,"TowerMembersWidth",2);p(this,"Longitude",0);p(this,"Latitude",0);p(this,"Altitude",0);p(this,"RollX",0);p(this,"RollY",90);p(this,"RollZ",0)}}function ti(W){debugger;const o=W.split(`
|
|
13
|
+
`},translucent:function(){return!0}})}setLineVisible(o){this.Keym=="OW_JPS_EEngin_001"&&(this.entityCollection2.show=o,this.LineentityCollection2.show=o)}RemoveLineModel(){this.Keym=="OW_JPS_EEngin_001"&&(this.viewer.dataSources.remove(this.dataSource2),this.entityCollection2.show=!1,this.viewer.dataSources.remove(this.LinedataSource2),this.LineentityCollection2.show=!1,this.cameraMoveHandler&&(this.cameraMoveHandler(),this.cameraMoveHandler=null),this.loadedTowerIndices.clear(),this.modelCache.clear())}}class ii{constructor(){p(this,"id","");p(this,"name","");p(this,"towerFZinfo","");p(this,"towerDisFile","");p(this,"stressFileContent","");p(this,"streesistrue",0);p(this,"TowerMemberColor","#FFFFFF");p(this,"TowerMembersWidth",2);p(this,"Longitude",0);p(this,"Latitude",0);p(this,"Altitude",0);p(this,"RollX",0);p(this,"RollY",90);p(this,"RollZ",0)}}function ti(W){debugger;const o=W.split(`
|
|
14
14
|
`),i=[],f=[],s=/^\s*(\d+)\s+([\d.-]+)\s+([\d.-]+)\s+([\d.-]+)\s+(-?\d+)/,C=/^\s*(\d+)\s+(\d+)\s+(\d+)\s*(?:#|$)/;for(const a of o){const L=a.trim();if(!L)continue;const A=L.match(s);if(A){i.push({id:parseInt(A[1]),x:parseFloat(A[2]),y:parseFloat(A[3]),z:parseFloat(A[4]),flag:parseInt(A[5])});continue}const d=L.match(C);d&&f.push({from:parseInt(d[1]),to:parseInt(d[2]),type:parseInt(d[3])})}return{TowerNodes:i,connections:f}}function ei(W){const o=W.split(`
|
|
15
15
|
`),i=[];for(const f of o){if(!f.trim())continue;const s=f.trim().split(/\s+/).filter(L=>L!==""),C=parseInt(s[0]);if(isNaN(C))continue;const a=[];for(let L=1;L<s.length;L+=3){const A=parseFloat(s[L]),d=parseFloat(s[L+1]),t=parseFloat(s[L+2]);if(!isNaN(A)&&!isNaN(d)&&!isNaN(t)){const l=Math.floor((L-1)/3)+1;a.push({timeStep:l,x:A,y:d,z:t})}}i.push({nodeId:C,displacements:a})}return i}function ms(W){const o={};return W.forEach(i=>{i.displacements.forEach(f=>{o[f.timeStep]||(o[f.timeStep]=[]),o[f.timeStep].push({nodeId:i.nodeId,...f})})}),o}function oi(W){const o=W.split(`
|
|
16
16
|
`),i=[];for(const s of o){if(!s.trim())continue;const C=s.match(/^\s*(\d+-\s*\d+)\s+((?:\d+\.\d+\s*)+)/);if(C){const a=C[1].replace(/\s+/g,""),L=C[2].trim().split(/\s+/).map(Number);i.push({elementId:a,stressRatios:L})}}const f=[];if(i.length>0){const s=i[0].stressRatios.length;for(let C=0;C<s;C++){const a={timeIndex:C,elements:[]};for(const L of i){let A;const d=L.stressRatios[C];d>1?A=Z.Color.RED:d>.95&&d<=1?A=Z.Color.PINK:d>.85&&d<=.95?A=Z.Color.YELLOW:d>.7&&d<=.85?A=Z.Color.GREEN:A=Z.Color.BLUE,a.elements.push({elementId:L.elementId,stressRatio:d,ylbColor:A})}f.push(a)}}return{byElement:i,byTime:f}}class bs{constructor(o){p(this,"viewer");p(this,"lines",[]);this.viewer=o}addLine(o,i){const f=Ms(this.viewer,o,i);return this.lines.push(f),f}removeAll(){this.lines.forEach(o=>this.viewer.entities.remove(o)),this.lines=[]}}var _s={exports:{}};(function(W,o){(function(i,f){f()})(ts,function(){function i(d,t){return typeof t>"u"?t={autoBom:!1}:typeof t!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function f(d,t,l){var u=new XMLHttpRequest;u.open("GET",d),u.responseType="blob",u.onload=function(){A(u.response,t,l)},u.onerror=function(){console.error("could not download file")},u.send()}function s(d){var t=new XMLHttpRequest;t.open("HEAD",d,!1);try{t.send()}catch{}return 200<=t.status&&299>=t.status}function C(d){try{d.dispatchEvent(new MouseEvent("click"))}catch{var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(t)}}var a=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof ts=="object"&&ts.global===ts?ts:void 0,L=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),A=a.saveAs||(typeof window!="object"||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!L?function(d,t,l){var u=a.URL||a.webkitURL,e=document.createElement("a");t=t||d.name||"download",e.download=t,e.rel="noopener",typeof d=="string"?(e.href=d,e.origin===location.origin?C(e):s(e.href)?f(d,t,l):C(e,e.target="_blank")):(e.href=u.createObjectURL(d),setTimeout(function(){u.revokeObjectURL(e.href)},4e4),setTimeout(function(){C(e)},0))}:"msSaveOrOpenBlob"in navigator?function(d,t,l){if(t=t||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(i(d,l),t);else if(s(d))f(d,t,l);else{var u=document.createElement("a");u.href=d,u.target="_blank",setTimeout(function(){C(u)})}}:function(d,t,l,u){if(u=u||open("","_blank"),u&&(u.document.title=u.document.body.innerText="downloading..."),typeof d=="string")return f(d,t,l);var e=d.type==="application/octet-stream",c=/constructor/i.test(a.HTMLElement)||a.safari,B=/CriOS\/[\d]+/.test(navigator.userAgent);if((B||e&&c||L)&&typeof FileReader<"u"){var m=new FileReader;m.onloadend=function(){var P=m.result;P=B?P:P.replace(/^data:[^;]*;/,"data:attachment/file;"),u?u.location.href=P:location=P,u=null},m.readAsDataURL(d)}else{var b=a.URL||a.webkitURL,w=b.createObjectURL(d);u?u.location=w:location.href=w,u=null,setTimeout(function(){b.revokeObjectURL(w)},4e4)}});a.saveAs=A.saveAs=A,W.exports=A})})(_s);var us=_s.exports;const vs=require("shp-write");class ri{constructor(o,i,f){p(this,"towerNodes",[]);p(this,"connections",[]);p(this,"towerFZS");this.towerNodes=o,this.connections=i,this.towerFZS=f}async exportTowerToSHP(){try{const o=await this.generatePointFeatures(),i=await this.generateLineFeatures();await this.generateSHPFiles(o,i),console.log("SHP文件导出成功")}catch(o){console.error("导出SHP文件失败:",o)}}async generatePointFeatures(){const o=[],i=new n.HeadingPitchRoll(n.Math.toRadians(this.towerFZS.RollX),this.towerFZS.RollY,this.towerFZS.RollZ),f=n.Cartesian3.fromDegrees(this.towerFZS.Longitude,this.towerFZS.Latitude,this.towerFZS.Altitude);for(const s of this.towerNodes){const C=new n.Cartesian3(s.x,s.y,s.z),a=this.getPositionByHprAndOffset(f,C,i),L=n.Ellipsoid.WGS84.cartesianToCartographic(a),A=n.Math.toDegrees(L.longitude),d=n.Math.toDegrees(L.latitude),t=L.height,l={type:"Feature",geometry:{type:"Point",coordinates:[A,d]},properties:{id:s.id,node_id:s.id,x:s.x,y:s.y,z:s.z,longitude:A,latitude:d,height:t,elevation:t,type:"tower_node"}};o.push(l)}return o}async generateLineFeatures(){const o=[],i=new n.HeadingPitchRoll(n.Math.toRadians(this.towerFZS.RollX),this.towerFZS.RollY,this.towerFZS.RollZ),f=n.Cartesian3.fromDegrees(this.towerFZS.Longitude,this.towerFZS.Latitude,this.towerFZS.Altitude);for(const s of this.connections){const C=this.towerNodes.find(g=>g.id===s.from),a=this.towerNodes.find(g=>g.id===s.to);if(!C||!a)continue;const L=new n.Cartesian3(C.x,C.y,C.z),A=new n.Cartesian3(a.x,a.y,a.z),d=this.getPositionByHprAndOffset(f,L,i),t=this.getPositionByHprAndOffset(f,A,i),l=n.Ellipsoid.WGS84.cartesianToCartographic(d),u=n.Ellipsoid.WGS84.cartesianToCartographic(t),e=n.Math.toDegrees(l.longitude),c=n.Math.toDegrees(l.latitude),B=l.height,m=n.Math.toDegrees(u.longitude),b=n.Math.toDegrees(u.latitude),w=u.height,P={type:"Feature",geometry:{type:"LineString",coordinates:[[e,c],[m,b]]},properties:{id:`${s.from}-${s.to}`,from_node:s.from,to_node:s.to,from_height:B,to_height:w,avg_height:(B+w)/2,length:this.calculateDistance(d,t),type:"tower_member",width:this.towerFZS.TowerMembersWidth,from_longitude:e,from_latitude:c,to_longitude:m,to_latitude:b}};o.push(P)}return o}async generateSHPFiles(o,i){try{if(o.length>0){const f={type:"FeatureCollection",features:o},s=vs.point(f);this.downloadSHPFiles(s,"tower_nodes")}if(i.length>0){const f={type:"FeatureCollection",features:i},s=vs.line(f);this.downloadSHPFiles(s,"tower_members")}}catch(f){console.error("生成SHP文件时出错:",f),await this.alternativeExport(o,i)}}downloadSHPFiles(o,i){const f=new Blob([o],{type:"application/zip"});us.saveAs(f,`${i}.zip`)}async alternativeExport(o,i){if(console.log("使用备用方案导出为GeoJSON格式"),o.length>0){const f={type:"FeatureCollection",features:o};this.downloadJSON(f,"tower_nodes.geojson")}if(i.length>0){const f={type:"FeatureCollection",features:i};this.downloadJSON(f,"tower_members.geojson")}}downloadJSON(o,i){const f=new Blob([JSON.stringify(o,null,2)],{type:"application/json"});us.saveAs(f,i)}calculateDistance(o,i){return n.Cartesian3.distance(o,i)}getPositionByHprAndOffset(o,i,f){const s=n.Transforms.headingPitchRollToFixedFrame(o,f);return n.Matrix4.multiplyByPoint(s,i,new n.Cartesian3)}}class hi{static async exportToCSV(o,i,f){const s=this.exportNodesToCSV(o,f);this.downloadCSV(s,"tower_nodes.csv");const C=this.exportConnectionsToCSV(i,o,f);this.downloadCSV(C,"tower_connections.csv")}static exportNodesToCSV(o,i){let f=`ID,X,Y,Z,Longitude,Latitude,Height
|