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

SQL Anywhere 17 » SQL Anywhere Server - Spatial Data Support

Spatial data

Spatial data is data that describes the position, shape, and orientation of objects in a defined space.

Spatial data is represented as 2D geometries in the form of points, curves (line strings and strings of circular arcs), and polygons. For example, the following image shows the state of Massachusetts, representing the union of polygons representing zip code regions.


Image showing Massachusetts broken into colorful polygons, with each polygon representing a zip code region.

Two common operations performed on spatial data are calculating the distance between geometries, and determining the union or intersection of multiple objects. These calculations are performed using predicates such as intersects, contains, and crosses.

The spatial data documentation assumes you already have some familiarity with spatial reference systems and with the spatial data you intend to work with.

Note Spatial data support for 32-bit Windows and 32-bit Linux requires a CPU that supports SSE2 instructions. This support is available with Intel Pentium 4 or later (released in 2001) and AMD Opteron or later (released in 2003).

The software provides storage and data management features for spatial data, allowing you to store information such as geographic locations, routing information, and shape data.

These information pieces are stored as points and various forms of polygons and lines in columns defined with a corresponding spatial data type (such as ST_Point and ST_Polygon). You use methods and constructors to access and manipulate the spatial data. The software also provides a set of SQL spatial functions designed for compatibility with other products.

Example

Spatial data support lets application developers associate spatial information with their data. For example, a table representing companies could store the location of the company as a point, or store the delivery area for the company as a polygon. This could be represented in SQL as:

CREATE TABLE Locations(
   ID INT,
   ManagerName CHAR(16),
   StoreName CHAR(16),
   Address ST_Point,
   DeliveryArea ST_Polygon )

The spatial data type ST_Point in the example represents a single point, and ST_Polygon represents an arbitrary polygon. With this schema, the application could show all company locations on a map, or find out if a company delivers to a particular address using a query similar to the following:

CREATE VARIABLE @pt ST_Point;
SET @pt = ST_Geometry::ST_GeomFromText( 'POINT(1 1)' );

SELECT * FROM Locations
WHERE DeliveryArea.ST_Contains( @pt ) = 1