Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find set of latitudes and longitudes using user's current latitude, longitude and direction of viewing an object

I am building an Android application based on Augmented Reality. The main idea is when user opens up my application, by default device's camera starts in preview mode. Based on user's current GPS location and the direction in which user/camera is facing I want to calculate which are the set of latitudes and longitudes in the range?

Following image explains my scenario very well. I have full set of latitudes and longitudes as drawn all black spots in the figure. Now suppose user is at the center of the circle. Also considering that he is viewing in North direction. If we consider an angle of 45 degree towards North direction. I want to get set of latitudes and longitudes which are coming in this 45 degree viewable area.

enter image description here

I am able to get the direction in which user's camera is facing. I am also able to find user's current GPS location. I have full set of latitudes and longitudes stored in my SQLite database. Now I want to calculate is the set of latitudes and longitudes in which user's device camera is facing.

I hope I have explained pretty well here. Its bit urgent if anyone can help on this.

Thanks in advance.

like image 462
hp.android Avatar asked Feb 08 '12 09:02

hp.android


People also ask

What is longitude and latitude in Google map?

The latitude is specified by degrees, starting from 0° and ending up with 90° to both sides of the equator, making latitude Northern and Southern. The equator is the line with 0° latitude. The longitude has the symbol of lambda and is another angular coordinate defining the position of a point on a surface of earth.

How do you find the latitude of a line?

Use the sight line on the top of the aiming beam to align the beam with the North Star. Use the protractor to measure the angle between the beam and the horizon (which is 90º to the plumb line). This angle is your latitude.


2 Answers

To obtain the viewing angle, you can use as an approximation the Camera.Parameters getHorizontalViewAngle() method. Let's call it alpha. You also know the bearing of your device from its point of view to magnetic North, let's call it beta.

From there, within a given radius, iterate through set of database locations, compute the bearing from your position to its, and check if it is inside the interval [beta-alpha/2, beta+alpha/2]

If you're not really on a rush into this, I would suggest to take a look into Mixare, its an open source framework which deals with location and AR.

like image 76
MobileCushion Avatar answered Nov 09 '22 03:11

MobileCushion


you can check the code of mixare, an augmented reality browser released under the GPLv3. The repository is available at: http://github.com/mixare/mixare

There are a lot of details you have to take care of, starting from the fact that the Field of View of the camera is only programatically available since version 2.3 (IIRC) of android. You find these and lots of others in the compatibility class.

HTH, Daniele - mixare team

like image 31
Daniele Avatar answered Nov 09 '22 03:11

Daniele