def testAddValueToAltitude(self): rawDataCopy = bytearray(rawData) deltaValue = 138.31 sourceValue = BGLStructure.subsectionData[248].entities[49].segments[ 0].altitude[0] destValue = 138.31 + sourceValue bglTested.AddValueToAltitude( deltaValue, rawDataCopy, BGLStructure.subsectionData[248].entities[49].segments[0]) bglStructureCopy = bglTested.parse(rawDataCopy) checkedValue = bglTested.parse(rawDataCopy).subsectionData[ 248].entities[49].segments[0].altitude[0] self.assertEqual('%.3f' % (destValue), '%.3f' % (checkedValue))
def testChangeAltitudeIlsRecordsAssignedToAirportRecord(self): rawDataCopy = bytearray(rawDataAPX5828) airportRecord = BGLStructureAPX_5828.sections[0].subsectionData[ 3].records[2] airportRecord.setAltitude(2300.1, rawDataCopy) bglStructureCopy = bglTested.parse(rawDataCopy) ilsRecord = bglStructureCopy.sections[2].subsectionData[0].records[0] self.assertEqual(2300.1, ilsRecord.altitude)
def testSetAltitudeToCvxAirportSegment(self): rawDataCopy = bytearray(rawData) destValue = 158.31 cvxAirportSegment = BGLStructure.subsectionData[248].entities[ 49].segments[0] cvxAirportSegment.setAltitude(destValue, rawDataCopy) checkedValue = bglTested.parse(rawDataCopy).subsectionData[ 248].entities[49].segments[0].altitude[0] self.assertEqual('%.3f' % (destValue), '%.3f' % (checkedValue))
def testSetValueToAirport(self): rawDataCopy = bytearray(rawApxData) destValue = 114.24 bglStruct = BGLStructure_apx airport = bglStruct.subsectionData[0].records[1] airport.setAltitude(destValue, rawDataCopy) bglStructCopy = bglTested.parse(rawDataCopy) airportFromCopy = bglStructCopy.subsectionData[0].records[1] self.assertEqual('%.3f' % (destValue), '%.3f' % (airportFromCopy.altitude)) self.assertEqual('%.3f' % (destValue), '%.3f' % (airportFromCopy.subrecords[1].elevation)) #runway self.assertEqual('%.3f' % (destValue), '%.3f' % (airportFromCopy.subrecords[3].elevation)) #start
import bglTested from struct import unpack fileName = "cvx9247.bgl" fileCVX = open(fileName, "rb") rawData = fileCVX.read() fileCVX.close() BGLStructure = bglTested.parse(rawData) segments = BGLStructure.subsectionData[248].entities[49].segments for seg in segments: print('altitude', seg.altitude) print('final coordinates') finCoord = seg.CalculateFinalCoordinates() for fC in finCoord: print(fC[0], fC[1]) """ Use a bytearray: >>> frame = bytearray() >>> frame.append(0xA2) >>> frame.append(0x01) >>> frame.append(0x02) >>> frame.append(0x03) >>> frame.append(0x04) >>> frame bytearray(b'\xa2\x01\x02\x03\x04')
file_cvx_NameCopy = file_cvx_Name_0 + '_bak' + fileName_ext file_APX_NameCopy = file_APX_Name_0 + '_bak' + fileName_ext file_cvx_Source = open(file_cvx_Name, "rb") raw_cvx_Data = file_cvx_Source.read() file_cvx_Source.close() file_APX_Source = open(file_APX_Name, "rb") raw_APX_Data = file_APX_Source.read() file_APX_Source.close() if lat != None and lon != None: print('wyszukać z obu plików lotnisko najbliższe współrzędnym') #~ else: bgl_APX_Structure = bglTested.parse(raw_APX_Data) bgl_cvx_Structure = bglTested.parse(raw_cvx_Data) airports = [] for subs in bgl_APX_Structure.subsectionData: for rec in subs.records: airports += [rec] a_numb = 0 for apt in airports: toPrint = '[' + str(a_numb) + ']' + ' ' + str(apt.getICAO()) + ' ' + str( apt.name) + ' ' + str(apt.latitude) + ' ' + str( apt.longtitude) + ' ' + str(apt.altitude) print(toPrint) a_numb += 1 which_airport = int(input('w którym lotnisku zmieniamy wysokość?:')) newAltitude = input('podaj nową wysokość koniec(q)')
if decision == 'n': exit() fileSource = open(fileName, "rb") rawData = fileSource.read() fileSource.close() fileCopy = open(fileNameCopy, "wb") fileCopy.write(rawData) fileCopy.close() copyRawData = bytearray(rawData) airportSegments = [] i = 0 for a_seg in bglTested.FindAirportSegments(bglTested.parse(rawData)): airportSegments.append(a_seg) entity = a_seg.owner_entity subsection = entity.owner_subsection coords = bglTested.GetMeanCoordinates(a_seg.CalculateFinalCoordinates()) print('[', i, ']', subsection.nr_id, entity.nr_id, a_seg.altitude[0], coords[0], coords[1]) i += 1 inp = None while inp != 'q': inp = input('którą wysokość zmieniamy (q - koniec):') if inp == 'q': break inp = int(inp) if inp < len(airportSegments):
fileCVX.close() fileApx = open("APX92470.bgl", "rb") rawApxData = fileApx.read() fileApx.close() fileCVX5828 = open("cvx5828.bgl", "rb") rawDataCVX5828 = fileCVX5828.read() fileCVX5828.close() fileAPX5828 = open("APX58280.bgl", "rb") rawDataAPX5828 = fileAPX5828.read() fileAPX5828.close() subsections = bglTested.getSubsections(rawData) BGLStructure = bglTested.parse(rawData) BGLStructure_apx = bglTested.parse(rawApxData) BGLStructureCVX5828 = bglTested.parse(rawDataCVX5828) BGLStructureAPX_5828 = bglTested.parse(rawDataAPX5828) chain = '84 3E 56 37 65 10 74 1D 3C 44 5B 9F 11 C5 D0 05 C9 2C F3 D5 B2 3A 8D 8A 8D 9D 9B 67 8B ED 52 59 B3 BC 0B 36 35 5F 54 25 B5 33 30 6D E2 64 4B EB 36 A1 8F D5 0D' chain = chain.split() chain = bytes([int('0x' + chain[i], 16) for i in range(len(chain))]) result = '3E84 6EAC 4194 6BA0 43C1 6B68 4467 6862 4905 6659 4B57 69D5 58A8 73B1 59E6 76C5 5952 7966 582E 79A9 5545 76A4 4C0C 7136 4B64 6DD6 3E84 6EAC' result = result.split() result = [int('0x' + result[i], 16) for i in range(len(result))] maskRoot = 0xf nbPoints = 14