Definition
ST_Entity returns the spatial entity type of a geometry object. The spatial entity type is the value stored in the entity member field of the geometry object.
Syntax
Oracle and PostgreSQL
sde.st_entity (geometry1 sde.st_geometry)
SQLite
st_entity (geometry1 geometryblob)
Return type
A number (Oracle) or integer (SQLite and PostgreSQL) is returned that represents the following entity types:
0 | nil shape |
1 | point |
2 | line (includes spaghetti lines) |
4 | linestring |
8 | area |
257 | multipoint |
258 | multiline (includes spaghetti lines) |
260 | multilinestring |
264 | multiarea |
Example
The following examples create a table and insert different geometries to the table. ST_Entity is run on the table to return the geometry subtype of each record in the table.
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;
The SELECT statement returns the following values:
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;
The SELECT statement returns the following values:
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;
The SELECT statement returns the following values:
entity type 1 ST_POINT 4 ST_LINESTRING 8 ST_POLYGON