rtree/retrieveOverlapZipcode.c
static RDM_RETCODE retrieveOverlapZipCode (RDM_DB db)
{
RDM_CURSOR cursor = NULL;
POINTSOFINTEREST poi = {0};
POINTSOFINTEREST_LOCATION_KEY keyVal = {{0}};
RDM_RTREE_KEY key = {0};
/* Set the key value for the lookup */
keyVal.location[0] = -180.0; /* Longitude is the 'x' value */
keyVal.location[1] = 43.601772; /* Latitude is the 'y' value */
keyVal.location[2] = 180.0; /* Longitude is the 'x' value */
keyVal.location[3] = 47.432251; /* Latitude is the 'y' value */
/* Set key lookup information */
key.type = RDM_RTREE_OVERLAP; /* Find any rows that overlap */
key.value = &keyVal;
key.bytesIn = sizeof (POINTSOFINTEREST_LOCATION_KEY);
/* Start an update transaction */
rc = rdm_dbStartRead (db, RDM_LOCK_ALL, 0, NULL);
if (rc == sOKAY)
{
/* Get a cursor based on the r-tree key information */
db, KEY_POINTSOFINTEREST_LOCATION, &key, &cursor);
if (rc == sOKAY)
{
/* Move to the first (should be only) row in the cursor */
rc = rdm_cursorMoveToFirst (cursor);
while (rc == sOKAY)
{
/* Read the entire row */
cursor, &poi, sizeof (POINTSOFINTEREST), NULL);
/* Move to the next result row */
if (rc == sOKAY)
{
rc = rdm_cursorMoveToNext (cursor);
}
}
/* We expect to break out of the loop with sENDOFCURSOR */
if (rc == sENDOFCURSOR)
{
rc = sOKAY;
}
/* Free the cursor */
(void) rdm_cursorFree (cursor);
}
/* End the read transaction (free locks) */
(void) rdm_dbEnd (db);
}
return rc;
}
RDM_RETCODE rdm_cursorMoveToFirst(RDM_CURSOR cursor)
Position a cursor to the first row in the collection.
RDM_RETCODE rdm_cursorMoveToNext(RDM_CURSOR cursor)
Position a cursor to the next row in the collection.
@ sENDOFCURSOR
Definition: rdmretcodetypes.h:58
RDM_RETCODE rdm_dbEnd(RDM_DB db)
End a transactional operation.
struct RDM_CURSOR_S * RDM_CURSOR
Definition: rdmtypes.h:347
RDM_RETCODE rdm_dbStartRead(RDM_DB db, const RDM_TABLE_ID *tableIds, uint32_t numTableIds, RDM_TRANS *pTrans)
Get read locks.
RDM_RETCODE rdm_cursorReadRow(RDM_CURSOR cursor, void *colValues, size_t bytesIn, size_t *bytesOut)
Read all columns from a row.
@ sOKAY
Definition: rdmretcodetypes.h:100
The RaimaDB R-tree Key data structure.
Definition: rdmtypes.h:109
RDM_RETCODE rdm_dbGetRowsByKeyInRtreeKeyRange(RDM_DB db, RDM_KEY_ID keyId, const RDM_RTREE_KEY *keyValue, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with a row set based on a R-tree.
size_t bytesIn
Definition: rdmtypes.h:111
RDM_RETCODE rdm_cursorFree(RDM_CURSOR cursor)
Free an RDM_CURSOR.
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
RDM_RTREE_TYPE type
Definition: rdmtypes.h:112
@ RDM_RTREE_OVERLAP
Definition: rdmtypes.h:91
struct RDM_DB_S * RDM_DB
Definition: rdmtypes.h:346
#define RDM_LOCK_ALL
Definition: rdmtypes.h:183
const void * value
Definition: rdmtypes.h:110