2011-07-03 84 views
0

我正在尝试从http://panoramio.com附近获取我的位置附近的照片。 它的工作,如果经度和经度是积极的,但如果其中一个是负的panoramio不给我任何结果。 任何想法代码有什么问题?在我的位置附近获取panoramio.com照片

String getPanoramioUrl(double minx, double maxx, double miny, double maxy){ 
    //set=full or = public? 
    return "http://www.panoramio.com" + 
      "/map/get_panoramas.php?" + 
      "set=public&from=0&to=100&minx="+minx+"&miny="+miny+"&maxx="+maxx+"&maxy="+maxy; 
} 

  lat = loc.getLatitude(); 
      lon = loc.getLongitude(); 

      //lat = -74.005973; 
      //lon = 40.714353; 

      double diff = 0.002; 
      JSONObject json; 
      int retries = 0; 
      while (true){ 
       if (retries > 10){ 
        Log.d(TAG, "giving up after 10 retries to get photo"); 
        return; 
       } 

       String url = getPanoramioUrl(
         lon>0 ? lon-diff : lon+diff, 
         lon>0 ? lon+diff : lon-diff, 
         lat>0 ? lat-diff : lat+diff, 
         lat>0 ? lat+diff : lat-diff); 
       Log.d(TAG, "getting url: " + url); 
       json = getJSONfromURL(url); 
       int count; 
       Log.d(TAG, "got response: " + json.toString()); 
       try{ 
        count = json.getJSONArray("photos").length(); 
       }catch(JSONException exc){ 
        Log.d(TAG, exc.toString()); 
        return; 
       } 
       if (count > 0){ 
        break; 
       } 
       diff = diff*3; 
       retries++; 
      } 

回答

0

差异始终是正的,所以 字符串URL = getPanoramioUrl(LON-DIFF,LON + DIFF,LAT-diff时,LAT + DIFF);

+0

如果拉特是负值,ad dont wokrs ... – nomoral