Spatial Index in MySQL - ERROR - Cannot get geometry object from data you send to the GEOMETRY field(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 字段的数据中获取几何对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 中的空间索引 - 错误 - 无法从您发送到 GEOMETRY 字段的数据中获取几何对象


基础教程推荐
- oracle区分大小写的原因? 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在多列上分布任意行 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01