Returns a copy of the geometry with all points snapped to the specified grid.
 Syntax
 Syntaxgeometry-expression.ST_SnapToGrid(origin,cell-size-x,cell-size-y,cell-size-z,cell-size-m) Parameters
 Parameters| Name | Type | Description | 
|---|---|---|
| origin | ST_Point | The origin of the grid. | 
| cell-size-x | DOUBLE | The cell size for the grid in the X dimension. | 
| cell-size-y | DOUBLE | The cell size for the grid in the Y dimension. | 
| cell-size-z | DOUBLE | The cell size for the grid in the Z dimension. | 
| cell-size-m | DOUBLE | The cell size for the grid in the M dimension. | 
 Returns
 ReturnsST_Geometry Returns the geometry with all points snapped to the grid.
The spatial reference system identifier of the result is the same as the spatial reference system of the geometry-expression.
 Remarks
 RemarksThe ST_SnapToGrid method can be used to reduce the precision of data by snapping all points in a geometry to a grid defined by an origin and cell size.
You can specify a different cell size for each dimension. If you do not wish to snap the points of one dimension, you can use a cell size of zero.
Reducing precision may cause the resulting geometry to have different properties. For example, it may cause a simple linestring to cross itself, or it may generate an invalid geometry.
Each spatial reference system defines a grid that all geometries are automatically snapped to. You can not store more precision than this predefined grid.
By default, ST_SnapToGrid uses the original format for a geometry, if it is available. Otherwise, the internal format is used. For more information about internal and original formats, see STORAGE FORMAT clause, CREATE SPATIAL REFERENCE SYSTEM statement.
 See also
 See also Standards and compatibility
 Standards and compatibilitySQL/MM (ISO/IEC 13249-3: 2006) Vendor extension
 Example
 ExampleThe following example returns the result LineString(1.010101 20.20202, 1.015625 20.203125, 1.01 20.2).
               
| SELECT NEW ST_LineString( NEW ST_Point( 1.010101, 20.202020 ), TREAT( NEW ST_Point( 1.010101, 20.202020 ).ST_SnapToGrid( NEW ST_Point( 0.0, 0.0 ), POWER( 2, -6 ), POWER( 2, -7 ), 0.0, 0.0 ) AS ST_Point ), TREAT( NEW ST_Point( 1.010101, 20.202020 ).ST_SnapToGrid( NEW ST_Point( 1.01, 20.2 ), POWER( 2, -6 ), POWER( 2, -7 ), 0.0, 0.0 ) AS ST_Point ) ) | 
The first point of the linestring is the point ST_Point( 1.010101, 20.202020 ), snapped to the grid defined for SRID 0.
The second point of the linestring is the same point snapped to a grid defined with its origin at point ( 0.0 0.0 ), where cell size x is POWER( 2, -6 ) and cell size y is POWER( 2, -7 ).
The third point of the linestring is the same point snapped to a grid defined with its origin at point ( 1.01, 20.2 ), where cell size x is POWER( 2, -6 ) and cell size y is POWER( 2, -7 ).
|  | Discuss this page in DocCommentXchange.
                   | Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |