ST_Within

更新时间:
复制 MD 格式

Returns true if a grid or geometry is completely within another geometry or grid.

Syntax

boolean ST_Within(geomgrid grid, geometry geom);
boolean ST_Within(geometry geom, geomgrid grid);
boolean ST_Within(geomgrid grid1, geomgrid grid2);

Parameters

ParameterDescription
gridThe grid whose spatial relationship you want to query.
geomThe geometry whose spatial relationship you want to query.

Usage notes

  • The geometry argument must use the CGC2000 spatial reference system. Its spatial reference system identifier (SRID) must be 4490.

  • geomgrid is an AnalyticDB for PostgreSQL proprietary type. Construct grid values with ST_gridfromtext.

Examples

Check whether a point lies within a grid

SELECT ST_Within(
  ST_GeomFromText('POINT(116.31522216796875 39.910277777777778)', 4490),
  ST_gridfromtext('G001331032213300013')
);

Result: f — the point is not within the specified grid.

Check whether a finer-grained grid lies within a coarser grid

SELECT ST_Within(
  ST_gridfromtext('G001331032213300013'),
  ST_gridfromtext('G001331032213300')
);

Result: tG001331032213300013 lies entirely within G001331032213300.