地理关系函数
st_area
Double st_area(Geometry g)
如果Geometry g是面状几何对象,则以坐标参照系的平方单位返回其表面的面积(例如,degrees^2 for EPSG:4326)。 对于非面状几何对象(例如,点,非闭合LineStrings等),返回0.0。
示例:
st_centroid
Point st_centroid(Geometry g)
返回g的几何中心点。
示例:
st_closestPoint
Point st_closestPoint(Geometry a, Geometry b)
返回a中最接近b的Point。 即a、b之间最短连线的第1个点。
示例:
st_contains
Boolean st_contains(Geometry a, Geometry b)
当且仅当没有b的点在a的外部时,返回true,并且b至少有一个点位于a的内部。
示例:
st_covers
Boolean st_covers(Geometry a, Geometry b)
如果Geometry b中没有点在Geometry a之外,则返回true。
示例:
st_crosses
Boolean st_crosses(Geometry a, Geometry b)
如果第一个Geometry与第二个Geometry存在一些相同但不全相同的Point,则返回true。
示例:
st_disjoint
Boolean st_disjoint(Geometry a, Geometry b)
如果a和b不是“空间相交”的,则返回true; 即,他们不共享任何空间。 相当于NOT st_intersects(a,b)。
示例:
st_distance
Double st_distance(Geometry a, Geometry b)
返回a和b之间的2D笛卡尔距离(例如,EPSG的度数:4236)。
示例:
st_distanceSphere
Double st_distanceSphere(Geometry a, Geometry b)
返回a和b之间经度/纬度几何对象之间的近似最小球面距离。
示例:
st_distanceSpheroid
Double st_distanceSpheroid(Geometry a, Geometry b)
返回a和b之间经度/纬度几何对象之间的最小WGS84椭球距离。
示例:
st_equals
Boolean st_equals(Geometry a, Geometry b)
不考虑方向的条件下,如果给定的Geometry a和b在逻辑上是相同的,则返回true。
示例:
st_intersects
Boolean st_intersects(Geometry a, Geometry b)
如果a和b在2D中空间相交(即共享空间的任何部分),则返回true。 相当于NOT st_disjoint(a,b)。
示例:
st_length
Double st_length(Geometry geom)
返回线性几何的2D路径长度或面几何的周长(例如,EPSG的度数:4236)。 对于其他几何类型(例如Point),返回0.0。
示例:
st_lengthSphere
Double st_lengthSphere(LineString line)
使用球形地球模型近似得到的LineString几何体的2D路径长度。 返回的长度以米为单位。 与st_lengthSpheroid的计算误差在0.3%范围内,并且计算效率更高。
示例:
- 查询命令:
select st_lengthSphere(st_castToLineString(st_geomFromWKT(location))) from geotbl where id='5'
- 查询结果:
1.0013773137296816E7
st_lengthSpheroid
Double st_lengthSpheroid(LineString line)
返回在WGS84球体上使用经度/纬度坐标定义的LineString几何体的2D路径长度。 返回的长度以米为单位。
示例:
st_overlaps
Boolean st_overlaps(Geometry a, Geometry b)
如果a和b具有一些但不是所有的共同点,具有相同的维度,并且a和b的内部的交点与几何本身具有相同的维度,则返回true。
示例:
st_relate
String st_relate(Geometry a, Geometry b)
返回描述a和b的内部、边界和外部之间的交叉点的维度的DE-9IM 3x3交互矩阵模式。
示例:
st_relateBool
Boolean st_relateBool(Geometry a, Geometry b, String mask)
如果DE-9IM交互矩阵mask与从st_relate(a,b)获得的交互矩阵模式匹配,则返回true。
示例:
st_touches
Boolean st_touches(Geometry a, Geometry b)
如果a和b具有至少一个共同点,但它们的内部不相交,则返回true。
示例:
