将坐标转换为可用的

发布于 2024-11-08 22:47:19 字数 216 浏览 0 评论 0原文

我有一个坐标采用以下格式的数据源。

N642500,W0241600
N660700,W0240000
N652000,W0222700
N660800,W0195500
S645500,E0170800
S644000,E0162200

我不知道这些是什么格式,也不知道如何将它们转换成我可以使用的格式。这可以是 JavaScript 或 PHP!

I have a data source with coordinates in the following format.

N642500,W0241600
N660700,W0240000
N652000,W0222700
N660800,W0195500
S645500,E0170800
S644000,E0162200

I do not know what format these are in or how to get these into a format I can use. This can either be JavaScript or PHP!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

过去的过去 2024-11-15 22:47:19

看起来像以度、分、秒 (DMS) 表示的纬度、经度。请参阅http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/readme。 htm 进行转换。

通常,地图应用程序会采用十进制形式的纬度和经度,因此您需要将 DMS 转换为十进制(N 为 +,S 为 -)。也就是说,我有点惊讶地发现 Google 地图将直接采用 DMS - 请参阅 http://groups.google.com/group/Google-Maps-API/msg/670c54481d91e6b3?pli=1。所以你甚至不需要转换它。例如:

51 57' 32.48",00 55' 55.23" 
http://maps.google.com/maps?f=q&hl=en&q=51++57%27+32.48%22,00+55%27+5... 

如果您需要计算它:

function DMS(lat,latm,lats,lon,lonm,lons) { 
  if (lat<0) { 
    latm = -latm; 
    lats = -lats; 
  } 
  if (lon<0) { 
    lonm = -lonm; 
    lons = -lons; 
  } 
  lat = lat + latm/60 + lats/3600; 
  lon = lon + lonm/60 + lons/3600; 
  return new GLatLng(lat,lon); 
} 
map.setCenter( DMS(35,3,39.08, -118,9,2.20)); 

按照 http://groups。 google.com/group/google-maps-api/msg/2e3436f3bf7d6155。但我认为API应该直接获取它。

Looks like latitude, longitude in degrees, minutes, seconds (DMS). See http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/readme.htm for conversions.

Typically map applications will take the latitude and longitude in decimal form, so you would need to convert DMS to decimal (N is +, S is -). That said, I was somewhat surprised to find that Google maps will take DMS directly - see http://groups.google.com/group/Google-Maps-API/msg/670c54481d91e6b3?pli=1. So you don't even need to convert it. For example:

51 57' 32.48",00 55' 55.23" 
http://maps.google.com/maps?f=q&hl=en&q=51++57%27+32.48%22,00+55%27+5... 

If you need to compute it:

function DMS(lat,latm,lats,lon,lonm,lons) { 
  if (lat<0) { 
    latm = -latm; 
    lats = -lats; 
  } 
  if (lon<0) { 
    lonm = -lonm; 
    lons = -lons; 
  } 
  lat = lat + latm/60 + lats/3600; 
  lon = lon + lonm/60 + lons/3600; 
  return new GLatLng(lat,lon); 
} 
map.setCenter( DMS(35,3,39.08, -118,9,2.20)); 

Per http://groups.google.com/group/google-maps-api/msg/2e3436f3bf7d6155. But I think the API should take it directly.

三月梨花 2024-11-15 22:47:19

这些将是 纬度经度。数据源的文档应该告诉您单位是什么;通常它们是度数(以各种小数形式),但您需要知道给出的数字是度数的小数部分,还是度、分和秒。

在将它们转换为有用的数字方面,这取决于它们是小数度还是度、分和秒;以及您想用它们做什么。

Those would be latitude and longitude. The documentation of the data source should tell you what the units are; usually they're degrees (in various fractional forms), but you'll need to know whether the numbers given are decimal fractions of degrees, or degrees, minutes, and seconds.

In terms of converting them to useful numbers, that will depend on whether they're fractional degrees or degrees, minutes, and seconds; and what you want to use them for.

╰◇生如夏花灿烂 2024-11-15 22:47:19

格式似乎是逗号分隔值 (CSV)

这些值看起来像纬度(北 + 或南 -)和经度(西 + 或东 -),后跟 ddmmss

我认为 ddmmss 比十进制度更有可能,因为 MM 和 SS位数小于 59 -

编辑-

经度的值必须为 +/- 180 (DDDMMSS),但纬度的值必须为 +/- 90 (DDDMMSS)

The format appears to be comma-separated values (CSV)

The values look like latitude (North + or South -) and longitude (West + or East -) followed by ddmmss

I think ddmmss is more likely than decimal degrees since the MM and SS digits are less than 59

-EDIT-

The values for LONGITUDE have to be +/- 180 (DDDMMSS) but the values for LATITUDE need to be +/- 90 (DDMMSS)

朕就是辣么酷 2024-11-15 22:47:19

这个js函数会将你的字符串清理成已知的经纬度格式,用法示例:

clean('N51618017,W0248291');

非常简单,所以这里是函数

function clean(string){

var values = string.split(','),
    lat,
    lon;

if(values[0].search(/S/)){
    lat = '-';
}
if(values[1].search(/W/)){
    lon = '-';
}

lat += values[0].substring(1, 3)+'.'+values[0].substring(4);
lon += values[1].substring(1, 3)+'.'+values[1].substring(4);

//now you got your values

//so can do this:
var url = 'http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat='+lat+'&lon='+lon+'&setLatLon=Set';

//or just return them as an object:
pos = {name:'your pos name',latitude:lat,longitude:lon}


}

this js function will clean your string into an known lat lon format, usage example:

clean('N51618017,W0248291');

pretty simple, so here is the function

function clean(string){

var values = string.split(','),
    lat,
    lon;

if(values[0].search(/S/)){
    lat = '-';
}
if(values[1].search(/W/)){
    lon = '-';
}

lat += values[0].substring(1, 3)+'.'+values[0].substring(4);
lon += values[1].substring(1, 3)+'.'+values[1].substring(4);

//now you got your values

//so can do this:
var url = 'http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat='+lat+'&lon='+lon+'&setLatLon=Set';

//or just return them as an object:
pos = {name:'your pos name',latitude:lat,longitude:lon}


}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文