参数化对象
对象构造
ELLIPTICALSTRING
参数化的椭圆弧对象,支持存储为 WKT 和 WKB 数据格式,支持Z、M属性。 此椭圆弧对象在参与空间计算时(如缓冲区计算、空间关系计算),需先通过ST_Curvetoline()函数,将参数化对象转换成普通的矢量线或面对象,再进行空间计算。
语法
ELLIPTICALSTRING(xstart ystart,xend yend ,xcenter ycenter,minor,clockwise,rotation,axis,ratio)
------含Z属性的椭圆弧------
ELLIPTICALSTRINGZ(xstart ystart,xend yend ,xcenter ycenter,minor,clockwise,rotation,axis,ratio)
------含M属性的椭圆弧------
ELLIPTICALSTRINGM(xstart ystart,xend yend ,xcenter ycenter,minor,clockwise,rotation,axis,ratio)
参数:
xstart,ystart - 椭圆弧起点坐标
xend,yend - 椭圆弧终点坐标
xcenter,ycenter - 椭圆弧中心点坐标
minor - 椭圆弧方向,值域为 0 或 1
clockwise - 保留参数,暂未使用
rotation - 椭圆弧旋转角度
axis - 长半轴长度
ratio - 短轴与长轴之比
注意:
椭圆的起始点和终止点必须要在椭圆上,否则会报错:
ERROR: the parameters of the ellipse must be valid
示例
-----构造一个椭圆弧对象-----
SELECT 'ELLIPTICALSTRING(-2 0,2 0,0 0,0,0,0,2,0.5)'::geometry;
-----创建包含椭圆弧对象的表----
create table ellipsetest(id serial,geom geometry(ELLIPTICALSTRING,4326));
BEZIER3CURVE
贝塞尔曲线,支持由四个点确定构成一段三阶贝塞尔曲线。
语法
BEZIER3CURVE(x1 y1,x2 y2,x3 y3,x4 y4)
参数:
x1,y1 - 贝塞尔曲线的第1个点坐标
x2,y2 - 贝塞尔曲线的第2个点坐标
x3,y3 - 贝塞尔曲线的第3个点坐标
x4,y4 - 贝塞尔曲线的第4个点坐标
示例
-----构造一个三阶贝塞尔曲线对象-----
SELECT ('BEZIER3CURVE(1 1, 2 2, 3 2, 3 1)'::geometry);
--------------------------
011300000004000000000000000000F03F000000000000F03F00000000000000400000000000000040000000000000084000000000000000400000000000000840000000000000F03F
COMPOUNDCURVE
含线、椭圆弧或贝塞尔曲线的复合线对象。 注意:COMPOUNDCURVE 中每个单元对象的几何必须连续。
示例
-----构造一个线与椭圆弧的复合线对象-----
select ST_AsText(st_curvetoline('COMPOUNDCURVE((1 0,2 0),ELLIPTICALSTRING(2 0 ,4 0, 3 0 ,1,0,0,1,0.5))'));
-----构造一个线与三阶贝塞尔曲线的复合线对象-----
select ST_AsText(st_curvetoline('COMPOUNDCURVE((1 2,2 0),BEZIER3CURVE(2 0,20 20 ,30 10,10 10))'));
CURVEPOLYGON
含曲线的复合面对象。 注意:CURVEPOLYGON 中的各个子对象必须是闭合的。
示例
-----构造一个圆与椭圆的复合面对象-----
select st_curvetoline('CURVEPOLYGON(ELLIPTICALSTRING(2 0,2 0,0 0,0,0,0,2,0.5),CIRCULARSTRING(-0.5 0,0.5 0,-0.5 0))');
-----构造一个圆弧、一条三阶贝塞尔曲线的复合面对象-----
select st_curvetoline('CURVEPOLYGON(BEZIER3CURVE(1 1, 2 2, 3 1, 1 1),CIRCULARSTRING(1.7 1.2,1.9 1.2,1.7 1.2))');
转换函数
ST_AsText
将 geometry 类型转换为 text 文本类型,同时支持椭圆弧、贝塞尔曲线类型。
语法
text ST_AsText(geometry geom);
参数:
geom - 空间对象
返回:
返回空间对象几何的文本字符串。
示例
select ST_AsText('ELLIPTICALSTRINGM (-2 0 0,2 0 0,0 0 0,0,0,0,2,0.5)'::geometry);
--------------------------
ELLIPTICALSTRINGM(-2 0 0,2 0 0,0 0 0,0,0,0,2,0.5)
ST_Curvetoline
将圆弧(CIRCULARSTRING)、椭圆弧(ELLIPTICALSTRING)、贝塞尔曲线(BEZIER3CURVE)以及相关复合对象转换为常规线或面。
语法
geometry ST_Curvetoline(geometry geom);
参数:
geom - 空间对象
返回:
返回常规对象的 geometry。
示例
select ST_Curvetoline('ELLIPTICALSTRING(-2 0,1.1602773 0.8145177,0 0,0,0,0,2,0.5)');
--------------------------
0102000020E61000004000000000000000000000C0075C143326A6A13C4387327875FFFFBFBC07AA7B168A873FE128DAC918F7FFBF3583AAE032DDA73FD5FF6AB8A2E4FFBF96A165FD2AE8B43F22560F1919C8FFBF08A76F9021DBBD3F3D0AEFEF84A1FFBFE272BEAC5462C33F8C50566DF270FFBF130CC3C1F8D0C73FD1DDDBE97036FFBF6776188C1638CC3F04B287E112F2FEBF543595F8244BD03FB60BFCEDEDA3FEBF2AD1BFD31875D23F675CA2BF1A4CFEBF76112CD33799D43FB565DE15B5EAFDBFC73822CAD4B6D63F55F649B6DB7FFDBF085F499A44CDD83FE60BFC62B00BFDBF95B9B769DEDBDA3FE86BDECF578EFCBF0A814BD8FBE1DC3F91121597F907FCBF1B9A3B34F9DEDE3F51217B2CC078FBBFE9B2E7D61A69E03F114139D0D8E0FABF1FB116C5895DE13FF9B479807340FABF1F47982A7C4CE23F0FA23EEAC297F9BFE2681A89A635E33F1A565F59FCE6F8BFD87FE535BF18E43FBE9CB1A7572EF8BF7DAF22717EF5E43FB474642B0F6EF7BF2403877C9ECBE53F68B891A45FA6F6BF755B5CB1DB9AE63F9A8C0C2A88D7F5BF6825E195F462E73F80A57215CA01F5BF131AF8F1A923E83F8DAE86EE6825F4BF007E21E3BEDCE83FC65ADA55AA42F3BFB690B7EFF88DE93F5EDBCEEED559F2BF771868192037EA3FC7AFF248356BF1BF1434E5EEFED7EA3FE2F5C3C81377F0BFE0DBC79C6270EB3F1C24BD1F7DFBEEBF29BC9EFD1A00EC3F4B6B3BC908FFECBF6F5624A9FA86EC3FD9ED70326BF9EABFF69A9702D704ED3FDCAEC2E447EBE8BF707232468879ED3F987AE11A45D5E6BFCCF6B995E9E4ED3FEE11458C0BB8E4BF0F632404D946EE3F9626DE374694E2BF0D0C51A0379FEE3F42FF0F2EA26AE0BF16FFCE7EE9EDEE3FD7AA05B49C77DCBFF42FAFC2D532EF3F6966C094F610D8BFB46C5FA5E66DEF3F488E15F3B5A2D3BFE99B8B7D099FEF3F24368D55825CCEBFF71803C52EC6EF3FF04DB11A016AC5BF8C51A01D4AE3EF3FAEB1F5C077E1B8BF8017315552F6EF3F64501BA8439C9BBF286B5E6841FFEF3F2449D56E082BA63F13D3928414FEEF3FF218FCDA980EBD3F85A7DE08CCF2EF3FEF23C4A93F7FC73F9009DA856BDDEF3FB99D9B36E337D03F5B8F84BCF9BDEF3FC1C07BD606ABD43F8C00239C8094EF3F392283CDA217D93F8ECF1B3F0D61EF3FCF52D844517CDD3F7D4DD3E6AF23EF3F8C246B73D7EBE03F95E788F67BDCEE3F3C24A8A72D14E33F800D37ED878BEE3F3BDD73BD7C36E53F05B0775EED30EE3FC666A81A1852E73FD2966FEAC8CCED3F698131435566E93F1B1BC3343A5FED3F969AE90E8C72EB3F6C2297DA63E8EC3F8788BADE1676ED3F4782A1676B68EC3F4C35F1D05270EF3F00414C4A79DFEB3F65D859FA4FB0F03F5273EFC6B84DEB3FB9B344BE30A3F13FD5BF25EA57B3EA3F44C3F2F77E90F23FFAD93F7A8710EA3F
SELECT ST_Curvetoline('BEZIER3CURVE(1 1, 2 2, 3 3,4 4)');
--------------------------
0102000020E610000048000000000000000000F03F000000000000F03F00000080AAAAF03F00000080AAAAF03F000000605555F13F000000605555F13F000000E0FFFFF13F000000E0FFFFF13F000000C0AAAAF23F000000C0AAAAF23F000000605555F33F000000605555F33F000000200000F43F000000200000F43F000000A0AAAAF43F000000A0A
AAAF43F000000805555F53F000000805555F53F000000000000F63F000000000000F63F00000080AAAAF63F00000080AAAAF63F000000605555F73F000000605555F73F000000400000F83F000000400000F83F000000C0AAAAF83F000000C0AAAAF83F000000405555F93F000000405555F93F000000200000FA3F000000200000FA3F00000000ABAAF
A3F00000000ABAAFA3F000000805555FB3F000000805555FB3F000000000000FC3F000000000000FC3F000000C0AAAAFC3F000000C0AAAAFC3F000000C05555FD3F000000C05555FD3F000000400000FE3F000000400000FE3F000000C0AAAAFE3F000000C0AAAAFE3F000000C05555FF3F000000C05555FF3F000000400000004000000040000000400
0000080555500400000008055550040000000C0AAAA0040000000C0AAAA004000000020000001400000002000000140000000A055550140000000A055550140000000E0AAAA0140000000E0AAAA014000000020000002400000002000000240000000A055550240000000A05555024000000000ABAA024000000000ABAA0240000000400000034000000
0400000034000000080555503400000008055550340000000E0AAAA0340000000E0AAAA034000000060000004400000006000000440000000A055550440000000A055550440000000E0AAAA0440000000E0AAAA044000000060000005400000006000000540000000C055550540000000C05555054000000000ABAA054000000000ABAA0540000000400
00006400000004000000640000000A055550640000000A05555064000000020ABAA064000000020ABAA064000000060000007400000006000000740000000A055550740000000A05555074000000020ABAA074000000020ABAA074000000080000008400000008000000840000000C055550840000000C05555084000000000ABAA084000000000ABAA0
84000000060000009400000006000000940000000E055550940000000E05555094000000020ABAA094000000020ABAA09400000006000000A400000006000000A40000000E055550A40000000E055550A4000000040ABAA0A4000000040ABAA0A400000008000000B400000008000000B40000000C055550B40000000C055550B4000000020ABAA0B400
0000020ABAA0B40000000A000000C40000000A000000C40000000E055550C40000000E055550C4000000020ABAA0C4000000020ABAA0C40000000A000000D40000000A000000D400000000056550D400000000056550D4000000040ABAA0D4000000040ABAA0D400000008000000E400000008000000E40000000E055550E40000000E055550E4000000
060ABAA0E4000000060ABAA0E40000000A000000F40000000A000000F40000000E055550F40000000E055550F4000000060ABAA0F4000000060ABAA0F40
测量函数
ST_Area
计算空间面对象的面积,区别于ST_AreaParam,包含支持椭圆弧、不支持贝塞尔曲线。
语法
float ST_Area(geometry geom);
参数:
geom - 椭圆弧对象
返回:
返回椭圆弧对象的面积。
示例
select ST_Area('COMPOUNDCURVE(ELLIPTICALSTRING(-1 0, -1 0, 0 0,1,0,0,1,0.5))');
--------------------------
1.5707963267948966
ST_AreaParam
计算空间面对象的精确面积,包含支持椭圆弧、贝塞尔曲线。
语法
float ST_AreaParam(geometry geom);
参数:
geom - 椭圆弧对象
返回:
返回椭圆弧对象的精确面积。
示例
select ST_AreaParam('CURVEPOLYGON(CIRCULARSTRING(-1 5, 1 5 ,-1 5))');
--------------------------
3.141592653589793
ST_Length
计算空间对象的周长,包含支持椭圆弧、贝塞尔曲线。
语法
float ST_Length(geometry geom);
参数:
geom - 椭圆弧对象
返回:
返回椭圆弧对象的周长。
示例
select ST_Length('ELLIPTICALSTRING(0 0,0 0,2 0,0,1,0,2,0.5)');
--------------------------
9.685374273494208