Skip to content

3. Spatial Application Development#

This chapter describes the Spatial API, which can be used by an application developer to access spatial data.

Using the Spatial API#

This section describes how to use the Spatial API. For more information on the ODBC CLI, please refer to the CLI User's Manual.

The Relationship between the Spatial API and the ODBC CLI#

The Spatial API is a library that is useful for accessing spatial objects via the ODBC CLI. It is used together with the ODBC CLI to write an ODBC application that uses spatial objects. As shown in the following diagram, the Spatial API is not directly called using the ODBC CLI, nor is it used to access an Altibase server directly. Rather, it is used alongside the ODBC CLI and an Altibase server to create and interpret spatial data.

Basic Usage#

As shown in the following diagram, a typical ODBC application can be divided into 3 stages. The Spatial API is called between these stages.

  • Initial Configuration

  • Transaction Processing

  • Termination

Certain tasks, such as processing diagnostic messages, are conducted throughout an application, and thus do not fall into only one of the above three stages.

Initial Configuration#

In this stage, environment settings are made, and connection handles are allocated and initialized. The handles that must be allocated during the initial configuration include those that are needed to call the Spatial API. The order in which the Spatial API or the ODBC API is initialized is irrelevant.

Transcation Processing#

in the following diagram. Between ODBC calls, spatial object creation and search functions are called in order to manipulate spatial objects.

Termination#

After the handles that were allocated to the application are terminated and allocated memory freed, the application itself is terminated.

Examples of Application Programming#

Search for Spatial Object#

The general method of querying spatial objects is shown below.

The ODBC CLI is used to execute a SELECT statement to search for records.

The Spatial API is used to interpret the GEOMETRY type columns in the retrieved records.

A sample application in which spatial objects are queried can be found at:

$ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

Inserting, Updating, and Deleting Spatial Objects#

Generally, spatial objects are inserted, updated and deleted as shown below.

First, the Spatial API is used to create a spatial object.

Then, the ODBC CLI is used to execute an INSERT, UPDATE or DELETE statement.

Sample applications in which spatial objects are inserted, updated and deleted can be found at:

  • $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

  • $ALTIBASE_HOME/sample/SPATIAL/deleteObject.cpp

  • $ALTIBASE_HOME/sample/SPATIAL/updateObject.cpp

Data Types and Functions for Use with the Spatial API#

The Names of Basic Data Types#

To ensure compatibility with C data types across platforms, the basic data types that are available in the Spatial API use the names of corresponding ODBC data types, or aliases for those types. The exact data type definitions can be checked by viewing the contents of: $ALTIBASE_HOME/include/acsTypes.h

The following table provides a brief description of each of the basic data types:

ODBC Type Alias Name Meaning
SQLSCHAR SChar 8-bit signed char
SQLCHAR UChar 8-bit unsigned char
SQLSMALLINT SShort 16-bit signed small integer
SQLUSMALLINT UShort 16-bit unsigned small integer
SQLINTEGER SInt 32-bit signed integer
SQLUINTEGER UInt 32 -bit unsigned integer
SQLBIGINT SLong 64-bit signed big integer
SQLUBIGINT ULong 64-bit unsigned big integer
SQLREAL SFloat 32-bit signed float number
SQLDOUBLE SDouble 64-bit signed double float number
SQLLEN vSLong 32-bit signed integer on 32-bit platform 64-bit signed integer on 64-bit platform
SQLULEN vULong 32-bit unsigned integer on 32-bit platform 64-bit unsigned integer on 64-bit platform

[Table 3‑1] The Names of Basic Data Types

The Structure of Spatial Data Types#

The names of the spatial object data structures that are stored internally in the Altibase server have the prefix "std" (which stands for "Spatio-Temporal Datatype"). Each data structure is stored, managed and interpreted in the same way on the server as it is in client applications

The definitions of these data structures can be checked by viewing the contents of: $ALTIBASE_HOME/include/stdNativeTypes.i

