IPhone : google maps directions - iphone

i'm developing an iPhone app which embed a mapView made with mkmapkit.
I got two coordinates and I'm tracing the direction between these two points.
Everything works well. I'm using google maps api : maps.googleapis.com/maps/api/directions to retrieve xml with all the steps of the direction.
But one thing is very strange : I just can't understand why driving direction is not accurate.
Between two steps it trace a right line and don't follow the road while walking travel mode trace a very accurate direction, following roads.
Driving Mode :
http://www.michael-blin.fr/misc/aden/google/driving.png
Walking Mode :
http://www.michael-blin.fr/misc/aden/google/walking.png
My question is simple : have you ever used the google maps api and can you understand why one is more accurate than the other...

Your driving directions seems to take you along major roads or highways, so there are no change of driving directions between each of these points. You have not stated the reply you get from the directions api, but my guess is that you are receiving the steps along the route where you have to change direction, eg. highway junctions, etc:
Google documentation:
Each element in the steps array
defines a single step of the
calculated directions. A step is the
most atomic unit of a direction's
route, containing a single step
describing a specific, single
instruction on the journey. E.g. "Turn
left at W. 4th St." The step not only
describes the instruction but also
contains distance and duration
information relating to how this step
relates to the following step. For
example, a step denoted as "Merge onto
I-80 West" may contain a duration of
"37 miles" and "40 minutes,"
indicating that the next step is 37
miles/40 minutes from this step.
When you are walking, you are taking turns more often in order to get the shortest route.
The directions api does not provide you with the exact overlays that match the actually roads travelled. Only the positions where you make changes.
Alternatively you could take a look at the overview_polyline field in the reply. It may have a smoother path than by using the waypoints.

Related

Understanding GazeProvider GazeDirection Vector3

I am working on taking two HoloLens 2 users' gaze data, and comparing them to verify they are tracking the same hologram's trajectory. I have access to the GazeProvider data, no issues there. However, the GazeProvider.GazeDirection data throws me. For instance, I've referenced the API at:
GazeDirection API Data
But, I dont really understand what the Vector 3 it returns means. Are the X,Y,Z relative motion? If not, can I use Vector3.angle to compute relative motion vectors between two points?
The vector returned by the GazeDirection property leveraging three coordinate parameters to point the direction that the user's eyes are looking towards. The origin is located between the user's eyes. The Vector3.angle method you mentioned can help you compute the angle between the two eye gaze directions.
I have just started to dig into gaze from a different scenario, but one suggestion I would make is that you also take a look at the gaze origin api.
Each user occupies a different location in space and is gazing into the world in a "gaze direction" from their location in space which would be their "gaze origin".
Basically you need to reconcile the different spatial coordinate systems.

How do I use the snap to road function using OSRM?

