-
Notifications
You must be signed in to change notification settings - Fork 18
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
Inefficient Overpass queries #4
Comments
It's a code from LineageOS Thanks |
Don't know who maintains it |
@mmd-osm like this? |
Hi, you need to pass an actual bounding box to the query, like described here: http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Bounding_box
This site has a good description of the approach and even a reference implementation in Java: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates |
I know shit about SQL you can comment on the gerrit patch that I linked with actual code and please post your github user and email so I can put you as an author |
I edited my post lol.. It looked like I told you that you don't know shit about sql hahaha |
Sure, no problem.
Coming to think about it, I should probably open an issue with LineageOS then. However, they seem to have a pretty strange bug reporting policy and need logcat attached, which I don't have for obvious reasons (see https://wiki.lineageos.org/bugreport-howto.html). Oh, well. We might consider blocking these kind of queries altogether. |
Sorry, due to my employment, I can't submit a patch for this without going through an approval process. |
@chenxiaolong : thank you for your feedback! Could you point us to a location where we should report this issue, so that we can keep track of it? |
@mmd-osm I'm not aware of a bug tracker for this kind of issue. It's been several years since I contributed to an Android ROM. At the time, I'm pretty sure I just submitted a pull request at CyanogenMod's (now LineageOS's) Gerrit instance. It wasn't attached to any feature request ticket or bug report. Sorry I couldn't help more! |
I believe your library creates rather inefficient Overpass queries, which consume quite some resources on the server. Btw: it looks like this code originates from CyanogenMod/android_packages_apps_Dialer, is this correct? Do you know who is maintaining this?
https://github.com/AICP/packages_apps_Dialer/blob/n7.1/src/com/android/dialer/lookup/openstreetmap/OpenStreetMapForwardLookup.java#L53
Here are few recommendations on how you could improve the situation:
Replace
(around: )
by a bounding box filter({{bbox}}
.This is much more efficient and causes less server load. This means that you would have to calculate a suitable bounding box on your own and use it in the query.
Example:
[out:json];node[name~"[Xx][Ee]"][phone](around:30000,21.104282,105.978105);out body;
=> Takes 3s - 15s
[out:json];node[name~"[Xx][Ee]"][phone](20.86266160095456,105.66238403320312,21.193374899371197,106.0400390625);out body;
=> Just takes 1s
Enforce a minimum number of characters for
name
, no single character name queries, please.Don't use the service in a type-ahead fashion, as this will quickly trigger HTTP 429 errors due to rate limiting.
Make sure, your users don't enter a phone number in the name field, because that really doesn't make that much sense. There are many queries like:
[out:json];node[name~"[99][11][99][22][44]"][phone](around:30000,16.783533,82.077653);out body;
Cache requests on your end, don't repeatedly send the same requests
Always send a suitable HTTP User-Agent Header field
Thanks!
// cc: @chenxiaolong
The text was updated successfully, but these errors were encountered: