5. Geospatial Functions : Spatial SQL Function Details
 
Share this page                  
Spatial SQL Function Details
An extended type of WKB format is used to represent geospatial data types internally, which looks like this:
2 bytes: data version number (starts at 1 which is current version)
4 bytes: SRID
4 bytes: geometry envelope size
4 bytes: geometry WKB size
Variable length: envelope WKB + geometry WKB
When using spatial functions, the following conventions must be followed:
All spatial functions require the internal format except the following:
All fromWKB functions
All fromText functions
All geometry type returning functions return the internal format except the following:
asBinary
asText
This means you should always wrap geometry returning functions inside asBinary or asText, whichever their preferred data format is. The following example is a valid SQL statement that will take the boundary of one column and insert it into another:
INSERT INTO boundaries VALUES (LineFromWKB(asBinary(Boundary(somePolygon))));
The following is NOT valid:
INSERT INTO boundaries VALUES (Boundary(somePolygon));