@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "7.16.0-qa-dev03.4",
3
+ "version": "7.16.0-qa-09.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
@@ -1,13 +1,13 @@
1
1
 
2
2
  import {
3
- translate2D,
4
- getDegree
3
+ translate2D,
4
+ getDegree
5
5
  } from '../geometry'
6
6
  import {
7
- substractVector,
8
- normalizeVector,
9
- multiplyVector,
10
- addVector
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
- getDirectionSnapAngle(){
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
- return [toCanvasRef(D),toCanvasRef(F),toCanvasRef(E)]
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
- } else if (this.layer == 'panel') {
171
- extraSerialization.index = this.index
172
- extraSerialization.moduleField = { id: this.moduleField.id }
173
- } else if (this.layer == 'user_deactivated_panel') {
174
- extraSerialization.index = this.index
175
- extraSerialization.moduleField = { id: this.moduleField.id }
176
- }
177
- return JSON.parse(JSON.stringify({ ...baseSerialization, ...extraSerialization }))
178
- }
179
- serializeForBEStorage() {
180
- if (this.layer == 'roof') {
181
- const margins_roof_mm = this.margins.isSameMargin
182
- ? Array(this.outline.length).fill(this.margins.sameMargin)
183
- : this.margins.distances
184
- return {
185
- roof_uuid: this.id,
186
- version: this.version,
187
- roof_outline: this.outline.map((v) => [v.x, v.y, v.z]),
188
- roof_margins_mm: margins_roof_mm,
189
- roof_slope_degrees: this.incline,
190
- roof_orientation_degrees: this.direction,
191
- roof_name: this.name,
192
- shading_data: this.shadingData ? this.shadingData : undefined
193
- }
194
- } else if (this.layer == 'obstacle') {
195
- const margins_obstacle_mm = this.margins.isSameMargin
196
- ? Array(this.outline.length).fill(this.margins.sameMargin)
197
- : this.margins.distances
198
- return {
199
- obstacle_uuid: this.id,
200
- version: this.version,
201
- obstacle_outline: this.outline.map((v) => [v.x, v.y, v.z]),
202
- obstacle_margins_mm: margins_obstacle_mm,
203
- obstacle_height_above_ground_mm: this.height,
204
- obstacle_slope_is_parallel_to_roof: this.isParallel
205
- }
206
- } else if (['moduleField', 'tmpModuleField'].includes(this.layer)) {
207
- if (!this.panels) {
208
- this.panels = []
209
- }
210
- if (!this.userDeactivatedPanels) {
211
- this.userDeactivatedPanels = []
212
- }
213
- const modules = this.data.modules
214
- return {
215
- module_field_uuid: this.id,
216
- roof_uuid: this.roof.id,
217
- version: this.version,
218
- module_field_outline: this.outline.map((v) => [v.x, v.y, v.z]),
219
- col_spacing_mm: this.data.col_spacing_mm,
220
- row_spacing_mm: this.data.row_spacing_mm,
221
- offset_percent: this.data.offset_percent,
222
- panel_orientation: this.data.panel_orientation,
223
- panel_direction_degrees: this.data.panel_direction_degrees,
224
- component_id_pv_module: this.data.component_id_pv_module,
225
- component_id_mounting_system: this.data.component_id_mounting_system,
226
- modules: modules,
227
- module_tilt_degrees: this.data.module_tilt_degrees,
228
- base_line_index: this.data.base_line_index,
229
- justify_percent: this.data.justify_percent,
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
- number_of_panels_override:!!this.data.number_of_panels_override,
232
- number_of_panels:this.data.number_of_panels,
233
- yearly_yield_manual_entry:this.data.yearly_yield_manual_entry,
234
- yearly_yield_kwh_kwp:this.data.yearly_yield_kwh_kwp,
235
- yearly_yield_kwh_kwp_2:this.data.yearly_yield_kwh_kwp_2
236
- }
237
- } else if (['panel', 'user_deactivated_panel'].includes(this.layer)) {
238
- return {
239
- id: this.id,
240
- index: this.index,
241
- outline: this.outline.map((v) => [v.x, v.y, v.z]),
242
- moduleField: {
243
- id: this.moduleField.id
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
  }