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.
This commit is contained in:
Lucas Verney 2017-06-19 14:25:02 +02:00
parent c4f6a80b0c
commit b7f9427d53
2 changed files with 21 additions and 8 deletions

View File

@ -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

View File

@ -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,