37. 附录 A:PostGIS 函数

37.1. 构造器

ST_MakePoint(Longitude, Latitude)

返回一个新的点。注意坐标分量的顺序(先经度,然后纬度)。

ST_GeomFromText(WellKnownText, srid)

输入 WKT 字符串和 srid 并返回一个新的几何对象。

ST_SetSRID(geometry, srid)

Updates the srid on a geometry. Returns the same geometry. This does not alter the coordinates of the geometry, it just updates the srid. This function is useful for conditioning geometries created without an srid.

ST_Expand(geometry, Radius)

Returns a new geometry that is an expanded bounding box of the input geometry. This function is useful for creating envelopes for use in indexed searches.

37.2. 输出

ST_AsText(geometry)

Returns a geometry in a human-readable text format.

ST_AsGML(geometry)

Returns a geometry in standard OGC GML format.

ST_AsGeoJSON(geometry)

将一个几何对象转为标准的 GeoJSON 格式。

37.3. 量测

ST_Area(geometry)

返回基于坐标系单位的几何对象的面积。

ST_Length(geometry)

Returns the length of the geometry in the units of the spatial reference system.

ST_Perimeter(geometry)

Returns the perimeter of the geometry in the units of the spatial reference system.

ST_NumPoints(linestring)

Returns the number of vertices in a linestring.

ST_NumRings(polygon)

返回 Polygon 中 Ring 的数量。

ST_NumGeometries(geometry)

返回几何容器(GeometryCollection)中几何对象的个数。

37.4. 关系查询

ST_Distance(geometry, geometry)

Returns the distance between two geometries in the units of the spatial reference system.

ST_DWithin(geometry, geometry, radius)

Returns true if the geometries are within the radius distance of one another, otherwise false.

ST_Intersects(geometry, geometry)

Returns true if the geometries are not disjoint, otherwise false.

ST_Contains(geometry, geometry)

Returns true if the first geometry fully contains the second geometry, otherwise false.

ST_Crosses(geometry, geometry)

Returns true if a line or polygon boundary crosses another line or polygon boundary, otherwise false.