边界框之外的Andr​​oid getFromLocationName返回结果 [英] Android getFromLocationName return results outside the bounding box

查看:144
本文介绍了边界框之外的Andr​​oid getFromLocationName返回结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做从我的Andr​​oid应用程序的位置搜索。用户输入一个地址,我做了以下code查找,

I am doing a location search from my android app. User enter an address and I do a lookup with the following code,

 private void doSearch(String query){
    FNMApplication.logInfo("Searching:"+query);
    //create a geocoder
    Geocoder gc = new Geocoder(this,Locale.getDefault());
    try{
        //lookup locations which match the query input by the user
        List<Address> addresses = gc.getFromLocationName(query, 5, -44.00, 111.00, -12.0, 155.0);
        //if there are any results save them in an ivar for re-use
        locationSearchResults=addresses;
        promptSearch();          
    }
    catch (Exception e){
        ;
    }
}

边框上面的是澳大利亚,但如果我搜索洛杉矶安耶洛斯它返回的结果是在美国。有什么我错过了什么?在我看来,它应该只在边框内返回地址作为每<一href="http://developer.android.com/reference/android/location/Geo$c$cr.html#getFromLocationName%28java.lang.String,%20int,%20double,%20double,%20double,%20double%29"相对=nofollow>参考文件

推荐答案

从我尝试这样的问题,我得到的结果如下所示。

From the Question I tried this and the results I got are shown below.

18.55, 72.54 = Mumbai
22.18, 70.56 = Rajkot

1)

当我路过的左下和搜索我得到这个字符串纬度较低vaue

1)

When I pass lower latitude vaue as left lower and search for the string I got this

Geocoder gc = new Geocoder(this, Locale.getDefault());
        try {

            List<Address> addresses = gc.getFromLocationName("akshardham", 5,
                    18.55, 72.54, 22.18, 70.56);

            Log.i("Address", "=========0----------------------"
                    + addresses.get(0).getAddressLine(0)
                    + addresses.get(0).getAddressLine(1));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(1).getAddressLine(0)
                    + addresses.get(1).getAddressLine(1));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(2).getAddressLine(0));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(3).getAddressLine(0));
            Log.i("Address", "=========0----------------------"
                    + addresses.get(4).getAddressLine(0));
        } catch (Exception e) {
            ;
        }

这个

的logcat

11-17 12:42:32.419: INFO/Address(802): =========0----------------------AkshardhamNH 8C, Sector 20
11-17 12:42:32.429: INFO/Address(802): =========0----------------------AkshardhamRajkot, Gujarat 360005
11-17 12:42:32.429: INFO/Address(802): =========0----------------------Akshardham

2)

当我把更高纬度vaue为左下和搜索我得到这个字符串

2)

When I pass higher latitude vaue as left lower and search for the string I got this

List<Address> addresses = gc.getFromLocationName("akshardham",5, 22.18, 70.56,18.55, 72.54 );

这个

的logcat

11-17 12:43:53.170: INFO/Address(837): =========0----------------------HardhamPulborough, West Sussex RH20 1

3)

该文档的 <一个href="http://developer.mapquest.com/content/mobile/android/documentation/api/com/mapquest/android/Geo$c$cr.html#getFromLocationName%28java.lang.String,%20int,%20double,%20double,%20double,%20double%29"相对=nofollow>这里 本身说的边框内匹配的地址被赋予更高的排名。的,我觉得他们的意思是说,它不是必要的,如果搜索字符串是这个盒子之间的地址仅会回报,如果他们发现即使其出边界框,他们将返回地址。 我想,边框只是设定结果的优先级,同时获取装置从箱子导致西港岛线是第一,然后其他类似的get(0),得到(1)名单。但结果将给出即使它们不是在边界框。

3)

The doc here itself says "The addresses matching inside the bounding box is given higher rank." , I think they mean to say, Its not necessary that If search string is address between this box only will be return,if they found the address they will return even if its out of bounding box. I Suppose;Bounding Box is just for setting the priority of result while getting means result from the box wil be first and and then other like in get(0),get(1) of the list. but the result will be given even if they are not in bounding box.

<一个href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.1_r2/android/location/Geo$c$cr.java#Geo$c$cr.getFromLocationName%28java.lang.String,int,double,double,double,double%29"相对=nofollow>地理coder.java这里 他们只是要求得到的地址与传递双精度值作为参数simple..no任何检查结果的方法用于有别的检查最低和最高值

In the Geocoder.java here they are just calling the method to get addresses with passing double values as argument simple..no any checking for the result is used there else to check the lowest and highest value

=>所以最终答案,以你的问题,你只需要调用的函数,你在呼唤,你可以检查他们是否匹配到你是指国家或国家是一样的第二个地址线。找到你的边框值使用getFromLocation(纬度,经度,maxResults)的国家,国家的名字,我还没有找到一个完美的解决方案对于​​这一点,所以我也是在搜索

=> So final answer to you problem you just call the function as you are calling and you can check the second address line that does they matches to yours means the state or country is same. to find the country,state name of your bounding box value use getFromLocation(latitude, longitude, maxResults), I still Didn't Find A Perfect Solution For this,So me too Searching

=> 更多关于这个可以由专家从谷歌本身。解释(这是我不是),或开发

=> More on this can be explained by an expert (That's I am not) or Developer from Google itself.

这篇关于边界框之外的Andr​​oid getFromLocationName返回结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