Object Type Member Type Meaning
stdPoint2DType mType UShort = 2001
mByteOrder SChar Byte order
mPadding SChar Padding byte for memory alignment
mSize UInt The size of the object, including the header
mMBR stdMBR Minimum boundary rectangle
mPoint stdPoint2D Point

[Table 3‑2] The Structure of Spatial Data Types

The Name of API Functions#

The names of the Spatial API functions have the prefix "ACS", which signifies "Altibase Call-level Spatial".

These functions are classified as follows, and are described in corresponding sections:

  • Handle & Error Management Functions

  • Spatial Object Creation Functions

Refer to $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp file.

  • Spatial Object Querying Functions

Refer to $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp file.

  • Endian Functions

The interface for each function can also be checked directly by viewing the following file:

$ALTIBASE_HOME/include/ulsAPI.i

Handle & Error Management Functions#

ACSAllocEnv#

This function allocates and initializes a handle, which is required in order to use the Spatial API.

Syntax#

ACSRETURN ACSAllocEnv( ACSHENV * aHandle );

Argument#

Data Type Argument Input/Output Description
ACSHENV * aHandle Output This is a pointer to an environment handle.

Return Value#

ACS_SUCCESS
ACS_INVALID_HANDLE

Description#

A handle must be allocated in order to use the Spatial API in client applications. One of the functions of this environment handle is to manage information about errors that occur during the use of the Spatial API.

Diagnosing Errors#

If this function returns ACS_INVALID_HANDLE, either NULL was input for the aHandle function argument, or else there is insufficient memory to allocate the environment handle.

ACSFreeEnv

Example#

ACSHENV sAcsEnv;
if ( ACSAllocEnv(&sAcsEnv) != ACS_SUCCESS )
{
    printf("ACSAllocEnv error!!₩n");
    exit(-1);
}

ACSFreeEnv#

This function terminates a Spatial API handle.

Syntax#

ACSRETURN ACSFreeEnv( ACSHENV  aHandle );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE

Description#

This function returns the memory that was obtained for an environment handle using ACSAllocEnv().

ACSAllocEnv

Example#

ACSHENV sAcsEnv;
…
ACSFreeEnv( sAcsEnv );

ACSError#

This function is used to retrieve error information after a call to a Spatial API function fails.

Syntax#

ACSRETURN ACSError(     ACSHENV       aHandle,
                        SQLUINTEGER   * aErrorCode, 
                        SQLSCHAR      ** aErrorMessage,
                        SQLSMALLINT   * aErrorMessageLength );

Argument#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
SQLUINTEGER* aErrorCode Output This is a pointer to a buffer in which the error code is returned.
SQLSCHAR ** aErrorMessage Output This is a pointer to a buffer in which the error message is returned.
SQLSMALLINT* aErrorMessageLength Output This is a pointer to a buffer containing the size of the returned error message, in bytes.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE

Description#

This function is used to retrieve error information after a call to a Spatial API function fails.

ACSAllocEnv

Example#

ACSHENV        sAcsEnv;
SQLUINTEGER   sAcsErrNo;
SQLSCHAR    * sErrMsg;
SQLSMALLINT   sMsgLength;
…
if( ACSCreatePoint2D( sAcsEnv, 
sGeoBuffer, 
sGeoBufferSize, 
& sPoint, 
0, 
& sGeomSize )!= ACS_SUCCESS ) 
{
 if( ACSError( sAcsEnv,  
& sAcsErrNo, 
& sErrMsg, 
& sMsgLength ) == ACS_SUCCESS )
{
        printf( "ERROR(%d) : %s\n", sErrNo, sErrMsg );
    }
}

Spatial Object Creation Functions#

ACSCreatePoint2D#

This function is used to create a POINT spatial object in 2-dimensional space.

Syntax#

ACSRETURN ACSCreatePoint2D(      ACSHENV          aHandle,
                                 stdGeometryType  * aBuffer,
                                 SQLLEN           aBufferSize,
                                 stdPoint2D       * aPoint,
                                 SQLINTEGER       aSRID,
                                 SQLLEN           * aObjLength );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aBuffer Output This is a pointer to a buffer in which to store the data for the Point object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
