How to Get distance between coordinate AR Location Based - android

How to Get distance between coordinate on AR Location Based
I lerning from com.cobyplain.augmentreality.AugmentRealityStep4
( https://github.com/cplain/augmented-reality-tutorial )
How to show distance with mSport and mPaint on screen
http://upic.me/i/a1/dckar.png

First of all always share your code. We`re not here to give you codes but instead you help you achieve it.
If you want to show the distance between your position and some POI position that you need two things: Your position and the POI position which have both your coordinates and the POI coordinates. This can be done via manual calculation or can be done using an API.
I recommend Google Maps API for this since their function include those of which you have asked.

Related

Dynamically hide/show markers when indoor maps floor changed in android

I am creating one google indoor map application as a part of my project. As of now i just try to create some working prototype before main application gets starts. As of now i am using one college location where i can find indoor maps available.
My main goal is show markers with windowInfo on different floors locations like rooms, theater or auditorium. I just used 1st floor one room lat long and set marker as of now. But when user switch to second floor then map should hide first floor marker and have to show other available markers on floor 2. Same thing would apply for all other floor levels.
Here, my main problem is that how can i get to know exact lat long or location of particular place on floor 2 where i should have to show marker point. Is there any way where google give response of upper floor locations with lat long or some height so i can try to determine that and show marker.
Second confusion is that when user zoom in or out or else user changes floor level at that how we can handle a lot markers hide and show.
Please share your ideas and views on this. As of now i can able to put marker on only first floor. you may find that image below.
Any help would be really appreciated.
you can use getLevels ()
Gets the levels in the building. While a level is usually enclosed by a single building, a level might be enclosed by several buildings (e.g., a carpark level might span multiple buildings). The levels are in 'display order' from top to bottom.
You can also use various methods in IndoorBuilding class getActiveLevelIndex(), getDefaultLevelIndex(),isUnderground() etc
Read more about IndoorLevel
Hope it helps
Some apps include your altitude along with your the lat/long information. What you need to do is to get your altitude and keep that as a variable. Then find out what altitude each of the levels of the building are. I am attempting to do the same thing for a University and that is the only way I knew of where you could know that you are on a second or third floor. Think of it as having your x,y, and z values. Lat/Long is basically a 2d representation of the earth's surface. But, you also have a 3rd plane. You could do the following: Download a program that not only tells you your lat/long but, also the altitude. Then have a variable that is a constant for each building. (building name) (Floor number) (Floor elevation). Then when you give the building lat/long you also give the elevation variable and then it associates it with a floor number.
Ashe

How to Filter Locations Based on A specific location and a direction

I'm trying to implement a small part of AR, The purpose is to filter locations based on My Location and A direction (North by example) :
I know that to know Direction i need to use Sensor type Orientation
Memory Conception
So can someone help ?
Well, you can get the distance and angle to a point by using Location.distanceTo(). So you'd want to loop through all the points, get the distance and bearing. If the object is close enough and the bearing is within the angle you want, then you treat it as a good point and display it. If it isn't, you skip it.

get location address w.r.t the polygon I am in

I have over 200 polygons to create and I get the location by LocationListenerOnChanged() but I would like to know which polygon I am in based on the current location .
How will I use LatLng to check within within each polygon every 2 miles.And how can I make the entire process faster or will android os has inbuilt function.
I checked a lot of documents related android maps v2 but I did not get any info about it.I appreciate any help w.r.t the topic .Thanks in advance.
There is no direct method in android api v2 to know if a latlng lies within a polygon. So you need to do a mathemetical calculation known as point inside polygon check. You can check out the below two methods suggested in earlier posts:
1, Raycasting method
2, Winding number method
If in your case, checking a point against all 200 or more polygons is slowing your app, you can consider reducing the number of polygons to be checked. First of all , for each polygon, other than their vertices, also store an approximate geometric center. Then when you get a new location for checking, find the distance between this location and the geometric center of all the polygons. Now take only few polygons ( say 8) whose centers are closest to the point and then do any of the above point inside polygon check for those chosen polygons.

Android:given a current location and lat/long of places arround me how to decide which places are visible in camera?

I am creating AR app for Android which would write name of places/buildings/etc over camera view when I point to places with live camera. I get my current location in lat and long, also I am able to get list of places (with their lat/long) in certain radius from my current location.
However, the most confusing part to implement is to show only those places which are visible in camera in that moment (don't show places). One of idea was to calculate azimuth of my current location, then calculate azimuth of all places which I get in set radius, then calculate camera horizontal angle using getHorizontalViewAngle() and having all this parameters calculate which of places azimuth gets into this interval: [my_current_loc + (getHorizontalViewAngle()/2) ; my_current_loc - (getHorizontalViewAngle()/2)].
However I think it is not very efficient way, can anyone suggest my any solution, or maybe some had similar problem and find good solution. If it is difficult to understand my problem, let me know and I will try to explain in more details.
You are doing the right thing, but in our project we found better (performance wise) to use the rotationmatrix instead of the azimuth. You can take a look at the source code of mixare augmented reality engine. It's on github: https://github.com/mixare/mixare
The core logic is in the MixView class. The main idea is to convert anything to vectors and project them onto a "virtual" sphere that surrounds the phone.
HTH,
Daniele

How to create a compass where the needle always point to a certain GPS position? (in Android)

I would like to write a app in Android where you see a pointer that always point to a certain GPS position. So when you are turning your phone or driving around the pointer will still point to the gps position.
But I have no idea how to do the calculations with the gps position and the compass sensordata.
Can anyone give me some pointers how to get started or maybe have a example of how to do this?
To achieve this you will need to know several things:
Where you want to point to.
Where you are.
What map projection you are using (metres, degrees etc)
Use the android LocationManager and register for position updates. When these updates arrive you need to extract the position and bearing (could also use compass for bearing) and convert them to the map format you are using. Commonly this will be the Google maps spherical Mercator variation.
With this information you can use trigonometry to calculate the angle between you and your tagged location and use this to draw your direction arrow on a map, or with the bearing data to tell you which way to turn.
Same starting point as above answer, but no trigonometry calculation required. Just calls of existing methods.
You have
your actual position from onLocationChanged (method of the Location class)
the coordinates (lat/lon) to point to
You can now
create an overlay on googleMaps, and draw a line from your position to the point to point to.
or if you want a shorter line (or arrow)
"bearingTo()" (again from the Location class)gives you the direction to point to. Draw a line (or arrow) and rotate it to this direction

Categories

Resources