Created
          March 29, 2019 17:29 
        
      - 
      
 - 
        
Save berinhard/a718f0ab07e83c3fc64d6b0dc00675c0 to your computer and use it in GitHub Desktop.  
    Exemplo 006
  
        
  
    
      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 | |
| @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, geometria=None, unidade=None): | |
| geometria = geometria or GeometriaPlana() | |
| unidade = unidade or UnidadeQuilometro() | |
| dist = self.geometria.distance(self.phi, self.theta, pos.phi, pos.theta) | |
| return self.unidade.converte(dist) | |
| def direcao(self, pos, geometria=None): | |
| geometria = geometria or GeometriaPlana() | |
| 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