-
Notifications
You must be signed in to change notification settings - Fork 244
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
Added a new end point that determines a road type according to lon and lat #1583
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
from anyway.backend_constants import BE_CONST | ||
from anyway.base import user_optional | ||
from anyway.models import NewsFlash | ||
from anyway.models import WazeAllerts | ||
|
||
|
||
|
||
@user_optional | ||
|
@@ -103,3 +105,16 @@ def single_news_flash(news_flash_id: int): | |
json.dumps(news_flash_obj.serialize(), default=str), mimetype="application/json" | ||
) | ||
return Response(status=404) | ||
from sys import maxsize | ||
@user_optional | ||
def get_road_type(lat: float, lon: float): | ||
offset = 0.00001 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did you decide on the offset size (0.00001)? In this case - I think that using both the geographical query and the road_number / street name together can be very powerful - just using one of them is not enought. |
||
result = db.session.query(WazeAllerts).filter( | ||
and_(WazeAllerts.latitude <= lat + offset, | ||
WazeAllerts.latitude >= lat - offset, | ||
WazeAllerts.longitude <= lon + offset, | ||
WazeAllerts.longitude >= lon - offset)).first() | ||
|
||
return Response( | ||
json.dumps(result.road_type, default=str), mimetype="application/json" | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ urllib3==1.25.9 | |
webassets==2.0 | ||
xlrd==1.2.0 | ||
lxml==4.5.1 | ||
boto3==1.14.48 | ||
boto3==1.14.48 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waze alerts table exists (See class WazeAlert in this file)
What there's a need in another one?