Skip to content

Commit

Permalink
fix: finish up agrc -> ugrc
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Aug 28, 2023
1 parent cf08657 commit 0cb3dbe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"FULLADD",
"geocoder",
"geosearch",
"Geospatial",
"getenv",
"gnis",
"GUNNISON",
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
name="masquerade",
version="1.1.12",
license="MIT",
description="A proxy service that creates an Esri locator from AGRC data and web services.",
description="A proxy service that creates an Esri locator from UGRC data and web services.",
author="UGRC",
author_email="agrc@utah.gov",
author_email="ugrc-developers@utah.gov",
url="https://github.com/agrc/masquerade",
packages=find_packages("src"),
package_dir={"": "src"},
Expand Down
4 changes: 2 additions & 2 deletions src/masquerade/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def geocode_base():
"WriteStandardizedAddressField": "false",
"WriteXYCoordFields": "true",
},
"serviceDescription": "Utah AGRC Locators wrapped with Masquerade",
"serviceDescription": "Utah Geospatial Resource Center locators wrapped with Masquerade",
#: this was the key to WAB Search widget validation...
"singleLineAddressField": {
"name": "Single Line Input",
Expand Down Expand Up @@ -190,7 +190,7 @@ def suggest():
@as_json_p
def find_candidates():
"""get address candidates from address points (if there is a magic key) or
agrc geocoding service
ugrc geocoding service
"""

magic_key = request.args.get("magicKey")
Expand Down
28 changes: 12 additions & 16 deletions src/masquerade/providers/web_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# * coding: utf8 *
"""
A module that contains methods for querying the AGRC geocoding service
A module that contains methods for querying the UGRC geocoding service
This module shares a fair amount of code with this one:
https://github.com/agrc/geocoding-toolbox/blob/master/src/agrcgeocoding/geocode.py
Expand Down Expand Up @@ -75,7 +75,7 @@ def _get_retry_session():
new_session = requests.Session()
new_session.headers.update(
{
"x-agrc-geocode-client": "masquerade",
"x-ugrc-geocode-client": "masquerade",
}
)
retry = Retry(
Expand All @@ -102,7 +102,7 @@ def make_request(address, zone, out_spatial_reference, max_locations):
"suggest": max_locations,
}

headers = {"Referer": "https://masquerade.agrc.utah.gov"}
headers = {"Referer": "https://masquerade.ugrc.utah.gov"}
url = f"{WEB_API_URL}/{_cleanse_street(address)}/{_cleanse_zone(zone)}"

response = session.get(url, params=parameters, headers=headers, timeout=10)
Expand Down Expand Up @@ -149,15 +149,11 @@ def get_candidate_from_parts(address, zone, out_spatial_reference):
return None


def etl_candidate(agrc_candidate):
"""translates an AGRC Web API candidate to an Esri locator candidate"""
address = (
agrc_candidate["address"]
if "address" in agrc_candidate
else agrc_candidate["matchAddress"]
)
def etl_candidate(ugrc_candidate):
"""translates an UGRC Web API candidate to an Esri locator candidate"""
address = ugrc_candidate["address"] if "address" in ugrc_candidate else ugrc_candidate["matchAddress"]
try:
standardized_address = agrc_candidate["standardizedAddress"]
standardized_address = ugrc_candidate["standardizedAddress"]
except KeyError:
standardized_address = None

Expand All @@ -166,11 +162,11 @@ def etl_candidate(agrc_candidate):
"attributes": {
"Status": "M",
"matchAddress": address,
"score": agrc_candidate["score"],
"score": ugrc_candidate["score"],
"standardizedAddress": standardized_address,
"locator": agrc_candidate["locator"],
"addressGrid": agrc_candidate["addressGrid"],
"locator": ugrc_candidate["locator"],
"addressGrid": ugrc_candidate["addressGrid"],
},
"location": agrc_candidate["location"],
"score": agrc_candidate["score"],
"location": ugrc_candidate["location"],
"score": ugrc_candidate["score"],
}

0 comments on commit 0cb3dbe

Please sign in to comment.