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 字段的数据中获取几何对象
基础教程推荐
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
