当前位置:网站首页>Golden Warehouse Database KingbaseGIS User Manual (6.5. Geometry Object Editing Function)

Golden Warehouse Database KingbaseGIS User Manual (6.5. Geometry Object Editing Function)

2022-08-10 00:55:00 A thousand sails pass by the side of the sinking boat_

6.5. 几何对象编辑函数

6.5.1. ST_AddPoint

ST_AddPoint — 在LINESTRING对象的某个点的位置之前添加一个点(点的位置计数从0开始).

用法

geometry ST_AddPoint(geometry linestring, geometry point);
geometry ST_AddPoint(geometry linestring, geometry point, integer position);

描述

在LINESTRING对象的某个点的位置之前添加一个点(点的位置计数从0开始),This parameter can be omitted, or set to-1Said at the end add point.

  • 这个函数支持3D对象,并且不会删除z坐标.

样例

--guarantee all linestrings in a table are closed
--by adding the start point of each linestring to the end of the line string
--only for those that are not closed
UPDATE sometable
SET the_geom = ST_AddPoint(the_geom, ST_StartPoint(the_geom))
FROM sometable
WHERE ST_IsClosed(the_geom) = false;

--Adding point to a 3-d line
SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT(
   'LINESTRING(0 0 1, 1 1 1)'), ST_MakePoint (1, 2, 3)));

--result
st_asewkt
----------
LINESTRING(0 0 1,1 1 1,1 2 3)

参考

ST_RemovePoint , ST_SetPoint

6.5.2. ST_CollectionExtract

ST_CollectionExtract — 根据输入的(multi)几何对象,返回一个(multi)几何对象,Return of geometric object contains only the specified type of element.

用法

geometry ST_CollectionExtract(geometry collection);
geometry ST_CollectionExtract(geometry collection, integer type);

描述

Based on the input geometry object collection,Returns a homogenization of multiple(multi)几何对象. 如果指定了 type 参数,Return of geometric object contains only type Specify the type of the elements of the.Do not belong to the specified type of geometric objects will be ignored. If there is no corresponding collection types of geometric objects son,This function returns the empty geometry object. 本函数只支持point、line和 polygon类型.Type value and type the name of the corresponding relationship is as follows:1 == POINT, 2 == LINESTRING, 3 == POLYGON .

样例

-- Constants: 1 == POINT, 2 == LINESTRING, 3 == POLYGONSELECT
SELECT
ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))'),1));

st_astext
---------------
MULTIPOINT(0 0)
(1 row)

SELECT
ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1)),LINESTRING(2 2, 3 3))'),2));

st_astext
---------------
MULTILINESTRING((0 0, 1 1), (2 2, 3 3))
(1 row)

参考

ST_Multi , ST_Dump , ST_CollectionHomogenize

6.5.3. ST_CollectionHomogenize

ST_CollectionHomogenize —根据给定的geometry collection对象,The simplest object returns a

用法

geometry ST_CollectionHomogenize(geometry collection);

描述

根据给定的geometry collection对象,The simplest object returns a.Singleton return or singleton,同类的collectionObject returns a suitablemulti-type类型

警告

当指定type类型为3的时候,返回值为 multipolygon对象,即使polygonBoundary is Shared,在许多情况下,Such as the function applied to aST_SplitWhen a value object,The return value is an invalidmultipolygon对象

样例

SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0))'));

st_astext
------------
POINT(0 0)
(1 row)

SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0),POINT(1 1))'));

st_astext
---------------------
MULTIPOINT(0 0,1 1)
(1 row)

参考

ST_Multi , ST_CollectionExtract

6.5.4. ST_CurveToLine

ST_CurveToLine — 把一个CIRCULARSTRING/CURVEDPOLYGON对象转换成一个LINESTRING/POLYGON对象

用法

geometry ST_CurveToLine(geometry curveGeom, integer segments_per_qtr_circle);

描述

把一个CIRCULARSTRINGAn object into a ruleLINESTRING对象,或者把一个CURVEDPOLYGONAn object into a rulePOLYGON对象.对于那些不支持CIRCULARSTRINGGeometric types of platforms,这很有用.

Converts a chance to enter the object into a linear geometric objects.每一个CurveGeometric objects or fragments can be separated into approximate line processing,The default separation process is every quarter round into32弧段.

  • This function method realized the standard OpenGIS Simple Features Implementation Specification for SQL 1.1.

  • This function method realized the standard SQL/MM specification. SQL-MM 3: 7.1.7

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持CircularString和Curve几何类型对象

样例

