 # Spatial functions

Use the spatial functions to transform data so it can be used to create map charts.

If the map information is included in a Shape file, you do not need to use the spatial functions. However, if you have geographic information in some other type of BLOB column containing WKB (Well-Known Binary) data, then this information needs to be extracted into seven different columns

• Geometry
• XMax
• XMin
• YMax
• YMin
• XCenter
• YCenter
Note: The Geometry column is the original, binary column.

The bounding box for a geometry is called the envelope. It is specified by the four coordinates XMax, XMin, YMax and YMin. The center of the geometry is specified by the two coordinates XCenter and YCenter. These coordinate columns can be calculated from the binary WKB column using the spatial functions with the binary WKB column as an argument. In order for the map chart to identify these columns, they must also have the required property values (the same as the column names listed above) set on the mapchart.columntypeid property. This is automatically done when the spatial functions below are applied.

Function Description
GreatCircleDistance(Arg1, Arg2, Arg3, Arg4) Returns the shortest distance between two points, calculated on the surface of a unit sphere. The arguments are the latitude and longitude of the coordinates (lat1, long1, lat2, long2), expressed in degrees.

To obtain the result in a certain unit, multiply the result from the GreatCircleDistance method with the radius of the interesting sphere in the desired unit. For example, the radius of the earth is approximately 6371 km (3959 miles), so the first example below will give the distance between two cities expressed in kilometers and the second example gives it in miles.

Examples:

6371*GreatCircleDistance(57.717829, 11.990509, 42.355145, -71.057892)

3959*GreatCircleDistance(57.717829, 11.990509, 42.355145, -71.057892)

6371*GreatCircleDistance([Latitude], [Longitude], 42.355145, -71.057892)

WKBEnvelopeXCenter(Arg1) Calculates the X center of the geometry envelope and sets the XCenter value on the mapchart.columntypeid property. The argument is a binary WKB column.

Example:

WKBEnvelopeXCenter([WKB])

WKBEnvelopeXMin(Arg1) Calculates the X min of the geometry envelope and sets the XMin value on the mapchart.columntypeid property. The argument is a binary WKB column.

Example:

WKBEnvelopeXMin([WKB])

WKBEnvelopeXMax(Arg1) Calculates the X max of the geometry envelope and sets the XMax value on the mapchart.columntypeid property. The argument is a binary WKB column.

Example:

WKBEnvelopeXMax([WKB])

WKBEnvelopeYCenter(Arg1) Calculates the Y center of the geometry envelope and sets the YCenter value on the mapchart.columntypeid property. The argument is a binary WKB column.

Example:

WKBEnvelopeYCenter([WKB])

WKBEnvelopeYMin(Arg1) Calculates the Y min of the geometry envelope and sets the YMin value on the mapchart.columntypeid property. The argument is a binary WKB column.

Example:

WKBEnvelopeYMin([WKB])

WKBEnvelopeYMax(Arg1) Calculates the Y max of the geometry envelope and sets the YMax value on the mapchart.columntypeid property. The argument is a binary WKB column.

Example:

WKBEnvelopeYMax([WKB])