package dk.thoerup.traininfo.provider; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; import android.location.Location; import android.util.Log; import dk.thoerup.android.traininfo.common.StationBean; import dk.thoerup.traininfo.util.DownloadUtil; @Deprecated public class GoogleStationProvider implements StationProvider { public StationBean lookupStationsByName(String name) { return null; // Not supported } @Override public StationBean lookupStationsByIds(String ids) { return null; } @Override public StationBean lookupStations(Location location) { StationBean stations = new StationBean(); /* //ToDo: to be nice put the api key into the request 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=56.2%2C9.0&v=1.0"; try { String data = DownloadUtil.getContentString(urlSource, 30000); StringBuilder builder = new StringBuilder(data); while (builder.charAt(0) != '{') builder.deleteCharAt(0); while (builder.charAt(builder.length()-1) != '}') builder.deleteCharAt(builder.length()-1); JSONObject json = new JSONObject(builder.toString()); // now have some fun with the results... JSONArray res = json.getJSONArray("results"); Location tmpLocation = new Location("gps"); stations.clear(); for (int i=0; i