Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NLMaps Tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Will
NLMaps Tools
Commits
df324c2c
Commit
df324c2c
authored
4 years ago
by
Simon Will
Browse files
Options
Downloads
Patches
Plain Diff
Improve error handling in MRL answering
parent
e41f7061
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nlmaps_tools/answer_mrl.py
+30
-13
30 additions, 13 deletions
nlmaps_tools/answer_mrl.py
with
30 additions
and
13 deletions
nlmaps_tools/answer_mrl.py
+
30
−
13
View file @
df324c2c
...
...
@@ -5,6 +5,7 @@ import json
import
logging
import
math
import
traceback
from
urllib.error
import
HTTPError
from
geopy.distance
import
geodesic
import
jinja2
...
...
@@ -230,10 +231,19 @@ def overpass_query(features, template_name):
logging
.
info
(
'
Querying Overpass: {}
'
.
format
(
ql
))
try
:
result
=
OVERPASS
.
query
(
ql
)
except
HTTPError
as
exc
:
traceback
.
print_exc
()
if
exc
.
code
==
429
:
error
=
'
Too Many Requests to Overpass API.
'
elif
exc
.
code
==
504
:
error
=
'
Gateway Timeout at Overpass API.
'
else
:
error
=
'
HTTP Error with Overpass API.
'
ans
=
{
'
type
'
:
'
error
'
,
'
error
'
:
error
}
return
ans
except
:
traceback
.
print_exc
()
ans
=
{
'
type
'
:
'
error
'
,
'
error
'
:
'
Error when retrieving result. Maybe a Timeout?
'
}
ans
=
{
'
type
'
:
'
error
'
,
'
error
'
:
'
Error when retrieving result.
'
}
return
ans
return
result
...
...
@@ -527,17 +537,24 @@ def answer(features):
features
=
transform_features
(
features
,
add_name_tags
)
print
(
features
)
if
features
[
'
query_type
'
]
in
[
'
around_query
'
,
'
in_query
'
]:
ans
,
_
,
_
=
answer_simple_query
(
features
)
return
ans
elif
features
[
'
query_type
'
]
==
'
dist
'
and
len
(
features
[
'
sub
'
])
==
1
:
ans
,
_
,
_
=
answer_simple_query
(
features
)
return
ans
elif
features
[
'
query_type
'
]
==
'
dist
'
and
len
(
features
[
'
sub
'
])
==
2
:
ans
,
_
,
_
=
answer_dist_between_query
(
features
)
return
ans
error
=
'
query_type {} not supported yet
'
.
format
(
features
[
'
query_type
'
])
try
:
if
features
[
'
query_type
'
]
in
[
'
around_query
'
,
'
in_query
'
]:
ans
,
_
,
_
=
answer_simple_query
(
features
)
return
ans
elif
features
[
'
query_type
'
]
==
'
dist
'
and
len
(
features
[
'
sub
'
])
==
1
:
ans
,
_
,
_
=
answer_simple_query
(
features
)
return
ans
elif
features
[
'
query_type
'
]
==
'
dist
'
and
len
(
features
[
'
sub
'
])
==
2
:
ans
,
_
,
_
=
answer_dist_between_query
(
features
)
return
ans
else
:
error
=
'
query_type {} not supported yet
'
.
format
(
features
[
'
query_type
'
])
except
Exception
as
exc
:
if
len
(
exc
.
args
)
>
0
:
error
=
exc
.
args
[
0
]
else
:
error
=
'
Unknown MRL interpretation error
'
else
:
error
=
'
No features given
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment