0

我正在尝试在 mysql 数据库中插入多边形形状。Polygon 形状的顶点由 double 值组成。要插入我尝试使用以下查询的值。但我得到以下错误。

INSERT INTO HIBERNATE_SPATIAL 
(PRD_GEO_REGION_ID,OWNER_ID,GEO_REGION_NAME,GEO_REGION_DESCRIPTION,GEO_REGION_DEFINITION) 
VALUES (8,1,'POLYGON8','SHAPE8',Polygon(LineString(10.12345612341243,11.12345612341234),LineString(10.34512341246,11.4123423456),LineString(10.31423424456,11.34123423456),LineString(10.341234256,11.3412342456),LineString(10.11423423456,11.123424)));

表格说明

+------------------------+--------------+------+-----+---------+----------------+
| Field                  | Type         | Null | Key | Default | Extra          |
+------------------------+--------------+------+-----+---------+----------------+
| PRD_GEO_REGION_ID      | int(11)      | NO   | PRI | NULL    | auto_increment |
| OWNER_ID               | decimal(3,0) | NO   |     | NULL    |                |
| GEO_REGION_NAME        | varchar(50)  | NO   | UNI | NULL    |                |
| GEO_REGION_DESCRIPTION | varchar(70)  | YES  |     | NULL    |                |
| GEO_REGION_DEFINITION  | geometry     | YES  |     | NULL    |                |
+------------------------+--------------+------+-----+---------+----------------+

错误 :_:

错误 1367 (22007):在解析过程中发现非法的非几何“10.12345612341243”值

问候,阿伦拉吉。

4

1 回答 1

1

解决了这个问题。成功存储十进制值。我犯了两个错误。

1 ) LineString 只能存储 Points 数据类型(不是十进制值或坐标)。更正的语法如下。

INSERT INTO HIBERNATE_SPATIAL 
(PRD_GEO_REGION_ID,OWNER_ID,GEO_REGION_NAME,GEO_REGION_DESCRIPTION,GEO_REGION_DEFINITION) 
VALUES (8,1,'POLYGON8','SHAPE8',Polygon(LineString(POINT(10.12345612341243,11.12345612341234)),LineString(POINT(10.34512341246,11.4123423456)),LineString(POINT(10.31423424456,11.34123423456)),LineString(POINT(10.341234256,11.3412342456)),LineString(POINT(10.11423423456,11.123424))));

2)如果是多边形。形状必须是封闭的(起点和终点应该相同)。 这就是问题所在。

工作查询

INSERT INTO HIBERNATE_SPATIAL 
(PRD_GEO_REGION_ID,OWNER_ID,GEO_REGION_NAME,GEO_REGION_DESCRIPTION,GEO_REGION_DEFINITION) 
VALUES (8,1,'POLYGON8','SHAPE8',Polygon(LineString(POINT(10.12345612341243,11.12345612341234)),LineString(POINT(10.34512341246,11.4123423456)),LineString(POINT(10.31423424456,11.34123423456)),LineString(POINT(10.341234256,11.3412342456)),LineString(POINT(10.12345612341243,11.12345612341234))));
于 2014-03-05T04:58:23.003 回答