ST_PointOnSurface

定义

ST_PointOnSurface 以 ST_Polygon 或 ST_MultiPolygon 类型的对象为输入参数,并返回保证位于其表面上的 ST_Point。

语法

Oracle 和 PostgreSQL

sde.st_pointonsurface (polygon1 sde.st_geometry)
sde.st_pointonsurface (multipolygon1 sde.st_geometry)

SQLite

st_pointonsurface (polygon1 geometryblob)
st_pointonsurface (multipolygon1 geometryblob)

返回类型

ST_Point

示例

市政工程师想要为每个历史建筑物的覆盖区创建标注点。历史建筑物覆盖区存储在使用以下 CREATE TABLE 语句创建的 hbuildings 表中:

ST_PointOnSurface 函数生成确保位于建筑物覆盖区表面上的点。ST_PointOnSurface 函数返回点对象以便由 ST_AsText 函数将其转换为文本进一步供应用程序使用。

Oracle

CREATE TABLE hbuildings (
 hbld_id integer,
 hbld_name varchar(40)
 footprint sde.st_geometry
);
INSERT INTO hbuildings (hbld_id, hbld_name, footprint) VALUES (
 1,
 'First National Bank',
 sde.st_polygon ('polygon ((0 0, 0 .010, .010 .010, .010 0, 0 0))', 4326)
);

INSERT INTO hbuildings (hbld_id, hbld_name, footprint) VALUES (
 2,
 'Courthouse',
 sde.st_polygon ('polygon ((.020 0, .020 .010, .030 .010, .030 0, .020 0))', 4326)
);
SELECT sde.st_astext (sde.st_pointonsurface (footprint)) Historic_Site
 FROM HBUILDINGS;

HISTORIC_SITE

POINT  (0.00500000 0.00500000)
POINT  (0.02500000 0.00500000)

PostgreSQL

CREATE TABLE hbuildings (
 hbld_id serial,
 hbld_name varchar(40)
 footprint sde.st_geometry
);
INSERT INTO hbuildings (hbld_name, footprint) VALUES (
 'First National Bank',
 sde.st_polygon ('polygon ((0 0, 0 .010, .010 .010, .010 0, 0 0))', 4326)
);

INSERT INTO hbuildings (hbld_name, footprint) VALUES (
 'Courthouse',
 sde.st_polygon ('polygon ((.020 0, .020 .010, .030 .010, .030 0, .020 0))', 4326)
);
SELECT sde.st_astext (sde.st_pointonsurface (footprint)) 
 AS "Historic Site"
 FROM hbuildings;

Historic Site

POINT  (0.00500000 0.00500000)
POINT  (0.02500000 0.00500000)

SQLite

CREATE TABLE hbuildings (
 hbld_id integer primary key autoincrement not null,
 hbld_name text(40)
);

SELECT AddGeometryColumn(
 NULL,
 'hbuildings',
 'footprint',
 4326,
 'polygon',
 'xy',
 'null'
);
INSERT INTO hbuildings (hbld_name, footprint) VALUES (
 'First National Bank',
 st_polygon ('polygon ((0 0, 0 .010, .010 .010, .010 0, 0 0))', 4326)
);

INSERT INTO hbuildings (hbld_name, footprint) VALUES (
 'Courthouse',
 st_polygon ('polygon ((.020 0, .020 .010, .030 .010, .030 0, .020 0))', 4326)
);
SELECT st_astext (st_pointonsurface (footprint)) 
 AS "Historic Site"
 FROM hbuildings;

Historic Site

POINT  (0.00500000 0.00500000)
POINT  (0.02500000 0.00500000)

相关主题

5/25/2014