Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS Coordinates translating

I am developing GPS tracking web site with a device from VisionTek with the model no 86VT

http://www.visiontek.co.in/vehicle-tracking-systems/86vt.html

I am able to get the device location but could not parse it correctly as we use in google maps. For. Ex. I am getting the following longitude for Visakhapatnam which is 17.xxx in original Coordinate in google maps location.

17480249N

I dont know what is this format, and how to convert 17480249N to 17.xxx . I also know that "N" is for positive values.

Please help, I am using PHP, but any logic will be appreciated.

This is how I am getting the response from device. Please see the bold text for coordinates, I am near to Visakhapatnam beach.

$1,GlamourBik,14,11,10,14,40,08,17434800N,083185195E,02.1,13,0,0,A#

$2,GlamourBik,14,11,10,14,45,08,17440069N,083187747E,19.8,12,1,0,A#

$1,GlamourBik,14,11,10,16,53,42,17440319N,083176376E,00.3,178,1,0,A#

$1,GlamourBik,14,11,10,16,58,41,17440319N,083176376E,00.0,166,1,0,A#

$1,GlamourBik,14,11,10,17,03,42,17440319N,083176376E,00.0,42,1,0,A#

like image 429
AjayR Avatar asked Apr 07 '26 06:04

AjayR


1 Answers

Are you sure it is not Latitude ? (N should mean North and Longitude is for East/West)

In javascript this should probably do what you want..

function getUsable ( coordinate ) 
{
  var signMultiplier = {'S':-1,'N':1, 'W':-1, 'E':1};
  var sign = coordinate[ coordinate.length-1 ];
  return signMultiplier[sign] * parseInt(coordinate.replace( sign, '' ), 10) / 1000000;
}

using getUsable('17480249N') will return the google-map friendly version.

I assume that the format is an integer representation of six digit floating precision.

N is positive because it denotes North as opposed to South which should be negative.
Same for E (east) and W (west).

Demo at http://jsfiddle.net/gaby/Rjk8e/


Update

After your update with full coordinates and the answer from @wallyk, here is a version that can calculate the coords if they are in DMS format.

function getUsableDMS( coordinate )
{
    var signMultiplier = {'S':-1,'N':1, 'W':-1, 'E':1};
    var sign = coordinate[ coordinate.length-1 ];
    var length = coordinate.length-1;
    var D = parseInt( coordinate.substr(0,(length==8)?2:3), 10 );
    var M = parseInt( coordinate.substr(2,2), 10 );
    var S = parseInt( coordinate.substr(4,4), 10 ) / 100;
  return signMultiplier[sign] * (D + (M/60) + (S/3600));
}

Demo at http://jsfiddle.net/gaby/Rjk8e/1/


Examples

Is the first coordinate in your question 17434800N, 083185195E located at any (both are in the sea) of

google map using translation by first method
or
google map using translation by DMS method ?

like image 161
Gabriele Petrioli Avatar answered Apr 09 '26 20:04

Gabriele Petrioli