Skip to content

<->

功能描述

计算对象之间的距离。

适用于POINT与另一种几何类型的所有组合,以及这些额外的类型对:(BOX, LSEG),(BOX, LINE),(LSEG, LINE),(POLYGON, CIRCLE),以及易子情况。

数据类型

L_OPERAND_TYP(左操作数类型)R_OPERAND_TYP(右操作数类型)RET_TYPE(返回类型)
POINTPOINTDOUBLE
POINTBOX
POINTLSEG
POINTLINE
POINTPATH
POINTPOLYGON
POINTCIRCLE
BOXPOINT
BOXBOX
BOXLSEG
LINEPOINT
LINELSEG
LINELINE
LSEGPOINT
LSEGBOX
LSEGLSEG
LSEGLINE
POLYGONPOINT
POLYGONPOLYGON
POLYGONCIRCLE
PATHPOINT
PATHPATH
CIRCLEPOINT
CIRCLEPOLYGON
CIRCLECIRCLE

示例

  • 计算圆到圆的距离

    sql
    SQL> SELECT CIRCLE('<(0,0),1>') <-> CIRCLE('<(5,0),1>');
    
    EXPR1 |
    ------------------------------------------------------------------------------
    3.000000e+00 |
    
    Total 1 records.
  • 计算点到线段的距离

    sql
    SQL> SELECT POINT('(0,0)') <-> LSEG('[(2,0),(0,2)]') ;
    
    EXPR1 |
    ------------------------------------------------------------------------------
    1.414214e+00 |
    
    Total 1 records.
  • 计算圆到多边形的距离

    sql
    SQL> SELECT CIRCLE('<(0,0),1>') <-> POLYGON('( 10, 110, 20, 120, 30, 130, 40, 140)');
    
    EXPR1 |
    ------------------------------------------------------------------------------
    1.094536e+02 |
    
    Total 1 records.