This topic describes the ST_OffsetCurve function. This function returns a geometry object representing all offset lines at the specified distance and margin from the input geometry object.

Syntax

geometry  ST_OffsetCurve(geometry  line , float  signedDistance , text  styleParameters);

Parameters

Parameter Description
line The line object that you want to specify.
signedDistance The distance that you want to specify.
styleParameters The style of the offset lines. The default value is an empty string.

Description

  • The distance between points on the returned geometry object and the input geometry object does not exceed the specified distance.
  • If the value of the signedDistance parameter is a positive number, the offset lines are on the left side of the input geometry object and in the same direction as the input geometry object. If the value of the signedDistance parameter is a negative number, the offset lines are on the right side of the input geometry object and in the opposite direction of the input geometry object.
  • This function ignores z coordinates. If you specify a 3D geometry object, this function returns a 2D geometry object.
  • This function supports GeometryCollection objects and MultiLineString objects.
  • The following table describes the fields of the styleParameters parameter.
    Field Description Type Default value Description
    quad_segs The number of segments that are used to approximate a quarter circle. integer 8 A greater value indicates a smoother quarter circle.
    join The join style of offset lines. string round Valid values:
    • round
    • mitre
    • bevel
    mitre_limit The limit of the miter ratio. float -- This parameter is valid only when you set the join parameter to mitre.

Examples

  • Results returned with different values of the quad_segs field:
    select st_curvetoline(ST_OffsetCurve(g,1,'quad_segs=2')),
                 st_curvetoline(ST_OffsetCurve(g,1.1,'quad_segs=3')),
                 st_curvetoline(ST_OffsetCurve(g,1.2))g
           from (select 'LINESTRING(0 0,0 1,1 1)'::geometry as g) as t;
    1
  • Results returned with different values of the join field:
    select st_curvetoline(ST_OffsetCurve(g,1,'join=round')),
                 st_curvetoline(ST_OffsetCurve(g,1.1,'join=mitre')),
                 st_curvetoline(ST_OffsetCurve(g,1.2,'join=bevel')),g
           from (select 'LINESTRING(0 0,0 1,1 1)'::geometry as g) as t;
    2
  • Results returned with different values of the mitre_limit field:
    select st_curvetoline(ST_OffsetCurve(g,1,'join=mitre mitre_limit=0.1')),
                 st_curvetoline(ST_OffsetCurve(g,1.1,'join=mitre mitre_limit=0.5')),
                 st_curvetoline(ST_OffsetCurve(g,1.2,'join=mitre mitre_limit=1')),g
           from (select 'LINESTRING(0 0,0 1,1 1)'::geometry as g) as t;
    3
  • Results returned with a positive value and a negative value of the signedDistance parameter:
    select st_curvetoline(ST_OffsetCurve(g,2)),
             st_curvetoline(ST_OffsetCurve(g,-2)),g
           from (select 'LINESTRING(0 0,0 1,1 2)'::geometry as g) as t;
    4