定义
ST_Geometry 通过熟知文本表示构造几何。
创建将用于 ArcGIS 的空间表时,最好将列创建为几何父类型(如 ST_Geometry),而不要指定一个 ST_Geometry 子类型,如 ST_LineString。
语法
Oracle
- 对于线串、面和点
sde.st_geometry (wkt clob, srid integer)
- 对于优化的点(不启动 extproc 代理,因此查询的处理速度更快)
sde.st_geometry (x, y, z, m, srid)
在批量插入大量的点数据时,请使用优化的点构造。
- 对于参数圆
sde.st_geometry (x, y, z, m, radius, number_of_points, srid)
- 对于参数椭圆
sde.st_geometry (x, y, z, m, semi_major_axis, semi_minor_axis, angle, number_of_points, srid)
- 对于参数楔形
sde.st_geometry (x, y, z, m, startangle, endangle, outerradius, innerradius, number_of_points, srid)
PostgreSQL
- 对于线串、面和点
sde.st_geometry (wkt, srid integer) sde.st_geometry (esri_shape bytea, srid integer)
- 对于参数圆
sde.st_geometry (x, y, z, m, radius, number_of_points, srid)
- 对于参数椭圆
sde.st_geometry (x, y, z, m, semi_major_axis, semi_minor_axis, angle, number_of_points, srid)
- 对于参数楔形
sde.st_geometry (x, y, z, m, startangle, endangle, outerradius, innerradius, number_of_points, srid)
SQLite
- 对于线串、面和点
st_geometry (text WKT_string,int32 srid)
- 对于参数圆
st_geometry (x, y, z, m, radius, number_of_points, srid)
- 对于参数椭圆
st_geometry (x, y, z, m, semi_major_axis, semi_minor_axis, angle_of_rotation, number_of_points, srid)
- 对于参数楔形
st_geometry (x, y, z, m, start_angle, end_angle, outer_radius, inner_radius, number_of_points, srid)
返回类型
Oracle 和 PostgreSQL
ST_Geometry
SQLite
Geometryblob
示例
创建并查询点、线串和面要素
这些示例将创建表 (geoms),并将点、线串以及面值插入其中。
Oracle
CREATE TABLE geoms (
id integer,
geometry sde.st_geometry
);
INSERT INTO GEOMS (id, geometry) VALUES (
1901,
sde.st_geometry ('point (1 2)', 4326)
);
--To insert the same point using optimized point construction:
INSERT INTO GEOMS (id, geometry) VALUES (
1901,
sde.st_geometry (1,2,null,null,4326)
);
INSERT INTO GEOMS (id, geometry) VALUES (
1902,
sde.st_geometry ('linestring (33 2, 34 3, 35 6)', 4326)
);
INSERT INTO GEOMS (id, geometry) VALUES (
1903,
sde.st_geometry ('polygon ((3 3, 4 6, 5 3, 3 3))', 4326)
);
PostgreSQL
CREATE TABLE geoms (
id serial,
geometry sde.st_geometry
);
INSERT INTO geoms (geometry) VALUES (
sde.st_geometry ('point (1 2)', 4326)
);
INSERT INTO geoms (geometry) VALUES (
sde.st_geometry ('linestring (33 2, 34 3, 35 6)', 4326)
);
INSERT INTO geoms (geometry) VALUES (
sde.st_geometry ('polygon ((3 3, 4 6, 5 3, 3 3))', 4326)
);
SQLite
CREATE TABLE geoms (
id integer primary key autoincrement not null
);
SELECT AddGeometryColumn (
NULL,
'geoms',
'geometry',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO geoms (geometry) VALUES (
st_geometry ('point (1 2)', 4326)
);
INSERT INTO geoms (geometry) VALUES (
st_geometry ('linestring (33 2, 34 3, 35 6)', 4326)
);
INSERT INTO geoms (geometry) VALUES (
st_geometry ('polygon ((3 3, 4 6, 5 3, 3 3))', 4326)
);
创建并查询参数圆
创建表 radii,并将圆插入其中。
Oracle
CREATE TABLE radii (
id integer,
geometry sde.st_geometry
);
INSERT INTO RADII (id, geometry) VALUES (
1904,
sde.st_geometry (10,10,NULL,NULL,25,50,4326)
);
INSERT INTO RADII (id, geometry) VALUES (
1905,
sde.st_geometry (5,15,NULL,NULL,10,20,4326)
);
PostgreSQL
CREATE TABLE radii (
id serial,
geometry sde.st_geometry
);
INSERT INTO radii (geometry) VALUES (
sde.st_geometry (10,10,NULL,NULL,25,50,4326)
);
INSERT INTO radii (geometry) VALUES (
sde.st_geometry (5,15,NULL,20,10,30,4326)
);
SQLite
CREATE TABLE radii (
id integer primary key autoincrement not null
);
SELECT AddGeometryColumn (
NULL,
'radii',
'geometry',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO radii (geometry) VALUES (
st_geometry (10,10,NULL,NULL,25,50,4326)
);
INSERT INTO radii (geometry) VALUES (
st_geometry (5,15,NULL,20,10,30,4326)
);
创建并查询参数椭圆
创建表 track,并将椭圆插入其中。
Oracle
CREATE TABLE track (
id integer,
geometry sde.st_geometry
);
INSERT INTO TRACK (id, geometry) VALUES (
1907,
sde.st_geometry (0,0,NULL,NULL,10,5,0,50,4326)
);
INSERT INTO TRACK (id, geometry) VALUES (
1908,
sde.st_geometry (4,19,10,20,10,5,0,40,4326)
);
PostgreSQL
CREATE TABLE track (
id serial,
geometry sde.st_geometry
);
INSERT INTO track (geometry) VALUES (
sde.st_geometry (0,0,NULL,NULL,10,5,0,50,4326)
);
INSERT INTO track (geometry) VALUES (
sde.st_geometry (4,19,10,20,10,5,0,40,4326)
);
SQLite
CREATE TABLE track (
id integer primary key autoincrement not null
);
SELECT AddGeometryColumn (
NULL,
'track',
'geometry',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO track (geometry) VALUES (
st_geometry (0,0,NULL,NULL,10,5,0,50,4326)
);
INSERT INTO track (geometry) VALUES (
st_geometry (4,19,10,20,10,5,0,40,4326)
);
创建并查询参数楔形
创建表 pwedge,并将楔形插入其中。
Oracle
CREATE TABLE pwedge (
id integer,
label varchar2(8),
shape sde.st_geometry
);
INSERT INTO PWEDGE (id, label, shape) VALUES (
1,
'Wedge1',
sde.st_geometry (10,30,NULL,NULL,45,145,5,2,60,4326)
);
PostgreSQL
CREATE TABLE pwedge (
id serial,
label varchar(8),
shape sde.st_geometry
);
INSERT INTO pwedge (label, shape) VALUES (
'Wedge',
sde.st_geometry(10,30,NULL,NULL,45,145,5,2,60,4326)
);
SQLite
CREATE TABLE pwedge (
id integer primary key autoincrement not null,
label varchar(8)
);
SELECT AddGeometryColumn (
NULL,
'pwedge',
'shape',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO pwedge (label, shape) VALUES (
'Wedge',
st_geometry(10,30,NULL,NULL,45,145,5,2,60,4326)
);