Created
          March 18, 2019 20:49 
        
      - 
      
 - 
        
Save berinhard/e171e5faaa01841548d1e2483434a86a to your computer and use it in GitHub Desktop.  
    Exemplo 005
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import math | |
| class Posicao(): | |
| def __init__(self, lat, lng): | |
| self.lat, self.lng = lat, lng | |
| self.geometria = GeometriaPlana() | |
| self.unidade = UnidadeQuilometro() | |
| @property | |
| def lat(self): | |
| return math.degree(self.phi) | |
| @lat.setter | |
| def lat(self, value): | |
| self.phi = math.radians(value) | |
| @property | |
| def phi(self): | |
| return self._phi | |
| @phi.setter | |
| def phi(self, value): | |
| if not -math.pi / 2 <= value <= math.pi / 2: | |
| raise ValueError("Latitude inválida") | |
| self._phi = value | |
| @property | |
| def lng(self): | |
| return math.degree(self.theta) | |
| @lng.setter | |
| def lng(self, value): | |
| self.theta = math.radians(value) | |
| @property | |
| def theta(self): | |
| return self._theta | |
| @theta.setter | |
| def theta(self, value): | |
| if not -math.pi <= value <= math.pi : | |
| raise ValueError("Longitude inválida") | |
| self._theta = value | |
| def distancia(self, pos): | |
| dist = self.geometria.distance(self.phi, self.theta, pos.phi, pos.theta) | |
| return self.unidade.converte(dist) | |
| def direcao(self, pos): | |
| return self.geometria.direcao(self.phi, self.theta, pos.phi, pos.theta) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment