Android Question Does GPS bearing depend on the way you hold your handset

llama

Member
Licensed User
Longtime User
Quick GPS question -I am trying to get the direction of travel and I wanted to know the following , Much appreciated in Advanced.

1- Does the GPS bearing Bearing matter which way you hold the phone reading Erel's notes here

"In GPS_LocationChanged event you can easily calculate the direction to the target with Location.BearingTo. Point to the north and test it.
When you get this step correctly you need adjust the direction based on the current orientation."

QUESTION 1 is there a way to get the direction of travel without worrying if the handset is in a bag held in a funny way (upside down ) or at an angle.. I need to know if I am travelling down a river in a direction or up a river in the opposite direction so I need to know the bearing without worrying which way the device is held.

Any help much apprecieted or simple calculation example.. even better

QUESTION 2
Is there a library that can handle this in B4A, with this taken into consideration.

Thanks
 

emexes

Expert
Licensed User
1- Does the GPS bearing Bearing matter which way you hold the phone
Assuming "way" means "orientation" then:

No. The GPS bearing measurement (and speed measurement) is done using Doppler shift to detect differences of movement of the GPS receiver relative to the satellites, to calculate movement of the receiver relative to the earth's surface. Bearing is the direction of movement of the receiver, not its orientation.

QUESTION 1 is there a way to get the direction of travel without worrying if the handset is in a bag held in a funny way (upside down ) or at an angle.
A GPS fix received via the LocationChanged event includes Bearing and Speed (and BearingValid and SpeedValid) of travel:



Ignore the "or sets" mention; the Location type is used for a variety of navigation-related calculations, not just for returning GPS readings.

I need to know if I am travelling down a river in a direction or up a river in the opposite direction so I need to know the bearing without worrying which way the device is held.
Today is your lucky day: it's like the designers of GPS saw you coming

Assuming you know the direction of the river that you are on, then: if the GPS bearing is within 90 degrees of this direction, you are heading down-river; otherwise, you are heading up-river.

QUESTION 2 Is there a library that can handle this in B4A, with this taken into consideration.
Again assuming you know the direction of the river you are on, then: no library required, a simple comparison with the GPS LocationChanged Bearing will do the job.

Determining the direction of the river at your current location is perhaps trickier. Rivers often have bends and loopbacks and diversions and forks where the river path wends left or right and can often end up being the opposite direction to the overall path of the river. I know that in OpenStreetMap data, a "way" (line segment) has direction, and I would be very surprised if the ways used to represent a river were not in the direction of river flow.

Another issue might be a tide-affected waterway, where the water alternately flows in both directions. And then there's canals, with nominally no water movement. I'd guess there that the direction would be taken as being towards locks to a lower water level. Actually, that could be a way of determining the direction of a river - use the river's elevations to work out which way is downhill. Although that opens up a new can of exceptions, like if you're a caver canoeing on an underground waterway. Or on a canal viaduct. But these are all bridges we can cross when we get to them.
 
Last edited:
Upvote 0

llama

Member
Licensed User
Longtime User
Thank you very much chaps , Really appreciate that what great answers so thank you . Have a great Christmas.
 
Upvote 0

rabbitBUSH

Well-Known Member
Licensed User
1- Does the GPS bearing Bearing matter which way you hold the phone
Are you trying to get 'direction' in degrees bearing or compass rose bearing.? I haven't used the library so don't know what it returns.

You need to get your head around the spherical nature of this stuff. BEARING is traditionally in the horizontal plane. A compass/GPS based device will normally give you the 'compass' whichever way up it is-but it likes to be horizontal and face up. But, if the device is vertical it will show a compass and calculate bearing- that being the direction of movement.

There is, of course, the 360deg version based on AZIMUTH which means you would be quoting in degrees East of North and North-East-North as a bearing. [actually, if I recall, the azimuth can be : the sun is at 90deg bearing and its azimuth is 25deg meaning its 25deg above the horizon, I think]

The pedantic part is - read these :



What the GPS does with it is probably to always assume things are the right way up.

@emexes is right, if a little facetious, as the river bends in landscape bearing will rotate away from north with 180degrees being south. So if you're trying to work out 'am I generally going north' : that's a different issue - regardless of whether or not the 'gps' is in a bag, upside down or whatever {or the river is flowing downhill}. ?
 
Upvote 0

emexes

Expert
Licensed User
@emexes is right, if a little facetious, as the river bends
I'm going to take that as a complement ;-)

Original specification was: I need to know if I am travelling down a river in a direction or up a river in the opposite direction.

I'm only writing this post because, curiously and coincidentally, I was looking at the issue of Trump wall vs butterflies the other day, where the border is the Rio Grande, and the map reminded me of this thread. In just a few km, the river covers like 300 degrees of 360.

 
Upvote 0

rabbitBUSH

Well-Known Member
Licensed User
Which way was the Thumper travelling? Downriver I hope

And there is this lot as well.......


Interesting that quite a bit of that border already had 'walls' before Thumpy came along....
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…