MySQL 中的空间索引 - 错误 - 无法从您发送到 GEOMETRY 字段的数据中获取几何对象 [英] Spatial Index in MySQL - ERROR - Cannot get geometry object from data you send to the GEOMETRY field

查看:88
本文介绍了MySQL 中的空间索引 - 错误 - 无法从您发送到 GEOMETRY 字段的数据中获取几何对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对整个空间索引"这件事很陌生,但它似乎是基于纬度/经度进行过滤的最佳解决方案.所以我在表中添加了一列:

I am new to the whole 'spatial index' thing, but it seems to be the best solution for filtering based on latitude/longitude. So I added a column to my table:

所以我创建了一个 geometry 字段:

So I created a geometry field:

  ALTER TABLE `addresses` ADD `point` POINT NOT NULL 

然后我尝试添加一个索引:

And then I tried to add an index:

  ALTER TABLE `addresses` ADD SPATIAL INDEX ( `point` ) 

但我得到一个错误:

  #1416 - Cannot get geometry object from data you send to the GEOMETRY field

我在这里做错了什么?

推荐答案

好的,我找到了解决方案:如果某些列字段不包含数据,则无法创建空间索引.运行后

OK I found the solution: Can't create a spatial index if some of the column fields contain no data. After running

  UPDATE `addresses` SET `point` = POINT( lng, lat )

一切正常.

这篇关于MySQL 中的空间索引 - 错误 - 无法从您发送到 GEOMETRY 字段的数据中获取几何对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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