MySQL 中的空间索引 - 错误 - 无法从发送到 GEOMETRY 字段的数据中获取几何对象
我对整个“空间索引”很陌生,但它似乎是基于纬度/经度进行过滤的最佳解决方案。所以我在表中添加了一列:
因此我创建了一个几何字段:
ALTER TABLE `addresses` ADD `point` POINT NOT NULL
然后我尝试添加索引:
ALTER TABLE `addresses` ADD SPATIAL INDEX ( `point` )
但我收到错误:
#1416 - Cannot get geometry object from data you send to the GEOMETRY field
我在这里做错了什么?
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:
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` )
But I get an error:
#1416 - Cannot get geometry object from data you send to the GEOMETRY field
What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我找到了解决方案:如果某些列字段不包含数据,则无法创建空间索引。运行后
一切正常。
OK I found the solution: Can't create a spatial index if some of the column fields contain no data. After running
Everything worked fine.
我遇到了同样的错误(无法从发送到 GEOMETRY 字段的数据中获取几何对象),但是当尝试从 mysql 转储导入空间数据时。
我发现有些行具有“空”(X 为空或 Y 为空)空间数据,即使该列为“NOT NULL”。
检查您是否遇到与我使用此 SQL 描述的问题相同的问题:
如果您有一些行,那么这对我有用:
然后尝试 mysqldump(或从 phpmyadmin)并再次导入。
I had this same error (Cannot get geometry object from data you send to the GEOMETRY field) but when trying to import spatial data from a mysql dump.
I found that some rows had "null" (X is null or Y is null) spatial data even though the column was "NOT NULL"..
Check if you have the same problem as I'm describing with this SQL:
If you have some rows then this is what worked for me:
Then try your mysqldump (or from phpmyadmin) and import again.