Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTC-3081: Add political/id-lookup endpoint #616

Merged
merged 48 commits into from
Jan 29, 2025

Conversation

dmannarino
Copy link
Member

@dmannarino dmannarino commented Dec 23, 2024

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Check the commit's or even all commits' message styles matches our requested structure.
  • Check your code additions will fail neither code linting checks nor unit test.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

No geoencode endpoint

Issue Number: GTC-3081

What is the new behavior?

  • There is now an endpoint to look-up GADM v4.1 IDs by name

Does this introduce a breaking change?

  • Yes
  • No

Other information

Open to suggestions for a better URL path. Not really crazy about either "thematic" or "geoencode".

@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 40.51724% with 69 lines in your changes missing coverage. Please review.

Project coverage is 79.91%. Comparing base (986405d) to head (ffe9b6b).

Files with missing lines Patch % Lines
app/routes/political/id_lookup.py 21.42% 55 Missing ⚠️
app/models/pydantic/political.py 66.66% 14 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #616      +/-   ##
===========================================
- Coverage    80.67%   79.91%   -0.77%     
===========================================
  Files          131      133       +2     
  Lines         6014     6129     +115     
===========================================
+ Hits          4852     4898      +46     
- Misses        1162     1231      +69     
Flag Coverage Δ
unittests 79.91% <40.51%> (-0.77%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dmannarino dmannarino marked this pull request as ready for review December 28, 2024 23:53
@dmannarino dmannarino changed the title Gtc 3081 geoencoder endpoint GTC-3081: Add geoencode endpoint Dec 28, 2024
@@ -0,0 +1,216 @@
import re
Copy link
Member

Choose a reason for hiding this comment

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

@dmannarino I know you said you didn't like thematic. I was thinking of other ideas, is this admin area specific endpoints, maybe we just put it under like something like "political"? E.g. /political/geoencoder. Then the future can include additional GADM endpoints, WDPA, concessions, etc. Not sure if we need to distinguish it from the rest of the API, or we can just have it all in under a header in the docs.

Copy link
Member

Choose a reason for hiding this comment

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

But I do think geoencoder is a little vague if it only works for admin areas, geoencoding implies converting any text of the place into coordinates: https://en.wikipedia.org/wiki/Address_geocoding

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to /political/id-lookup

@dmannarino
Copy link
Member Author

Looks great! Just a few minor comments

And great job with the tests!

Thanks!

@dmannarino dmannarino changed the title GTC-3081: Add geoencode endpoint GTC-3081: Add political/id-lookup endpoint Jan 24, 2025
Copy link
Contributor

@gtempus gtempus left a comment

Choose a reason for hiding this comment

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

I like the new name of the endpoint, Daniel!

What about changing the name of the model from geoencoder? 😬

)


def sanitize_names(
Copy link
Contributor

@gtempus gtempus Jan 27, 2025

Choose a reason for hiding this comment

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

What about normalize_names? Sanitize comes with a different connotation about what this method does (for me, anyway).

Copy link
Member Author

Choose a reason for hiding this comment

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

Roger, will change, thanks!

@dmannarino
Copy link
Member Author

I like the new name of the endpoint, Daniel!

What about changing the name of the model from geoencoder? 😬

Yes, that's the right thing to do. :) Will do, thanks!

Copy link
Collaborator

@danscales danscales left a comment

Choose a reason for hiding this comment

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

Looks good to me!

"adminSource": admin_source,
"adminVersion": admin_version,
"matches": matches,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit (optional): I guess this code works in Pydantic, but the types would be clearer if 'data' was a AdminIDLookupResponseData, which I guess you could do via:

data = AdminIDLookupResponseData(**{
"adminSource": admin_source,
"adminVersion": admin_version,
"matches": matches,
})

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, will implement, thanks!

@dmannarino dmannarino merged commit 8af1960 into develop Jan 29, 2025
2 checks passed
@dmannarino dmannarino deleted the gtc-3081_geoencoder_endpoint branch January 29, 2025 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants