extract informations about corners

This commit is contained in:
GotPPay
2017-12-24 23:35:11 +01:00
parent db7453f438
commit 7daa9db4ed
3 changed files with 53 additions and 2 deletions

View File

@@ -290,6 +290,7 @@ def array_summary():
calculator.subarrays,
max_y)
context['buildings'] = project_presenter.get_buildings(calculator.buildings_for_drawing, max_y)
context['corners'] = project_presenter.get_corners(calculator.buildings)
context['override_form'] = True
context['cad_file_name'] = session_manager.site.cad_file_name or 'Upload System Text Data'
context['dxf_file_name'] = session_manager.site.dxf_file_name or 'Upload System DXF'
@@ -297,6 +298,11 @@ def array_summary():
context['inaccurate_drawing_warning'] = 'The subarrays in this design are not parallel to each other, \
and the graphical representation on this page may not be accurate.'
print("=================")
print("CORNERS : ")
print(context['corners'])
print("=================")
except FileValidationException as error:
# when calculator is about to enter infinte loop
# it throws an exception - it is supplied wrong data

12
helix/models/corner.py Normal file
View File

@@ -0,0 +1,12 @@
class Corner(object):
def __init__(self, x, y, length, angle):
self.x = x
self.y = y
self.length = length
self.angle = angle
@property
def dictionary(self):
return {"x": self.x, "y": self.y, "length": self.length, "angle": self.angle}

View File

@@ -1,4 +1,6 @@
import sys
from math import sqrt, atan, degrees
from helix.models.corner import Corner
class ProjectPresenter(object):
def __init__(self, system_type, module_type):
@@ -18,8 +20,6 @@ class ProjectPresenter(object):
spacing_x, spacing_y = module_constants.presenter_spacing
wind_zones = system_constants.wind_zones
for panel in panels:
subarray = [x for x in subarrays if x.subarray_number == panel.subarray][0]
origin = subarray.origin
@@ -73,6 +73,39 @@ class ProjectPresenter(object):
return result
def get_corners(self, buildings):
result = []
for building in buildings:
presentable_building = []
result.append(presentable_building)
previous_corner = building[-1]
for i, corner in enumerate(building):
if (i+1 == len(building)):
next_corner = building[0]
else:
next_corner = building[i+1]
corner_length = sqrt((next_corner[0] - corner[0])**2 + (next_corner[1] - corner[1])**2)
k1 = (corner[1] - previous_corner[1]) / (corner[0] - previous_corner[0])
k2 = (next_corner[1] - corner[1]) / (next_corner[0] - corner[0])
theta1 = degrees(atan(k1))
theta2 = degrees(atan(k2))
theta1 = theta1 - theta2
if (theta1 < 0):
if (k1 < 0 and k2 < 0):
theta1 = 360 + theta1
elif (k1 < 0 and k2 > 0):
theta1 = 180 + theta1
else:
if (k1 > 0 and k2 > 0):
theta1 = 180 + theta1
corner_angle = theta1
presentable_building.append(Corner(corner[0], corner[1], corner_length, corner_angle).__dict__)
previous_corner = corner
return result
def get_max_y(self,buildings, panels):
module_constants = self.system_type.module_constants(self.module_type)