定义
ST_Entity 返回几何对象的空间实体类型。空间实体类型是存储在几何对象的实体成员字段中的值。
语法
Oracle 和 PostgreSQL
sde.st_entity (geometry1 sde.st_geometry)
SQLite
st_entity (geometry1 geometryblob)
返回类型
将返回数字 (Oracle) 或整数(SQLite 和 PostgreSQL)来表示以下实体类型:
0 | nil 形状 |
1 | 点 |
2 | 线(包括 spaghetti 线) |
4 | 线串 |
8 | 面/区域 |
257 | 多点 |
258 | 多线(包括 spaghetti 线) |
260 | 多线串 |
264 | 多区域 |
示例
以下示例会创建一个表并向表中插入不同的几何。ST_Entity 随即在表上运行并返回表中各记录的几何子类型。
Oracle
CREATE TABLE sample_geos (
id integer,
geometry sde.st_geometry
);
INSERT INTO sample_geos (id, geometry) VALUES (
1901,
sde.st_geometry ('point (1 2)', 4326)
);
INSERT INTO sample_geos (id, geometry) VALUES (
1902,
sde.st_geometry ('linestring (33 2, 34 3, 35 6)', 4326)
);
INSERT INTO sample_geos (id, geometry) VALUES (
1903,
sde.st_geometry ('polygon ((3 3, 4 6, 5 3, 3 3))', 4326)
);
SELECT sde.st_entity (geometry) entity, UPPER (sde.st_geometrytype (geometry)) TYPE
FROM sample_geos;
SELECT 语句返回以下值:
ENTITY TYPE 1 ST_POINT 4 ST_LINESTRING 8 ST_POLYGON
PostgreSQL
CREATE TABLE sample_geos (
id integer,
geometry sde.st_geometry
);
INSERT INTO sample_geos (id, geometry) VALUES (
1900,
sde.st_geometry ('Point Empty', 4326)
);
INSERT INTO sample_geos (id, geometry) VALUES (
1901,
sde.st_geometry ('point (1 2)', 4326)
);
INSERT INTO sample_geos (id, geometry) VALUES (
1902,
sde.st_geometry ('linestring (33 2, 34 3, 35 6)', 4326)
);
INSERT INTO sample_geos (id, geometry) VALUES (
1903,
sde.st_geometry ('polygon ((3 3, 4 6, 5 3, 3 3))', 4326)
);
INSERT INTO sde.entity_test (id, geometry) VALUES (
1904,
sde.st_geometry ('multipoint (10.01 20.03, 10.52 40.11, 30.29 41.56, 31.78 10.74)', 4326)
);
INSERT INTO sde.entity_test (id, geometry) VALUES (
1905,
sde.st_geometry ('multilinestring ((10.01 20.03, 10.52 40.11, 30.29 41.56,31.78 10.74), (20.93 20.81, 21.52 40.10))', 4326)
);
INSERT INTO sde.entity_test (id, geometry) VALUES (
1906,
sde.st_geometry ('multipolygon (((3 3, 4 6, 5 3, 3 3), (8 24, 9 25, 1 28, 8 24), (13 33, 7 36, 1 40, 10 43, 13 33)))', 4326)
);
SELECT id AS "id",
sde.st_entity (geometry) AS "entity",
sde.st_geometrytype (geometry) AS "geom_type"
FROM sample_geos;
SELECT 语句返回以下值:
id entity geom_type 1900 0 "ST_GEOMETRY" 1901 1 "ST_POINT" 1902 4 "ST_LINESTRING" 1903 8 "ST_POLYGON" 1904 257 "ST_MULTIPOINT" 1905 260 "ST_MULTILINESTRING" 1906 264 "ST_MULTIPOLYGON"
SQLite
CREATE TABLE sample_geos (
id integer primary key autoincrement not null
);
SELECT AddGeometryColumn (
NULL,
'sample_geos',
'geometry',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO sample_geos (geometry) VALUES (
st_geometry ('point (1 2)', 4326)
);
INSERT INTO sample_geos (geometry) VALUES (
st_geometry ('linestring (33 2, 34 3, 35 6)', 4326)
);
INSERT INTO sample_geos (geometry) VALUES (
st_geometry ('polygon ((3 3, 4 6, 5 3, 3 3))', 4326)
);
SELECT st_entity (geometry) AS "entity",
st_geometrytype (geometry) AS "type"
FROM sample_geos;
SELECT 语句返回以下值:
entity type 1 ST_POINT 4 ST_LINESTRING 8 ST_POLYGON