Calculate actual distance between two points using Google Directions API - objective-c

In my iphone application i am creating a route between two points and using the google directions api to show the html instructions, step distance for each turn in text format.
When using the Directions API i had observed that when the user moves from location A to location D and there is a turn at location B, then the user is notified regarding the turn (i.e in the step of the json response from the direction api ) at point A' (consider A' between A and B). Now the distance of this step should be till location B, but i had found that it is till location B' (which appears after B), now again if i have a turn at location C
then the start location of step should start from location B, instead it starts from B'.
So my question is how would the user know the actual length of the step. Kindly help.
Thanks in advance

This doesn't really answer your question, but I thought I should mention it anyway.
Once iOS 6 rolls out in a few months, you won't be able to use Google's services to do this. Not for any technical reason, but in their TOS, they explicitly state that if you use their mapping services, they must be used in conjunction with their maps. Since Apple is using a different map provider come iOS 6, you would be in violation of their terms.

I had solved the issue related to calculate the actual length of the step.
Actually i was simulating the current location by taking fake locations and testing it.
In live mode (i.e while testing the application on the road) it works perfectly fine.

Related

Different responses when using Google Distance Matrix API

I have two postcodes (A) and (B) and I am seeing different distances and durations between A to B and B to A and while this matches the Google Maps website, we have seen the distance and duration between A to B in that direction change from one day to the next.
I don't believe the API request URL is set to include traffic so I don't know why Google has altered the primary preferred route between when we first ran this request and the second request.
I hope that makes sense.
I did my research and I found that both Distance Matrix API and Directions API alters their duration_in_traffic value for my requests with periods which is about 30 seconds. It just gives me 1 of 2 possible values with difference of couple seconds. So obvious solution is API response local caching.

Google Map Directions API Optimize Waypoint and Force Waypoint Order

I am having difficulty in overcoming the situation I am facing. I have a route as follow:
StartPoint
WayPoint A-1 <--- Pickup
WayPoint A-2 <--- Dropoff
WayPoint B-1 <--- Pickup
WayPoint B-2 <--- Dropoff
WayPoint C-1 <--- Pickup
WayPoint C-2 <--- Dropoff
EndPoint
A bus is starting to drive from Start Point and it is supposed to pick 3 passengers up (A, B, C) and drop them off in different locations. The locations are not static and it changes based on passenger.
If I pass all these to google map directions api and set the OptimizeWaypoint option to true the issue that occurs is sometimes the dropoff waypoint occurs before pickup waypoint for a passenger due to route optimization.
Does anyone know a solution to force google map api route optimization to always have pickup before the dropoff for each passenger please?
I appreciate all your help in advance guys.
I have found a solution to my problem after 3 days of research. The solution is not through Google Map API and it's using a third party API called RouteXL. They are providing an API which does such this thing I am looking for. Here is the link to documentation although their documentation is not clearly documented but it has helped me to work it out.
https://www.routexl.nl/blog/api/?lang=en#post-tour
The function which I needed was the Tour Post and that does what I exactly needed.
If anyone needs any help on this I am happy to help.
I hope this helps everyone else.
Thank you all for the help.
The waypoint optimization feature in Google Maps is limited to basic travelling salesmen scenarios in which all the waypoints are re-ordered to find the optimal route. What you are looking to do falls under the category of Vehicle Routing problem, more precisely the Vehicle Routing Problem with pickup and delivery. Google doesn't provide a service for this. However, there are some open source algorithm available for this. Here are a few:
https://github.com/pgRouting/pgrouting/wiki/VRP%20Pickup%20Delivery%20Problem
https://github.com/graphhopper/jsprit
https://github.com/mck-/Open-VRP
Most of these use straight line distances to generate a distance matrix between your locations which are then used within the algorithm. For better accuracy you may want to use a distance matrix service that based on travel time. For even more accuracy you may want to take a look at the Bing Maps distance matrix service which also provides the option to generate a distance matrix over a period of time intervals for a day which would fluctuate based on predictive traffic conditions.

How to get daily steps from the Microsoft Band

With Microsoft Band and Windows Phone app I want to get from the MSBand the steps taken in the current day. Today, when I subscribe to the pedometer, the totalsteps attribute returns the steps taken overall. For example, my MSBand is returning 1M 444K steps. Does anyone knows how to get only the total daily steps?
The Band SDK does not expose the number of steps (by its internal count) taken by the wearer in the current day. The closest approximation to your goal would be to register a time-triggered background task that retrieves a pedometer sensor reading every n-number of minutes/hours and then calculates the number of steps taken on the current day based on a delta between successive readings. Obviously this implies a certain margin of error, based on how often (and when) that background task executes.
(On Windows Phone (8.1), for example, a background task can execute at most every ~30 minutes and isn't necessarily aligned to any given minute of the hour, which means steps could be attributed to one day or the next based on which side of the "midnight" hour the task happens to run.)
If you are accessing microsoft health cloud API. You can get the step counts(Per day) from the Summary URL Cloud API. refer my post https://stackoverflow.com/questions/32221481/android-get-active-minutes-for-the-step-counts-in-microsoft-band Else if you want it from the band SDK alone, Its good to go with Phil's above suggestion. Hope this may help who use health cloud API.

Can we track the user location without internet in IOS?

Actually i build the travel app which helps to track the user location but if there is no internet how can i store the location ?is there any trick to findout the location with GSM ?
Yes It is very much possible but gets useless to you.
You can get the approximate (lati & longi) position(if operator allows, I dont think they do) but what would you do because It wouldn't be possible to communicate back to traveler/user. At most you can do is send user SMS.
Mobile network is consisting of up of a number of adjacent radio cells, each of which is characterized by an identifier made up of four data items:
Cell ID
LAC, or Local Area Code
MCC, an acronym for Mobile Country Code
MNC, or Mobile Network Code, which obviously identifies the phone company itself
For this reason, once a cell name and coordinates(latitude and longitude) are known, and considering the maximum distance allowed between this cell and a phone before the phone connects to a new cell, it is possible to find out, approximately, the most distant position of the phone itself.
Its not possible to use GSM.GSM service providers can get the location details but they don't share those data to public.

limit address search by distance

I recently joined a team working on an application that maintains listings with addresses. The user searches, and includes their zipcode, and the application displays the distance to each listing. Currently we use the Google Maps API for this. Reading through questions here on StackOverflow seem to suggest that this is the best way of doing things:
php/mysql zip code proximity search
Search engine by distance
However, while reading through the API documentation, this seems to be expressly forbidden unless we also show a map for each result (and possibly also for each result we filter out, depending on how you read the following statement):
Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.
( https://developers.google.com/maps/documentation/distancematrix/ )
What's the best way to accomplish this without running afoul of any API terms?
do you consider the Geo::PostalCode module (perl)? It uses maxmind database to calculate distances between locations (and there is bind in different languages).