mysql - 如何将空间数据插入包含道路列的表中
问题描述
我在尝试将数据插入线表时收到此错误消息,使用路段之间点的坐标。
ERROR: parse error - invalid geometry
HINT: "SRID=27700;LINESTRING((5" <-- parse error at position 24 within geometry
SQL state: XX000
我的部分代码:
NSERT INTO public."RoadSegments"("no", "seg_ID", "description", "location", "length", "the_geom")
VALUES
(1,'Seg_1','Shephards Bush to Royal Crescent','Shephards Bush','540',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.504593 -0.220437),(51.505233 -0.214105))')),
(2,'Seg_2','Royal Crescent to Norland Square','Notting Hill','306',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.505233 -0.214105),(51.506053 -0.209956))')),
(3,'Seg_3','Norland Square to Holland Park','Notting Hill','383',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.506053 -0.209956),(51.507575 -0.204795))')),
(4,'Seg_4','Holland Park to Notting Hill Gate','Notting Hill','477',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.507575 -0.204795),(51
解决方案
您的 LINESTRING 参数中的括号似乎太多。尝试以下操作:
INSERT INTO public."RoadSegments"("no", "seg_ID", "description", "location", "length", "the_geom")
VALUES
(1,'Seg_1','Shephards Bush to Royal Crescent', 'Shephards Bush','540',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.504593 -0.220437,51.505233 -0.214105)')),
(2,'Seg_2','Royal Crescent to Norland Square', 'Notting Hill', '306',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.505233 -0.214105,51.506053 -0.209956)')),
(3,'Seg_3','Norland Square to Holland Park', 'Notting Hill', '383',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.506053 -0.209956,51.507575 -0.204795)')),
(4,'Seg_4','Holland Park to Notting Hill Gate','Notting Hill', '477',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.507575 -0.204795,51 ... '))
这应该是正确的语法(坐标周围没有额外的括号)
推荐阅读
- javascript - 在 Angular 的 node_modules 中导入 JS 文件
- javascript - 从 OnClick 在 React Dialog 上传递参数
- svg - 在 Canvas 上绘制一个带有 gradientUnits="objectBoundingBox" 的 SVG 矩形,而不使用内置的变换函数或更改色标?
- visual-studio-2019 - 我想用 C++ 为 VS 2019 编写一个语法高亮编辑器扩展(仅此而已),是否有任何示例可以帮助我入门?
- javascript - JEST:异步方法中的错误:ReferenceError:regeneratorRuntime 未定义
- conduktor - 无法安装导体
- java - Android自动链接链接总是启动浏览器
- javascript - React Hooks,有条件地改变 onClick 函数中的状态,在下次点击时更新
- powershell - 修剪 Powershell 输出
- ios - 注销后如何关闭推送的 ViewController?