stdPoint2D * aPoint Input This is a pointer to information about the location of the Point object to be created.
SQLINTEGER aSRID Input This is the spatial reference system ID of the input spatial object aPoint (reserved for future use).
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a POINT spatial object as a GEOMETRY type from location data stored in the stdPoint2D structure. The definition of the stdPoint2D structure can be checked in the $ALTIBASE_HOME/include/stdNativeTypes.i file.

If aBuffer is NULL, only the size of the spatial object that was created is returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

ACSCreateLineString2D#

This function is used to create a LINESTRING spatial object in 2-dimensional space.

Syntax#

 ACSRETURN ACSCreateLineString2D( ACSHENV            aHandle,
                                  stdGeometryType    * aBuffer,
                                  SQLLEN             aBufferSize,
                                  SQLUINTEGER        aNumPoints,
                                  stdPoint2D         * aPoints,
                                  SQLINTEGER         aSRID,
                                  SQLLEN             * ObjLength);

Argument#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aBuffer Output This is a pointer to a buffer in which to store the data for the LineString object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumPoints Input This is the number of points in the object to be created.
stdPoint2D * aPoints Input This is an array of Points in which to hold the coordinates of the points of the object to be created.
SQLINTEGER aSRID Input This is the spatial reference system ID of the input spatial object aPoints (reserved for future use)
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Value#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a LINESTRING spatial object as a GEOMETRY type from input Points.

If aBuffer is NULL, only the size of the spatial object to be created will be returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumPoints must be 2 or greater.

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

ACSCreateLinearRing2D#

This function is used to create a LINEARRING spatial object in 2-dimensional space.

Syntax#

 ACSRETURN ACSCreateLinearRing2D(    ACSHENV          aHandle,
                                     stdLinearRing2D  * aBuffer,
                                     SQLLEN           aBufferSize,
                                     SQLUINTEGER      NumPoints,
                                     stdPoint2D       * aPoints,
                                     SQLLEN           * aObjLength);

Arguments#

Data Type Argument Input/Out Description
ACSHENV aHandle Input This is an environment handle.
stdLinearRing2D * aBuffer Output This is a pointer to a buffer in which to store the data for the LinearRing object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumPoints Input This is the number of points in aPoints.
stdPoint2D * aPoints Input This is an array of Points in which to hold the coordinates of the points of the object to be created.
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a LINEARRING spatial object in 2-dimensional space from input Points. The created LINEARRING object has the stdLinearRing2D structure, and is subsequently used to create a Polygon GEOMETRY object.

If aBuffer is NULL, only the size of the spatial object to be created will be returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumPoints must be 2 or greater.
ACSCreatePolygon2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

ACSCreatePolygon2D#

This function is used to create a POLYGON spatial object in 2-dimensional space..

Syntax#

ACSRETURN ACSCreatePolygon2D(      ACSHENV           aHandle,
                                   stdGeometryType   * aBuffer,
                                   SQLLEN            aBufferSize,
                                   SQLUINTEGER       aNumRings,
                                   stdLinearRing2D   ** aRings,
                                   SQLINTEGER        aSRID,
                                   SQLLEN            * aObjLength);

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType* aBuffer Output This is a pointer to a buffer in which to store the data for the spatial object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumRings Input This is the number of rings in aRings.
stdLinearRing2D** aRings Input This is an array of pointers to the Ring type objects that the Polygon will comprise.
SQLINTEGER aSRID Input This is the spatial reference system ID of the input spatial object aRings (reserved for future use).
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Value#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a Polygon GEOMETRY object from input LinearRings stored in a stdLinearRing2D structure. The definition of the stdLinearRing2D structure can be checked in the $ALTIBASE_HOME/include/stdNativeTypes.i file.

If aBuffer is NULL, only the size of the spatial object that was created is returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumRings must be 1 or greater.
ACSCreateLinearRing2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

ACSCreateMultiPoint2D#