I am currently working with OSRM and used some GPS data for testing which i generated using googles Interactive Polyline Encoder Utility
https://developers.google.com/maps/documentation/utilities/polylineutility
The concept im going for is that a car is driving along a street sending every 20 seconds its GPS location. I want to display the path and the kilometers it drove at the end of its trip.
I set up a Client in C# performing a GET request with the match algorithm to communicate with the api on the open demoserver backend http://router.project-osrm.org
The problem is that i cannot use the match algorithm because it only takes two GPS points instead of a polyline consisting of several GPS locations. To me this does not make sense.
I tried this and it worked not that bad but it lost track and somehow ended at a point i didn't define, probably because of the quite long distance between the two points but i need it to work for more than two though:
here's the picture of it where it went wrong
http://router.project-osrm.org/match/v1/driving/13.682632,47.393753;13.6849281,47.3935649?overview=full&radiuses=49;49
I also found some decent blogs and websites telling me that I should use the OSRM matching algorithm as a Snap to road tool. One of them is this one: https://www.jamesrcroft.com/2015/06/snapping-gps-tracks-to-roads/
I also tried the route method which according to the OSRM wiki finds the fastest route between coordinates in the supplied order. Thats not exactly what I want. At least it could take a polyline of GPS locations but it was always extremely inacurate and faulty.
This is the GET Request for the method route I used:
Pic of how it looked before OSRM, it is slightly inacurate so i want it snapped to the road:
string polyline = #"kz~dHclrbBbAfAn#iBb#{Cf#aBXkA_#s#m#i#_A}#c#c#Fu#Tq#ZWXT";
string.Format("http://router.project-osrm.org/route/v1/driving/polyline({0})?overview=full", polyline);
As response i got this polyline in the attribute geometry:
mz~dHalrbB`#b#XZFFFHBK#CBI#E\\uA\\mA?[?SH[Ru#Nm#XkAFOg#a#m#g#AA}#_Ac#c#IIPk#Tq#Nc#?A??
This is what i got when I decoded it through the google polyline encoder: a complete mess..
Could someone explain what I am doing wrong? Thank you in advance!
I am sure the problem is that you do not send the timestamp of each geolocation in unix time.
Take a look at the official documentation: http://project-osrm.org/docs/v5.5.1/api/#match-service
This is how your request should look like:
http://router.project-osrm.org/match/v1/driving/13.682632,47.393753;13.6849281,47.3935649?overview=full&radiuses=49;49&timestamps=1563459949;1563460007

Matlab - Flag points using nearest neighbour search

I have the following problem and I am a bit clueless how to tackle it as my programming skills are very elementary ( I am an engineer, so please dont bite my head off).
Problem
I have a point cloud, the picture above displaying one level off it. Every point is a centroid off a block (x =5, y=1, z=5) and is specefied by carteisian coordinates.
The centroids further have two values: one called "access" and one "product". If the product value is positive and pays for the access to the point I want to include it in my outcome. The red marker in the picture represents a possible starting point.
Starting Idea
As a start I am trying to set up an algorithm, that starts at the red marker, runs through the blocks left and right (along the x-axis), checks until where it would be feasible to access (so sum "product" > sum "access") and then goes to the next point (in y direction from marker) and does the same until the end of the level.
Final Goal
My final goal is that I can Flag points as accessed and the algorithm connects profitable "products" (so products that would pay for their access) on the shortest way to the access point (by setting blocks/points on the way to accessed).
I know this is a very open question and I apologize for that. I am just lacking a good starting point programming wise. I was thinking of knnsearch, but I am not sure if this is the right way to go as the blocks have different sizes and i technically want the nearest neighbour in every direction but also only one per direction.
Another idea I had was using shortestpath or creating a travel salesman problem out of it, but I am not sure how to properly implement it.
If you have any ideas or you could offer any help I would very much appreciate it. If any more information is needed I gladly provide it.

How does routing services for OSM determine the distance between two points

I am going to design an Android application and I will be needing the distances of the pathways inside our university(pathways between buildings)
I read about OSM(OpenStreetMap) and tried it. It is a map which is editable which means anyone can contribute to that map(like a wikipedia map version).
It has many routing services that give routes and directions between two point(start and end).
There is a routing service named GraphHopper and it is very easy to use. I can just drag and drop the start and end pt and it gives the distance(km) between the two pts.
What I want to know is how did they come up with the distance?
Is the distance reliable and accurate?
Any help is greatly appreciated because I want to use the distances for my Android app and I need to know if these distances have basis.
The distance is 'accurate' in the sense that it correctly processes the existing information from OpenStreetMap and correctly adds road segments for the final route. You can just try for your local area and compare to your own knowledge.
There could be mapping errors, where a road is incorrectly mapped. And there could be also roads missing and so the router uses a detour making the path unnecessarily longer. Also there are different modes like for cars or bikes or fastest and shortest where you get a different distance between two coordinates.

A specific PathFinding approach

I am working on Unity, using C# for a project that should be quite simple.
I am stuck to pathFinding .
I have Looked at Dikjstra's and A* for reference, but for some reason I still can't adopt them to work in my case. I guess my brain :=while(1);
Here is the Idea:
From a textfile I import a "map" where each "*" means Wall, and each " " walkarea. In the map there area randomly placed 2 objects: a bomb and an agent.
The agent must investigate the map (which forms a maze) and discover the bomb. The agent may move to his 8 neighbour tiles if they are NOT Wall. In my code , the agent class hold his own map. for every tile that he visits, he asks the "world map" for info, about his 8 neighbour tiles.
On his own map then he takes a note of the known tiles type(wall / walkpath) , and if it is a walkpath, he also notes, how many times he has visited it. The agent also has a "Prefered direction " list. This tells which tile to choose next to move to, if more than 1 have not been visited.
Up to this point, I have set it up all good and running, and if I let it run, he eventually finds the bomb. The Issue is that because he only runs on a Prefered direction according to the least visited tile , he has to re-visit some tiles too many times like a moron. So what
I must do is this:
If the agent reaches a tile for which, every nighbour is either wall or already visited, then he should investigate his own map, and the notes from the past to find an unvisited tile , and walk to there. Every walk direction has the same weight/cost, so we don't need to consider cost of path.
In my opinion, Dijkstra's is the closest to apply , but I still can't get it right .
Any Ideas or help would be much appreciated.
Thank You
Alex
Part of the issue is how much information you want to allow your agent. If you're willing to let him know where the target is, or at least its general direction in relation to himself, then you can use that to help influence the agent's decisions. This would allow you him to always favor moving in the direction that gets him closest to the goal while taking the least visited path.
Otherwise I'd keep track of each place he visited in a separate map, as well as the 8 neighboring tiles since he has "seen" them, with something like -1 indicating a wall that has been seen, -2 indicating an unseen location, and 0 indicating seen but unvisited. I'd then use A* or a variant on it that would move him to the closest unvisited point based on number of tiles traversed, breaking ties randomly. This would lead to a more trial and error rat in a maze approach.