SELECT ST_AsText(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227
150505,220227 150406)')));
--Result --
LINESTRING(220268 150415,220269.95064912 150416.539364228,220271.823415575
150418.17258804,220273.613787707 150419.895736857,
220275.317452352 150421.704659462,220276.930305234 150423.594998003,220278.448460847
150425.562198489,
220279.868261823 150427.60152176,220281.186287736 150429.708054909,220282.399363347
150431.876723113,
220283.50456625 150434.10230186,220284.499233914 150436.379429536,220285.380970099
150438.702620341,220286.147650624 150441.066277505,
220286.797428488 150443.464706771,220287.328738321 150445.892130112,220287.740300149
150448.342699654,
220288.031122486 150450.810511759,220288.200504713 150453.289621251,220288.248038775
150455.77405574,
220288.173610157 150458.257830005,220287.977398166 150460.734960415,220287.659875492
150463.199479347,
220287.221807076 150465.64544956,220286.664248262 150468.066978495,220285.988542259
150470.458232479,220285.196316903 150472.81345077,
220284.289480732 150475.126959442,220283.270218395 150477.39318505,220282.140985384
150479.606668057,
220280.90450212 150481.762075989,220279.5637474 150483.85421628,220278.12195122
150485.87804878,
220276.582586992 150487.828697901,220274.949363179 150489.701464356,220273.226214362
150491.491836488,
220271.417291757 150493.195501133,220269.526953216 150494.808354014,220267.559752731
150496.326509628,
220265.520429459 150497.746310603,220263.41389631 150499.064336517,220261.245228106
150500.277412127,
220259.019649359 150501.38261503,220256.742521683 150502.377282695,220254.419330878
150503.259018879,
220252.055673714 150504.025699404,220249.657244448 150504.675477269,220247.229821107
150505.206787101,
220244.779251566 150505.61834893,220242.311439461 150505.909171266,220239.832329968
150506.078553494,
220237.347895479 150506.126087555,220234.864121215 150506.051658938,220232.386990804
150505.855446946,
220229.922471872 150505.537924272,220227.47650166 150505.099855856,220225.054972724
150504.542297043,
220222.663718741 150503.86659104,220220.308500449 150503.074365683,
220217.994991777 150502.167529512,220215.72876617 150501.148267175,
220213.515283163 150500.019034164,220211.35987523 150498.7825509,
220209.267734939 150497.441796181,220207.243902439 150496,
220205.293253319 150494.460635772,220203.420486864 150492.82741196,220201.630114732
150491.104263143,
220199.926450087 150489.295340538,220198.313597205 150487.405001997,220196.795441592
150485.437801511,
220195.375640616 150483.39847824,220194.057614703 150481.291945091,220192.844539092
150479.123276887,220191.739336189 150476.89769814,
220190.744668525 150474.620570464,220189.86293234 150472.297379659,220189.096251815
150469.933722495,
220188.446473951 150467.535293229,220187.915164118 150465.107869888,220187.50360229
150462.657300346,
220187.212779953 150460.189488241,220187.043397726 150457.710378749,220186.995863664
150455.22594426,
220187.070292282 150452.742169995,220187.266504273 150450.265039585,220187.584026947
150447.800520653,
220188.022095363 150445.35455044,220188.579654177 150442.933021505,220189.25536018
150440.541767521,
220190.047585536 150438.18654923,220190.954421707 150435.873040558,220191.973684044
150433.60681495,
220193.102917055 150431.393331943,220194.339400319 150429.237924011,220195.680155039
150427.14578372,220197.12195122 150425.12195122,
220198.661315447 150423.171302099,220200.29453926 150421.298535644,220202.017688077
150419.508163512,220203.826610682 150417.804498867,
220205.716949223 150416.191645986,220207.684149708 150414.673490372,220209.72347298
150413.253689397,220211.830006129 150411.935663483,
220213.998674333 150410.722587873,220216.22425308 150409.61738497,220218.501380756
150408.622717305,220220.824571561 150407.740981121,
220223.188228725 150406.974300596,220225.586657991 150406.324522731,220227 150406)


--3d example
SELECT ST_AsEWKT(ST_CurveToLine(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227
150505 2,220227 150406 3)')));

Output
------
LINESTRING(220268 150415 1,220269.95064912 150416.539364228 1.0181172856673,
220271.823415575 150418.17258804 1.03623457133459,220273.613787707 150419.895736857
1.05435185700189,....AD INFINITUM ....
220225.586657991 150406.324522731 1.32611114201132,220227 150406 3)

--use only 2 segments to approximate quarter circle
SELECT ST_AsText(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227
150505,220227 150406)'),2));

st_astext
------------------------------
LINESTRING(220268 150415,220287.740300149 150448.342699654,220278.12195122 ←
150485.87804878,
220244.779251566 150505.61834893,220207.243902439 150496,220187.50360229 150462.657300346,
220197.12195122 150425.12195122,220227 150406)

参考

ST_LineToCurve

6.5.5. ST_FlipCoordinates

ST_FlipCoordinates —Swap an input geometry objectX和Y坐标,For the user to longitude/Dimension coordinate error input into dimension/Useful when longitude,可以 Use this function to fix it

用法

geometry ST_FlipCoordinates(geometry geom);

描述

Swap an input geometry objectX和Y坐标.

  • 该函数支持CircularString和Curve几何类型对象

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持MMeasured value coordinate.

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 该函数支持 Triangles 和 Triangulated Irregular Network Surfaces (TIN)类型.

Example

SELECT ST_AsEWKT(ST_FlipCoordinates(GeomFromEWKT('POINT(1 2)')));

st_asewkt
------------
POINT(2 1)

6.5.6. ST_Force2D

ST_Force2D —将一个几何对象转换成2D the object,The transformed objects onlyX和Y坐标

用法

geometry ST_Force2D(geometry geomA);

描述

将一个几何对象转换成2D the object,The transformed objects onlyX和Y坐标. The function of the output must be withOGCSpecification compatible scene is very useful(因为当前的OGC规范只规定了2D几何对象)

  • 该函数支持CircularString和Curve几何类型对象

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 这个函数支持3D对象,并且不会删除z坐标

样例

SELECT ST_AsEWKT(ST_Force2D(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));

st_asewkt
-------------------------------------
CIRCULARSTRING(1 1,2 3,4 5,6 7,5 6)

SELECT ST_AsEWKT(ST_Force2D('POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))'));

st_asewkt
----------------------------------------------
POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))

参考

ST_Force3D

6.5.7. ST_Force3D

ST_Force3D — 将几何对象转换成XYZ模式,该函数是ST_Force3DZ别名

用法

geometry ST_Force3D(geometry geomA, float Zvalue = 0.0);

描述

将几何对象转换成XYZ模式,该函数是ST_Force3DZ别名.If the geometric objects have noZ部分坐标,那么Z值被设置为0

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 该函数支持CircularString和Curve几何类型对象

  • 这个函数支持3D对象,并且不会删除z坐标

样例

--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force3D(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));

st_asewkt
-----------------------------------------------
CIRCULARSTRING(1 1 2,2 3 2,4 5 2,6 7 2,5 6 2)

SELECT ST_AsEWKT(ST_Force3D('POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))'));

st_asewkt
--------------------------------------------------------------
POLYGON((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))

参考

ST_AsEWKT , ST_Force2D , ST_Force3DM , ST_Force3DZ

6.5.8. ST_Force3DZ

ST_Force3DZ —将几何对象转换成XYZ模式,该函数是ST_Force3D别名.