This function is used to create a MULTIPOINT spatial object in 2-dimensional space.

Syntax#

ACSRETURN ACSCreateMultiPoint2D(    ACSHENV          aHandle,
                                    stdGeometryType  * aBuffer,
                                    SQLLEN           aBufferSize,
                                    SQLUINTEGER      aNumPoints,
                                    stdPoint2DType   ** aPoints,
                                    SQLLEN           * aObjLength);

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aBuffer Output This is a pointer to a buffer in which to store the data for the spatial object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumPoints Input This is the number of Point objects in aPoints.
stdPoint2DType ** aPoints Input This is an array of pointers to the Point objects that the MultiPoint object consists of.
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a MultiPoint GEOMETRY object from the input Point objects.

If aBuffer is NULL, only the size of the spatial object that was created is returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumPoints must be 1 or greater.
ACSCreatePoint2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

ACSCreateMultiLineString2D#

This function is used to create a MULTILINESTRING spatial object in 2-dimensional space.

Syntax#

ACSRETURN ACSCreateMultiLineString2D(
                         ACSHENV             aHandle,
                         stdGeometryType     * aBuffer,
                         SQLLEN              aBufferSize,
                         SQLUINTEGER         aNumLineStrings,
                         stdLineString2DType ** aLineStrings,
                         SQLLEN              * aObjLength );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aBuffer Output This is a pointer to a buffer in which to store the data for the spatial object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumLineStrings Input This is the number of LineStrings in aLineStrings.
stdLineString2DType ** aLineStrings Input This is an array of pointers to the LineString objects that the MultiLineString object consists of.
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a MultiLineString GEOMETRY object from the input LineString objects.

If aBuffer is NULL, only the size of the spatial object that was created is returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumLineStrings must be 1 or greater.
ACSCreateLineString2D

Example#

$ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp파일을 참고하기 바란다.

ACSCreateMultiPolygon2D#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

Syntax#

ACSRETURN ACSCreateMultiPolygon2D( ACSHENV            aHandle,
                                   stdGeometryType    * aBuffer,
                                   SQLLEN             aBufferSize,
                                   SQLUINTEGER        aNumPolygons,
                                   stdPolygon2DType   ** aPolygons,
                                   SQLLEN             * aObjLength );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aBuffer Output This is a pointer to a buffer in which to store the data for the spatial object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumPolygons Input This is the number of Polygons in aPolygons.
stdPolygon2DType ** aPolygons Input This is an array of pointers to the Polygon objects that the MultiPolygon object consists of.
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a MultiPolygon GEOMETRY object from the input Polygon objects.

If aBuffer is NULL, only the size of the spatial object that was created is returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumPoints must be 1 or greater.
ACSCreatePolygon2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

ACSCreateGeomCollection2D#

This function is used to create a GEOMETRYCOLLECTION spatial object in 2-dimensional space.

Syntax#

ACSRETURN ACSCreateGeomCollection2D( ACSHENV              aHandle,
                                     stdGeometryType      * aBuffer,
                                     SQLLEN               aBufferSize,
                                     SQLUINTEGER          aNumGeometries,
                                     stdGeometryType      ** aGeometries,
                                     SQLLEN               * aObjLength);

Argument#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle
stdGeometryType * aBuffer Output This is a pointer to a buffer in which to store the data for the spatial object to be created.
SQLLEN aBufferSize Input This is the maximum size of aBuffer, in bytes.
SQLUINTEGER aNumGeometries Input This is the number of spatial objects in aGeometries.
stdGeometryType ** aGeometries Input This is an array of pointers to the spatial objects that the GeometryCollection object consists of.
SQLLEN * aObjLength Output This is a pointer to a buffer in which the size of the spatial object that was created is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to create a GEOMETRYCOLLECTION spatial object from the input GEOMETRY objects.

If aBuffer is NULL, only the size of the spatial object that was created is returned in aObjLength.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F5(332277) Insufficient Buffer Space This error code indicates that the spatial object to be created is larger than the input buffer.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNumLineStrings must be 1 or greater.
ACSCreatePoint2D
ACSCreateLineString2D
ACSCreatePolygon2D
ACSCreateMultiPoint2D
ACSCreateMultiLineString2D
ACSCreateMultiPolygon2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/insertObject.cpp

