Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate the gps coordinates of sides of street on a map [closed]

enter image description here

I have the GPS co ordinate of the user on a map (Indicated by red dot in the picture)

I would like to calculate the GPS co ordinates of the blue dots on the map.

The dots are equidistant from the red dot on either side. If I can get the heading of the street compared to magnetic north I can calculate the dots or is there any other easy way?

like image 979
Pavan K Avatar asked Nov 12 '22 17:11

Pavan K


1 Answers

(I tested it use map version 1, not map api V2.)

Before follow steps, you should know distance and angle before finding coordinates.

Steps:

  1. Change geo point to pixel(x, y). (Use projection)

  2. Get pixel size of distance(d). (Use metersToEquatorPixels)

  3. Then you get a point (d, 0)

  4. Rotate (d,0) ==> You will get a new point which spaced apart at d from (0, 0) ==> (a, b)

  5. (x+a, b+y) is a point that you want.

  6. Get geo coordinate of (x+a, y+b) use this.

Rotation formular is

(x'*cos(θ) - y'*sin(θ), x'*sin(θ) + y'*cos(θ))

so, you can change this simple.

(d*cos(θ), d*sin(θ)) // This is a point of step 4. (a,b)

My code is.

// you should know distance and angle

Point px = new Point();
Point px2 = new Point();

mapView.getProjection().toPixels(mGeoPt, px);
float pixedDis = mapView.getProjection().metersToEquatorPixels(distance);

px2.x = (int)(pixedDis*Math.cos(angle)) + px.x;
px2.y = (int)(pixedDis*Math.sin(angle)) + px.y;

GeoPoint gp3 = mapView.getProjection().fromPixels(px2.x, px2.y);
like image 152
Kyoung-june Yi Avatar answered Nov 15 '22 07:11

Kyoung-june Yi