-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address handling fixes in import script (#188)
- Include spreadsheet distance error calculations in building notes - Reduce warning distance to 100 meters - Convert to using spreadsheet lat/lon with a warning about discrepancies - Add fixup for common address parsing problems
- Loading branch information
1 parent
a85142e
commit 3777746
Showing
4 changed files
with
185 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/meshdb/utils/spreadsheet_import/tests/test_fixup_bad_address.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from meshdb.utils.spreadsheet_import.building.resolve_address import call_pelias_parser, fixup_bad_address | ||
|
||
|
||
def test_fixup(): | ||
assert fixup_bad_address("244 E 45st New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 E 45St New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 E 45ST New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 E 45 St New York") == "244 E 45 St New York" | ||
|
||
assert fixup_bad_address("244 5Ave New York") == "244 5 Ave New York" | ||
assert fixup_bad_address("244 5AVE New York") == "244 5 Ave New York" | ||
assert fixup_bad_address("244 5 Ave New York") == "244 5 Ave New York" | ||
|
||
assert fixup_bad_address("357 13th Steet Apt #2") == "357 13th Street Apt #2" | ||
assert fixup_bad_address("357 13th STEET Apt #2") == "357 13th Street Apt #2" | ||
assert fixup_bad_address("357 13th steet Apt #2") == "357 13th Street Apt #2" | ||
|
||
assert fixup_bad_address("357 6th Avue") == "357 6th Avenue" | ||
assert fixup_bad_address("357 6th steet") == "357 6th Street" | ||
assert fixup_bad_address("357 Grand concoourse") == "357 Grand Concourse" | ||
|
||
assert fixup_bad_address("244 E45 St New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 e45St New York") == "244 e 45 St New York" | ||
assert fixup_bad_address("244 W45St New York") == "244 W 45 St New York" | ||
|
||
assert fixup_bad_address("244 Abc nlvd New York") == "244 Abc Boulevard New York" | ||
|
||
assert fixup_bad_address("244 W 45St New York") == "244 W 45 St New York" | ||
assert fixup_bad_address("244 W 45St New York; 10023") == "244 W 45 St New York, 10023" | ||
|
||
|
||
def test_pelias_bowery(): | ||
# If this is failing, it's probably because you don't have connectivity | ||
# to a pelias parser, maybe you need to run it with Docker? | ||
|
||
result = call_pelias_parser("123 Bowery, New York, NY") | ||
assert result[0][1] == {"housenumber": "123", "locality": "New York", "region": "NY", "street": "Bowery"} | ||
assert result[0][2] == {"housenumber": (0, 3), "locality": (12, 20), "region": (22, 24), "street": (4, 10)} | ||
|
||
result = call_pelias_parser("123 Bowery") | ||
assert result[0][1] == {"housenumber": "123", "street": "Bowery"} | ||
assert result[0][2] == {"housenumber": (0, 3), "street": (4, 10)} |