【发布时间】:2021-04-01 13:56:10
【问题描述】:
所以我正在使用 mysql 数据库来保存位置的纬度和经度,我的查询结果如下:
[ TextRow { platitude: '34.19226000', plongitude: '-118.53556100' } ],
我想摆脱 [TextRow ] 并简单地拥有可以存储在变量中的数组以通过 Geolib 函数。
我目前将经纬度以小数形式存储在我的数据库中
platitude : {
type : DataTypes.DECIMAL(10,8),
},
plongitude : {
type : DataTypes.DECIMAL(11,8)
},
我的目标是在我的查询结果中使用 findNeast Geolib 函数
这是我目前拥有的:
const query = sequelize.query("SELECT platitude,plongitude FROM peachyPatient.registeredPractices where practiceID ='1'").then(
function(result){
const practices = result;
const location = geolib.findNearest({ latitude: 52.456221, longitude: 12.63128, }, [
practices,
{ latitude: 51.503333, longitude: -0.119722 },
{ latitude: 55.751667, longitude: 37.617778 },
{ latitude: 48.8583, longitude: 2.2945 },
{ latitude: 59.3275, longitude: 18.0675 },
{ latitude: 59.916911, longitude: 10.727567 },
// { latitude: 52.516272, longitude: 13.377722 },
]); console.log(location);
}
);
当我 console.log 位置时,它只是返回我的查询结果。
这是 geoLib 函数在文档中的样子
geolib.findNearest({ latitude: 52.456221, longitude: 12.63128 }, [
{ latitude: 52.516272, longitude: 13.377722 },
{ latitude: 51.515, longitude: 7.453619 },
{ latitude: 51.503333, longitude: -0.119722 },
{ latitude: 55.751667, longitude: 37.617778 },
{ latitude: 48.8583, longitude: 2.2945 },
{ latitude: 59.3275, longitude: 18.0675 },
{ latitude: 59.916911, longitude: 10.727567 },
]);
任何有关如何清除此问题的帮助将不胜感激。
【问题讨论】:
-
TextRow 标签是 js 类的名称。虽然它在控制台中打印出来,但它不应该是一个问题。期望的输出是什么?