C++ CSS HTML Java JavaScript MySQL Oracle PERL PHP SQL Unix VBScript XHTML XML Сети
Supported Spatial Data Formats (MySQL 4.0)
 
Supported Spatial Data Formats
==============================

This section describes the standard spatial data formats that are used
to represent geometry objects in queries.  They are:

   * Well-Known Text (WKT) format

   * Well-Known Binary (WKB) format


Internally, MySQL stores geometry values in a format that is not
identical to either WKT or WKB format.

Well-Known Text (WKT) Format
----------------------------

The Well-Known Text (WKT) representation of Geometry is designed to
exchange geometry data in ASCII form.

Examples of WKT representations of geometry objects are:

   * A `Point':

          POINT(15 20)

     Note that point coordinates are specified with no separating comma.

   * A `LineString' with four points:

          LINESTRING(0 0, 10 10, 20 25, 50 60)

   * A `Polygon' with one exterior ring and one interior ring:

          POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))

   * A `MultiPoint' with three `Point' values:

          MULTIPOINT(0 0, 20 20, 60 60)

   * A `MultiLineString' with two `LineString' values:

          MULTILINESTRING((10 10, 20 20), (15 15, 30 15))

   * A `MultiPolygon' with two `Polygon' values:

          MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((5 5,7 5,7 7,5 7, 5 5)))

   * A `GeometryCollection' consisting of two `Point' values and one
     `LineString':

          GEOMETRYCOLLECTION(POINT(10 10), POINT(30 30), LINESTRING(15 15, 20 20))


A Backus-Naur grammer that specifies the formal production rules for
writing WKT values may be found in the OGC specification document
referenced near the beginning of this chapter.

Well-Known Binary (WKB) Format
------------------------------

The Well-Known Binary (WKB) representation for geometric values is
defined by the OpenGIS specifications.  It is also defined in the ISO
"SQL/MM Part 3: Spatial" standard.

WKB is used to exchange geometry data as binary streams represented by
`BLOB' values containing geometric WKB information.

WKB uses 1-byte unsigned integers, 4-byte unsigned integers, and 8-byte
double-precision numbers (IEEE 754 format). A byte is 8 bits.

For example, a WKB value that corresponds to `POINT(1 1)' consists of
this sequence of 21 bytes (each represented here by two hex digits):

     0101000000000000000000F03F000000000000F03F

The sequence may be broken down into these components:

     Byte order : 01
     WKB type   : 01000000
     X          : 000000000000F03F
     Y          : 000000000000F03F

Component representation is as follows:

   
     Data Representation (XDR), respectively.

   

   * A `Point' value has X and Y coordinates, each represented as a
     double-precision value.


WKB values for more complex geometry values are represented by more
complex data structures, as detailed in the OpenGIS specification.

[Назад] [Содержание] [Вперед]

Главная