Guest User

Untitled

a guest
Jul 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. class Zone:
  2.  
  3. ZONE = []
  4. MIN_LONGITUDE_DEGREES = -180
  5. MAX_LONGITUDE_DEGREES = 180
  6. MIN_LATITUDE_DEGREES = -90
  7. MAX_LATITUDE_DEGREES = 90
  8. WIDTH_DEGREES = 1
  9. HEIGHT_DEGREES = 1
  10.  
  11. def __init__(self, corner1, corner2):
  12. self.corner1 = corner1
  13. self.corner2 = corner2
  14. self.inhabitants = 0
  15.  
  16. @classmethod # etand donner qu'on ne sommes plus dans l'instance, masi oui dans la classe il faut changer self par cls
  17. def initialize_zones(cls):
  18. for latitude in range(cls.MIN_LATITUDE_DEGREES, cls.MAX_LATITUDE_DEGREES):
  19. for longitude in range(cls.MIN_LONGITUDE_DEGREES, cls.MAX_LONGITUDE_DEGREES, WIDTH_DEGREES):
  20. bottom_left_corner = Position(longitude, latitude)
  21. top_right_corner = Position(longitude + cls.WIDTH_DEGREES, latitude + cls.HEIGHT_DEGREES)
  22. zone = Zone(bottom_left_corner, top_right_corner)
  23. cls.ZONE.append(zone)
  24. #zone = Zone(bottem_letf_corner, top_right_corner)
  25. print(len(cls.ZONES))
  26.  
  27.  
  28. def main():
  29.  
  30. for agent_attributes in json.load(open("agents-100k.json")):
  31. latitude = agent_attributes.pop('latitude')
  32. longitude = agent_attributes.pop('longitude')
  33. position = Position(longitude, latitude)
  34. agent = Agent(position, **agent_attributes)
  35. Zone.initialize_zones()
  36.  
  37. main()
Add Comment
Please, Sign In to add comment