Slide 13
Slide 13 text
mysql> CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, geom GEOMETRY);
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> INSERT INTO test(geom) VALUES(ST_GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))'));
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test(geom) VALUES(ST_GeomFromText('POLYGON((1 0,2 0,2 1,2 1,1 0))'));
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test(geom) VALUES(ST_GeomFromText('POLYGON((1 0,2 0,2 1,2 1,1 0))'));
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> SELECT ST_AsText(ST_Collect(geom)) AS result FROM test1;
+---------------------------------------------------------------------------------------+
| result |
+---------------------------------------------------------------------------------------+
| MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((1 0,2 1,2 1,2 0,1 0)),((1 0,2 1,2 1,2 0,1 0))) |
+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT ST_AsText(ST_Collect(DISTINCT geom)) AS result FROM test1;
+---------------------------------------------------------------+
| result |
+---------------------------------------------------------------+
| MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((1 0,2 1,2 1,2 0,1 0))) |
+---------------------------------------------------------------+
1 row in set (0.00 sec)
ST_Correctの実行例 3つのポリゴンを1つに集約(重複排除なし、あり)
Copyright © 2022 Oracle and/or its affiliates. All rights reserved.
13
0,0 1,0
0,1 1,1
1,0 2,0
1,1 2,1
ST_Correct
0,0 1,0
0,1 1,1
2,0
2,1