如何检查Lat Long是否在特定城市内?

时间:2016-11-17 05:59:31

标签: java android location

我想检查我的lat long是否属于特定城市。 我从GraphDatabase

收到我的lat和long
        Bundle buyIntentBundle  = mService.getBuyIntent(3, mActivity.getPackageName(), _item, "inapp", "test");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

        if (pendingIntent != null)
        {
            mHelper.launchPurchaseFlow(mActivity, mActivity.getPackageName(), REQUEST_CODE, mPurchaseFinishedListener, "test");
        }
        else
        {
            // Cannot purchase
            Toast.makeText(mActivity, "purchase failed", Toast.LENGTH_SHORT).show();
        }

请给我解决方案

4 个答案:

答案 0 :(得分:0)

我想你可以尝试下面的谷歌api,你会得到所有特定的地方细节

https://community.cloudera.com/t5/Web-UI-Hue-Beeswax/Connecting-to-Solrcloud-from-Hue/td-p/32110

答案 1 :(得分:0)

您可以使用反向地理编码http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding找到城市名称和详细信息。

或者您可以使用谷歌apis查找使用纬度和经度的所有细节 http://maps.googleapis.com/maps/api/geocode/json?latlng=26.8432779,77.8027763&sensor=true

检查完毕后,您可以找到解决方案。

答案 2 :(得分:0)

(require data/maybe)    

(define (find f xs)
  (cond ((empty? xs) nothing)
        ((f (car xs)) (just (car xs)))
        (else (find f (cdr xs)))))

(define (find-index f xs (i 0))
  (cond ((empty? xs) nothing)
        ((f (car xs)) (just i))
        (else (find-index f (cdr xs) (add1 i)))))

(find (λ (x) (< x 10)) '(10 11 3 2 1))       ;; (just 3)
(find-index (λ (x) (< x 10)) '(10 11 3 2 1)) ;; (just 2)

(find (λ (x) (< x 0)) '(10 11 3 2 1))       ;; nothing
(find-index (λ (x) (< x 0)) '(10 11 3 2 1)) ;; nothing

答案 3 :(得分:0)

你可以像这样检查

String latitudeStr = String.valueOf(address.getLatitude());
                latitudeStr = latitudeStr.substring ( latitudeStr.indexOf ( "." ) );

                String longitudeStr = String.valueOf(address.getLongitude());
                longitudeStr = longitudeStr.substring ( longitudeStr.indexOf ( "." ) );


                if(latitudeStr.length()>=8) {

                //this is city  
                } 

通过这个你可以让城市拉长......