Spatial Object Querying Functions#

ACSGetGeometryType#

This function is used to determine the type of a spatial object.

Syntax#

ACSRETURN ACSGetGeometryType(   ACSHENV            aHandle,
                                stdGeometryType    * aGeometry,
                                stdGeoTypes        * aGeoType );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aGeometry Input This is a pointer to a spatial object.
stdGeoTypes * aGeoType Output This is a pointer to a buffer in which the type of the input spatial object is returned.

Return Value#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the type of a spatial object.

The type of a spatial object is one of the following:

typedef enum stdGeoTypes
{
    STD_UNKNOWN_TYPE                = 0,
    STD_POINT_2D_TYPE               = 2001,
    STD_LINESTRING_2D_TYPE          = 2003,
    STD_POLYGON_2D_TYPE             = 2005,
    STD_MULTIPOINT_2D_TYPE          = 2011,
    STD_MULTILINESTRING_2D_TYPE     = 2013,
    STD_MULTIPOLYGON_2D_TYPE        = 2015,
    STD_GEOCOLLECTION_2D_TYPE       = 2020,
    STD_NULL_TYPE                   = 9990,  // Null Geometry Object
    STD_EMPTY_TYPE                  = 9991   // Empty Geometry Object
} stdGeoTypes;

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetGeometrySize#

This function is used to determine the amount of storage space that a spatial object occupies.

Syntax#

ACSRETURN ACSGetGeometrySize(   ACSHENV            aHandle,
                                stdGeometryType    * aGeometry,
                                SQLLEN             * aGeomSize );

Arguments#

Data Type Argument Input/Out Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aGeometry Input This is a pointer to the spatial object.
SQLLEN * aGeomSize Output This is a pointer to a buffer in which the amount of storage space occupied by the input spatial object will be returned

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the amount of storage space that a spatial object occupies.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.

Example#

ACSHENV             sAcsEnv;
stdGeometryType * sSubObj;
SQLLEN              sGeomSize;
…
if( ACSGetGeometryType( sAcsEnv, sSubObj, & sGeomSize ) 
== ACS_SUCCESS )
{
printf( "Geometry Size = %d\n", sGeomSize );    
}
else
{
    exit(-1);
}

ACSGetGeometrySizeFromWKB#

This function is used to determine the size of a GEOMETRY object. It is used before a spatial object in WKB (Well-Known Binary) format is converted to a GEOMETRY object.

Syntax#

ACSRETURN ACSGetGeometrySizeFromWKB(
                              ACSHENV             aHandle,
                              SQLCHAR             * aWKB,
                              SQLUINTEGER         aWKBLength,
                              SQLLEN              * aSize );

Arguments#

Data Type Argument Input/Out Description
ACSHENV aHandle Input This is an environment handle.
SQLCHAR * aWKB Input This is a string for a spatial object in WKB format.
SQLUINTEGER aWKBLength Input This is the length of aWKB, in bytes.
SQLLEN * aSize Output This is a pointer to a buffer in which the size of the GEOMETRY object is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the size of a GEOMETRY object. It is used before a spatial object in WKB (Well-Known Binary) format is converted to a GEOMETRY object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x511FC(332284) Invalid WKB This error message indicates that the format of the specified WKB is not valid.

Example#

ACSHENV            sAcsEnv;
SQLCHAR          * sWKB;
SQLUINTEGER        sWKBLength;
SQLLEN             sSize;
…
if( ACSGetGeometryType( sAcsEnv, sWKB, sWKBLength, & sSize ) 
    == ACS_SUCCESS )
{
    printf( "Geometry Size = %d\n", sSize );
}
else
{
    exit(-1);
}

ACSGetNumGeometries#

This function is used to determine the number of child spatial objects in a compound spatial object, such as a MultiPoint, MultiLineString, MultiPolygon or GeometryCollection object.

