Returns the WKB representation of an ST_Geometry value.
geometry-expression.ST_AsBinary([ format])
Name | Type | Description |
---|---|---|
format |
VARCHAR(128) |
A string defining the output binary format to use when converting the geometry-expression to a binary representation. If not specified, the value of the st_geometry_asbinary_format option is used to choose the binary representation. See st_geometry_asbinary_format option. |
LONG BINARY Returns the WKB representation of the geometry-expression.
The ST_AsBinary method returns a binary string representing the geometry. A number of different binary formats are supported (with associated options) and the desired format is selected using the optional format parameter. If the format parameter is not specified, the st_geometry_asbinary_format option is used to select the output format to use. See st_geometry_asbinary_format option.
The format string defines an output format and parameters to the format. The format string has one of the following formats:
format-name |
format-name(parameter1=value1;parameter2=value2;...) |
parameter1=value1;parameter2=value2;... |
The first format specifies the format name and no parameters. All format parameters use their default values. The second format specifies the format name and a list of named parameter values. Parameters that are not supplied use their default values. The last format specifies only parameter values, and the format name defaults to 'WKB'.
The following format names may be used:
WKB The Well-Known Binary format defined by SQL/MM and the OGC.
EWKB The Extended Well-Known Binary format defined by PostGIS. This format includes the geometry's SRID and it differs from WKB in the way it represents Z and M values.
The following format parameters can be specified:
Format Name | Parameter Name | Default Value | Allowed Values | Description |
---|---|---|---|---|
WKB | Version | 1.2 |
|
The version parameter controls the version of the WKB specification used. |
When converting a geometry value to BINARY, the server uses the ST_AsBinary method. The st_geometry_asbinary_format option defines the format that is used for the conversion. See st_geometry_asbinary_format option.
By default, ST_AsBinary 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.
SQL/MM (ISO/IEC 13249-3: 2006) 5.1.37
If the st_geometry_asbinary_format option has its default value of 'WKB', the following returns the result 0x01b90b0000000000000000f03f000000000000004000000000000008400000000000001040
.
SELECT NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ).ST_AsBinary() |
If the st_geometry_asbinary_format option has its default value of 'WKB', the following returns the result 0x01b90b0000000000000000f03f000000000000004000000000000008400000000000001040
.
The server implicitly invokes the ST_AsBinary method when converting geometries to BINARY.
SELECT CAST( NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ) AS LONG BINARY) |
The following returns the result 0x0101000000000000000000f03f0000000000000040
.
The Z and M values are omitted because version 1.1 of the OGC specification for WKB does not support these.
SELECT NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ).ST_AsBinary('WKB(Version=1.1)') |
The following returns the result 0x01010000e0e6100000000000000000f03f000000000000004000000000000008400000000000001040
.
The extended WKB contains the SRID.
SELECT NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ).ST_AsBinary('EWKB') |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |