@eturnity/eturnity_maths 7.16.0-qa-dev03.4 → 7.16.0-qa-09.0
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/package.json +1 -1
- package/src/objects/Polygon.js +161 -87
package/package.json
CHANGED
package/src/objects/Polygon.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
translate2D,
|
|
4
|
+
getDegree
|
|
5
5
|
} from '../geometry'
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
substractVector,
|
|
8
|
+
normalizeVector,
|
|
9
|
+
multiplyVector,
|
|
10
|
+
addVector
|
|
11
11
|
} from '../vector'
|
|
12
12
|
|
|
13
13
|
import { v4 as uuidv4 } from 'uuid'
|
|
@@ -55,8 +55,15 @@ export class Polygon {
|
|
|
55
55
|
const secondPoint = this.outline[i % length]
|
|
56
56
|
const thirdPoint = this.outline[(i + 1) % length]
|
|
57
57
|
return getDegree(firstPoint, secondPoint, thirdPoint)
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
}
|
|
59
|
+
getAngleFromTop(i){
|
|
60
|
+
const length=this.outline.length
|
|
61
|
+
const firstPoint = {...this.outline[(i-1+length) % length],z:0}
|
|
62
|
+
const secondPoint = {...this.outline[i % length],z:0}
|
|
63
|
+
const thirdPoint = {...this.outline[(i + 1) % length],z:0}
|
|
64
|
+
return getDegree(firstPoint, secondPoint, thirdPoint)
|
|
65
|
+
}
|
|
66
|
+
getDirectionSnapAngle(){
|
|
60
67
|
let angles=[]
|
|
61
68
|
for(let k=0;k<this.outline.length;k++){
|
|
62
69
|
let p_0=this.outline[k]
|
|
@@ -100,9 +107,74 @@ export class Polygon {
|
|
|
100
107
|
const E=addVector(B,BE)
|
|
101
108
|
const F=addVector(D,BE)
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
return [toCanvasRef(D),toCanvasRef(F),toCanvasRef(E)]
|
|
111
|
+
}
|
|
105
112
|
|
|
113
|
+
<<<<<<< HEAD
|
|
114
|
+
translate(vectorInMm) {
|
|
115
|
+
this.version++
|
|
116
|
+
this.outline = this.outline.map((point) => {
|
|
117
|
+
return translate2D(point, vectorInMm)
|
|
118
|
+
})
|
|
119
|
+
updateComputedGeometryPolygon(this)
|
|
120
|
+
}
|
|
121
|
+
serialize() {
|
|
122
|
+
const baseSerialization = {
|
|
123
|
+
id: this.id,
|
|
124
|
+
version: this.version,
|
|
125
|
+
name: this.name,
|
|
126
|
+
type: this.type,
|
|
127
|
+
outline: this.outline.map(p=>{return {
|
|
128
|
+
x: p.x,
|
|
129
|
+
y: p.y,
|
|
130
|
+
z: p.z,
|
|
131
|
+
selected:p.selected,
|
|
132
|
+
open:p.open,
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
holes: this.holes.map((p) => p.id),
|
|
136
|
+
layer: this.layer,
|
|
137
|
+
highlight: this.highlight,
|
|
138
|
+
visible: this.visible,
|
|
139
|
+
margins: {
|
|
140
|
+
isSameMargin:this.margins.isSameMargin,
|
|
141
|
+
sameMargin:this.margins.sameMargin,
|
|
142
|
+
distances:JSON.parse(JSON.stringify(this.margins.distances))
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const extraSerialization = {}
|
|
146
|
+
if (this.layer == 'roof') {
|
|
147
|
+
extraSerialization.moduleFields = this.moduleFields.map((m) => {
|
|
148
|
+
return {
|
|
149
|
+
id: m.id
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
} else if (this.layer == 'obstacle') {
|
|
153
|
+
extraSerialization.isParallel = this.isParallel
|
|
154
|
+
extraSerialization.height = this.height
|
|
155
|
+
extraSerialization.roofs = this.roofs.map((roof) => {
|
|
156
|
+
return { id: roof.id }
|
|
157
|
+
})
|
|
158
|
+
} else if (this.layer == 'moduleField') {
|
|
159
|
+
const modules=[]
|
|
160
|
+
if(this.panels){
|
|
161
|
+
this.panels.forEach((p) => {
|
|
162
|
+
modules.push({ id: p.id, index: p.index, outline: p.outline, status: p.status || 'active',clipped:p.clipped || false })
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
if(this.userDeactivatedPanels){
|
|
166
|
+
this.userDeactivatedPanels.forEach((p) => {
|
|
167
|
+
modules.push({ id: p.id, index: p.index, outline: p.outline, status: p.status || 'user_deactivated',clipped:p.clipped || false })
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
extraSerialization.data = {...this.data,modules:[...this.data.modules]}
|
|
171
|
+
extraSerialization.roof = { id: this.roof.id }
|
|
172
|
+
extraSerialization.pvData = this.pvData?{...this.pvData}:null
|
|
173
|
+
extraSerialization.mountingData = this.mountingData?{...this.mountingData}:null
|
|
174
|
+
extraSerialization.modules = modules
|
|
175
|
+
extraSerialization.needsOptimisation = this.needsOptimisation
|
|
176
|
+
extraSerialization.priority = this.priority
|
|
177
|
+
=======
|
|
106
178
|
translate(vectorInMm) {
|
|
107
179
|
this.version++
|
|
108
180
|
this.outline = this.outline.map((point) => {
|
|
@@ -121,6 +193,7 @@ export class Polygon {
|
|
|
121
193
|
y: p.y,
|
|
122
194
|
z: p.z,
|
|
123
195
|
selected:p.selected,
|
|
196
|
+
locked:p.locked,
|
|
124
197
|
open:p.open,
|
|
125
198
|
}
|
|
126
199
|
}),
|
|
@@ -166,83 +239,84 @@ export class Polygon {
|
|
|
166
239
|
extraSerialization.modules = modules
|
|
167
240
|
extraSerialization.needsOptimisation = this.needsOptimisation
|
|
168
241
|
extraSerialization.priority = this.priority
|
|
242
|
+
>>>>>>> qa-dev03-7.16.0
|
|
169
243
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
244
|
+
} else if (this.layer == 'panel') {
|
|
245
|
+
extraSerialization.index = this.index
|
|
246
|
+
extraSerialization.moduleField = { id: this.moduleField.id }
|
|
247
|
+
} else if (this.layer == 'user_deactivated_panel') {
|
|
248
|
+
extraSerialization.index = this.index
|
|
249
|
+
extraSerialization.moduleField = { id: this.moduleField.id }
|
|
250
|
+
}
|
|
251
|
+
return JSON.parse(JSON.stringify({ ...baseSerialization, ...extraSerialization }))
|
|
252
|
+
}
|
|
253
|
+
serializeForBEStorage() {
|
|
254
|
+
if (this.layer == 'roof') {
|
|
255
|
+
const margins_roof_mm = this.margins.isSameMargin
|
|
256
|
+
? Array(this.outline.length).fill(this.margins.sameMargin)
|
|
257
|
+
: this.margins.distances
|
|
258
|
+
return {
|
|
259
|
+
roof_uuid: this.id,
|
|
260
|
+
version: this.version,
|
|
261
|
+
roof_outline: this.outline.map((v) => [v.x, v.y, v.z]),
|
|
262
|
+
roof_margins_mm: margins_roof_mm,
|
|
263
|
+
roof_slope_degrees: this.incline,
|
|
264
|
+
roof_orientation_degrees: this.direction,
|
|
265
|
+
roof_name: this.name,
|
|
266
|
+
shading_data: this.shadingData ? this.shadingData : undefined
|
|
267
|
+
}
|
|
268
|
+
} else if (this.layer == 'obstacle') {
|
|
269
|
+
const margins_obstacle_mm = this.margins.isSameMargin
|
|
270
|
+
? Array(this.outline.length).fill(this.margins.sameMargin)
|
|
271
|
+
: this.margins.distances
|
|
272
|
+
return {
|
|
273
|
+
obstacle_uuid: this.id,
|
|
274
|
+
version: this.version,
|
|
275
|
+
obstacle_outline: this.outline.map((v) => [v.x, v.y, v.z]),
|
|
276
|
+
obstacle_margins_mm: margins_obstacle_mm,
|
|
277
|
+
obstacle_height_above_ground_mm: this.height,
|
|
278
|
+
obstacle_slope_is_parallel_to_roof: this.isParallel
|
|
279
|
+
}
|
|
280
|
+
} else if (['moduleField', 'tmpModuleField'].includes(this.layer)) {
|
|
281
|
+
if (!this.panels) {
|
|
282
|
+
this.panels = []
|
|
283
|
+
}
|
|
284
|
+
if (!this.userDeactivatedPanels) {
|
|
285
|
+
this.userDeactivatedPanels = []
|
|
286
|
+
}
|
|
287
|
+
const modules = this.data.modules
|
|
288
|
+
return {
|
|
289
|
+
module_field_uuid: this.id,
|
|
290
|
+
roof_uuid: this.roof.id,
|
|
291
|
+
version: this.version,
|
|
292
|
+
module_field_outline: this.outline.map((v) => [v.x, v.y, v.z]),
|
|
293
|
+
col_spacing_mm: this.data.col_spacing_mm,
|
|
294
|
+
row_spacing_mm: this.data.row_spacing_mm,
|
|
295
|
+
offset_percent: this.data.offset_percent,
|
|
296
|
+
panel_orientation: this.data.panel_orientation,
|
|
297
|
+
panel_direction_degrees: this.data.panel_direction_degrees,
|
|
298
|
+
component_id_pv_module: this.data.component_id_pv_module,
|
|
299
|
+
component_id_mounting_system: this.data.component_id_mounting_system,
|
|
300
|
+
modules: modules,
|
|
301
|
+
module_tilt_degrees: this.data.module_tilt_degrees,
|
|
302
|
+
base_line_index: this.data.base_line_index,
|
|
303
|
+
justify_percent: this.data.justify_percent,
|
|
230
304
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
305
|
+
number_of_panels_override:!!this.data.number_of_panels_override,
|
|
306
|
+
number_of_panels:this.data.number_of_panels,
|
|
307
|
+
yearly_yield_manual_entry:this.data.yearly_yield_manual_entry,
|
|
308
|
+
yearly_yield_kwh_kwp:this.data.yearly_yield_kwh_kwp,
|
|
309
|
+
yearly_yield_kwh_kwp_2:this.data.yearly_yield_kwh_kwp_2
|
|
310
|
+
}
|
|
311
|
+
} else if (['panel', 'user_deactivated_panel'].includes(this.layer)) {
|
|
312
|
+
return {
|
|
313
|
+
id: this.id,
|
|
314
|
+
index: this.index,
|
|
315
|
+
outline: this.outline.map((v) => [v.x, v.y, v.z]),
|
|
316
|
+
moduleField: {
|
|
317
|
+
id: this.moduleField.id
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
248
322
|
}
|