@eturnity/eturnity_3d 0.0.4
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/.babelrc +3 -0
- package/.env +0 -0
- package/.eslintrc +18 -0
- package/.eslintrc.json +18 -0
- package/.prettierrc +7 -0
- package/Dockerfile +17 -0
- package/README.md +18 -0
- package/bitbucket-pipelines.yml +681 -0
- package/dist/assets/images/panels/longiSolarLR4_60HPH_350M.png +0 -0
- package/dist/assets/images/panels/longiSolarLR4_60HPH_370M.png +0 -0
- package/dist/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw copy.png +0 -0
- package/dist/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
- package/dist/assets/images/panels/uv.png +0 -0
- package/dist/assets/panels/longiSolarLR4_60HPH_350M.png +0 -0
- package/dist/assets/panels/longiSolarLR4_60HPH_370M.png +0 -0
- package/dist/assets/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
- package/dist/assets/panels/uv.png +0 -0
- package/dist/assets/theme.js +43 -0
- package/dist/assets/vue.svg +1 -0
- package/dist/css/main.1f8fe45d.css +1 -0
- package/dist/img/longiSolarLR4_60HPH_350M.85a84b2e.png +0 -0
- package/dist/img/longiSolarLR4_60HPH_370M.bf6b1f4e.png +0 -0
- package/dist/img/reneSola_Virtus_2_JC320S_24_Bbw.8b1892e0.png +0 -0
- package/dist/index.html +26 -0
- package/dist/main.js +60230 -0
- package/dist/main.js.map +1 -0
- package/dist/vite.svg +1 -0
- package/docker_conf/nginx/nginx.conf +16 -0
- package/index.html +26 -0
- package/package.json +71 -0
- package/postcss.config.js +1 -0
- package/preview.html +55 -0
- package/public/assets/images/panels/longiSolarLR4_60HPH_350M.png +0 -0
- package/public/assets/images/panels/longiSolarLR4_60HPH_370M.png +0 -0
- package/public/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw copy.png +0 -0
- package/public/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
- package/public/assets/images/panels/uv.png +0 -0
- package/public/assets/panels/longiSolarLR4_60HPH_350M.png +0 -0
- package/public/assets/panels/longiSolarLR4_60HPH_370M.png +0 -0
- package/public/assets/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
- package/public/assets/panels/uv.png +0 -0
- package/public/assets/theme.js +43 -0
- package/public/assets/vue.svg +1 -0
- package/public/vite.svg +1 -0
- package/server.js +17 -0
- package/src/App.vue +28 -0
- package/src/assets/images/panels/longiSolarLR4_60HPH_350M.png +0 -0
- package/src/assets/images/panels/longiSolarLR4_60HPH_370M.png +0 -0
- package/src/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw copy.png +0 -0
- package/src/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
- package/src/assets/images/panels/uv.png +0 -0
- package/src/assets/images/white_tile.png +0 -0
- package/src/assets/theme.js +43 -0
- package/src/components/ThreeCanvasViewer.vue +247 -0
- package/src/config.js +104 -0
- package/src/functions.js +2 -0
- package/src/helper/DFS.js +80 -0
- package/src/helper/MapView.js +253 -0
- package/src/helper/UpdateRoofModuleFieldRelations.js +119 -0
- package/src/helper/UpdateRoofObstacleRelations.js +86 -0
- package/src/helper/clearThreeObjects.js +21 -0
- package/src/helper/customProvider.js +57 -0
- package/src/helper/geometryHandler.js +606 -0
- package/src/helper/graphCreation.js +43 -0
- package/src/helper/materials.js +55 -0
- package/src/helper/projectedMaterial.js +502 -0
- package/src/helper/renderMixin.js +1132 -0
- package/src/helper/threeMixin.js +171 -0
- package/src/main.js +28 -0
- package/src/store/AddMargin.js +107 -0
- package/src/store/hydrateData.js +209 -0
- package/src/store/nodesEdgesCreation.js +216 -0
- package/src/store/store.js +10 -0
- package/src/store/three-d-module.js +142 -0
- package/src/style.css +96 -0
- package/src/utils/layers.js +265 -0
- package/src/utils/leaflet-config.service.js +67 -0
- package/vue.config.js +46 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
|
3
|
+
import { Sky } from 'three/examples/jsm/objects/Sky.js'
|
|
4
|
+
import {UnitsUtils,MapView} from 'geo-three'
|
|
5
|
+
import {CustomProvider} from './customProvider'
|
|
6
|
+
import clearThreeObjects from './clearThreeObjects'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
methods:{
|
|
10
|
+
initialiseThreeMap(){
|
|
11
|
+
if(this.three_map){
|
|
12
|
+
this.three_map.clear()
|
|
13
|
+
this.scene.remove(this.three_map)
|
|
14
|
+
clearThreeObjects(this.three_map)
|
|
15
|
+
}
|
|
16
|
+
if(this.background_map){
|
|
17
|
+
this.background_map.clear()
|
|
18
|
+
this.scene.remove(this.background_map)
|
|
19
|
+
clearThreeObjects(this.background_map)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//add background_map
|
|
23
|
+
this.background_map=new THREE.Group();
|
|
24
|
+
//plane
|
|
25
|
+
let sizeInMm={width:2000000,height:2000000}
|
|
26
|
+
|
|
27
|
+
if(this.layoutSettings.background_map_settings && this.layoutSettings.background_map_settings.sizeInMm){
|
|
28
|
+
sizeInMm=this.layoutSettings.background_map_settings.sizeInMm
|
|
29
|
+
}
|
|
30
|
+
let planeGeometry = new THREE.PlaneGeometry(sizeInMm.height/1000, sizeInMm.width/1000)
|
|
31
|
+
let planeMaterial = new THREE.MeshBasicMaterial( {
|
|
32
|
+
color: 0xf0f0f0,
|
|
33
|
+
opacity: 1
|
|
34
|
+
})
|
|
35
|
+
this.meshes.backgroundMesh = new THREE.Mesh(planeGeometry, planeMaterial)
|
|
36
|
+
|
|
37
|
+
this.meshes.backgroundMesh.position.z=0.1
|
|
38
|
+
|
|
39
|
+
//helper grid
|
|
40
|
+
let helper = new THREE.GridHelper(2000, 100)
|
|
41
|
+
helper.material.opacity = 0.25
|
|
42
|
+
helper.material.transparent = true
|
|
43
|
+
helper.rotateX(-Math.PI / 2)
|
|
44
|
+
helper.position.z=-0.1
|
|
45
|
+
this.scene.add(helper)
|
|
46
|
+
this.background_map.add( this.meshes.backgroundMesh )
|
|
47
|
+
this.background_map.add( helper )
|
|
48
|
+
clearThreeObjects(helper)
|
|
49
|
+
helper=null
|
|
50
|
+
|
|
51
|
+
//Extention of the map with geo-map
|
|
52
|
+
console.log("this.selectedMapLayer",this.selectedMapLayer)
|
|
53
|
+
if(this.selectedMapLayer && !['googleLayerRoadmap','googleLayer','googleLayerTerrain'].includes(this.selectedMapLayer.key)){
|
|
54
|
+
console.log("creation of custom provider")
|
|
55
|
+
this.provider = new CustomProvider('',this.selectedMapLayer.key);
|
|
56
|
+
console.log( this.provider)
|
|
57
|
+
|
|
58
|
+
// Create the map view and add it to your THREE scene
|
|
59
|
+
this.three_map = new MapView(MapView.PLANAR, this.provider);
|
|
60
|
+
this.three_map.rotateX(Math.PI / 2)
|
|
61
|
+
const coef=Math.cos(this.layoutSettings.layout_latitude*Math.PI/180)
|
|
62
|
+
this.three_map.scale.set(2*20015111.9287618*coef, 1, 2*20015111.9287618*coef);
|
|
63
|
+
var coords = UnitsUtils.datumsToSpherical(this.layoutSettings.layout_latitude, this.layoutSettings.layout_longitude)
|
|
64
|
+
|
|
65
|
+
this.three_map.position.set(-coords.x*coef,-coords.y*coef,-0.1)
|
|
66
|
+
this.scene.add(this.three_map)
|
|
67
|
+
}
|
|
68
|
+
this.scene.add(this.background_map)
|
|
69
|
+
|
|
70
|
+
},
|
|
71
|
+
initSky() {
|
|
72
|
+
// Add Sky
|
|
73
|
+
let sky = new Sky()
|
|
74
|
+
sky.scale.setScalar(450000)
|
|
75
|
+
// sky.rotateX( - Math.PI / 2 );
|
|
76
|
+
this.scene.add(sky)
|
|
77
|
+
clearThreeObjects(sky)
|
|
78
|
+
let sun = new THREE.Vector3()
|
|
79
|
+
|
|
80
|
+
const uniforms = sky.material.uniforms
|
|
81
|
+
uniforms.up.value = new THREE.Vector3(0, 0, 1)
|
|
82
|
+
uniforms['turbidity'].value = 20
|
|
83
|
+
uniforms['rayleigh'].value = 0.06
|
|
84
|
+
uniforms['mieCoefficient'].value = 0.01
|
|
85
|
+
uniforms['mieDirectionalG'].value = 0.1
|
|
86
|
+
const elevation=10
|
|
87
|
+
const azimuth=-20
|
|
88
|
+
const phi = THREE.MathUtils.degToRad(90 - elevation)
|
|
89
|
+
const theta = THREE.MathUtils.degToRad(azimuth)
|
|
90
|
+
|
|
91
|
+
sun.setFromSphericalCoords(1, phi, theta)
|
|
92
|
+
|
|
93
|
+
uniforms['sunPosition'].value.copy(sun)
|
|
94
|
+
sun=null
|
|
95
|
+
},
|
|
96
|
+
initialiseThree() {
|
|
97
|
+
|
|
98
|
+
//this.loader.crossOrigin = null
|
|
99
|
+
|
|
100
|
+
this.scene.background = new THREE.Color(0xb0b0b0)
|
|
101
|
+
|
|
102
|
+
this.camera.position.set(0, -100, 50)
|
|
103
|
+
this.camera.up.set(0, 0, 1)
|
|
104
|
+
|
|
105
|
+
this.cameraprojection = new THREE.PerspectiveCamera(1, 300 / 300, 100, 1000)
|
|
106
|
+
this.cameraprojection.position.set(0, 0, 24)
|
|
107
|
+
this.cameraprojection.up.set(0, 0, 1)
|
|
108
|
+
|
|
109
|
+
// const helper = new THREE.CameraHelper( this.cameraprojection );
|
|
110
|
+
// this.scene.add( helper );
|
|
111
|
+
|
|
112
|
+
// const axesHelper = new THREE.AxesHelper( 20 );
|
|
113
|
+
// this.scene.add( axesHelper );
|
|
114
|
+
//Light
|
|
115
|
+
const ambientLight = new THREE.AmbientLight(0xf0f0f0, 0.8)
|
|
116
|
+
this.scene.add(ambientLight)
|
|
117
|
+
|
|
118
|
+
var directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
|
|
119
|
+
directionalLight.position.set(0, 1000, 500);
|
|
120
|
+
var directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.5);
|
|
121
|
+
directionalLight2.position.set(0, -1000, 500);
|
|
122
|
+
this.scene.add(directionalLight);
|
|
123
|
+
this.scene.add(directionalLight2);
|
|
124
|
+
|
|
125
|
+
// this.renderer.setClearColor('#ffffff');
|
|
126
|
+
this.renderer.setPixelRatio(window.devicePixelRatio)
|
|
127
|
+
this.renderer.toneMappingExposure = 0.01
|
|
128
|
+
this.$refs.canvas3DContainer.appendChild(this.renderer.domElement)
|
|
129
|
+
|
|
130
|
+
//sky
|
|
131
|
+
this.initSky()
|
|
132
|
+
this.orbitControl=new OrbitControls(this.camera, this.renderer.domElement)
|
|
133
|
+
this.orbitControl.maxPolarAngle=Math.PI/2
|
|
134
|
+
window.addEventListener('resize', this.onWindowResize, false)
|
|
135
|
+
|
|
136
|
+
ambientLight.dispose()
|
|
137
|
+
directionalLight.dispose()
|
|
138
|
+
directionalLight2.dispose()
|
|
139
|
+
|
|
140
|
+
},
|
|
141
|
+
onWindowResize() {
|
|
142
|
+
this.camera.aspect = window.innerWidth / window.innerHeight
|
|
143
|
+
this.camera.updateProjectionMatrix()
|
|
144
|
+
this.canvasOffset = this.getCanvasOffset()
|
|
145
|
+
this.canvasHeight = this.$refs.canvas3DContainer.clientHeight
|
|
146
|
+
this.canvasWidth = this.$refs.canvas3DContainer.clientWidth
|
|
147
|
+
this.resizeCanvasToDisplaySize()
|
|
148
|
+
//this.renderer.setSize(window.innerWidth / 2, window.innerHeight / 2)
|
|
149
|
+
},
|
|
150
|
+
resizeCanvasToDisplaySize() {
|
|
151
|
+
const canvas = this.renderer.domElement
|
|
152
|
+
// look up the size the canvas is being displayed
|
|
153
|
+
const width = canvas.clientWidth
|
|
154
|
+
const height = canvas.clientHeight
|
|
155
|
+
|
|
156
|
+
// adjust displayBuffer size to match
|
|
157
|
+
if (canvas.width !== width || canvas.height !== height) {
|
|
158
|
+
// you must pass false here or three.js sadly fights the browser
|
|
159
|
+
this.renderer.setSize(width, height, false)
|
|
160
|
+
this.renderer.setViewport(0, 0, width, height)
|
|
161
|
+
|
|
162
|
+
this.camera.aspect = width / height
|
|
163
|
+
this.camera.updateProjectionMatrix()
|
|
164
|
+
|
|
165
|
+
// update any render target sizes here
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
}
|
package/src/main.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import Vuex from 'vuex'
|
|
3
|
+
import App from './App.vue'
|
|
4
|
+
// import axios from 'axios'
|
|
5
|
+
import threeDModule from './store/three-d-module'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Vue.use(Vuex)
|
|
9
|
+
|
|
10
|
+
const Renderer = class {
|
|
11
|
+
constructor(){}
|
|
12
|
+
mount(identifier,geometryData,specificData){
|
|
13
|
+
const myStore = new Vuex.Store({
|
|
14
|
+
modules:{
|
|
15
|
+
threeDModule:{
|
|
16
|
+
...threeDModule,
|
|
17
|
+
state:{...threeDModule.state,geometryData,...specificData}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
this.App=new Vue({
|
|
22
|
+
store:myStore,
|
|
23
|
+
render: (h) => h(App),
|
|
24
|
+
})
|
|
25
|
+
this.App.$mount(identifier)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {Renderer}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
multiplyVector,
|
|
3
|
+
getMarginPoint,
|
|
4
|
+
} from '@eturnity/eturnity_maths'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export function updateMarginsOutline(state){
|
|
8
|
+
state.polygons.filter(p=>p.layer=='roof').forEach(polygon=>{
|
|
9
|
+
polygon=getRoofMarginOutline(polygon)
|
|
10
|
+
})
|
|
11
|
+
state.polygons.filter(p=>p.layer=='obstacle').forEach(polygon=>{
|
|
12
|
+
polygon=getObstacleMarginOutline(polygon)
|
|
13
|
+
})
|
|
14
|
+
return state
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function updateMarginOutlinePolygon(polygon){
|
|
18
|
+
if(polygon.layer=="roof"){
|
|
19
|
+
return getRoofMarginOutline(polygon)
|
|
20
|
+
}else if(polygon.layer=='obstacle'){
|
|
21
|
+
return getObstacleMarginOutline(polygon)
|
|
22
|
+
}else{
|
|
23
|
+
return polygon
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getRoofMarginOutline(polygon){
|
|
28
|
+
|
|
29
|
+
let clockwiseNormalVector=polygon.normalVector
|
|
30
|
+
if(!polygon.isClockwise){
|
|
31
|
+
clockwiseNormalVector=multiplyVector(-1,clockwiseNormalVector)
|
|
32
|
+
}
|
|
33
|
+
//outterOutline is the outline close to the wall
|
|
34
|
+
polygon.margins.outterOutline=polygon.flatOutline
|
|
35
|
+
polygon.margins.innerOutline=[]
|
|
36
|
+
const length=polygon.margins.outterOutline.length
|
|
37
|
+
for(let index=0;index<length;index++){
|
|
38
|
+
const B=polygon.margins.outterOutline[index]
|
|
39
|
+
//A,B,C three consecutive points on the polygon.
|
|
40
|
+
//n is a vector in the plan normal to AB of length margin[A] directed towards the inside
|
|
41
|
+
//m is a vector in the plan normal to BC of length margin[B] directed towards the inside
|
|
42
|
+
//K is the margin outline linked with B
|
|
43
|
+
const A=polygon.margins.outterOutline[(index-1+length)%length]
|
|
44
|
+
const C=polygon.margins.outterOutline[(index+1)%length]
|
|
45
|
+
//filling the margins values if not initiated.
|
|
46
|
+
let marginA
|
|
47
|
+
let marginB
|
|
48
|
+
if(polygon.margins.isSameMargin){
|
|
49
|
+
marginA=polygon.margins.sameMargin
|
|
50
|
+
marginB=polygon.margins.sameMargin
|
|
51
|
+
polygon.margins.distances[index]=polygon.margins.sameMargin
|
|
52
|
+
}else{
|
|
53
|
+
if(!polygon.margins.distances[(index-1+length)%length]===undefined){
|
|
54
|
+
polygon.margins.distances[(index-1+length)%length]=polygon.margins.sameMargin
|
|
55
|
+
}
|
|
56
|
+
if(!polygon.margins.distances[index]===undefined){
|
|
57
|
+
polygon.margins.distances[index]=polygon.margins.sameMargin
|
|
58
|
+
}
|
|
59
|
+
marginA=polygon.margins.distances[(index-1+length)%length]
|
|
60
|
+
marginB=polygon.margins.distances[index]
|
|
61
|
+
}
|
|
62
|
+
let K=getMarginPoint(A,B,C,marginA,marginB,clockwiseNormalVector)
|
|
63
|
+
polygon.margins.innerOutline.push(K)
|
|
64
|
+
}
|
|
65
|
+
return polygon
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export function getObstacleMarginOutline(polygon){
|
|
70
|
+
let clockwiseNormalVector=polygon.normalVector
|
|
71
|
+
if(polygon.isClockwise){
|
|
72
|
+
clockwiseNormalVector=multiplyVector(-1,clockwiseNormalVector)
|
|
73
|
+
}
|
|
74
|
+
//outterOutline is the outline close to the wall
|
|
75
|
+
polygon.margins.innerOutline=polygon.flatOutline
|
|
76
|
+
polygon.margins.outterOutline=[]
|
|
77
|
+
const length=polygon.margins.innerOutline.length
|
|
78
|
+
for(let index=0;index<length;index++){
|
|
79
|
+
const B=polygon.margins.innerOutline[index]
|
|
80
|
+
//A,B,C three consecutive points on the polygon.
|
|
81
|
+
//n is a vector in the plan normal to AB of length margin[A] directed towards the inside
|
|
82
|
+
//m is a vector in the plan normal to BC of length margin[B] directed towards the inside
|
|
83
|
+
//K is the margin outline linked with B
|
|
84
|
+
const A=polygon.margins.innerOutline[(index-1+length)%length]
|
|
85
|
+
const C=polygon.margins.innerOutline[(index+1)%length]
|
|
86
|
+
//filling the margins values if not initiated.
|
|
87
|
+
let marginA
|
|
88
|
+
let marginB
|
|
89
|
+
if(polygon.margins.isSameMargin){
|
|
90
|
+
marginA=polygon.margins.sameMargin
|
|
91
|
+
marginB=polygon.margins.sameMargin
|
|
92
|
+
polygon.margins.distances[index]=polygon.margins.sameMargin
|
|
93
|
+
}else{
|
|
94
|
+
if(polygon.margins.distances[(index-1+length)%length]===undefined){
|
|
95
|
+
polygon.margins.distances[(index-1+length)%length]=polygon.margins.sameMargin
|
|
96
|
+
}
|
|
97
|
+
if(polygon.margins.distances[index]===undefined){
|
|
98
|
+
polygon.margins.distances[index]=polygon.margins.sameMargin
|
|
99
|
+
}
|
|
100
|
+
marginA=polygon.margins.distances[(index-1+length)%length]
|
|
101
|
+
marginB=polygon.margins.distances[index]
|
|
102
|
+
}
|
|
103
|
+
let K=getMarginPoint(A,B,C,marginA,marginB,clockwiseNormalVector)
|
|
104
|
+
polygon.margins.outterOutline.push(K)
|
|
105
|
+
}
|
|
106
|
+
return polygon
|
|
107
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
//Synchronisation with BE:
|
|
2
|
+
import {
|
|
3
|
+
Polygon,
|
|
4
|
+
updateComputedGeometryPolygon,
|
|
5
|
+
getRoofMarginOutline,
|
|
6
|
+
getObstacleMarginOutline
|
|
7
|
+
} from '@eturnity/eturnity_maths'
|
|
8
|
+
import getLayers from '../utils/layers'
|
|
9
|
+
import {
|
|
10
|
+
UpdateRoofObstacleRelations
|
|
11
|
+
} from '../helper/UpdateRoofObstacleRelations'
|
|
12
|
+
|
|
13
|
+
export async function hydrateData({ state, commit }, data) {
|
|
14
|
+
console.log(data)
|
|
15
|
+
let roofsResponse = data.roofs
|
|
16
|
+
let obstaclesResponse = data.obstacles
|
|
17
|
+
let moduleFieldsResponse = data.moduleFields
|
|
18
|
+
const layoutSettingResponse = data.layoutSettings
|
|
19
|
+
console.log("roofsResponse",roofsResponse)
|
|
20
|
+
console.log("obstaclesResponse",obstaclesResponse)
|
|
21
|
+
console.log("moduleFieldsResponse",moduleFieldsResponse)
|
|
22
|
+
console.log("layoutSettingResponse",layoutSettingResponse)
|
|
23
|
+
//removing empty roof,obstacle and modulefield generated by BE on variant creation
|
|
24
|
+
roofsResponse=roofsResponse.reduce((acc,cur)=>{
|
|
25
|
+
if(cur.roof_outline.length>0){acc.push(cur)}
|
|
26
|
+
return acc
|
|
27
|
+
},[])
|
|
28
|
+
obstaclesResponse=obstaclesResponse.reduce((acc,cur)=>{
|
|
29
|
+
if(cur.obstacle_outline.length>0){acc.push(cur)}
|
|
30
|
+
return acc
|
|
31
|
+
},[])
|
|
32
|
+
moduleFieldsResponse=moduleFieldsResponse.reduce((acc,cur)=>{
|
|
33
|
+
if(cur.module_field_outline.length>0){acc.push(cur)}
|
|
34
|
+
return acc
|
|
35
|
+
},[])
|
|
36
|
+
|
|
37
|
+
if (!!layoutSettingResponse) {
|
|
38
|
+
const layoutSetting = layoutSettingResponse
|
|
39
|
+
|
|
40
|
+
commit('mutate_layoutSettings', layoutSetting)
|
|
41
|
+
commit('mutate_module_texture_version_id', layoutSetting.module_texture_version_id)
|
|
42
|
+
let layers=getLayers()
|
|
43
|
+
console.log(layers,layoutSetting.map_layer)
|
|
44
|
+
let selectedLayer=layers.find(layer=>layer.key==layoutSetting.map_layer)
|
|
45
|
+
commit('mutate_selectedMapLayer', selectedLayer)
|
|
46
|
+
|
|
47
|
+
//end of layoutSetting correction
|
|
48
|
+
const newMapConfig = state.mapConfig
|
|
49
|
+
newMapConfig.center = {
|
|
50
|
+
lat: layoutSetting.layout_latitude,
|
|
51
|
+
lng: layoutSetting.layout_longitude
|
|
52
|
+
}
|
|
53
|
+
newMapConfig.layer = layoutSetting.map_layer
|
|
54
|
+
newMapConfig.zoom = layoutSetting.map_zoom
|
|
55
|
+
commit('mutate_mapConfig', newMapConfig)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const roofs = []
|
|
59
|
+
const obstacles = []
|
|
60
|
+
const moduleFields = []
|
|
61
|
+
const panels = []
|
|
62
|
+
const userDeactivatedPanels = []
|
|
63
|
+
let pv_module_ids = []
|
|
64
|
+
let mounting_system_ids = []
|
|
65
|
+
roofsResponse.forEach((roofResp) => {
|
|
66
|
+
const roof_outline = roofResp.roof_outline.map((p) => {
|
|
67
|
+
return { x: p[0], y: p[1], z: p[2] }
|
|
68
|
+
})
|
|
69
|
+
let roof = new Polygon(roof_outline, 'roof')
|
|
70
|
+
roof.id = roofResp.roof_uuid
|
|
71
|
+
roof.name = roofResp.roof_name
|
|
72
|
+
roof = updateComputedGeometryPolygon(roof)
|
|
73
|
+
roof.margins.distances = roofResp.roof_margins_mm
|
|
74
|
+
roof.margins.isSameMargin = roofResp.roof_margins_mm.every(
|
|
75
|
+
(val) => val == roofResp.roof_margins_mm[0]
|
|
76
|
+
)
|
|
77
|
+
roof.margins.sameMargin = roof.margins.isSameMargin
|
|
78
|
+
? roofResp.roof_margins_mm[0]
|
|
79
|
+
: 200
|
|
80
|
+
roof.moduleFields = []
|
|
81
|
+
roof = getRoofMarginOutline(roof)
|
|
82
|
+
roofs.push(roof)
|
|
83
|
+
})
|
|
84
|
+
obstaclesResponse.forEach((obstacleResp) => {
|
|
85
|
+
const obstacle_outline = obstacleResp.obstacle_outline.map((p) => {
|
|
86
|
+
return { x: p[0], y: p[1], z: p[2] }
|
|
87
|
+
})
|
|
88
|
+
let obstacle = new Polygon(obstacle_outline, 'obstacle')
|
|
89
|
+
obstacle.id = obstacleResp.obstacle_uuid
|
|
90
|
+
obstacle.height = obstacleResp.obstacle_height_above_ground_mm
|
|
91
|
+
obstacle.isParallel = obstacleResp.obstacle_slope_is_parallel_to_roof
|
|
92
|
+
obstacle = updateComputedGeometryPolygon(obstacle)
|
|
93
|
+
obstacle.margins.distances = obstacleResp.obstacle_margins_mm
|
|
94
|
+
obstacle.margins.isSameMargin = obstacleResp.obstacle_margins_mm.every(
|
|
95
|
+
(val) => val === obstacleResp.obstacle_margins_mm[0]
|
|
96
|
+
)
|
|
97
|
+
obstacle.margins.sameMargin = obstacle.margins.isSameMargin
|
|
98
|
+
? obstacleResp.obstacle_margins_mm[0]
|
|
99
|
+
: 200
|
|
100
|
+
obstacle = getObstacleMarginOutline(obstacle)
|
|
101
|
+
obstacles.push(obstacle)
|
|
102
|
+
})
|
|
103
|
+
moduleFieldsResponse.forEach((moduleFieldResp) => {
|
|
104
|
+
const module_field_outline = moduleFieldResp.module_field_outline.map(
|
|
105
|
+
(p) => {
|
|
106
|
+
return { x: p[0], y: p[1], z: p[2] }
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
let moduleField = new Polygon(module_field_outline, 'moduleField')
|
|
111
|
+
moduleField.id = moduleFieldResp.module_field_uuid
|
|
112
|
+
moduleField.data = {}
|
|
113
|
+
moduleField.data.texture_img_url = moduleFieldResp.texture_img_url
|
|
114
|
+
moduleField.data.col_spacing_mm = moduleFieldResp.col_spacing_mm
|
|
115
|
+
moduleField.data.row_spacing_mm = moduleFieldResp.row_spacing_mm
|
|
116
|
+
moduleField.data.offset = moduleFieldResp.offset
|
|
117
|
+
moduleField.data.panel_orientation = moduleFieldResp.panel_orientation
|
|
118
|
+
moduleField.data.panel_direction_degrees =
|
|
119
|
+
moduleFieldResp.panel_direction_degrees
|
|
120
|
+
moduleField.data.component_id_pv_module =
|
|
121
|
+
moduleFieldResp.component_id_pv_module
|
|
122
|
+
moduleField.data.component_id_mounting_system =
|
|
123
|
+
moduleFieldResp.component_id_mounting_system
|
|
124
|
+
moduleField.data.module_tilt_degrees = moduleFieldResp.module_tilt_degrees
|
|
125
|
+
moduleField.data.base_line_index = moduleFieldResp.base_line_index
|
|
126
|
+
pv_module_ids.push(moduleFieldResp.component_id_pv_module)
|
|
127
|
+
mounting_system_ids.push(moduleFieldResp.component_id_mounting_system)
|
|
128
|
+
|
|
129
|
+
moduleField.data.modules = moduleFieldResp.modules
|
|
130
|
+
moduleFieldResp.modules.forEach((m) => {
|
|
131
|
+
const panel = new Polygon(
|
|
132
|
+
m.outline.map((p) => {
|
|
133
|
+
return { x: p[0], y: p[1], z: p[2] }
|
|
134
|
+
}),
|
|
135
|
+
'panel'
|
|
136
|
+
)
|
|
137
|
+
panel.index = m.index
|
|
138
|
+
panel.moduleField = moduleField
|
|
139
|
+
panels.push(panel)
|
|
140
|
+
})
|
|
141
|
+
moduleField.data.user_deactivated_modules =
|
|
142
|
+
moduleFieldResp.user_deactivated_modules
|
|
143
|
+
moduleFieldResp.user_deactivated_modules.forEach((m) => {
|
|
144
|
+
const panel = new Polygon(
|
|
145
|
+
m.outline.map((p) => {
|
|
146
|
+
return { x: p[0], y: p[1], z: p[2] }
|
|
147
|
+
}),
|
|
148
|
+
'user_deactivated_panel'
|
|
149
|
+
)
|
|
150
|
+
panel.moduleField = moduleField
|
|
151
|
+
panel.index = m.index
|
|
152
|
+
userDeactivatedPanels.push(panel)
|
|
153
|
+
})
|
|
154
|
+
const roof = roofs.find((r) => r.id == moduleFieldResp.roof_uuid)
|
|
155
|
+
if (!roof.moduleFields) {
|
|
156
|
+
roof.moduleFields = []
|
|
157
|
+
}
|
|
158
|
+
roof.moduleFields.push(moduleField)
|
|
159
|
+
moduleField.roof = roof
|
|
160
|
+
moduleField.panels = panels
|
|
161
|
+
moduleField.userDeactivatedPanels = userDeactivatedPanels
|
|
162
|
+
moduleField = updateComputedGeometryPolygon(moduleField)
|
|
163
|
+
moduleFields.push(moduleField)
|
|
164
|
+
})
|
|
165
|
+
//Get PV & Mounting system component Data (texture):
|
|
166
|
+
pv_module_ids = [...new Set(pv_module_ids)]
|
|
167
|
+
mounting_system_ids = [...new Set(mounting_system_ids)]
|
|
168
|
+
const promiseList = []
|
|
169
|
+
// for (let k in pv_module_ids) {
|
|
170
|
+
// promiseList.push(
|
|
171
|
+
// axios.get('/component_library/products/pv_modules/' + pv_module_ids[k])
|
|
172
|
+
// )
|
|
173
|
+
// }
|
|
174
|
+
// for (let k in mounting_system_ids) {
|
|
175
|
+
// promiseList.push(
|
|
176
|
+
// axios.get(
|
|
177
|
+
// '/component_library/products/mounting_systems/' + mounting_system_ids[k]
|
|
178
|
+
// )
|
|
179
|
+
// )
|
|
180
|
+
// }
|
|
181
|
+
// const results = await Promise.all(promiseList)
|
|
182
|
+
// for (let k in pv_module_ids) {
|
|
183
|
+
// const pv_module_id = pv_module_ids[k]
|
|
184
|
+
// const pvData = results[k].data
|
|
185
|
+
// moduleFields.forEach((m) => {
|
|
186
|
+
// if (m.data.component_id_pv_module == pv_module_id) {
|
|
187
|
+
// m.pvData = pvData
|
|
188
|
+
// }
|
|
189
|
+
// })
|
|
190
|
+
// }
|
|
191
|
+
// for (let k in mounting_system_ids) {
|
|
192
|
+
// const mounting_system_id = mounting_system_ids[k]
|
|
193
|
+
// const mountingData = results[parseInt(k) + pv_module_ids.length].data
|
|
194
|
+
// moduleFields.forEach((m) => {
|
|
195
|
+
// if (m.data.component_id_mounting_system == mounting_system_id) {
|
|
196
|
+
// m.mountingData = mountingData
|
|
197
|
+
// }
|
|
198
|
+
// })
|
|
199
|
+
// }
|
|
200
|
+
state.polygons = [
|
|
201
|
+
...roofs,
|
|
202
|
+
...obstacles,
|
|
203
|
+
...moduleFields,
|
|
204
|
+
...panels,
|
|
205
|
+
...userDeactivatedPanels
|
|
206
|
+
]
|
|
207
|
+
state = UpdateRoofObstacleRelations(state)
|
|
208
|
+
}
|
|
209
|
+
|