-
Notifications
You must be signed in to change notification settings - Fork 2
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
Geocoding location lookup #4
Merged
Merged
Conversation
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
I've made it so that we can look up locations and fetch the closest station. This adds a dependency of `geopy`. This ignores several edge cases. Namely, it assumes a flat earth with rectangular coordinates corresponding to the latitude and longitude. I am assuming these edge cases will not be noticeable. Expected behavior: ``` user: !noaa tide 8722588 scubot: <a listing for station #8722588> user: !noaa tide 32.8548228,-79.9614
I improved the regular expression for matching latitude/longitude coordinate pairs to remove an edge case where they were separated by only a comma and no space. To continue the expected behavior listing on the previous commit: ``` user: !noaa tide 8722588 scubot: <listing for station #8722588> user: !noaa tide "33.6926725,-78.8841985" scubot: <listing for station #8661000, Myrtle Beach, SC> user: !noaa tide "Myrtle Beach, SC" scubot: <listing for station #8661000, Myrtle Beach, SC> ```
Static methods decorated with `@staticmethod` aren't attached to a class instance and therefore aren't (and indeed can't be) passed a reference to `self`
I've found the NOAA website's listing for the latitude and longitude of their stations. This removes a great deal of strain from the geocoding API, which is good because our initial fetch was extremely taxing on the geocoder. It will still be necessary to merge this branch with the branch that has database caching, as NOAA's response times result in the globe taking several hours to initialize.
Adding basic station caching
Geocoding from NOAA instead of nominatim
The object structure prior to this change did not make it easy to isolate the `StationGlobe` class, whether for testing or prefetching the database cache. I have separated it using dependency injection patterns. NOTE: This breaks the initialization on L150. Waiting for @suclearnub to provide more information on the NOAA.module_db object scope to fix that
Fix initialization of the updated `StationGlobe` object from the previous commit. Also I've moved the work into a method to eliminate import side effects.
Dependency Injection of database
TinyDB was incompatible with the `Station` object so I created serialization methods to convert between it and a standard Python dictionary.
Scraper was parsing latitude and longitude incorrectly. Search always returned the last station, regardless of which one was closest. Both of those issues have been resolved in this commit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This resolves issue #1 . There are some known bugs that may or may not cause realistic edge cases, but in general this functionality works and the old functionality remains for backwards compatibility.
While my classes function, I have not done integration testing for the bot module.