Add max distance for adjacent buildings in the config file.

If the distance is bigger than the given one it's not even checked for shared walls
This commit is contained in:
Guille Gutierrez 2020-06-22 14:35:52 -04:00
parent 0b187a05a1
commit 02d6c652e0

View File

@ -4,12 +4,12 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
import math
from datetime import datetime
import numpy as np
import open3d as o3d
from trimesh import Trimesh
from trimesh import intersections
from helpers.configuration_helper import ConfigurationHelper
class GeometryHelper:
@ -19,6 +19,18 @@ class GeometryHelper:
def __init__(self, delta=0.5):
self._delta = delta
def adjacent_locations(self, location1, location2):
"""
Determine when two buildings may be adjacent or not based in the dis
:param location1:
:param location2:
:return: Boolean
"""
max_distance = ConfigurationHelper().max_location_distance_for_shared_walls
x = location1[0] - location2[0]
y = location1[1] - location2[1]
return math.sqrt(math.pow(x, 2) + math.pow(y, 2)) < max_distance
def almost_equal(self, v1, v2):
"""
Compare two points and decides if they are almost equal (quadratic error under delta)
@ -36,7 +48,6 @@ class GeometryHelper:
:param s2: Surface
:return: Boolean
"""
start = datetime.utcnow()
# delta is grads an need to be converted into radians
delta = np.rad2deg(self._delta)
@ -61,7 +72,7 @@ class GeometryHelper:
minimum_distance = distance
if minimum_distance <= self._delta:
break
print('intersect', datetime.utcnow() - start)
if minimum_distance > self._delta or s1.intersect(s2) is None:
return False
else: