我是新来的npm module
和node.js 所以这对我来说真的很难。
我有一个包含很多点的js代码,对于每个点我想获取最近的城市。
为此,在其他问题中(使用大数组进行反向地理编码是最快的方法吗? - JavaScript 和性能 https://stackoverflow.com/questions/49494643/reverse-geocoding-with-big-array-is-fastest-way-javascript-and-performance/49542182?noredirect=1#comment86123448_49542182),一位用户建议我使用两个npm 模块,
const kdbush = require('kdbush');
const geokdbush = require('geokdbush');
// I've stored the data points as objects to make the values unambiguous
const cities = [
{ name: "Abano Terme (PD)", latitude: 45.3594, longitude: 11.7894 },
{ name: "Abbadia Cerreto (LO)", latitude: 45.3122, longitude: 9.5928 },
{ name: "Abbadia Lariana (LC)", latitude: 45.8992, longitude: 9.3336 },
{ name: "Abbadia San Salvatore (SI)", latitude: 42.8800, longitude: 11.6775 },
{ name: "Abbasanta (OR)", latitude: 40.1250, longitude: 8.8200 }
];
// Create the index over city data ONCE
const index = kdbush(cities, ({ longitude }) => longitude, ({ latitude }) => latitude);
// Get the nearest neighbour in a radius of 50km for a point with latitude 43.7051 and longitude 11.4363
const nearest = geokdbush.around(index, 11.4363, 43.7051, 1, 50);
问题是这是我第一次这样做。此外,我是意大利人,英语说得不太好,而意大利语谷歌里什么也没有。
你能告诉我如何使用这些模块吗?
我必须安装吗Node.js
在我的服务器上?
是否可以在本地PC上使用模块?