Is there any way to connect to the web server of OpenStreetMap?
I want to receive the speed limit information given a geoLoc "lat and Lon". I thought of solving this issue by creating a huge database encompases
the node's lat and lon and the speed limit and then query the speed limit given a specific geoLoc.
but now i am wondering is it possible to connect directly the OSM server and query the speed limit given a specific geoLoc?! whic approach is more
efficient?
You can use Overpass API for querying (almost) any information. The language guide even has a very similar problem to yours: querying for name and rough location. Just replace the name tag with the maxspeed tag and you are almost done.
Overpass API has a really powerful language which can be quite a bit confusing at first. It might help you running your queries via the overpass turbo frontend which has a nice visualization of the results.
Related
I am working on an android application which can find users nearby.
I need help in design that application.
I am thinking:
1. When I start my application, I use API to find my location.
2. I send that location to my server.
3. server returns a list of other users nearby.
My question is how can the server keeps track of a list of users who are nearby?
Do I create a background service on phone who will report users location periodically?
And the server maintains a list of all users' location?
Is that approach feasible?
You're on the right track. If you are able to geocode or retrieve your current location lat/lon coordinates, there might be a library that can help you out.
My first thought was the Geocoder (https://github.com/alexreisner/geocoder) library for ruby, it offers a slick API that allows you to easily find other nearby objects:
if obj.geocoded?
obj.nearbys(30) # other objects within 30 miles
obj.distance_from([40.714,-100.234]) # distance from arbitrary point to object
obj.bearing_to("Paris, France") # direction from object to arbitrary point
end
There are other options that are easy enough too, if you're using PostgreSQL with PostGIS, you have some utility functions that I'm sure you could use to query 'nearby' users. (Found an example, "What is the best way to find all objects within a radius of another object?" http://postgis.net/docs/manual-1.3/ch03.html#id434832)
So the overall workflow would be:
Request lat/lon from device API
Send lat/lon to server/web service
Use library/database to find other users within a specified radius
Send list of users back down to device
I suspect the most difficult aspect would probably be keeping the lat/lon of other users up to date, but that's a different problem to solve.
Edit:
Just to clarify, you'll definitely want to store all the logged in users' lat/lon inside of some sort of database on the server. It's a very feasible approach, but you'll have to keep it up to date and be able to determine somehow if the data is stale (if that's important to your application). Whether you use a background service to keep that information up to date is kind of up to you and the constraints of the problem you're trying to solve.
I am making an application which needs to be able to find people nearby, who are users of my app.
I looked at many answers of precedent similar questions, and it seems I have no choice but to keep uploading a user's current location to the server, and get nearby users' list when necessary.
Then my question is,
1. To get the nearby list, there should be some algorithm or function which calculates the distance. Then doesn't that mean I have to get all distances between my location and the rest of the app users? So the server returns certain number of users who have the least distance results. If I'm correct, wouldn't there be memory or time issues?
2. This might sound weird, but how about this.
I'll probably send latitude and longitude information or address information to the server. Can't I compare those strings with all users' address list from the first numbers or letters using string searching algorithms or something?
For example, if my last updated address is 'abcde' on the server, the algorithm will look for addresses that start with 'a', if finished searching, then look for addresses that has 'b' after 'a', in other words 'ab'.
This might not be a right solution, but I thought it might work because the address will be saved in same forms.
To find nearby users efficiently, you need a spatial index. See: Hierarchical Triangular Mesh.
You also can use one of the databases that support spatial queries.
I'll probably send latitude and longitude information or address information to the server. Can't I compare those strings with all users' address list from the first numbers or letters using string searching algorithms or something?
That won't work with latitude and longitude because that way you can only search for proximity in one dimension. For example, 30°N 30°E will appear closer to 30°N 90°E than to 31°N 30°E.
It may work with addresses, but only if they are reliably connected with coordinates (i.e. not typed in by users), and only if you don't mind that users 200 meters apart but on different sides of some administrative border will not count as close to each other.
You can use the REST Api from Server Side using PHP which takes the Current LAT LONG of all user for your app From User's Android Phone at certain time Interval Lets Say 5 min & it returns the Nearest Location,Address Distance.You need to call the Api # certain time Interval & in response From Server You will get all the Details What You Want Like Nearest Location of Your App user, Distance and Other Thing.
Why i am suggesting this way because to do Computation from Android Side Will Affect the App Performance Having Battery Issues So its better to Have All computation from Server side instead of Android(User) Side
hope this will helps you.
I am a bit late here but for anyone who comes across this question, assuming you are using Firebase for your database, your best option would be GeoFire using queries around a specific point in coordinates and a radius in km. Here is a link to the github repo https://github.com/firebase/geofire-android which explains everything in detail.
I am developing a POI locator app. I am parsing a JSON file with over 1600 locations. How would effiecntly compare this list to the current users location and get the closest 10?
EDIT
The app is using no server, as I want to use local JSON files.
I fixed it by using a for loop and measuring the distance between the location and the users location.
distance = locationA.distanceTo(locationB);
if (distance <= 1000 * 10) //finding all within 10km Radius.{
ADD GEOPOINT HERE
}
It's better if you can store the 1600 locations in a database(like mongodb) which supports geo spatial queries. you can directly query over the database to determine the closest N no.of locations to the given latitude and longitude of the user.
If you are going to find distance by a birds-view approach you can just query your locations and check distance with formula located here. But if you are going to take roads (graphs) into accounts, I'm afraid you'll need to use some kind of pathfinding service like google maps or roll your own. (As far as I know there is no built-in mechanism in Android.)
We were writing this kind of app as well, and performed some performance tests on MySQL and MongoDB. Because MongoDB is document based and stores its data in json format, location based queries(like closest restaurants to the user) completes and returns incredibly fast. As far as I can remember, it was approximately 10 times faster than MySQL. So, even if your application doesn' t currently use a no-sql database, I strongly suggest you to use MongoDB even just for location calculating part of your project.
I have read many q and a's about this subject, but not quite what I am asking. Is there a way to store the cell-id to latitude - longitude database for the local area only, like the google maps new offline feature, could you get the localized information and store it, to cover the same ground as the map?, I am looking to make an android app which works offline, which is power efficient, and this is the best option that I have thought of. I have checked opencellid, and the kml file it provides, would that be enough to find the location without an internet connection or gps?
You could explore the offline database option provided by LocationAPI.org to use for your app. Storing 36 million+ cells offline would be a task though!
Geocoder getFromLocationName is not returning anything if I'm searching for business places. Here are my finding so far:
grocery places, commercial buildings -> no result
schools -> finding results, but only returning Latitude and Longitude. I have to do reverse geocoding in order to get the address based on the coordinates, but the address wouldn't be accurate.
complete address -> same as school, only returning Latitude and Longitude
hospital and pharmacy -> returning Latitude and Longitude
I've tested this on 1.6, 2.1 and 2.2 devices that has Google Maps.
I'm trying to find if there's a limitation explained somewhere on the SDK, but there is none except:
The amount of detail in a reverse
geocoded location description may
vary, for example one might contain
the full street address of the closest
building, while another might contain
only a city name and postal code. The
Geocoder class requires a backend
service that is not included in the
core android framework. The Geocoder
query methods will return an empty
list if there no backend service in
the platform
(http://developer.android.com/reference/android/location/Geocoder.html)
[update]
So after nights of research, I can't seems to make it work - Google simply wont give me the result. Some discussion on android-developers points a fact that getFromBusinessName was omitted when Google Navigation came out. So I'm starting to assume that Google is pulling back some of their geocoding service.
I can always create a webpage that use Google Geocoder API, but its limited to 2500 api call - and I dont think it will be legal (lol). So what are my alternatives here?
I've hit the same problem. I'm finding that the geocoding API often returns no results if I include the business/venue name, but by missing it off, the lat/long can be much less accurate.
I've implemented a pragmatic solution:
1. Call the API with a string including the business/venue name
2. If it fails, call it a second time without the business/venue name, just the address
I've yet to see a case where no location is returned, so it seems a decent compromise as it means I do at least get location data, if sometimes less accurate, and the cost of a second API call is mitigated with threaded calls.
I couldn't find the button to reply but, like you all, I have just run into the same problem. I haven't tried it yet but it sounds pretty solid. A potential workaround is located here:
Using Google Maps API to get Address of Business
Happy coding :)
Edit: Forget that link and check this one out: http://code.google.com/apis/maps/documentation/places/
Try this approach:
1) Use Geocoder to convert latitude-longitude to address
2) Make an API call to Whitepages (or similar service), specifically the reverse_address method which will get you business name for the address mentioned.