Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Testing cordinates
  • Loading branch information
Solracion committed Jul 22, 2021
commit 4285fbfd1fdb83f1014dd701f7e82778e9cde266
11 changes: 9 additions & 2 deletions app/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ def __init__(self, latitude, longitude):
self.latitude = latitude
self.longitude = longitude

def serialize(self):
class Serialize:
def serialize(self,latitude,longitude):
"""
Serializes the coordinates into a dict.

:returns: The serialized coordinates.
:rtype: dict
"""
return {"latitude": self.latitude, "longitude": self.longitude}
self.latitude=latitude
self.longitude=longitude

return {self.latitude,self.longitude}

def __str__(self):
return "lat: %s, long: %s" % (self.latitude, self.longitude)

latitude = Coordinates("latitude")
longitude= Coordinates("longitude")
21 changes: 12 additions & 9 deletions app/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
from ..services.location.nyt import NYTLocationService
from ..services.location import LocationService

# Mapping of services to data-sources.
class DATA_SOURCES:
data_SOURCES = {}
DATA_SOURCES = {
"jhu": JhuLocationService(),
"csbs": CSBSLocationService(),
"nyt": NYTLocationService(),
}

def data(self):
self.data_SOURCES['jhu'] = JhuLocationService()
self.data_SOURCES['csbs'] = CSBSLocationService()
self.data_SOURCES['nyt'] = NYTLocationService()

def data_source(self, source: str)-> LocationService:
def data_source(source):
"""
Retrieves the provided data-source service.

return self.data_SOURCES.get(source.lower())
:returns: The service.
:rtype: LocationService
"""
return DATA_SOURCES.get(source.lower())