Add support for Tcl data

This closes #58.
This commit is contained in:
Lucas Verney 2017-06-15 15:52:11 +02:00
parent 82a88590b6
commit 12a55e64be
2 changed files with 4629 additions and 3 deletions

View File

@ -143,13 +143,33 @@ def _preprocess_tcl():
:return: A list of ``PublicTransport`` objects to be inserted in database.
"""
# TODO: Tcl
data_file = "tcl.json"
LOGGER.info("Building from %s data.", data_file)
tcl_data_raw = []
# Load opendata file
try:
with open(os.path.join(MODULE_DIR, data_file), "r") as fh:
tcl_data_raw = json.load(fh)
except (IOError, ValueError):
LOGGER.error("Invalid raw Tcl opendata file.")
return []
# Process it
tcl_data = []
for item in tcl_data_raw["features"]:
tcl_data.append(PublicTransport(
name=item["properties"]["nom"],
area="FR-ARA",
lat=item["geometry"]["coordinates"][0],
lng=item["geometry"]["coordinates"][1]
))
return tcl_data
# List of all the available preprocessing functions. Order can be important.
PREPROCESSING_FUNCTIONS = [
_preprocess_laposte,
_preprocess_ratp,
#_preprocess_tcl
_preprocess_tcl
]

4606
flatisfy/data_files/tcl.json Normal file

File diff suppressed because it is too large Load Diff