Android - Get orientation (Compass like) where phone is pointing at - java

I have an array of Marker (google maps markers) with longitude and latitude.
I want to create some sort of radar like view that'll display these markers as points where I'm looking toward their directions with an angle of 45°.
Do you guys have any idea how I can say "This marker is behind me, this marker is in front of me".
I guess I should apply cos and sin considering my orientation, but that's too blurry atm.
Hope you'll help :)
Thanks

I assume you already know your location and orientation. You can then calculate the directions of the array of markers using computeHeading() method of Google maps Geometry Library on your current location and the points. Then you can adjust those values based on your current orientation.

Related

I want to find the closest path to the polyline

I need your knowledge to make my application, thanks in advance. Well, I'm using Android Studio - Java - Using the Google maps API, I generated several polylines on the map, I also added my current position, what I need is to generate a route that will take me to the nearest polyline and referring to the first image, I have a polyline with a certain number of coordinates represented by the red dots. The light blue dot would be my current position. What I need is to find the closest path to the polyline without needing it to be one of the coordinates
(PS: I don't speak English if you can explain me in the simplest way possible)
enter image description here
Aqui otros ejemplos
enter image description here
enter image description here
I found some examples but they all seek to
find the closest coordinate of the red points but the truth is that I
want the closest point to the polyline
, it is a challenge for me so I am looking for help.
enter image description here

How to place objects in ARCore that point in a given geographical direction

I am currently working on an ARCore app and want to place objects (eg. Arrows) in the AR scene that start at the current location of the user and point to geographical north.
My idea was to place objects on the X-axis, rotate them around the Y-axis and at last translate the objects to have their origin in the position of the user. I planned to at first get the device orientation in relation to north (which I am able to do) and also get the orientation in relation to the ARCore world coordinate system. I'm now struggling to do the latter. I think I need the angle around the Y-axis between the X-axis and the current direction of view. I figured out that it should be somehow possible to get this via the Pose:
arFragment.getArSceneView().getArFrame().getCamera().getDisplayOrientedPose();
I don’t have any clue what to do with the pose. The values qx(), qy(), qz(), getXAxis(), getYAxis() and getZAxis() don’t seem to be what I expected. As I watched them change while moving the device (after converting them to degrees) they ranged roughly from -55 to 55.
TL;DR:
How to rotate objects in ARCore to point to a given geographical direction?
I found this solution but don't know what the 'dHelper' is supposed to be:
Placing an object with a given compass bearing in ARCore
to put an arrow on the camera view that will direct you you do not need arcore in any matter. This is siple rotation of na ImageView
if you want to rotate 3D object according to the bearing you need to get actual position, target position, count the bearing and rotate based on the int value of degrees that you received from the calculation.

Draw Marker of Store along the route between two point

I have to show stores on Google map between two Locations.
Suppose I have 5000 stores all over the country. But how could I only draw store marker between my routes. I mean show stores coming in my way on Map. As Latitude longitude don't change gradually while moving b/w two points. How could I query like
Read all store which lie on the given route between two points.
As route consist of polyLines I think I should create circular area between each polyline and If any store lat lng lie in that area draw it on Map. But when I have a big polyline it's circle will be bigger and I don't want to show store that are far away from my routes.
I need a better approach to show my store on map in my route. And I need it before moving.
You don't need to create a circular region or a polygon. Consider the documentation of Polyline. I found a very helpful method here
isLocationOnPath(LatLng point, java.util.List<LatLng> polyline, boolean geodesic, double tolerance)
Computes whether the given point lies on or near a polyline, within a specified tolerance in meters.
For further detail consider this
http://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/PolyUtil.html

How to search nearby coordinates in android using google map

I'am new in android development my problem is.
I have to find nearby coordinates from a data in a given radius in android.
For example when i click a button. It will search nearby coordinates listed in an array or in a database.
Example: My current coordinates is 1.1
Nearby coordinates will show : 1.2,1.3,1.4,1.5 which is stored or from my database/array.
Is this possible? Can someone help me. Any answer is really appreciated.
Thanks!
One approach is to simply use a geographical distance function.
Have a look at: http://www.movable-type.co.uk/scripts/latlong.html
This will give you some background information on what you are trying to do. I've used this website many times during work with UAVs. Also, keep in mind that you might need to convert to/from Deg/Min/Sec Lat & Longitude <-> decimal Latitude/Longitude.
Find the method for calculating distance - and there are many coded examples already out there - and then run each of your target points through it to find out how far each is from you.
Good luck!

GPS coordinates to pixel

I need to create image (polygon) from GPS coordinates. I have coordinates like this:
(49.274633220,17.160206083),(49.276968797,17.162732143),(49.278188519,17.162391767),(49.279761626,17.161087954), ......
And I need to transform them to XY pixel points. Each pair of coordinates are vertex of created polygon.
File with all coordinates:
GPS.txt
and how the created polygon should look like:
Any idea how can I transform the coordinates? Thanks for all reply.
In all cases you need a transformation form lat,lon (spherical) to cartesian (x,y) coordinated.
If the polygon is not bigger than 100km you can use a simple Cyclindrical Equidistant Projection.
Otherwise, you may use a Mercator Projection. (Google Maps uses that too)
Are you sure the assignment says to create a graphic? Or is it just to read the text file and extract the pairs of coordinates? Because you can't create a graphic without defining a transformation. I would start by finding the max and min latitude and longitude values (making sure which is which!). Then just use a linear scale for the longitude so that your minimum longitude goes to px=0 and the maximum longitude goes to however wide you want your image to be. Then do the same for latitude - it'll look distorted but at least you'll see something to start with.
By the way, the graphic you pasted doesn't seem to correspond to the coordinates you gave. If it helps, yours look more like this red area.

Categories