Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Spatial Data Support » Spatial data » Advanced spatial topics


How polygon ring orientation works

Internally, SQL Anywhere interprets polygons by looking at the orientation of the constituent rings. As one travels a ring in the order of the defined points, the inside of the polygon is on the left side of the ring. The same rules are applied in PLANAR and ROUND EARTH spatial reference systems. In most cases, outer rings are in counter-clockwise orientation and interior rings are in the opposite (clockwise) orientation. The exception is for rings that contain the north or south pole in ROUND EARTH.

By default, polygons are automatically reoriented if they are created with a different ring orientation than the SQL Anywhere internal ring orientation. Use the POLYGON FORMAT clause of the CREATE SPATIAL REFERENCE SYSTEM statement to specify the orientation of polygon rings of the input data. This should only be done if all input data for the spatial reference system uses the same ring orientation. The polygon format can also be specified on some polygon and multisurface constructors.

For example, if you create a polygon and specify the points in a clockwise order Polygon((0 0, 5 10, 10 0, 0 0), (4 2, 4 4, 6 4, 6 2, 4 2)), the database server automatically rearranges the points to be in counter-clockwise rotation, as follows: Polygon((0 0, 10 0, 5 10, 0 0), (4 2, 4 4, 6 4, 6 2, 4 2)).

Triangle with arrows along the edge pointing counter-clockwise - this is the outer ring. Inside the triangle is a square with arrows along its edge pointing clockwise. This is the inner ring.

If the inner ring was specified before the outer ring, the outer ring would appear as the first ring

In order for polygon reorientation to work in round-Earth spatial reference systems, polygons are limited to 160° in diameter.

 See also