rtree/updateZipcode.c
static RDM_RETCODE updateZipCode (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] = -116.577610; /* Longitude is the 'x' value */
keyVal.location[1] = 43.529812; /* Latitude is the 'y' value */
keyVal.location[2] = -116.577610; /* Longitude is the 'x' value */
keyVal.location[3] = 43.529812; /* Latitude is the 'y' value */
/* Set key lookup information */
key.type = RDM_RTREE_EXACT; /* Lookup the exact value */
key.value = &keyVal;
key.bytesIn = sizeof (POINTSOFINTEREST_LOCATION_KEY);
/* Start an update transaction */
rc = rdm_dbStartUpdate (db, RDM_LOCK_ALL, 0, NULL, 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);
if (rc == sOKAY)
{
/* Read the entire row */
cursor, &poi, sizeof (POINTSOFINTEREST), NULL);
/* Increase the maximum longitude/latitude, this zipcode will
now have a rectangle instead of just a point */
keyVal.location[2] =
-116.577620; /* Longitude is the 'x' value */
keyVal.location[3] = 43.529822; /* Latitude is the 'y' value */
/* Write the update row values to the database */
cursor, &poi, sizeof (POINTSOFINTEREST));
}
/* Free the cursor */
(void) rdm_cursorFree (cursor);
}
if (rc == sOKAY)
{
/* Commit the successful transaction */
rc = rdm_dbEnd (db);
}
else
{
/* Rollback the failed transaction */
(void) rdm_dbEndRollback (db);
}
}
return rc;
}
RDM_RETCODE rdm_cursorMoveToFirst(RDM_CURSOR cursor)
Position a cursor to the first row in the collection.
@ RDM_RTREE_EXACT
Definition: rdmtypes.h:80
RDM_RETCODE rdm_dbEnd(RDM_DB db)
End a transactional operation.
struct RDM_CURSOR_S * RDM_CURSOR
Definition: rdmtypes.h:306
RDM_RETCODE rdm_cursorReadRow(RDM_CURSOR cursor, void *colValues, size_t bytesIn, size_t *bytesOut)
Read all columns from a row.
The RDM R-tree Key data structure.
Definition: rdmtypes.h:99
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:101
@ sOKAY
Definition: rdmretcodetypes.h:96
RDM_RETCODE rdm_cursorFree(RDM_CURSOR cursor)
Free an RDM_CURSOR.
RDM_RETCODE rdm_dbEndRollback(RDM_DB db)
End and rollback a transactional operation.
RDM_RTREE_TYPE type
Definition: rdmtypes.h:102
struct RDM_DB_S * RDM_DB
Definition: rdmtypes.h:305
RDM_RETCODE rdm_cursorUpdateRow(RDM_CURSOR cursor, const void *colValues, size_t bytesIn)
Update all columns in a row.
#define RDM_LOCK_ALL
Definition: rdmtypes.h:170
RDM_RETCODE rdm_dbStartUpdate(RDM_DB db, const RDM_TABLE_ID *writeTableIds, uint32_t numWriteTableIds, const RDM_TABLE_ID *readTableIds, uint32_t numReadTableIds, RDM_TRANS *pTrans)
Get write locks.
RDM_RETCODE
RDM status and error return codes.
Definition: rdmretcodetypes.h:44
const void * value
Definition: rdmtypes.h:100