Snaptogrid is the action of positioning the points in a geometry so they align with intersection points on a grid. When aligning a point with the grid, the X and Y values may be shifted by a small amount  similar to rounding. In the context of spatial data, a grid is a framework of lines that is laid down over a twodimensional representation of a spatial reference system. SQL Anywhere uses a square grid.
As a simplistic example of snaptogrid, if the grid size is 0.2, then the line from Point( 14.2321, 28.3262 ) to Point( 15.3721, 27.1128 ) would be snapped to the line from Point( 14.2, 28.4 ) to Point( 15.4, 27.2 ). Grid size is typically much smaller than this simplistic example, however, so the loss of precision is much less.
By default, SQL Anywhere automatically sets the grid size so that 12 significant digits can be stored for every point within the X and Y bounds of a spatial reference system. For example, if the range of X values is from 180 to 180, and the range of Y values is from 90 to 90, the database server sets the grid size to 1e9 (0.000000001). That is, the distance between both horizontal and vertical grid lines is 1e9. The intersection points of the grid line represents all the points that can be represented in the spatial reference system. When a geometry is created or loaded, each point's X and Y coordinates are snapped to the nearest points on the grid.
Tolerance defines the distance within which two points or parts of geometries are considered equal. This can be thought of as all geometries being represented by points and lines drawn by a marker with a thick tip, where the thickness is equal to the tolerance. Any parts that touch when drawn by this thick marker are considered equal within tolerance. If two points are exactly equal to tolerance apart, they are considered not equal within tolerance.
As a simplistic example of tolerance, if the tolerance is 0.5, then Point( 14.2, 28.4 ) and Point( 14.4, 28.2 ) are considered equal. This is because the distance between the two points (in the same units as X and Y) is about 0.283, which is less than the tolerance. Tolerance is typically much smaller than this simplistic example, however.
Tolerance can cause extremely small geometries to become invalid. Lines which have length less than tolerance are invalid (because the points are equivalent), and similarly polygons where all points are equal within tolerance are considered invalid.
Snaptogrid and tolerance are set on the spatial reference system and are always specified in same units as the X and Y (or Longitude and Latitude) coordinates. Snaptogrid and tolerance work together to overcome issues with inexact arithmetic and imprecise data. However, you should be aware of how their behavior can impact the results of spatial operations.
For planar spatial reference systems, setting grid size to 0 is never recommended as it can result in incorrect results from spatial operations. For roundEarth spatial reference systems, grid size and tolerance must be set to 0. SQL Anywhere uses fixed grid size and tolerance on an internal projection when performing roundEarth operations.
The following examples illustrate the impact of grid size and tolerance settings on spatial calculations.
Discuss this page in DocCommentXchange.

Copyright © 2014, SAP AG or an SAP affiliate company.  SAP Sybase SQL Anywhere 16.0 