Determining the side of the road I'm travelling using GPS

1.9k views Asked by At

How would I proceed to program which side of the road I'm travelling on in Android(LEFT SIDE OR RIGHT SIDE). I got the street name and the compass direction, But don't i need to know how to road is placed whether north to south or east to west to determine which side I'm going on? Basically, how should i find the orientation of the road

Example : Say the road is placed on the EAST-WEST axis and i were to move towards EAST, then the device should tell me I'm on the left side of the road.

3

There are 3 answers

0
AlexWien On

The location info has a heading a.k.a. bearing a.k.a course attribute. It is an angle 0 - 360 on the compass rose. Just take this and you know the direction. It is not neccessary to enable the compass.

Further the compass shows the heading of the device. not the direction of walking / driving.

further as MasterAweSome explained, dpeending on the country you will be usually on the right or left side. GPS and digital road maps, are not acurate enough, to determine wheter you drive / walk on the left or right border of street. The differecne is about 6m (2 lanes), which is also near the avg GPS accuacy.

Although special GPS /GNSS hardware used in land survey have a precision of sub centimeter or even mmilimete range, you will not achieve that accuray on a smart phone.

3
Gabriel Garrett On

The side of the road you are on depends upon which country you are in, regardless of direction being travelled. For instance, in the United States, you are always on the right side. In the United Kingdom, you are always on the left side.

You should find the country the user is in and determine what the traffic rules are for that country, if the side of the road they are (supposed) to be on is what you are looking for.

0
effy On

You start by determining the heading, you can do that by using the Google maps geometry library, it has a function called computeHeading() you pass in 2 coordinates and it'll return a numeric value of the heading of the 2 coordinates.

Here I'll explain how to interpret the heading to N, E, S & W.

Lets assume we have a clock, 12:00 is a -0 or a 0 heading which on the compass is North. 3:00 is heading 89.5 which on the compass is East. 6:00 is heading 179 or -179 which on the compass is South. 9:00 is heading -89.5 which on the compass is West.

When you get the heading returned from the function. if it's in the range of -44.75 to 44.75 the heading is North, If it's in the range of 44.75 to 134.25 you can determine the heading is East, and so on.

Your question is regarding the side of street the car is on, that's almost impossible to figure out without any user input (the user selects if they're on the right or left side of the street) since the car might not even be parallel to the road.

The heading does help you determine the direction the car is facing and based on the country the car is in you can presume it's driving on the side of the road driven in that country.