2015-07-08 14:37:25 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
2015-07-09 16:40:44 +02:00
|
|
|
import json
|
|
|
|
|
|
|
|
|
2015-07-08 14:37:25 +02:00
|
|
|
class Location(object):
|
2015-07-09 02:58:13 +02:00
|
|
|
def __init__(self,
|
|
|
|
longitude,
|
|
|
|
latitude):
|
|
|
|
self.longitude = longitude
|
|
|
|
self.latitude = latitude
|
2015-07-08 14:37:25 +02:00
|
|
|
|
|
|
|
@staticmethod
|
2015-07-09 02:15:46 +02:00
|
|
|
def de_json(data):
|
2015-07-08 14:37:25 +02:00
|
|
|
return Location(longitude=data.get('longitude', None),
|
2015-07-08 14:55:06 +02:00
|
|
|
latitude=data.get('latitude', None))
|
2015-07-09 16:40:44 +02:00
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
json_data = {'longitude': self.longitude,
|
|
|
|
'latitude': self.latitude}
|
|
|
|
return json.dumps(json_data)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.to_json()
|