节点服务器地理位置 [英] Node Server Geolocation

查看:53
本文介绍了节点服务器地理位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以使Node服务器在不使用浏览器的HTML Geolocation API的情况下确定其准确的(即GPS)位置?它还需要与互联网断开连接,即不依赖于某些外部查找.

Is there a way for a Node server to work out it's accurate (i.e. GPS) location without using the HTML Geolocation API from the browser? It also needs to be disconnected from the internet, i.e not depend on some external lookup.

在我的情况下,我有一台服务器,该服务器是一台笔记本电脑,未连接到Internet,并且实际在某个位置移动.当客户端连接到服务器时,服务器需要已经知道它在哪里,客户端可能不在同一位置.想象一下,客户端启动了一个地图并绘制了两个点,一个点是服务器的位置,另一个点是客户端的位置.

In my case I have a server which is a laptop, not connected to the internet, and physically moving around a location. When the client connects to the server, the server needs to already know where it is, the client may not be in the same location. Imagine the client starting up a map and drawing two dots, one with the location of the server and the other with the location of the client.

基本上,服务器是否存在与 navigator.geolocation.getCurrentPosition 等效的内容?

Basically, does an equivalent to navigator.geolocation.getCurrentPosition exist for a server?

推荐答案

执行此操作的唯一方法是连接一些GPS或GNSS硬件.之后,这非常容易.

The only way to do this is to have some GPS or GNSS hardware attached. After that, it's very easy.

几乎所有这些GPS/GNSS单元都显示为串行端口.您可以使用适用于所用系统的任何软件包打开串行端口.从那里开始,使用了一些协议,但是NMEA是最常见,最容易处理的协议.NMEA数据如下所示:

Almost all of those GPS/GNSS units show up as a serial port. You can open the serial port using whatever package is appropriate for whatever system you're using. From there, a handful of protocols are used but NMEA is the most common and easiest to deal with. NMEA data looks like this:

$GNRMC,143909.00,A,5107.0020216,N,11402.3294835,W,0.036,348.3,210307,0.0,E,A*31

在此示例中,北纬51度,北7.0017737分钟,西纬114度,02.3291611分钟.有可用于解析的NPM软件包.

In this example, the latitude is 51 degrees, 7.0017737 minutes North, 114 degrees, 02.3291611 minutes West. There are NPM packages available for parsing.

这篇关于节点服务器地理位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