Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Handle country code geocoding errors #1619

Merged
merged 1 commit into from Feb 3, 2022

Conversation

TaiWilkin
Copy link
Contributor

@TaiWilkin TaiWilkin commented Feb 2, 2022

Overview

Submitted facilities are frequently throwing the country code error,
which indicates that the geocoding process has returned a result that
doesn't contain the country which the contributor has submitted for the
facility.

There are two primary instances where this is occurring:

  1. The returned geocoding result is imprecise and contains no country
    code at all. In this case, we will now accept this as a valid result.

  2. There are multiple results returned, and although the top result
    has an invalid code, another result contains the correct country code.
    In this case, we will now select the result with the correct country
    code. (If there are both a result with a correct country code and an
    inexact result, we prefer the correct country code.)

We will still return a geocoding error if all results include
non-matching country codes.

Connects Client #62

Notes

I added additional mock data for geocoding responses in the test suite.

Testing Instructions

  • These directions assume that ./scripts/resetdb has been run.
  • Run ./scripts/server and upload facilities which previous threw geocoding errors.
    oar-country-geocode-errors.csv
  • Process the facilities.
./scripts/manage batch_process --list-id 16 --action parse
./scripts/manage batch_process --list-id 16 --action geocode
./scripts/manage batch_process --list-id 16 --action match
  • Confirm that the facilities have been successfully geocoded.
  • Submit one or more of the addresses (with new names) via the API. Confirm that they have been successfully geocoded.

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

Copy link
Contributor

@caseycesari caseycesari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well. Nice, clean implementation function.

src/django/api/geocoding.py Show resolved Hide resolved
Submitted facilities are frequently throwing the country code error,
which indicates that the geocoding process has returned a result that
doesn't contain the country which the contributor has submitted for the
facility.

There are two primary instances where this is occurring:

1) The returned geocoding result is imprecise and contains no country
code at all. In this case, we will now accept this as a valid result.

2) There are multiple results returned, and although the top result
has an invalid code, another result contains the correct country code.
In this case, we will now select the result with the correct country
code. (If there are both a result with a correct country code and an
inexact result, we prefer the correct country code.)

We will still return a geocoding error if all results include
non-matching country codes.
@TaiWilkin TaiWilkin force-pushed the tw/handle-country-code-errors branch from d72966b to 27ad508 Compare February 3, 2022 13:46
@TaiWilkin
Copy link
Contributor Author

Thank you for reviewing!

@TaiWilkin TaiWilkin assigned TaiWilkin and unassigned caseycesari Feb 3, 2022
@TaiWilkin TaiWilkin merged commit 78f919c into develop Feb 3, 2022
@TaiWilkin TaiWilkin deleted the tw/handle-country-code-errors branch February 3, 2022 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants