Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

# coding=utf-8 

 

import math 

import pickle 

from collections import namedtuple 

 

# noinspection PyProtectedMember 

from emiz._parking_spots import parkings 

from emiz.mission import Static 

 

ParkingSpot = namedtuple('ParkingSpot', 'airport spot') 

parkings = pickle.loads(parkings) 

 

 

def clear_farps(): 

parkings['FARP'] = {} 

 

 

def add_farp(farp: Static): 

parkings['FARP'][farp.static_name] = farp.static_position 

 

 

def unit_pos_to_spot(unit_pos) -> ParkingSpot: 

min_ = 50 

res = None 

for airport in parkings: 

for spot in parkings[airport]: 

spot_pos = parkings[airport][spot] 

dist = math.hypot(unit_pos[0] - spot_pos[0], unit_pos[1] - spot_pos[1]) 

if dist < min_: 

min_ = dist 

res = ParkingSpot(airport=airport, spot=spot) 

return res