From: Regina Obe Date: Fri, 24 Oct 2008 14:53:13 +0000 (+0000) Subject: Move over ST_SnapToGrid X-Git-Tag: 1.4.0b1~588 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18c9fa453a2daf44cf2b5ec573352e32922fae73;p=postgis Move over ST_SnapToGrid git-svn-id: http://svn.osgeo.org/postgis/trunk@3168 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference.xml b/doc/reference.xml index f25c703e5..88a2ce2d2 100644 --- a/doc/reference.xml +++ b/doc/reference.xml @@ -673,51 +673,7 @@ z' = z This method is a subcase of the 3D method - - ST_SnapToGrid(geometry, originX, originY, sizeX, sizeY) - - ST_SnapToGrid(geometry, sizeX, sizeY) - - ST_SnapToGrid(geometry, size) - - - Snap all points of the input geometry to the grid defined by - its origin and cell size. Remove consecutive points falling on the - same cell, eventually returning NULL if output points are not - enough to define a geometry of the given type. Collapsed - geometries in a collection are stripped from it. - - - The returned geometry might loose its simplicity (see - ). - - - - Before release 1.1.0 this function always returned a 2d - geometry. Starting at 1.1.0 the returned geometry will have same - dimensionality as the input one with higher dimension values - untouched. Use the version taking a second geometry argument to - define all grid dimensions. - - - Availability: 1.0.0RC1 - - - - - ST_SnapToGrid(geometry, geometry, sizeX, sizeY, sizeZ, - sizeM) - - - Snap all points of the input geometry to the grid defined by - its origin (the second argument, must be a point) and cell sizes. - Specify 0 as size for any dimension you don't want to snap to a - grid. - - Availability: 1.1.0 - - - + diff --git a/doc/reference_new.xml b/doc/reference_new.xml index 003eea0f7..6530eca17 100644 --- a/doc/reference_new.xml +++ b/doc/reference_new.xml @@ -3948,6 +3948,138 @@ SELECT ST_AsText(ST_SetPoint('LINESTRING(-1 2,-1 3)', 1, 'POINT(-1 1)')); + + + ST_SnapToGrid + + Snap all points of the input geometry to the grid defined by + its origin and cell size. Remove consecutive points falling on the + same cell, eventually returning NULL if output points are not + enough to define a geometry of the given type. Collapsed + geometries in a collection are stripped from it. Useful for reducing precision. + + + + + + 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 + + + + + + Description + + Variant 1,2,3: Snap all points of the input geometry to the grid defined by + its origin and cell size. Remove consecutive points falling on the + same cell, eventually returning NULL if output points are not + enough to define a geometry of the given type. Collapsed + geometries in a collection are stripped from it. + + + Variant 4: Introduced 1.1.0 - Snap all points of the input geometry to the grid defined by + its origin (the second argument, must be a point) and cell sizes. + Specify 0 as size for any dimension you don't want to snap to a + grid. + + + The returned geometry might loose its simplicity (see + ). + + + + Before release 1.1.0 this function always returned a 2d + geometry. Starting at 1.1.0 the returned geometry will have same + dimensionality as the input one with higher dimension values + untouched. Use the version taking a second geometry argument to + define all grid dimensions. + + + Availability: 1.0.0RC1 + Availability: 1.1.0 - Z and M support + + + + + + + This function supports 3d and will not drop the z-index. + + + + + Examples + + +--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) + + + + + + + See Also + + , , , , + + + ST_Transform