create a path between multiple pin as a route on MKMapView - iphone

i have three latitude and longitude for three different location, i want to draw a paths between all point . for example if i have A,B and C locations then i want connect A with B and B with C and C with A.
i have a iphone application in which i used mapkit framework,suppose user start travel from A point then reached on B and end the travel on C point. i want to draw a path between all three point. A to B, B To C and C

i think might be this url helps to you
https://github.com/kadirpekel/MapWithRoutes
http://mobileappdeve.blogspot.in/2013/05/how-to-add-annotation-on-mapview-ios.html

Related

Geopoints: From Single Coordinate to Bounds on map

I try to figure out how to come from a single given coordinate (lat/lon) to the nearest bounds which enclose this coordinate on a map e.g. streets or sea.
Here two examples to give you a better understanding of what I mean:
What i tried already or thought about:
Setting up a Nominatim server and search for the given coordinate via the reverse-function to get the bbox and/or the geojson polygon of this coordinate. -> this only works when the given coordinate is within a POI or for example directly on a street.
Writing an algorithm to walk in all 4 or 8 directions (n/e/s/w) and 'stop' when the map layer/surface changes (change = stop for this direction and mark a bounding-point)
Building up an image-recognition system using TensorFlow to detect the different colors and 'draw' the polygon. Worked with TensorFlow a couple of times but this seems to be the most tricky solution to implement (but at my current understanding the most precise one)
Does someone of you have any other ideas to get a solution for this problem? Would appreciate any kind of approaches
Cheers!
If I got your question right, you might wanna first select all polygons in which the given point is inside of using ST_Contains, and then compute the distance to this point using ST_Distance. If you ORDER BY distance and LIMIT to 1 result you'll get the nearest polygon, e.g.
Data Sample
CREATE TABLE t (gid int, geom geometry);
INSERT INTO t VALUES
(1,'POLYGON((-4.47 54.26,-4.44 54.28,-4.41 54.24,-4.46 54.23,-4.47 54.26))'),
(2,'POLYGON((-4.48 54.25,-4.40 54.25,-4.41 54.23,-4.48 54.23,-4.48 54.25))'),
(3,'POLYGON((-4.53 54.23,-4.44 54.29,-4.38 54.22,-4.53 54.23))');
Query
SELECT gid,ST_AsText(geom) FROM t
WHERE ST_Contains(geom,ST_MakePoint(-4.45, 54.25))
ORDER BY ST_Distance(geom,ST_MakePoint(-4.45, 54.25))
LIMIT 1;
gid | st_astext
-----+------------------------------------------------------------------------
1 | POLYGON((-4.47 54.26,-4.44 54.28,-4.41 54.24,-4.46 54.23,-4.47 54.26))
(1 Zeile)

Calculate Quaternions relatively

The question is explained in the following picture.
Now I have Quaternions data of Q1, Q2, and Q3. How could I calculate Q4?
Thanks in advance for helping.
enter image description here
To make it more clear:
I want to develop a 3D Indoor navigation app which allows the user to upload the route and reproduce the route at the same location.
When creating a path and upload:
At first, the user opens the camera and got the initiate location is O, then he will store the translation and rotation data of X, which is a predefined location. Finally creating their path by record another point like Y relative to O.
When reproducing the path user created before, they open the camera again and get another initiate location O'. He can go the predefined location again and get translation and rotation of X again. Then I could calculate the Y relative to O' and reproduce the point.
In my point of view, I could calculate translation by the vector calculation: O'X - OX + OY = O'Y
But I'm not familiar with quaternions and rotation part. I've tried the same method but turns out not correctly. So I simplize the question as the model described in the graph and ask for some help.
I think Quaternion.SetLookRotation suit your problem, it converts a forward vector (and a up vector) to quaternion, and the up vector for people is usually Vector3.up, so:
var Q4 = Quaternion.SetLookRotation(/* vector Y-O' here */);

Bing maps multiple way points same location

I am having trouble with bing maps and multiple waypoints in the same location.
Ex: Go from A to B
Back to A to C
Back to B to A
The waypoints are on top of eachother and not assuming the letters from the route. A B C D E F.
How to deal?
This is to be expected. The first pushpin added to the map is rendered on top. In this case "A", then "B".... So pushpins "E", "F"... are underneath A and B.

How to get number of random points around one point in iphone maps?

