Get altitude by longitude and latitude in Android

My approach is to use USGS Elevation Query Web Service: private double getAltitude(Double longitude, Double latitude) { double result = Double.NaN; HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); String url = “http://gisdata.usgs.gov/” + “xmlwebservices2/elevation_service.asmx/” + “getElevation?X_Value=” + String.valueOf(longitude) + “&Y_Value=” + String.valueOf(latitude) + “&Elevation_Units=METERS&Source_Layer=-1&Elevation_Only=true”; HttpGet httpGet = new HttpGet(url); try { HttpResponse … Read more

Get current location of user in Android without using GPS or internet

What you are looking to do is get the position using the LocationManager.NETWORK_PROVIDER instead of LocationManager.GPS_PROVIDER. The NETWORK_PROVIDER will resolve on the GSM or wifi, which ever available. Obviously with wifi off, GSM will be used. Keep in mind that using the cell network is accurate to basically 500m. http://developer.android.com/guide/topics/location/obtaining-user-location.html has some really great information … Read more

Get Country of IP Address with PHP [duplicate]

There are free, easy APIs you can use, like those: http://ipinfodb.com/ip_location_api.php http://www.ipgeo.com/api/ http://ip2.cc/ http://www.geobytes.com/IpLocator.htm https://iplocate.io/ and plenty others. Which one looks the most trustworthy is up to you 🙂 Otherwise, there are scripts which are based on local databases on your server. The database data needs to be updated regularly, though. Check out this one: … Read more

Get GPS location from the web browser

If you use the Geolocation API, it would be as simple as using the following code. navigator.geolocation.getCurrentPosition(function(location) { console.log(location.coords.latitude); console.log(location.coords.longitude); console.log(location.coords.accuracy); }); You may also be able to use Google’s Client Location API. This issue has been discussed in Is it possible to detect a mobile browser’s GPS location? and Get position data from mobile … Read more

Given the lat/long coordinates, how can we find out the city/country?

Another option: Download the cities database from http://download.geonames.org/export/dump/ Add each city as a lat/long -> City mapping to a spatial index such as an R-Tree (some DBs also have the functionality) Use nearest-neighbour search to find the closest city for any given point Advantages: Does not depend on an external server to be available Very … Read more

Simple calculations for working with lat/lon and km distance?

The approximate conversions are: Latitude: 1 deg = 110.574 km Longitude: 1 deg = 111.320*cos(latitude) km This doesn’t fully correct for the Earth’s polar flattening – for that you’d probably want a more complicated formula using the WGS84 reference ellipsoid (the model used for GPS). But the error is probably negligible for your purposes. Source: … Read more