Solved

Convert a bearing in degrees to compass point

Posted on 2009-06-28
7
2,725 Views
Last Modified: 2012-05-07
Hello

I have a gps tracking system in a vehicle. It provides the position of the vehicle as a latitide and longitude coordinate using wgs84. Apparently the unit can provide a heading for the vehicle in degrees.

Firstly, how does it calculate the heading? I know you won't know for definite but you will probably have an intelligent idea. Perhaps it stores the previous gps position and then compares this to the current gps position and uses this to calculate a bearing?

Secondly, if I have a heading in degrees, how could i convert this into one of the 8 compass points from N, NE, E, SE, S, SW, W, NW

Many thanks
0
Comment
Question by:andieje
  • 3
  • 3
7 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24740078
>>Apparently the unit can provide a heading for the vehicle in degrees.
Every GPS can provide you the rhumb (it is not always the same as the heading, specially for air/sea vehicles), but calculating by yourself is not a trivial stuff, because GPS use to give inaccurate positions that causes false heading calculations. For this, there is an algorithm named "Kalman Filter" that eliminates the error by providing many samples as input to have a stable heading value as output.
Besides this, calculating compass coordinates is quiet easy. Which programming language?
0
 

Author Comment

by:andieje
ID: 24744630
Hi

I dont know what a rhumb is. I looked it up on google but it doesnt seem to be possible to get a laymans explanation. However, I'm not sure I need to know exactly what it is but I would like to convert it to a compass bearing. I am using vb.net 2005.

Many thanks
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24751450
don't worry about rhumb versus heading, it should be the same for terrestrial applications. About compass algorithm, here is some implementation of my own:

Public Function Quadrant(ByVal degrees As Single) As String
    Dim AllQuadrants As String = "NNE,NE,NEE,E,SEE,SE,SSE,S,SSO,SO,SOO,O,NOO,NO,NNO"
    Dim Quadrants As String() = AllQuadrants.Split(","c)
   
    If degrees > 348.75 OrElse degrees <= 11.25 Then
        Return "N"
    End If
    Dim q As Integer = CInt(Math.Floor((degrees - 11.25) / 22.5))
    Return Quadrantes(q)
End Function
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:andieje
ID: 24757693
Thats brilliant. However I only need the 8 compass points in my question. I don't know how to modify the code you have supplied to restrict it to just those compass points.

I could do something 'rough' like assigning the more detailed compass points to a more general one
e.g. if function returns NNE then convert it to NE but it would be nicer and easier to read if i could modif the function ou supplied
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 24757753
ok, downgrading my function:

Public Function Quadrant(ByVal degrees As Single) As String
    Dim AllQuadrants As String = "NE,E,SE,S,SW,W,NW"
    Dim Quadrants As String() = AllQuadrants.Split(","c)
   
    If degrees > 337.5 OrElse degrees <= 22.5 Then
        Return "N"
    End If
    Dim q As Integer = CInt(Math.Floor((degrees - 22.5) / 45.0))
    Return Quadrantes(q)
End Function
0
 

Author Closing Comment

by:andieje
ID: 31597670
many thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I feel like more and more people want to know how to programmatically convert addresses into geospatial locations. So in this article, I will show you how you can do it with Bing Maps. I'm going to use PowerShell, which is a nice scripting language,…
Introduction This article is designed to assist GIS (Geographic Information System) and GPS (Global Positioning System) developers using ESRI ArcGIS and other spatial information management systems.   For the uninitiated the concept of projectio…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now