How does geofencing works? I mean I just need two GPS coordinates (user's and target's GPS coordinates) and radius, then find distance between of them and if distance is less than or equal to radius then person is in geofence . Or there is more?
That's pretty much it. There's probably some smoothing algorithms (to protect against bad readings causing a jump in a person's location),but its pretty much a distance check between two coordinates.
The above solution work fine if we have a circular geofence, But if we have a geofence in a polygon shape, then we have to check if the user's location is within the boundry of the polygon.
There are many ways to do so
1. Google apis (if we are looking for android development).
2. Here map ( if we are going to expose rest apis, it is paid service).
3. Openmap provide library which can be used to create rest back end points . (free)
Related
I have two Addresses let say Location A and Location B. And I have series of location between those Location A and Location B. I get those series of locations via Fused location API. and saved them on the server. Now following are my requirements :
What I want:
I want to calculate the distance between the Location A and Location B. Right Now I am using a code (link of post here) but it is giving me displacement.
Problems and Confusions:
I know about Google Distance matrix API and Google Directions api, but I really do not want to work on these apis as these are costly to me. But if I use them, I really did not understand that how API will know the route user selected. I mean it is possible that User has adopted the long way towards his destination. And I think google Direction and Distance API are returning the distance between Location A and Loation B using shortest route.
I really do not want to use the API, but if there is non other
possible way to do that then How could I get that ? and what is best
for me. Please suggest me the solution.
I think you have just idea of your logic but you do not know what it is called. Though it is too late but I am posting for your information or in case of if someone later on visit here.
To draw lines between two points on Map,Use Polylines and polygons. To read further I will refer you to this google page, It has a breif introduction and also a source code. And it is even really easy to implement. Here you go.
I am using Google maps api v2 in android. I have created xml parser for the bus stop. Bus stops are displayed using markers. I need to find the user's current location and find the nearest location (bus stop), best automatically (for example in a radius of 0.5 kilometer).
I tried to find a tutorial, but unfortunately I failed it.
Thank you for your help.
There is the distanceTo() method of Location class that gets the distance between 2 locations, in a straight line. You can find an example on how to use this here: How to get straight distance between two location in android?
But, if you don't want the straight line distance, rather the Travel distance, I'd recommend you take a look at this question and answer: Get the distance between two locations in android?
I am asking advice on the best way to create a geofence application for android application using google maps.
I have looked at the sample code given on the android documentation but I am not sure if this satisfys what I wish to do. Basically I wish to show the user location and a radius and alert if the user goes outside this radius. The size of the radius is dynamic and can be dependant upon the time of day.
Could anyone give me any good starting points on what I should be looking at please? I know this is a general question but I am seeking advice on the best way to achieve this not for someone to supply code and give me it.
Thank you
User location can be obtained using GPS and as you said radius is dynamic and is dependent on time, so radius can be figured out from time. Now you have user location and radius. Now, you can calculate distance of user location from center of circular geofence and then compare it with radius.
Distance calculation between two points over map can be done using API like "distanceTo" available in developer website. http://developer.android.com/reference/android/location/Location.html
If radius is bigger than distance, user is inside the geofence and if radius is smaller than calculated distance, then user is outside of dynamic geofence.
For more info regarding implementation- visit
http://developer.android.com/training/location/geofencing.html
i am developing an android application that use map view.
i can add point to the map, zoom, get current location and animate to point.
but how to get direction between 2 points?
when user click on point to show direction between current location and clicked location.
Thanks
but how to get direction between 2 points?
Math. This has nothing to do with Android. It has little to do with maps, even. It has everything to do with math.
Depending on the distances involved, you might be able to get away with treating things as plain Carteisan coordinates and do the necessary trigonometry. Over a significant distance, though, the curvature of the Earth starts to play a role, and the math will get harder.
You might consider using a search engine to find whatever versions of the formulas you would like to use.
in order to show a direction on maps (android)
you can try to make an Overlaying custom route on your application.
We shall further assume that the route returned may contain additional information such as the local slope of the route (which could be important if one is negotiating the route in a wheelchair, for example). Since this requires a network access that could block the main UI thread if there are network difficulties, we shall also use this example to introduce the important skill of putting time-consuming or potential UI-blocking tasks on a background thread. and use AsyncTask to run the process in the background. To use AsyncTask we must subclass it.
maybe this is helped you out.
This is more of a theoretical question on how to do it rather then an actual programming question. Target platform is Android, though.
I have a list of waypoints. And I have my current position. I want to know if any of the waypoints are close to me, eg. +/-5 km. I could calculate the distans to each waypoint seperately to find out if it is within the specified radius, but isn't there a better way to do this? Like, are these points included in this area (area beeing a 5km circle around my position) (you can do something like this when working with graphics and click/touch events)?
Any help is appreciated!
/Magnus
What you are looking for is Geo-spatial analysis? There is an open source java project for this.
http://java-source.net/open-source/geospatial
Google of course provides this service as part of pro maps package.
http://www.google.com/enterprise/earthmaps/index.html
(Note: I use semantic technology and allegrograph provides a decent geospatial api)