ST_Intersection

定义

ST_Intersection 获取两个 ST_Geometry 对象,然后以 ST_Geometry 对象形式返回交集。

语法

sde.st_intersection (g1 sde.st_geometry, g2 sde.st_geometry)

返回类型

ST_Geometry

示例

消防局局长必须获得医院、学校和疗养院与可能的危险废弃物污染范围的交集区域。

医院、学校和疗养院存储在使用后面的 CREATE TABLE 语句创建的 sensitive_areas 表中。定义为 polygon 的 shape 列存储每个敏感区域的轮廓。

危险场地存储在使用后面的 CREATE TABLE 语句创建的 hazardous_sites 表中。定义为 point 的 site 列存储表示每个危险场地的地理中心的位置。

CREATE TABLE sensitive_areas (id integer, 
                               shape sde.st_geometry); 

CREATE TABLE hazardous_sites (id integer, 
                              site sde.st_geometry);


INSERT INTO sensitive_areas VALUES (
1,
sde.st_geometry ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 0)
);

INSERT INTO sensitive_areas VALUES (
2,
sde.st_geometry ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 0)
);

INSERT INTO sensitive_areas VALUES (
3,
sde.st_geometry ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 0)
);

INSERT INTO hazardous_sites VALUES (
4,
sde.st_geometry ('point (60 60)', 0)
);

INSERT INTO hazardous_sites VALUES (
5,
sde.st_geometry ('point (30 30)', 0)
);

ST_Buffer 函数将生成危险废弃物场地周围的缓冲区。ST_Intersection 函数将生成表示已创建缓冲区的危险废弃物场地与敏感区域的交集的面。

Oracle

SELECT sa.id, sde.st_astext (sde.st_intersection (sde.st_buffer (hs.site, .1), sa.shape)) Intersection
FROM SENSITIVE_AREAS sa, HAZARDOUS_SITES hs
WHERE hs.id = 5
AND sde.st_astext (sde.st_intersection (sde.st_buffer (hs.site, .1), sa.shape)) 
NOT LIKE '%EMPTY%';

  ID  INTERSECTION

  1   POLYGON  ((29.90000000 30.00000000, 30.00000000 30.00000000, 30.00000000 30.10000000, 29.993
45969 30.09978589, 29.98694738 30.09914449, 29.98049097 30.09807853, 29.97411809
 30.09659258, 29.96785605 30.09469301, 29.96173166 30.09238795, 29.95577113 30.0
8968727, 29.95000000 30.08660254, 29.94444298 30.08314696, 29.93912386 30.079335
33, 29.93406542 30.07518398, 29.92928932 30.07071068, 29.92481602 30.06593458, 2
9.92066467 30.06087614, 29.91685304 30.05555702, 29.91339746 30.05000000, 29.910
31273 30.04422887, 29.90761205 30.03826834, 29.90530699 30.03214395, 29.90340742
 30.02588191, 29.90192147 30.01950903, 29.90085551 30.01305262, 29.90021411 30.0
0654031, 29.90000000 30.00000000)) 

  2   POLYGON  ((30.00000000 30.00000000, 30.10000000 30.00000000, 30.09978589 30.00654031, 30.099
14449 30.01305262, 30.09807853 30.01950903, 30.09659258 30.02588191, 30.09469301
 30.03214395, 30.09238795 30.03826834, 30.08968727 30.04422887, 30.08660254 30.0
5000000, 30.08314696 30.05555702, 30.07933533 30.06087614, 30.07518398 30.065934
58, 30.07071068 30.07071068, 30.06593458 30.07518398, 30.06087614 30.07933533, 3
0.05555702 30.08314696, 30.05000000 30.08660254, 30.04422887 30.08968727, 30.038
26834 30.09238795, 30.03214395 30.09469301, 30.02588191 30.09659258, 30.01950903
 30.09807853, 30.01305262 30.09914449, 30.00654031 30.09978589, 30.00000000 30.1
0000000, 30 30))

PostgreSQL

SELECT sa.id, sde.st_astext (sde.st_intersection (sde.st_buffer (hs.site, .1), sa.shape)) AS Intersection
FROM sensitive_areas sa, hazardous_sites hs
WHERE hs.id = 5
AND sde.st_astext (sde.st_intersection (sde.st_buffer (hs.site, .1), sa.shape))::varchar  NOT LIKE '%EMPTY%';

  id  intersection

  1  | POLYGON  ((29.90000000 30.00000000, 30 30, 30.00000000 30.1000000, 29.993
45969 30.09978589, 29.98694738 30.09914449, 29.98049097 30.09807853, 29.97411809
 30.09659258, 29.96785605 30.09469301, 29.96173166 30.09238795, 29.95577113 30.0
8968727, 29.95000000 30.08660254, 29.94444298 30.08314696, 29.93912386 30.079335
33, 29.93406542 30.07518398, 29.92928932 30.07071068, 29.92481602 30.06593458, 2
9.92066467 30.06087614, 29.91685304 30.05555702, 29.91339746 30.05000000, 29.910
31273 30.04422887, 29.90761205 30.03826834, 29.90530699 30.03214395, 29.90340742
 30.02588191, 29.90192147 30.01950903, 29.90085551 30.01305262, 29.90021411 30.0
0654031, 29.90000000 30.00000000))

  2  | POLYGON  ((30 30, 30.10000000 30.0000000, 30.09978589 30.00654031, 30.099
14449 30.01305262, 30.09807853 30.01950903, 30.09659258 30.02588191, 30.09469301
 30.03214395, 30.09238795 30.03826834, 30.08968727 30.04422887, 30.08660254 30.0
5000000, 30.08314696 30.05555702, 30.07933533 30.06087614, 30.07518398 30.065934
58, 30.07071068 30.07071068, 30.06593458 30.07518398, 30.06087614 30.07933533, 3
0.05555702 30.08314696, 30.05000000 30.08660254, 30.04422887 30.08968727, 30.038
26834 30.09238795, 30.03214395 30.09469301, 30.02588191 30.09659258, 30.01950903
 30.09807853, 30.01305262 30.09914449, 30.00654031 30.09978589, 30.00000000 30.1
0000000, 30 30))
9/15/2013