Syntax#

ACSRETURN ACSGetNumGeometries( ACSHENV          aHandle,
                              stdGeometryType   * aGeometry,
                              SQLUINTEGER       *aNumGeometries);

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aGeometry Input This is a pointer to a spatial object.
SQLUINTEGER * aNumGeometries Output This is a pointer to a buffer in which the number of child spatial objects that the input compound spatial object consists of is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the number of child spatial objects in a compound spatial object, such as a MultiPoint, MultiLineString, MultiPolygon or GeometryCollection object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL parameters This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function
ACSGetGeometryN

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetGeometryN#

This function is used to get the Nth child spatial object in a compound spatial object, such as a MultiPoint, MultiLineString, MultiPolygon or GeometryCollection object.

Syntax#

ACSRETURN ACSGetGeometryN( ACSHENV           aHandle,
                           stdGeometryType   * aGeometry, 
                           SQLUINTEGER       aNth,
                            stdGeometryType  ** aSubGeometry );

Arguments#

Data Type Argument Input/Out Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aGeometry Input This is a pointer to a spatial object whose child object is to be retrieved.
SQLUINTEGER aNth Input This indicates which of the compound spatial object's child spatial objects is to be retrieved. The child spatial objects of a compound spatial object are numbered starting at 1.
stdGeometryType ** aSubGeometry Output This is a pointer to a pointer to a buffer in which the child spatial object is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to get the Nth child spatial object in a compound spatial object, such as a MultiPoint, MultiLineString, MultiPolygon or GeometryCollection object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNth must satisfy the expression: 1 <= aNth <= (the number of child objects in aGeometry)
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetNumGeometries

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetExteriorRing2D#

This function is used to return the exterior ring ("ExteriorRing") of a Polygon object.

Syntax#

ACSRETURN ACSGetExteriorRing2D(
                         ACSHENV            aHandle,
                         stdPolygon2DType   * aPolygon,
                         stdLinearRing2D    ** aLinearRing );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdPolygon2DType * aPolygon Input This is a pointer to the Polygon object whose ExteriorRing is to be returned.
stdLinearRing2D ** aLinearRing Output This is a pointer to a pointer to a buffer in which the returned ExteriorRing is stored.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to return the exterior ring of a Polygon object. An ExteriorRing is the outermost LinearRing of a Polygon object. A Polygon object has only one ExteriorRing.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function. The type of aPolygon must be STD_POLYGON_2D_TYPE.
ACSGetNumInteriorRing2D
ACSGetInteriorRingNPolygon2D
ACSGetNumPointsLinearRing2D
ACSGetPointsLinearRing2D
ACSGetPointNLinearRing2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetNumInteriorRing2D#

This function is used to determine the number of interior rings ("InteriorRing") in a Polygon object.

Syntax#

ACSRETURN ACSGetNumInteriorRing2D( ACSHENV          aHandle,
                                   stdPolygon2DType * aPolygon,
                                   SQLUINTEGER      * aNumInterinor );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdPolygon2DType * aPolygon Input This is a pointer to the Polygon object for which it is desired to know the number of InteriorRings.
SQLUINTEGER * aNumInterior Output This is a pointer to a buffer in which the number of InteriorRings is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the number of interior rings ("InteriorRing") in a Polygon object. A Polygon can have 0 or more InteriorRings.

Diagonosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetExteriorRing2D,
ACSGetInteriorRingNPolygon2D
ACSGetNumPointsLinearRing2D
ACSGetPointsLinearRing2D
ACSGetPointNLinearRing2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetInteriorRingNPolygon2D#

This function is used to return the Nth InteriorRing of a Polygon object.

Syntax#

ACSRETURN ACSGetInteriorRingNPolygon2D(
                         ACSHENV            aHandle,
                         stdPolygon2DType   * aPolygon,
                         SQLUINTEGER        aNth,
                         stdLinearRing2D    ** aLinearRing );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdPolygon2DType * aPolygon Input This is a pointer to the Polygon object whose Nth InteriorRing is to be returned.
