From b7f9427d53b125a1d04360518f45c045d65d6070 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Mon, 19 Jun 2017 14:25:02 +0200 Subject: [PATCH] Fix GPS position import of Tcl stations Tcl stations GPS coordinates are given as `lng, lat` and not `lat, lng` hence it was not working because the found stations were too far from the housing post location, as reported by @bnjbvr. This commit should fix this. --- flatisfy/data_files/__init__.py | 4 ++-- flatisfy/filters/metadata.py | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/flatisfy/data_files/__init__.py b/flatisfy/data_files/__init__.py index ef4872a..c23d5f6 100644 --- a/flatisfy/data_files/__init__.py +++ b/flatisfy/data_files/__init__.py @@ -161,8 +161,8 @@ def _preprocess_tcl(): tcl_data.append(PublicTransport( name=item["properties"]["nom"], area="FR-ARA", - lat=item["geometry"]["coordinates"][0], - lng=item["geometry"]["coordinates"][1] + lat=item["geometry"]["coordinates"][1], + lng=item["geometry"]["coordinates"][0] )) return tcl_data diff --git a/flatisfy/filters/metadata.py b/flatisfy/filters/metadata.py index 7e793df..ce0063f 100644 --- a/flatisfy/filters/metadata.py +++ b/flatisfy/filters/metadata.py @@ -303,9 +303,13 @@ def guess_stations(flats_list, constraint, config, distance_threshold=1500): "gps": (station_data.lat, station_data.lng) }) break - LOGGER.debug( - "Station %s is too far from flat %s, discarding it.", - station[0], flat["id"] + LOGGER.info( + ("Station %s is too far from flat %s (%dm > %dm), " + "discarding it."), + station[0], + flat["id"], + int(distance), + int(distance_threshold) ) else: LOGGER.info( @@ -313,11 +317,20 @@ def guess_stations(flats_list, constraint, config, distance_threshold=1500): flat["id"] ) - # Store matched stations and the associated confidence + if not good_matched_stations: + # No stations found, log it and cotninue with next housing + LOGGER.info( + "No stations found for flat %s, matching %s.", + flat["id"], + flat["station"] + ) + continue + LOGGER.info( - "Found stations for flat %s: %s.", + "Found stations for flat %s: %s (matching %s).", flat["id"], - ", ".join(x["name"] for x in good_matched_stations) + ", ".join(x["name"] for x in good_matched_stations), + flat["station"] ) # If some stations were already filled in and the result is different,