2010-08-30 18:39:49 +00:00
/*
* * 2010 August 30
* *
* * The author disclaims copyright to this source code . In place of
* * a legal notice , here is a blessing :
* *
* * May you do good and not evil .
* * May you find forgiveness for yourself and forgive others .
* * May you share freely , never taking more than you give .
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
# ifndef _SQLITE3RTREE_H_
# define _SQLITE3RTREE_H_
2010-08-30 11:34:39 +00:00
# include <sqlite3.h>
2010-08-30 18:39:49 +00:00
# ifdef __cplusplus
extern " C " {
# endif
2010-08-30 11:34:39 +00:00
2010-08-30 18:39:49 +00:00
typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry ;
2014-04-28 17:56:19 +00:00
typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info ;
/* The double-precision datatype used by RTree depends on the
* * SQLITE_RTREE_INT_ONLY compile - time option .
*/
# ifdef SQLITE_RTREE_INT_ONLY
typedef sqlite3_int64 sqlite3_rtree_dbl ;
# else
typedef double sqlite3_rtree_dbl ;
# endif
2010-08-30 11:34:39 +00:00
/*
* * Register a geometry callback named zGeom that can be used as part of an
* * R - Tree geometry query as follows :
* *
2010-08-30 18:39:49 +00:00
* * SELECT . . . FROM < rtree > WHERE < rtree col > MATCH $ zGeom ( . . . params . . . )
2010-08-30 11:34:39 +00:00
*/
int sqlite3_rtree_geometry_callback (
sqlite3 * db ,
const char * zGeom ,
2014-04-28 17:56:19 +00:00
int ( * xGeom ) ( sqlite3_rtree_geometry * , int , sqlite3_rtree_dbl * , int * ) ,
2010-08-30 11:34:39 +00:00
void * pContext
) ;
2010-08-30 18:39:49 +00:00
/*
* * A pointer to a structure of the following type is passed as the first
* * argument to callbacks registered using rtree_geometry_callback ( ) .
*/
struct sqlite3_rtree_geometry {
void * pContext ; /* Copy of pContext passed to s_r_g_c() */
int nParam ; /* Size of array aParam[] */
2014-04-28 17:56:19 +00:00
sqlite3_rtree_dbl * aParam ; /* Parameters passed to SQL geom function */
2010-08-30 18:39:49 +00:00
void * pUser ; /* Callback implementation user data */
void ( * xDelUser ) ( void * ) ; /* Called by SQLite to clean up pUser */
} ;
2014-04-28 17:56:19 +00:00
/*
* * Register a 2 nd - generation geometry callback named zScore that can be
* * used as part of an R - Tree geometry query as follows :
* *
* * SELECT . . . FROM < rtree > WHERE < rtree col > MATCH $ zQueryFunc ( . . . params . . . )
*/
int sqlite3_rtree_query_callback (
sqlite3 * db ,
const char * zQueryFunc ,
int ( * xQueryFunc ) ( sqlite3_rtree_query_info * ) ,
void * pContext ,
void ( * xDestructor ) ( void * )
) ;
/*
* * A pointer to a structure of the following type is passed as the
* * argument to scored geometry callback registered using
* * sqlite3_rtree_query_callback ( ) .
* *
* * Note that the first 5 fields of this structure are identical to
* * sqlite3_rtree_geometry . This structure is a subclass of
* * sqlite3_rtree_geometry .
*/
struct sqlite3_rtree_query_info {
void * pContext ; /* pContext from when function registered */
int nParam ; /* Number of function parameters */
sqlite3_rtree_dbl * aParam ; /* value of function parameters */
void * pUser ; /* callback can use this, if desired */
void ( * xDelUser ) ( void * ) ; /* function to free pUser */
sqlite3_rtree_dbl * aCoord ; /* Coordinates of node or entry to check */
unsigned int * anQueue ; /* Number of pending entries in the queue */
int nCoord ; /* Number of coordinates */
int iLevel ; /* Level of current node or entry */
int mxLevel ; /* The largest iLevel value in the tree */
sqlite3_int64 iRowid ; /* Rowid for current entry */
sqlite3_rtree_dbl rParentScore ; /* Score of parent node */
int eParentWithin ; /* Visibility of parent node */
2018-11-30 20:59:00 +00:00
int eWithin ; /* OUT: Visibility */
2014-04-28 17:56:19 +00:00
sqlite3_rtree_dbl rScore ; /* OUT: Write the score here */
2015-05-20 21:28:32 +00:00
/* The following fields are only available in 3.8.11 and later */
sqlite3_value * * apSqlParam ; /* Original SQL values of parameters */
2014-04-28 17:56:19 +00:00
} ;
/*
* * Allowed values for sqlite3_rtree_query . eWithin and . eParentWithin .
*/
# define NOT_WITHIN 0 /* Object completely outside of query region */
# define PARTLY_WITHIN 1 /* Object partially overlaps query region */
# define FULLY_WITHIN 2 /* Object fully contained within query region */
2010-08-30 18:39:49 +00:00
# ifdef __cplusplus
} /* end of the 'extern "C"' block */
# endif
# endif /* ifndef _SQLITE3RTREE_H_ */