I am developing one iphone application which contains maps. Starting screen is navigation screen where user can select location, lets say florida. Now when User selects florida i want to pick up at least six random points (latitude and longitude of points so that I can put annotation) from florida only.
I do not have DB so that I can not fetch 5 points from DB for florida and place them.
Any ideas?
Thanks,
This is going to be quite hard if you don't have anything to tell you the shape and size of the area you are trying to produce random points within. Harikrishnan had given you a good start, though increasing the lat and long by 0.0001 each time is hardly random. At Florida's coordintes (28.0908° N, 81.9604° W according to Google) moving 0.0001 in both directions is only 14m away, so you're unlikely to leave Florida at that speed.
You could adjust Harikirshnan's method by using a random number instead of 0.0001, but you still need to know how big the area is that your user is looking at. Having 5 points all 14m when you're looking at a state, or even a city, is not much good.
Maybe you need to look more closely at what you are trying to achieve. If the points don't represent geographical data then why are you putting them on a map. If they do and they represent the entire area and not a single point then the best I can think of is to generate random points based on the maprect that Apple returns for the location the user has chosen. (roughly speaking that would be mapX = random*maprect.size.width + maprect.origin.x). And then incase you have an area like Florida that is not perfectly shaped like your MKMapView you'd need to reverse geocode to see if the point you picked really is within Florida (i.e. send the coords to Apple and check the address).
Or, you could consider now showing the data on the map
Try this
NSInteger i;
double offset=0.0001;
for(i=1;i<=5;i++){
double newlatitude=location.coordinate.longitude+offset;
double newlongitude=location.coordinate.longitude+offset;
NSLog(#"%f ,%f",newlatitude,newlongitude );
offset+=0.0001;
}

iPhone detecting touches on a map image

I have a static map image with a bunch of circles and squares on it that depict cities. I have loaded the image into an imageView that is sub-classed under a scrollView so that I can capture user touches and zoom/scroll across the map. My challenge is that I want to pop-up a label whenever a user touches one of these circles/squares for a city to tell them which city it is and possibly load a detail view for the city. I figured I could pre-load all the relative CGPoints for the cities based on the imageView map into a dictionary so I can reference them during a "touchesBegan" event, but I'm quickly getting in over my head and possibly going about this the wrong way.
So far everything is working and I can capture the CGPoint x and y coordinates of touches. The biggest issue I have is determining the proximity of the user touches to a discrete point I may have in the dictionary. In other words if the dictionary has "Boston = NSPoint: {235, 118};" how can I tell when a user is close to that point without making them repeat the touch until it is exact? Is there an easy way to determine if a user touch is "close" to a pre-existing point? Am I going about this the right way?
Any advice or slaps in the back of the head are welcome.
Thanks, Mike
You could use UIButtons to represent the cities. Then you'll get the standard touch, highlight, etc, behaviors with less effort. Adding the buttons as subviews on your map should cause them to scale and scroll along with the map.
if i understand it correctly, you want to know if the point at which the user tapped is "close" enough to a point that is marked as a city.
you would have to quantify close i.e. set a threshold value after which the tap is farther, before which the tap is closer.
once you do that, calculate the cartesian coordinate distance sqrt ( (x1-x2)^2 + (y1-y2)^2)
for each element ( read dictionary with x,y values for cities) in the array and store the results in another array. then take the minimum of the result. the index of that result is the city that is closest to the tap if it is lesser than the said threshold.
you can either use an R-Tree, or you can calculate the proximity of the touch to each visible point in the current view. To calculate the proximity you would normally use the Pythagorean theorem but in this case you can skip the square-root because you're only comparing the relative sizes. Also you can declare a distance cut off if you like say 50 pixels squared to 2500. So you'd put the result into an object containing distance and reference point and put the objects in an NSMutableArray, not adding the results under your cutoff, and select the minimum result.
So if you have a touched point pT, then for each point pN, you'd calculate:
d=(pT.x-pN.x)*(pT.x-pN.x) + (pT.y-pN.y)*(pT.y-pN.y); //d is the squared distance
The point pN with the minimum d is the point that was closest to pT. And like I said if you want only touches within 10 pixels to count, you can test that d <= 10*10;
The method of testing for touches within a 20x20 square area works too, except if two points are within 20 pixels of each other, then you need to know which is the closest touched point.