开发者

GPS Coordinates translating

开发者 https://www.devze.com 2023-03-02 12:50 出处:网络
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 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 w开发者_运维百科ill 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#


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 ?


Visakhapatnam is located at 17° 42′ N, 83° 15′ E or, in signed decimal +17.7°, +83.25°. Since Visakapatnam is fairly large, 17480249 probably means 17° 48' 2.49 ", which is about 2.5 km away EESE.

This is how GPS units format their data for the NMEA 0183 bus, for example.

Handle the quantities as a string. For the latitude, use the first pair of digits as degrees, the second pair as minutes, the third pair as seconds, and any additional digits as digits after the seconds' decimal point. For longitude, use the first three digits as degrees, and the remaining digits the same way as latitude.

To convert degrees, minutes, and seconds (DMS) to degrees, use the formula D + M/60.0 + S/3600.0.


That format is nowhere on this page

http://en.wikipedia.org/wiki/Geographic_coordinate_conversion

My suggestion is to collect some data for some more cities and hope that you can pick out a pattern.

0

精彩评论

暂无评论...
验证码 换一张
取 消