Name

ST_Covers — 测试 B 的每个点是否都位于 A 中

Synopsis

`boolean ST_Covers(`geometry geomA, geometry geomB`)`;

`boolean ST_Covers(`geography geogpolyA, geography geogpointB`)`;

描述

ST_Covers 与 ST_CoveredBy相反。 因此，`ST_Covers(A,B) = ST_CoveredBy(B,A)`

 此功能自动包括利用几何上可用的任何空间索引的边界框比较。 为了避免使用索引，请使用函数 `_ST_Covers`。
 增强：3.0.0 启用了对` GEOMETRYCOLLECTION` 的支持
 请勿将此函数用于无效的几何图形。 你会得到意想不到的结果。

示例

```--a circle covering a circle
SELECT ST_Covers(smallc,smallc) As smallinsmall,
ST_Covers(smallc, bigc) As smallcoversbig,
ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
--Result
smallinsmall | smallcoversbig | bigcoversexterior | bigcontainsexterior
--------------+----------------+-------------------+---------------------
t            | f              | t                 | f
(1 row) ```

```-- a point with a 300 meter buffer compared to a point, a point and its 10 meter buffer
SELECT ST_Covers(geog_poly, geog_pt) As poly_covers_pt,
ST_Covers(ST_Buffer(geog_pt,10), geog_pt) As buff_10m_covers_cent
FROM (SELECT ST_Buffer(ST_GeogFromText('SRID=4326;POINT(-99.327 31.4821)'), 300) As geog_poly,
ST_GeogFromText('SRID=4326;POINT(-99.33 31.483)') As geog_pt ) As foo;

poly_covers_pt | buff_10m_covers_cent
----------------+------------------
f              | t
```