def validate_alignment(self): ''' Ensure the alignment geometry is continuous. Any discontinuities (gaps between end / start coordinates) must be filled by a completely defined line ''' _prev_coord = self.geometry['meta']['Start'] _geo_list = [] for _geo in self.geometry['geometry']: if not _geo: continue _coord = _geo['Start'] if not Support.within_tolerance(_coord.Length, _prev_coord.Length): #build the line using the provided parameters and add it _geo_list.append( Line.get_parameters({ 'Start': App.Vector(_prev_coord), 'End': App.Vector(_coord), 'BearingIn': _geo['BearingIn'], 'BearingOut': _geo['BearingOut'], })) _geo_list.append(_geo) _prev_coord = _geo['End'] self.geometry['geometry'] = _geo_list
def set_geometry(self, geometry): ''' Assign geometry to the alignment object ''' self.geometry = geometry self.assign_meta_data() self.assign_station_data() for _i, _geo in enumerate(self.geometry['geometry']): if _geo['Type'] == 'Curve': _geo = Arc.get_parameters(_geo) elif _geo['Type'] == 'Line': _geo = Line.get_parameters(_geo) else: self.errors.append('Undefined geometry: ' + _geo) continue self.geometry['geometry'][_i] = _geo self.validate_datum() self.validate_stationing() if not self.validate_bearings(): return False self.validate_coordinates() self.validate_alignment() #call once more to catch any added geometry from validate_alignment() self.validate_stationing() return True