SQLUINTEGER aNth Input This indicates which InteriorRing to return.
stdLinearRing2D ** aLinearRing Output This is a pointer to a pointer to a buffer in which to return the InteriorRing.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to return the Nth InteriorRing of a Polygon object. A Polygon can have 0 or more InteriorRings.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNth must satisfy the following expression: 1 <= aNth <= (the number of InteriorRings in aPolygon)
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
Spatial Object Not
SupportedACSGetExteriorRing2D
ACSGetNumInteriorRing2D
ACSGetNumPointsLinearRing2D
ACSGetPointsLinearRing2D
ACSGetPointNLinearRing2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetNumPointsLineString2D#

This function is used to determine the number of Points that a LineString object consists of.

Syntax#

ACSRETURN ACSGetNumPointsLineString2D(
                          ACSHENV               aHandle,
                          stdLineString2DType   * aLineString,
                          SQLUINTEGER           * aNumPoints );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is a pointer to an environment handle.
stdLineString2DType * aPolygon Input This is a pointer to the LineString object for which it is desired to know the number of Points.
SQLUINTEGER* aNumPoints Output This is a pointer to a buffer in which the number of Points is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the number of Points that a LineString object consists of. A LineString must have at least two Points.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetPointsLineString2D
ACSGetPointNLineString2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetPointNLineString2D#

This function is used to return the Nth Point in a LineString object.

Syntax#

ACSRETURN ACSGetPointNLineString2D(
                          ACSHENV               aHandle,
                          stdLineString2DType   * aLineString,
                          SQLUINTEGER           aNth, 
                          stdPoint2D            * aPoint );

#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdLineString2DType * aPolygon Input This is a pointer to the LineString object whose Nth Point is to be returned.
SQLUINTEGER aNth Input This indicates which Point to return.
stdPoint2D * aPoint Output This is a pointer to a buffer in which to return the Point.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to return the Nth Point in a LineString object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNth must satisfy the following expression: 1 <= aNth <= (the number of Points in the input LineString)
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetNumPointsLineString2D
ACSGetPointsLineString2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetPointsLineString2D#

This function returns an array of Points that constitute a LineString object.

Syntax#

ACSRETURN ACSGetPointsLineString2D( ACSHENV               aHandle,
                                    stdLineString2DType   * aLineString,
                                    stdPoint2D            ** aPoints );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdLineString2DType * aPolygon Input This is a pointer to the LineString object for which the pointer to the array of Points will be returned.
stdPoint2D ** aPoints Output This is a pointer to a pointer to a buffer in which to return the Points.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function returns an array of Points that constitute a LineString object.

Diagnosing#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetNumPointsLineString2D
ACSGetPointNLineString2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetNumPointsLinearRing2D#

This function is used to determine the number of Points that a LinearRing object consists of.

Syntax#

ACSRETURN ACSGetNumPointsLinearRing2D(
                          ACSHENV               aHandle,
                          stdLinearRing2DType   * aLinearRing,
                          SQLUINTEGER           * aNumPoints );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdLinearRing2DType * aPolygon Input This is a pointer to the LinearRing object for which it is desired to know the number of Points.
SQLUINTEGER* aNumPoints Output This is a pointer to a buffer in which the number of Points is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to determine the number of Points that a LinearRing object consists of. A LinearRing must have at least two Points.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameters This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetPointsLinearRing2D
ACSGetPointNLinearRing2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetPointNLinearRing2D#

This function is used to get the Nth Point of a LinearRing object.

Syntax#

ACSRETURN ACSGetPointNLinearRing2D( ACSHENV               aHandle,
                                    stdLinearRing2DType   * aLinearRing,
                                    SQLUINTEGER           aNth, 
                                    stdPoint2D            * aPoint );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdLinearRing2DType * aPolygon Input This is a pointer to the LinearRing object whose Nth Point is to be returned.
