/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/provider/GoogleStationProvider.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/provider/GoogleStationProvider.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 255 by torben, Mon Aug 10 17:01:51 2009 UTC revision 381 by torben, Fri Oct 2 10:39:09 2009 UTC
# Line 15  public class GoogleStationProvider imple Line 15  public class GoogleStationProvider imple
15    
16          List<StationBean> stations = new ArrayList<StationBean>();          List<StationBean> stations = new ArrayList<StationBean>();
17                    
18            public boolean lookupStations(String name) {
19                    return false; // Not supported
20            }
21            
22          @Override          @Override
23          public void lookupStations(Location location) {          public boolean lookupStations(Location location) {
24                    boolean success = false;
25                  //ToDo: to be nice put the api key into the request                  //ToDo: to be nice put the api key into the request
26                  String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=" + location.getLatitude() + "%2C" + location.getLongitude() + "&v=1.0";                  String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=" + location.getLatitude() + "%2C" + location.getLongitude() + "&v=1.0";
27                  //String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=56.2%2C9.0&v=1.0";                  //String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=56.2%2C9.0&v=1.0";
28    
29                  try {                  try {
30                          String data = DownloadUtil.getContent(urlSource, 30000, "UTF-8");                          String data = DownloadUtil.getContentString(urlSource, 30000);
31                          StringBuilder builder = new StringBuilder(data);                          StringBuilder builder = new StringBuilder(data);
32    
33                          while (builder.charAt(0) != '{')                          while (builder.charAt(0) != '{')
# Line 54  public class GoogleStationProvider imple Line 59  public class GoogleStationProvider imple
59                                  Log.e("Location", title + " " + lat +"," + lng);                                  Log.e("Location", title + " " + lat +"," + lng);
60                          }                          }
61    
62                            success = true;
63                  } catch (Exception e) {                  } catch (Exception e) {
64                          Log.e("Location","Location",e);                          Log.e("Location","Location",e);
65                  }                  }
66                    return success;
67          }          }
68    
69          @Override          @Override

Legend:
Removed from v.255  
changed lines
  Added in v.381

  ViewVC Help
Powered by ViewVC 1.1.20