用法

geometry ST_Force3DZ(geometry geomA, float Zvalue = 0.0);

描述

将几何对象转换成XYZ模式,该函数是ST_Force3D别名.If the geometric objects have noZ部分坐标,那么Z值被设置为0

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持CircularString和Curve几何类型对象

样例

--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force3DZ(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));

st_asewkt
-----------------------------------------------
CIRCULARSTRING(1 1 2,2 3 2,4 5 2,6 7 2,5 6 2)

SELECT ST_AsEWKT(ST_Force3DZ('POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))'));

st_asewkt
--------------------------------------------------------------
POLYGON((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))

参考

ST_AsEWKT , ST_Force2D , ST_Force3DM , ST_Force3D

6.5.9. ST_Force3DM

ST_Force3DM —将几何对象转换为XYM模式

用法

geometry ST_Force3DM(geometry geomA, float Mvalue = 0.0);

描述

将几何对象转换为XYM模式. If a geometry object withoutM成分,将会把M值设置为0,If the geometry object has aZ参数值,This value will be discarded

  • 该函数支持CircularString和Curve几何类型对象

样例

--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force3DM(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));

st_asewkt
------------------------------------------------
CIRCULARSTRINGM(1 1 0,2 3 0,4 5 0,6 7 0,5 6 0)

SELECT ST_AsEWKT(ST_Force3DM('POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1)) '));

st_asewkt
---------------------------------------------------------------
POLYGONM((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))

参考

ST_AsEWKT , ST_Force2D , ST_Force3DM , ST_Force3D , ST_GeomFromEWKT

6.5.10. ST_Force4D

ST_Force4D — 将一个几何对象转换为XYZM模式

用法

geometry ST_Force4D(geometry geomA, float Zvalue = 0.0, float Mvalue = 0.0);

描述

将几何对象转换为XYZMModel description,如果没有Z和M值,则都用0代替

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持CircularString和Curve几何类型对象

样例

--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force4D(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));

st_asewkt
---------------------------------------------------------
CIRCULARSTRING(1 1 2 0,2 3 2 0,4 5 2 0,6 7 2 0,5 6 2 0)

SELECT ST_AsEWKT(ST_Force4D('MULTILINESTRINGM((0 0 1,0 5 2,5 0 3,0 0 4),(1 1 1,3 1 1,1 3 1,1 1 1))'));

st_asewkt
--------------------------------------------------------------------------------------
MULTILINESTRING((0 0 0 1,0 5 0 2,5 0 0 3,0 0 0 4),(1 1 0 1,3 1 0 1,1 3 0 1,1 1 0 1))

相关参考

ST_AsEWKT , ST_Force2D , ST_Force3DM , ST_Force3D

6.5.11. ST_ForcePolygonCCW

ST_ForcePolygonCCW — 对于(Multi)Polygon 对象,The outer ring vertex counterclockwise arranged,The inner ring vertex clockwise to arrange.The polygon object remains the same.

用法

geometry ST_ForcePolygonCCW ( geometry geom );

描述

对于(Multi)Polygon 对象,The outer ring vertex counterclockwise arranged,The inner ring vertex clockwise to arrange.The polygon object remains the same.

  • 该函数支持3D对象,并且不会删除z坐标

  • 该函数支持z坐标

参考

ST_ForcePolygonCW , ST_IsPolygonCCW , ST_IsPolygonCW

6.5.12. ST_ForceCollection

ST_ForceCollection — 把geometry对象转换成GEOMETRYCOLLECTION类型对象

用法

geometry ST_ForceCollection(geometry geomA);

描述

把geometry对象转换成GEOMETRYCOLLECTION类型对象. To simplify theWKBExpression is very useful

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持CircularString和Curve几何类型对象

样例

SELECT ST_AsEWKT(ST_ForceCollection('POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1))'));

st_asewkt
----------------------------------------------------------------------------------
GEOMETRYCOLLECTION(POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1)))

SELECT ST_AsText(ST_ForceCollection('CIRCULARSTRING(220227 150406,2220227 150407,220227 150406)'));

st_astext
--------------------------------------------------------------------------------
GEOMETRYCOLLECTION(CIRCULARSTRING(220227 150406,2220227 150407,220227 150406))
(1 row)