SQLUINTEGER aNth Input This indicates which Point to return.
stdPoint2D * aPoint Output This is a pointer to a buffer in which the Point is returned.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to get the Nth Point of a LinearRing object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511F8(332280) Invalid Input Value This error code indicates that an input value is not valid. The value of aNth must satisfy the expression: 1 <= aNth <= (the number of Points in LinearRing)
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetNumPointsLinearRing2D
ACSGetPointsLinearRing2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

ACSGetPointsLinearRing2D#

This function returns the array of Points that constitute a LineString object.

Syntax#

ACSRETURN ACSGetPointsLineString2D( ACSHENV               aHandle,
                                    stdLineString2DType   * aLineString,
                                    stdPoint2D            ** aPoints );

Arguments#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdLineString2DType * aPolygon Input This is a pointer to the LinearrRing object for which the pointer to the array of Points will be returned.
stdPoint2D ** aPoints Output This is a pointer to a pointer to a buffer in which to return the Points.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function returns the array of Points that constitute a LineString object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
0x511FB(332283) Spatial Object Not Supported This error code indicates that the type of the input spatial object is not supported for use with this function.
ACSGetNumPointsLineString2D
ACSGetPointNLineString2D

Example#

Sample code can be found at: $ALTIBASE_HOME/sample/SPATIAL/selectObject.cpp

Endian Functions#

ACSEndian#

This function is used to forcibly convert the Endian of a spatial object.

Syntax#

ACSRETURN ACSEndian(     ACSHENV               aHandle,
                         stdGeomeryType        * aGeometry );

Arguments#

Data Type Argument Input/Out Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType * aGeometry Input/Output This is a pointer to the spatial object whose Endian is to be converted.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to forcibly convert the Endian of a spatial object.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Data Type This error code indicates that the input spatial object is not valid
ACSAdjustBytOrder

ACSAdjustByteOrder#

This function is used to convert the Endian of a spatial object to that of the corresponding platform.

Syntax#

ACSRETURN ACSAdjustByteOrder( ACSHENV              aHandle,
                              stdGeomeryType       * aGeometry );

Arguments#

Data Type Arguments Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType* aGeometry Input/Output This is a pointer to the spatial object whose Endian is to be converted.

Return Values#

ACS_SUCCESS
ACS_INVALID_HANDLE
ACS_ERROR

Description#

This function is used to convert the Endian (i.e. byte order) of a spatial object to that of the corresponding platform. If the byte order of a spatial object is different from that of a client host, the byte order of the spatial object is converted so that it is the same as that of the client. If the byte order of the client and the spatial object are the same to begin with, then no conversion is performed.

Diagnosing Errors#

If this function returns ACS_ERROR, use ACSError() to check the information related to the error.

ErrorCode Description Notes
0x5101C(331804) NULL Parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.
ACSEndian

ACSGetGeometrySRID#

This function convert the endian of the spatial object to the same as the platform

Syntax#

ACSRENTURN ASCGetGeometrySRID( ACSHENV aHandle,
                               stdGeometryType * aGeometry,
                               SQLINTEGER * aSRID );

Argument#

Data Type Argument Input/Output Description
ACSHENV aHandle Input This is an environment handle.
stdGeometryType* aGeometry Input This is a pointer to a spatial object.
SQLINTEGER * aSRID Output This is a pointer to buffer to get SRID of input spatial object.

Return Values#

ACS_SUCCESS
ACS_ERROR

Description#

This function is used to get the SRID of a spatial object.

Diagnosing Errors#

If the function returns ACS_ERROR, the information obtained from ACSError can be used to identify the error.

ErrorCode Description Notes
0x5101C(331804) NULL parameter This error code indicates a NULL function argument.
0x511F9(332281) Invalid Spatial Object This error code indicates that the input spatial object is not valid.

Example#

ACSHENV sAcsEnv;
stdGeometryType * sSubObj;
SQLINTEGER sSRID;
...
if ( ACSGetGeometrySRID( sAcsEnv, sSubObj, &sSRID ) == ACS_SUCCESS )
{
    printf( "SRID=%d\n", sSRID );
}
else
{
    exit(-1);
}