Add an option to ignore stations

This commit is contained in:
Gautier P 2021-01-16 11:19:24 +01:00
parent 76a06cf795
commit 361725ea4d
2 changed files with 13 additions and 6 deletions

View File

@ -99,7 +99,8 @@ DEFAULT_CONFIG = {
"smtp_to": [],
# The web site url, to be used in email notifications. (doesn't matter
# whether the trailing slash is present or not)
"website_url": "http://127.0.0.1:8080"
"website_url": "http://127.0.0.1:8080",
"ignore_station": False,
}
LOGGER = logging.getLogger(__name__)
@ -169,6 +170,8 @@ def validate_config(config, check_with_data):
assert config["navitia_api_key"] is None or isinstance(config["navitia_api_key"], str) # noqa: E501
assert config["mapbox_api_key"] is None or isinstance(config["mapbox_api_key"], str) # noqa: E501
assert config["ignore_station"] is None or isinstance(config["ignore_station"], bool) # noqa: E501
# Ensure constraints are ok
assert config["constraints"]
for constraint in config["constraints"].values():

View File

@ -185,8 +185,11 @@ def first_pass(flats_list, constraint, config):
# Guess the postal codes
flats_list = metadata.guess_postal_code(flats_list, constraint, config)
if not config["ignore_station"]:
# Try to match with stations
flats_list = metadata.guess_stations(flats_list, constraint, config)
# Remove returned housing posts that do not match criteria
flats_list, ignored_list = refine_with_housing_criteria(flats_list,
constraint)
@ -222,6 +225,7 @@ def second_pass(flats_list, constraint, config):
flats_list = metadata.guess_postal_code(flats_list, constraint, config)
# Better match with stations (confirm and check better)
if not config["ignore_station"]:
flats_list = metadata.guess_stations(flats_list, constraint, config)
# Compute travel time to specified points