-- POLYHEDRAL example --
SELECT ST_AsEWKT(ST_ForceCollection('POLYHEDRALSURFACE(((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),
((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),
((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))'));

st_asewkt
----------------------------------------------------------------------------------
GEOMETRYCOLLECTION(
POLYGON((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),POLYGON((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),
POLYGON((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),POLYGON((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
POLYGON((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),POLYGON((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1))
)

相关参考

ST_AsEWKT , ST_Force2D , ST_Force3DM , ST_Force3D , ST_GeomFromEWKT

6.5.13. ST_ForcePolygonCW

ST_ForcePolygonCW — 对于(Multi)Polygon 对象,The outer ring vertex clockwise order,The inner ring vertex counterclockwise arranged.The polygon object remains the same.

用法

geometry ST_ForcePolygonCW ( geometry geom );

描述

对于(Multi)Polygon 对象,The outer ring vertex clockwise order,The inner ring vertex counterclockwise arranged.The polygon object remains the same.

  • 该函数支持3D对象,并且不会删除z坐标

  • 该函数支持z坐标

相关参考

ST_ForcePolygonCCW , ST_IsPolygonCCW , ST_IsPolygonCW

6.5.14. ST_ForceSFS

ST_ForceSFS — Convert geometry object to meetSFS 1.1Version of the specification of the geometry object type

用法

geometry ST_ForceSFS(geometry geomA);
geometry ST_ForceSFS(geometry geomA, text version);

描述

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 该函数支持 Triangles 和 Triangulated Irregular Network Surfaces (TIN)类型.

  • 该函数支持CircularString和Curve几何类型对象

  • 这个函数支持3D对象,并且不会删除z坐标

6.5.15. ST_ForceRHR

ST_ForceRHR —According to the right hand coordinate rule forpolygonVertex to

用法

boolean ST_ForceRHR(geometry g);

描述

According to the right hand coordinate rule forpolygonVertex to.在GIS术语中,This means that surrounded by polygon area will be turned to the border to the right.特别地:Outer ring is clockwise direction,And the inner ring is counterclockwise

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持 Polyhedral Surface类型几何对象.

样例

SELECT ST_AsEWKT(
ST_ForceRHR(
'POLYGON((0 0 2, 5 0 2, 0 5 2, 0 0 2),(1 1 2, 1 3 2, 3 1 2, 1 1 2))'
)
);

st_asewkt
--------------------------------------------------------------
POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))
(1 row)

相关参考

ST_BuildArea , ST_Polygonize , ST_Reverse

6.5.16. ST_ForceCurve

ST_ForceCurve — 把一个geometryConverted into a corresponding object upcurve类型,如果可以的话

用法

geometry ST_ForceCurve(geometry g);

描述

把一个geometryConverted into a corresponding object upcurve 类型,如果可以的话: lineAfter upcasting iscompoundcurve类型, multilineType transformation is upmulticurve,polygon向上转型是curvepolygon, multipolygon向上转型是multisurface.

  • 这个函数支持3D对象,并且不会删除z坐标.

样例

SELECT ST_AsText(
ST_ForceCurve(
'POLYGON((0 0 2, 5 0 2, 0 5 2, 0 0 2),(1 1 2, 1 3 2, 3 1 2, 1 1 2))'
)
);

st_astext
----------------------------------------------------------------------
CURVEPOLYGON Z ((0 0 2,5 0 2,0 5 2,0 0 2),(1 1 2,1 3 2,3 1 2,1 1 2))
(1 row)

相关参考

ST_LineToCurve

6.5.17. ST_LineMerge

ST_LineMerge — 把一些LineString对象组合在一起,形成一个MULTILINESTRING对象

用法

geometry ST_LineMerge(geometry amultilinestring);

描述

把一些LineString对象组合在一起,形成一个MULTILINESTRING对象.

注意

The function value supportMULTILINESTRING/LINESTRING类型对象.If the function is applied topolygon 或 geometry collection 类型对象,This function returns an emptyGEOMETRYCOLLECTION对象

样例

SELECT ST_AsText(ST_LineMerge(
ST_GeomFromText(
   'MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45 -33,-46 -32))')
)
);

st_astext
--------------------------------------------------------------------------------------------------
LINESTRING(-29 -27,-30 -29.7,-36 -31,-45 -33,-46 -32) (1 row)

--If can't be merged - original MULTILINESTRING is returned
SELECT ST_AsText(ST_LineMerge(
ST_GeomFromText(
   'MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45.2 -33.2,-46 -32))')
)
);

st_astext
----------------
MULTILINESTRING((-45.2 -33.2,-46 -32),(-29 -27,-30 -29.7,-36 -31,-45 -33))

相关参考

ST_Segmentize , ST_LineSubstring

6.5.18. ST_LineToCurve

ST_LineToCurve — 把一个LINESTRING/POLYGON 转换成一个CIRCULARSTRING,CURVED POLYGON类型对象

用法

geometry ST_LineToCurve(geometry geomANoncircular);

描述

把一个LINESTRING/POLYGON 转换成一个CIRCULARSTRING, CURVED POLYGON类型对象.注意:该函数的作用是,The transformed point geometry object need to equivalent to sayCurve类型对象

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持CircularString和Curve几何类型对象

样例

SELECT ST_AsText(ST_LineToCurve(foo.the_geom))
   As curvedastext,ST_AsText(foo.the_geom) As
non_curvedastext
FROM (SELECT ST_Buffer('POINT(1 3)'::geometry, 3)
   As the_geom) As foo;

curvedatext                                      | non_curvedastext
-------------------------------------------------+----------------------------------------------------------------------------------
CURVEPOLYGON(CIRCULARSTRING(4 3,3.12132034355964 | POLYGON((4 3,3.94235584120969 2.41472903395162,3.77163859753386 1.85194970290473,
0.878679656440359, 1 0,-1.12132034355965         | 3.49440883690764 1.33328930094119,3.12132034355964 0.878679656440359,
5.12132034355963,4 3))                           | 2.66671069905881 0.505591163092366,2.148050297 0.228361402466141, 1.58527096604839
                                                 | 0.0576441587903094,1 0, 0.414729033951621 0.0576441587903077,-0.1480502
                                                 | 0.228361402466137, -0.666710699058802 0.505591163092361,-1.12132034
                                                 | 0.878679656440353,-1.49440883690763 1.33328930094119,-1.771638597 1.85194970290472
                                                 | --ETC--
                                                 | ,3.94235584120969 3.58527096604839,4 3))

--3D example
SELECT ST_AsEWKT(ST_LineToCurve(ST_GeomFromEWKT(
   'LINESTRING(1 2 3, 3 4 8, 5 6 4, 7 8 4, 9 10 4)')));

st_asewkt
------------------------------------
CIRCULARSTRING(1 2 3,5 6 4,9 10 4)

相关参考

ST_CurveToLine

6.5.19. ST_Multi

ST_Multi — 返回几何对象为一个MULTI* 类型几何对象,If the geometry itself isMULTI*类型的,返回值不变,Namely and input.

用法

geometry ST_Multi(geometry g1);

描述

返回几何对象为一个MULTI* 类型几何对象,If the geometry itself isMULTI*类型的,返回值不变,Namely, and the input value.

样例

SELECT ST_AsText(ST_Multi(ST_GeomFromText('POLYGON((743238
2967416,743238 2967450, 743265 2967450,743265.625 2967416,743238
2967416))')));

st_astext
-----------------------------------------------------------------------------------------------
MULTIPOLYGON(((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416, 743238 2967416)))
(1 row)

相关参考

ST_AsText

6.5.20. ST_Normalize

ST_Normalize — 以常规/Canonical form returns a geometric object.The ring may be rearranging polygon vertex order、The order of the ring orMultiThe order of the elements in a geometric type.

用法

geometry ST_Normalize(geometry geom);

描述

以常规/Canonical form returns a geometric object.The ring may be rearranging polygon vertex order、The order of the ring orMultiThe order of the elements in a geometric type.

This function is normally only useful for testing(Compared to expectations and actual values).

样例

SELECT ST_AsText(ST_Normalize(ST_GeomFromText(
'GEOMETRYCOLLECTION(
   POINT(2 3),
   MULTILINESTRING((0 0, 1 1),(2 2, 3 3)),
   POLYGON(
      (0 10,0 0,10 0,10 10,0 10),
      (4 2,2 2,2 4,4 4,4 2),
      (6 8,8 8,8 6,6 6,6 8)
   )
)'
)));
                                                                     st_astext
----------------------------------------------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(6 6,8 6,8 8,6 8,6 6),(2 2,4 2,4 4,2 4,2 2)),MULTILINESTRING((2 2,3 3),(0 0,1 1)),POINT(2 3))
(1 row)

相关参考

ST_Equals,

6.5.21. ST_QuantizeCoordinates

ST_QuantizeCoordinates — Quantitative coordinate values.

用法

geometry ST_QuantizeCoordinates ( geometry g , int prec_x , int prec_y , int prec_z , int prec_m );

描述

According to the given significant digits after the decimal point figures,A given geometry object coordinate values set to the specified digits, Beyond the specified number of decimal part will be set to 0. The output of the roundness of the coordinates is the original coordinate values,Help to improve the compression ratio. 在使用 KES The storage compression feature, This can reduce the disk footprint of geometric type column. This function allows for each dimension to set the precision of different. Negative values representing the rounded to digits after the decimal point, As representative of the round to the front of the decimal point digits.(例如: prec_x=-2 代表将 x Coordinates are rounded to 100 的倍数).

The function of the coordinates is independent of the geometry object,Is relative with the geometry of the location of the internal coordinate system,因此, Topological relationship not be affected. If you specify a valid number of digits above the geometry was the precision of the, Could be generating illegal geometric objects.

技术背景

KingbaseES GIS All the coordinate values stored as a double-precision floating-point number,支持最大 15 位有效数字. 但是, KingbaseES GIS Internal can use less than 15 A valid number to manage the data. 其中一个例子是 TIGER 数据,It provides the accurate to decimal point 6 The coordinates of the accuracy(因此只需要 9 An effective figures show that the accuracy of, 8 An effective digital representation latitude) . 尽管有 15 A valid number available, In fact there is a big possibility need only 9 A valid number can say. A double-precision floating-point number to use52bits Said coordinates of valid number. 而一个 9 A valid number only need 30bits 就能表示,剩余 22bits 没有用到. 我们可以将这 22bits Set to any value we need,After the roundness and still can guarantee the coordinates of the same. 例如:数值 100.123456 Can be caused by the nearby 100.123456000000、 100.123456000001 或 100.123456432199 表示. All of these values are equivalent and legal, 向函数 ST_AsText(geom, 6) To the above any one value will get the same results. So we can put these bits set to any value,ST_QuantizeCoordinates Function to the bit is set to 0. For a long coordinate sequence, This will create a by the continuous 0 Block pattern consisting of, 可以采用 KES The compression algorithm is more efficient compression.

注意

Only on the disk will potentially affected by the size of the geometry object ST_QuantizeCoordinates 函数的影响. ST_MemSize Will report the geometric objects in memory size,Regardless of the geometry of disk storage object is much, ST_MemSize The returned value is the same.

样例

SELECT ST_AsText(ST_QuantizeCoordinates('POINT (100.123456 0)'::geometry, 4));
st_astext
-------------------------
POINT(100.123455047607 0)

WITH test AS (SELECT 'POINT (123.456789123456 123.456789123456)'::geometry AS geom)
SELECT
  digits,
  encode(ST_QuantizeCoordinates(geom, digits), 'hex'),
  ST_AsText(ST_QuantizeCoordinates(geom, digits))
FROM test, generate_series(15, -15, -1) AS digits;

digits  |                   encode                   |                st_astext
--------+--------------------------------------------+------------------------------------------
15      | 01010000005f9a72083cdd5e405f9a72083cdd5e40 | POINT(123.456789123456 123.456789123456)
14      | 01010000005f9a72083cdd5e405f9a72083cdd5e40 | POINT(123.456789123456 123.456789123456)
13      | 01010000005f9a72083cdd5e405f9a72083cdd5e40 | POINT(123.456789123456 123.456789123456)
12      | 01010000005c9a72083cdd5e405c9a72083cdd5e40 | POINT(123.456789123456 123.456789123456)
11      | 0101000000409a72083cdd5e40409a72083cdd5e40 | POINT(123.456789123456 123.456789123456)
10      | 0101000000009a72083cdd5e40009a72083cdd5e40 | POINT(123.456789123455 123.456789123455)
9       | 0101000000009072083cdd5e40009072083cdd5e40 | POINT(123.456789123418 123.456789123418)
8       | 0101000000008072083cdd5e40008072083cdd5e40 | POINT(123.45678912336 123.45678912336)
7       | 0101000000000070083cdd5e40000070083cdd5e40 | POINT(123.456789121032 123.456789121032)
6       | 0101000000000040083cdd5e40000040083cdd5e40 | POINT(123.456789076328 123.456789076328)
5       | 0101000000000000083cdd5e40000000083cdd5e40 | POINT(123.456789016724 123.456789016724)
4       | 0101000000000000003cdd5e40000000003cdd5e40 | POINT(123.456787109375 123.456787109375)
3       | 0101000000000000003cdd5e40000000003cdd5e40 | POINT(123.456787109375 123.456787109375)
2       | 01010000000000000038dd5e400000000038dd5e40 | POINT(123.45654296875 123.45654296875)
1       | 01010000000000000000dd5e400000000000dd5e40 | POINT(123.453125 123.453125)
0       | 01010000000000000000dc5e400000000000dc5e40 | POINT(123.4375 123.4375)
-1      | 01010000000000000000c05e400000000000c05e40 | POINT(123 123)
-2      | 01010000000000000000005e400000000000005e40 | POINT(120 120)
-3      | 010100000000000000000058400000000000005840 | POINT(96 96)
-4      | 010100000000000000000058400000000000005840 | POINT(96 96)
-5      | 010100000000000000000058400000000000005840 | POINT(96 96)
-6      | 010100000000000000000058400000000000005840 | POINT(96 96)
-7      | 010100000000000000000058400000000000005840 | POINT(96 96)
-8      | 010100000000000000000058400000000000005840 | POINT(96 96)
-9      | 010100000000000000000058400000000000005840 | POINT(96 96)
-10     | 010100000000000000000058400000000000005840 | POINT(96 96)
-11     | 010100000000000000000058400000000000005840 | POINT(96 96)
-12     | 010100000000000000000058400000000000005840 | POINT(96 96)
-13     | 010100000000000000000058400000000000005840 | POINT(96 96)
-14     | 010100000000000000000058400000000000005840 | POINT(96 96)
-15     | 010100000000000000000058400000000000005840 | POINT(96 96)

相关参考

ST_SnapToGrid

6.5.22. ST_RemovePoint

ST_RemovePoint — 从一个LINESTRINGObject removed aPoint点,下标从0开始

用法

geometry ST_RemovePoint(geometry linestring, integer offset);

描述

从一个LINESTRINGObject removed aPoint点,下标从0开始.This function for a closed ring dismantled into an openLINESTRING很有用

这个函数支持3D对象,并且不会删除z坐标

样例

--guarantee no LINESTRINGS are closed
--by removing the end point. The below assumes the_geom is of type LINESTRING
UPDATE sometable
SET the_geom = ST_RemovePoint(the_geom, ST_NPoints(the_geom) - 1) FROM sometable
WHERE ST_IsClosed(the_geom) = true;

相关参考

ST_AddPoint , ST_NPoints , ST_NumPoints

6.5.23. ST_RemoveRepeatedPoints

ST_RemoveRepeatedPoints — Returns a deleted the repeat point geometry object

用法

geometry ST_RemoveRepeatedPoints(geometry geom, float8 tolerance);

描述

Returns a deleted the repeat point geometry object.Can call this function to any geometry type,But in fact only for (Multi)Line、(Multi)Polygon 和 MultiPoints 进行处理. Due to simplify the operation for each geometry object to do,So can to the function to GeometryCollection 对象.

如果提供了 tolerance Tolerance parameters,Spacing within the tolerance range vertex would be considered the same,This is one of the used as the basis of repeated point.

  • 该函数支持 Polyhedral 表面

  • 该函数支持3D对象,并且不会删除z坐标

相关参考

ST_Simplify

6.5.24. ST_Reverse

ST_Reverse —In the reverse order of vertex returns ageometry对象

用法

geometry ST_Reverse(geometry g1);

描述

The function to support arbitrary geometry type object,In the reverse order of vertex returns ageometry对象

样例

SELECT ST_AsText(the_geom) as line, ST_AsText(ST_Reverse(the_geom)) As reverseline
FROM
(SELECT ST_MakeLine(ST_MakePoint(1,2),
ST_MakePoint(1,10)) As the_geom) as foo;
--result

line                 | reverseline
---------------------+----------------------
LINESTRING(1 2,1 10) | LINESTRING(1 10,1 2)

6.5.25. ST_Segmentize

ST_Segmentize — Returns a modifiedgeometry对象,Let the length of each segment of this object can not exceed the maximum length of the given.只在2DDimension can be calculated.For geometric objects,The length of the unit need to be inSRS表中,对于geographyGeographical objects,距离单位是米

用法

geometry ST_Segmentize(geometry geom, float max_segment_length);
geometry ST_Segmentize(geography geog, float max_segment_length);

描述

Returns a modifiedgeometry对象,Let the length of each segment of this object can not exceed the maximum length of the given.只在2DDimension can be calculated.For geometric objects,The length of the unit need to be inSRS表中,对于geographyGeographical objects,距离单位是米

  • 该查询 SELECT ST_Segmentize('LINESTRING(1 2, 3 4)',0.5);Returns the function name ambiguity error.Need to declare the correct object type,例如一个geometry或geography类型的列, 使用函数ST_GeomFromText,ST_GeogFromText 或 SELECT ST_Segmentize('LINESTRING(1 2, 3 4)'::geometry,0.5);查询

注意

This function increases the geometry on the number of pieces,And the length of the fragment will not longer than the largest length limit.

样例

SELECT ST_AsText(ST_Segmentize(
ST_GeomFromText('MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45 -33,-46 -32))'),5));

st_astext
-----------------------------------------------------------------------------------------------------
MULTILINESTRING((-29 -27,-30 -29.7,-34.886615700134 -30.758766735029,-36 -31,
-40.8809353009198 -32.0846522890933,-45 -33),(-45 -33,-46 -32))
(1 row)

SELECT ST_AsText(ST_Segmentize(ST_GeomFromText('POLYGON((-29 28, -30 40,-29 28))'),10));

st_astext
------------------------------------------------------------------------------------------------------
POLYGON((-29 28,-29.8304547985374 37.9654575824488,-30 40,-29.1695452014626 30.0345424175512,-29 28))
(1 row)

相关参考

ST_LineSubstring

6.5.26. ST_SetPoint

ST_SetPoint —Replace with the given point aLINESTRING对象的第N个点,下标从0开始

用法

geometry ST_SetPoint(geometry linestring, integer zerobasedposition,
geometry point);

描述

Replace with the given point aLINESTRING对象的第N个点,下标从0开始. In a move the vertices of geometric objects,In order to maintain and other point connection relationship,Will trigger a new connection relationship.

  • 这个函数支持3D对象,并且不会删除z坐标

样例

--Change first point in line string from -1 3 to -1 1
SELECT ST_AsText(ST_SetPoint('LINESTRING(-1 2,-1 3)', 0, 'POINT(-1 1)'));

st_astext
-----------------------
LINESTRING(-1 1,-1 3)

---Change last point in a line string (lets play with 3d linestring this time) SELECT ST_AsEWKT(ST_SetPoint(foo.the_geom,
ST_NumPoints(foo.the_geom) - 1, ST_GeomFromEWKT ('POINT(-1 1 3)')))
FROM (SELECT ST_GeomFromEWKT('LINESTRING(-1 2 3,-1 3 4, 5 6 7)') As the_geom) As foo;

st_asewkt
-----------------------
LINESTRING(-1 2 3,-1 3 4,-1 1 3)

相关参考

ST_AddPoint , ST_NPoints , ST_NumPoints , ST_PointN , ST_RemovePoint

6.5.27. ST_ShiftLongitude

ST_ShiftLongitude — Read the coordinates of each geometric object or point,If the longitude less than0,则加上360,如果大于0则不加.This function returns the latitude and longitude of the result in0到360Degree range in order to show planar map

用法

geometry ST_ShiftLongitude(geometry geomA);

描述

Read the coordinates of each geometric object or point,If the longitude less than0,则加上360,如果大于0则不加.This function returns the latitude and longitude of the result in0到360Degree range in order to show planar map

注意

This function is only applicable to latitude and longitude coordinates,比如WGS84Frame of reference of the latitude and longitude coordinates.

  • 这个函数支持3D对象,并且不会删除z坐标

  • 该函数支持 Polyhedral Surface类型几何对象.

  • 该函数支持 Triangles 和 Triangulated Irregular Network Surfaces (TIN)类型.

样例

--3d points
SELECT ST_AsEWKT(ST_ShiftLongitude(ST_GeomFromEWKT('SRID=4326;POINT(-118.58 38.38 10)')))
As geomA,
ST_AsEWKT(ST_ShiftLongitude(ST_GeomFromEWKT('SRID=4326;POINT(241.42 38.38 10)'))) As
geomB;

geomA                            | geomB
---------------------------------+-----------------------------------
SRID=4326;POINT(241.42 38.38 10) | SRID=4326;POINT(-118.58 38.38 10)

--regular line string
SELECT ST_AsText(ST_ShiftLongitude(ST_GeomFromText('LINESTRING(-118.58 38.38, -118.20 38.45)')));

st_astext
----------
LINESTRING(241.42 38.38,241.8 38.45)

参考

ST_GeomFromEWKT, ST_GeomFromText, ST_AsEWKT

6.5.28. ST_WrapX

ST_WrapX — 从 wrap 指定的 X Coordinate in segmentation of the input geometry,Then the output of each geometry element to the left(move > 0)或向右(move < 0)移动到 move Parameters specify the coordinates of the place,Then pray and set the results.

用法

geometry ST_WrapX(geometry geom, float8 wrap, float8 move);

描述

从 wrap 指定的 X Coordinate in segmentation of the input geometry,Then the output of each geometry element to the left(move > 0)或向右(move < 0)移动到 move Parameters specify the coordinates of the place,Then pray and set the results.

注意

This function can be of interest to the user elements of translation into the center of the map,Wrap to avoid the edge to the other side.

  • 该函数支持3D对象,并且不会丢弃 Z 坐标

样例

-- Move all components of the given geometries whose bounding box
-- falls completely on the left of x=0 to +360
select ST_WrapX(the_geom, 0, 360);

-- Move all components of the given geometries whose bounding box
-- falls completely on the left of x=-30 to +360
select ST_WrapX(the_geom, -30, 360);

参考

ST_ShiftLongitude

6.5.29. ST_SnapToGrid

ST_SnapToGrid — 把输入的几何对象的所有点重新组成一个规则的栅格

用法

geometry ST_SnapToGrid(geometry geomA, float originX, float originY, float sizeX, float sizeY);geometry ST_SnapToGrid(geometry geomA, float sizeX, float sizeY);
geometry ST_SnapToGrid(geometry geomA, float size);
geometry ST_SnapToGrid(geometry geomA, geometry pointOrigin, float sizeX, float sizeY, float sizeZ, float sizeM);

描述

函数形式1,2,3:The input of the geometry of all points to a center of the object and its the size of the grid as yuan.This function will remove the same like the consecutive points on the yuan,If the function of the output point is not enough to generate a given geometry object of type,那么返回值就是NULL.This function will be the input geometry object internal folding geometric objects deleted.This function is very useful to reduce the grid resolution.函数形式4:The input of the geometry of all points to a center of the object and its the size of the grid as yuan (第二个参数必须是point类型对象).If you don't want to change the input object into a grid,All dimension values are set to0

注意

该函数返回的geometryObjects may lose their simplicity(参考 ST_IsSimple).

样例

--Snap your geometries to a precision grid of 10^-3
UPDATE mytable
SET the_geom = ST_SnapToGrid(the_geom, 0.001);
SELECT ST_AsText(ST_SnapToGrid(
ST_GeomFromText(
   'LINESTRING(1.1115678 2.123, 4.111111 3.2374897, 4.11112 3.23748667) '), 0.001)
);

st_astext
-------------------------------------
LINESTRING(1.112 2.123,4.111 3.237)

--Snap a 4d geometry
SELECT ST_AsEWKT(ST_SnapToGrid(
ST_GeomFromEWKT(
   'LINESTRING(-1.1115678 2.123 2.3456 1.11111, 4.111111 3.2374897 3.1234 1.1111, -1.11111112 2.123 2.3456 1.1111112)'),
ST_GeomFromEWKT('POINT(1.12 2.22 3.2 4.4444)'), 0.1, 0.1, 0.1, 0.01) );

st_asewkt
------------------------------------------------------------------------------
LINESTRING(-1.08 2.12 2.3 1.1144,4.12 3.22 3.1 1.1144,-1.08 2.12 2.3 1.1144)

--With a 4d geometry - the ST_SnapToGrid(geom,size) only touches x and y coords but keeps m and z the same
SELECT ST_AsEWKT(ST_SnapToGrid(ST_GeomFromEWKT(
   'LINESTRING(-1.1115678 2.123 3 2.3456, 4.111111 3.2374897 3.1234 1.1111)'), 0.01) );

st_asewkt
---------------------------------------------------------
LINESTRING(-1.11 2.12 3 2.3456,4.11 3.24 3.1234 1.1111)

参考

ST_Snap , ST_AsEWKT , ST_AsText , ST_GeomFromText , ST_GeomFromEWKT ,ST_Simplify_

6.5.30. ST_Snap

ST_Snap — 把一个输入的几何对象的片段和顶点切割后重新组装成一个参考类型的几何对象

用法

geometry ST_Snap(geometry input, geometry reference, float tolerance);

描述

The geometry of an input object of fragments and vertex cut back to a reference type on the vertices of geometric objects,One of the biggest cut distance is used to control the fragment which position for cutting.Cutting a geometric object and assembled into another can improve boundary similar(Eliminate the boundary in the node intersection calculation will cause problems)The cover operation robustness of.Too many times cutting can cause the generated topology is invalid.So the position of the cutting point and the number of cutting is used to explore the method to determine how safe cut.However this can lead to some cutting omitted.

注意

Return of geometric objects may be lost simplicity (参考 ST_IsSimple ) 和有效性(参考 ST_IsValid ).

样例

图 6.5.4 A no cutting withLINESTRING展示的multipolygon 对象.

图 6.5.5 一个 MULTIPOLYGON 贴靠 LINESTRING 的实例,Should the gap from the as 1.01 .

SELECT  ST_AsText(ST_Snap(poly,line,
   ST_Distance(poly,line)*1.01)) AS polysnapped
FROM (SELECT
   ST_GeomFromText('MULTIPOLYGON(
    ((26 125, 26 200, 126 200, 126 125,26 125),
    ( 51 150, 101 150, 76 175, 51 150)),
    (( 151 100, 151 200, 176 175, 151 100 )))') As poly,
    ST_GeomFromText('LINESTRING (5 107, 54 84, 101 100)') As line
    ) As foo;

       polysnapped
---------------------------------------------------------------------------------
MULTIPOLYGON(((26 125,26 200,126 200,126 125,101 100,26 125), (51 150,101 150,76 175,51 150)), ((151 100,151 200,176 175,151 100)))

图 6.5.6 一个 MULTIPOLYGON 贴靠 LINESTRING 的实例,Should the gap from the as 1.25 .

SELECT ST_AsText(
  ST_Snap(poly,line,ST_Distance(poly,line)*1.25)
) AS polysnapped
FROM (SELECT
  ST_GeomFromText('MULTIPOLYGON(
  ((26 125, 26 200, 126 200, 126 125,26 125),
  ( 51 150, 101 150, 76 175, 51 150)),
  (( 151 100, 151 200, 176 175, 151
  100 )))') As poly,
  ST_GeomFromText('LINESTRING (5 107, 54 84, 101 100)') As line ) As foo;

       polysnapped
--------------------------------------------
MULTIPOLYGON(((5 107,26 200,126
200,126 125,101 100,54 84,5 107),
(51 150,101 150,76 175,51 150)),
((151 100,151 200,176 175,151 100)))

图 6.5.7 一个 LINESTRING 贴靠 MULTIPOLYGON 的实例,Should the gap from the as 1.01 .

SELECT ST_AsText(
   ST_Snap(line,poly,ST_Distance(poly,line)*1.01)
) AS polysnapped
FROM (SELECT
   ST_GeomFromText('MULTIPOLYGON(
   ((26 125, 26 200, 126 200, 126 125,26 125),
   ( 51 150, 101 150, 76 175, 51 150 )),
   (( 151 100, 151 200, 176 175, 151
   100 )))') As poly,
   ST_GeomFromText('LINESTRING (5 107, 54 84, 101 100)') As line) As foo;

      polysnapped
----------------------------------------------------
LINESTRING(5 107,26 125,54 84,101 100)

图 6.5.8 一个 LINESTRING 贴靠 MULTIPOLYGON 的实例,Should the gap from the as 1.25 .

SELECT ST_AsText(
   ST_Snap(line,poly,ST_Distance(poly,line)*1.25)
) AS polysnapped
FROM (SELECT
   ST_GeomFromText('MULTIPOLYGON(
   ((26 125, 26 200, 126 200, 126 125,26 125),
   ( 51 150, 101 150, 76 175, 51 150 )),
   (( 151 100, 151 200, 176 175, 151 100 )))')
   As poly,
   ST_GeomFromText('LINESTRING (5 107, 54 84, 101 100)') As line) As foo;

     polysnapped
---------------------------------
LINESTRING(26 125,54 84,101 100)

参考

ST_SnapToGrid

6.5.31. ST_SwapOrdinates

ST_SwapOrdinates — The input geometry object specified by the two coordinate exchange,And then return a new geometry object.

用法

geometry ST_SwapOrdinates(geometry geom, cstring ords);

描述

The input geometry object specified by the two coordinate exchange,And then return a new geometry object.

参数 ords 是由2个字符组成的字符串,Representatives to exchange the name of the two axes of.可用的名称包括:x,y,z,m .

  • 该函数支持 Circular String 和 Curve

  • 该函数支持3D对象,并且不会丢弃 z 坐标.

  • 该函数支持 M 坐标.

  • 该函数支持 Polyhedral 表面.

  • 该函数支持 Triangle 和 TIN.

样例

-- Scale M value by 2
SELECT ST_AsText(
ST_SwapOrdinates(
   ST_Scale(
      ST_SwapOrdinates(g,'xm'),
      2, 1
   ),
'xm')
) FROM ( SELECT 'POINT ZM (0 0 0 2)'::geometry g ) foo;
   st_astext
--------------------
POINT ZM (0 0 0 4)

参考

ST_FlipCoordinates

原网站

版权声明
本文为[A thousand sails pass by the side of the sinking boat_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208092204103170.html