• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ sqlite3_result_blob函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sqlite3_result_blob函数的典型用法代码示例。如果您正苦于以下问题:C++ sqlite3_result_blob函数的具体用法?C++ sqlite3_result_blob怎么用?C++ sqlite3_result_blob使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sqlite3_result_blob函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dbpageColumn

static int dbpageColumn(
  sqlite3_vtab_cursor *pCursor, 
  sqlite3_context *ctx, 
  int i
){
  DbpageCursor *pCsr = (DbpageCursor *)pCursor;
  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;
  int rc = SQLITE_OK;
  switch( i ){
    case 0: {           /* pgno */
      sqlite3_result_int(ctx, pCsr->pgno);
      break;
    }
    case 1: {           /* data */
      DbPage *pDbPage = 0;
      rc = sqlite3PagerGet(pTab->pPager, pCsr->pgno, (DbPage**)&pDbPage, 0);
      if( rc==SQLITE_OK ){
        sqlite3_result_blob(ctx, sqlite3PagerGetData(pDbPage), pTab->szPage,
                            SQLITE_TRANSIENT);
      }
      sqlite3PagerUnref(pDbPage);
      break;
    }
    default: {          /* schema */
      sqlite3 *db = sqlite3_context_db_handle(ctx);
      sqlite3_result_text(ctx, db->aDb[pTab->iDb].zDbSName, -1, SQLITE_STATIC);
      break;
    }
  }
  return SQLITE_OK;
}
开发者ID:cznic,项目名称:cc,代码行数:31,代码来源:dbpage.c


示例2: sha3Func

/*
** Implementation of the sha3(X,SIZE) function.
**
** Return a BLOB which is the SIZE-bit SHA3 hash of X.  The default
** size is 256.  If X is a BLOB, it is hashed as is.  
** For all other non-NULL types of input, X is converted into a UTF-8 string
** and the string is hashed without the trailing 0x00 terminator.  The hash
** of a NULL value is NULL.
*/
static void sha3Func(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  SHA3Context cx;
  int eType = sqlite3_value_type(argv[0]);
  int nByte = sqlite3_value_bytes(argv[0]);
  int iSize;
  if( argc==1 ){
    iSize = 256;
  }else{
    iSize = sqlite3_value_int(argv[1]);
    if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){
      sqlite3_result_error(context, "SHA3 size should be one of: 224 256 "
                                    "384 512", -1);
      return;
    }
  }
  if( eType==SQLITE_NULL ) return;
  SHA3Init(&cx, iSize);
  if( eType==SQLITE_BLOB ){
    SHA3Update(&cx, sqlite3_value_blob(argv[0]), nByte);
  }else{
    SHA3Update(&cx, sqlite3_value_text(argv[0]), nByte);
  }
  sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
}
开发者ID:cznic,项目名称:cc,代码行数:37,代码来源:shathree.c


示例3: recordFunc

/*
 ** The implementation of the sqlite_record() function. This function accepts
 ** a single argument of any type. The return value is a formatted database
 ** record (a blob) containing the argument value.
 **
 ** This is used to convert the value stored in the 'sample' column of the
 ** sqlite_stat3 table to the record format SQLite uses internally.
 */
static void recordFunc(
                       sqlite3_context *context,
                       int argc,
                       sqlite3_value **argv
                       ){
    const int file_format = 1;
    int iSerial;                    /* Serial type */
    int nSerial;                    /* Bytes of space for iSerial as varint */
    int nVal;                       /* Bytes of space required for argv[0] */
    int nRet;
    sqlite3 *db;
    u8 *aRet;
    
    UNUSED_PARAMETER( argc );
    iSerial = sqlite3VdbeSerialType(argv[0], file_format);
    nSerial = sqlite3VarintLen(iSerial);
    nVal = sqlite3VdbeSerialTypeLen(iSerial);
    db = sqlite3_context_db_handle(context);
    
    nRet = 1 + nSerial + nVal;
    aRet = sqlite3DbMallocRaw(db, nRet);
    if( aRet==0 ){
        sqlite3_result_error_nomem(context);
    }else{
        aRet[0] = nSerial+1;
        sqlite3PutVarint(&aRet[1], iSerial);
        sqlite3VdbeSerialPut(&aRet[1+nSerial], nVal, argv[0], file_format);
        sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
        sqlite3DbFree(db, aRet);
    }
}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:39,代码来源:vdbemem.c


示例4: OGR2SQLITE_ogr_inflate

static
void OGR2SQLITE_ogr_inflate(sqlite3_context* pContext,
                            int argc, sqlite3_value** argv)
{
    if( argc != 1 ||
            sqlite3_value_type (argv[0]) != SQLITE_BLOB )
    {
        sqlite3_result_null (pContext);
        return;
    }

    size_t nOutBytes = 0;
    void* pOut;

    const void* pSrc = sqlite3_value_blob (argv[0]);
    int nLen = sqlite3_value_bytes (argv[0]);
    pOut = CPLZLibInflate( pSrc, nLen, NULL, 0, &nOutBytes);

    if( pOut != NULL )
    {
        sqlite3_result_blob (pContext, pOut, nOutBytes, VSIFree);
    }
    else
    {
        sqlite3_result_null (pContext);
    }

    return;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:29,代码来源:ogrsqlitesqlfunctions.cpp


示例5: readfileFunc

SQLITE_EXTENSION_INIT1
#include <stdio.h>

/*
** Implementation of the "readfile(X)" SQL function.  The entire content
** of the file named X is read and returned as a BLOB.  NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zName;
  FILE *in;
  long nIn;
  void *pBuf;

  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;
  in = fopen(zName, "rb");
  if( in==0 ) return;
  fseek(in, 0, SEEK_END);
  nIn = ftell(in);
  rewind(in);
  pBuf = sqlite3_malloc( nIn );
  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
  }else{
    sqlite3_free(pBuf);
  }
  fclose(in);
}
开发者ID:1018824313,项目名称:sqlite,代码行数:33,代码来源:fileio.c


示例6: fts5MatchinfoFunc

static void fts5MatchinfoFunc(
  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */
  Fts5Context *pFts,              /* First arg to pass to pApi functions */
  sqlite3_context *pCtx,          /* Context for returning result/error */
  int nVal,                       /* Number of values in apVal[] array */
  sqlite3_value **apVal           /* Array of trailing arguments */
){
  const char *zArg;
  Fts5MatchinfoCtx *p;
  int rc;

  if( nVal>0 ){
    zArg = (const char*)sqlite3_value_text(apVal[0]);
  }else{
    zArg = "pcx";
  }

  p = (Fts5MatchinfoCtx*)pApi->xGetAuxdata(pFts, 0);
  if( p==0 || sqlite3_stricmp(zArg, p->zArg) ){
    p = fts5MatchinfoNew(pApi, pFts, pCtx, zArg);
    pApi->xSetAuxdata(pFts, p, sqlite3_free);
    if( p==0 ) return;
  }

  rc = fts5MatchinfoIter(pApi, pFts, p, fts5MatchinfoLocalCb);
  if( rc!=SQLITE_OK ){
    sqlite3_result_error_code(pCtx, rc);
  }else{
    /* No errors has occured, so return a copy of the array of integers. */
    int nByte = p->nRet * sizeof(u32);
    sqlite3_result_blob(pCtx, (void*)p->aRet, nByte, SQLITE_TRANSIENT);
  }
}
开发者ID:yaoweidong,项目名称:sqlite,代码行数:33,代码来源:fts5_test_mi.c


示例7: geo_simplify

void geo_simplify(sqlite3_context *context,int argc,sqlite3_value **argv)
{
	if(argc == 2 && sqlite3_value_type(argv[0]) == SQLITE_BLOB)
	{ 
		GEOSGeometry* geometry;
		GEOSGeometry* simplify_geo;
		unsigned char* wkb;
		size_t size;
		const void* data = sqlite3_value_blob(argv[0]);
		size_t data_size = sqlite3_value_bytes(argv[0]);

		double tolerance = sqlite3_value_double(argv[1]);

		_init_geos();
		geometry = _geo_from_wkb((const unsigned char*)data,data_size);
		if(geometry != 0)
		{
			simplify_geo = GEOSSimplify(geometry,tolerance);
			if(simplify_geo != 0)
			{
				wkb = GEOSGeomToWKB_buf(simplify_geo,&size);
				sqlite3_result_blob(context,wkb,size,SQLITE_TRANSIENT);
				GEOSGeom_destroy(simplify_geo);
				GEOSFree(wkb);
			}
		}
		GEOSGeom_destroy(geometry);
		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:30,代码来源:extfunction.c


示例8: OGR2SQLITE_ST_AsBinary

static
void OGR2SQLITE_ST_AsBinary(sqlite3_context* pContext,
                            int argc, sqlite3_value** argv)
{
    OGRGeometry* poGeom = OGR2SQLITE_GetGeom(pContext, argc, argv, NULL);
    if( poGeom != NULL )
    {
        int nBLOBLen = poGeom->WkbSize();
        GByte* pabyGeomBLOB = (GByte*) VSIMalloc(nBLOBLen);
        if( pabyGeomBLOB != NULL )
        {
            if( poGeom->exportToWkb(wkbNDR, pabyGeomBLOB) == OGRERR_NONE )
                sqlite3_result_blob( pContext, pabyGeomBLOB, nBLOBLen, CPLFree);
            else
            {
                VSIFree(pabyGeomBLOB);
                sqlite3_result_null (pContext);
            }
        }
        else
            sqlite3_result_null (pContext);
        delete poGeom;
    }
    else
        sqlite3_result_null (pContext);
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:26,代码来源:ogrsqlitesqlfunctions.cpp


示例9: sqlite_callback_return

static int sqlite_callback_return(Value v, sqlite3_context *ctx)
{
    const RefNode *r_type = fs->Value_type(v);
    if (r_type == fs->cls_int) {
        int err = FALSE;
        int64_t i64 = fs->Value_int64(v, &err);
        if (err) {
            fs->throw_errorf(mod_sqlite, "SQLiteError", "'INTEGER' out of range (-2^63 - 2^63-1)");
            return FALSE;
        }
        sqlite3_result_int64(ctx, i64);
    } else if (r_type == fs->cls_bool) {
        int i32 = Value_bool(v);
        sqlite3_result_int(ctx, i32);
    } else if (r_type == fs->cls_float) {
        double dval = Value_float2(v);
        sqlite3_result_double(ctx, dval);
    } else if (r_type == fs->cls_str) {
        RefStr *s = Value_vp(v);
        sqlite3_result_text(ctx, s->c, s->size, SQLITE_TRANSIENT);
    } else if (r_type == fs->cls_bytes) {
        RefStr *s = Value_vp(v);
        sqlite3_result_blob(ctx, s->c, s->size, SQLITE_TRANSIENT);
    } else if (r_type == fs->cls_null) {
        sqlite3_result_null(ctx);
    } else {
        fs->throw_errorf(fs->mod_lang, "TypeError", "Bool, Int, Float, Str, Bytes or Null required but %n", r_type);
        return FALSE;
    }
    return TRUE;
}
开发者ID:x768,项目名称:fox-lang,代码行数:31,代码来源:m_sqlite.c


示例10: _relation_compute

static void _relation_compute(sqlite3_context *context,int argc,sqlite3_value **argv,RelationCompute Func)
{
	if(argc == 2 && sqlite3_value_type(argv[0]) == SQLITE_BLOB &&
		sqlite3_value_type(argv[1]) == SQLITE_BLOB)
	{ 
		GEOSGeometry* geometry1;
		GEOSGeometry* geometry2;
		GEOSGeometry* geo_result;
		unsigned char* wkb;
		size_t size;
		const void* data1 = sqlite3_value_blob(argv[0]);
		size_t data_size1 = sqlite3_value_bytes(argv[0]);

		const void* data2 = sqlite3_value_blob(argv[1]);
		size_t data_size2 = sqlite3_value_bytes(argv[1]);

		_init_geos();
		geometry1 = _geo_from_wkb((const unsigned char*)data1,data_size1);
		geometry2 = _geo_from_wkb((const unsigned char*)data2,data_size2);
		if(geometry1 != 0 && geometry2 != 0)
		{
			geo_result = Func(geometry1,geometry2);
			if(geo_result != 0)
			{
				wkb = GEOSGeomToWKB_buf(geo_result,&size);
				sqlite3_result_blob(context,wkb,size,SQLITE_TRANSIENT);
				GEOSGeom_destroy(geo_result);
				GEOSFree(wkb);
			}
		}
		if(geometry1!=0)GEOSGeom_destroy(geometry1);
		if(geometry2!=0)GEOSGeom_destroy(geometry2);
		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:35,代码来源:extfunction.c


示例11: readfileFunc

/*
** Implementation of the "readfile(X)" SQL function.  The entire content
** of the file named X is read and returned as a BLOB.  NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zName;
  FILE *in;
  long nIn;
  void *pBuf;

  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;
  in = fopen(zName, "rb");
  if( in==0 ) return;
  fseek(in, 0, SEEK_END);
  nIn = ftell(in);
  rewind(in);
  pBuf = sqlite3_malloc64( nIn );
  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
  }else{
    sqlite3_free(pBuf);
  }
  fclose(in);
}
开发者ID:jmptrader,项目名称:sqlite,代码行数:30,代码来源:fuzzcheck.c


示例12: ST_SRID

static void ST_SRID(sqlite3_context *context, int nbArgs, sqlite3_value **args) {
  spatialdb_t *spatialdb;
  FUNCTION_GEOM_ARG(geomblob);

  FUNCTION_START_STATIC(context, 256);
  spatialdb = (spatialdb_t *)sqlite3_user_data(context);
  FUNCTION_GET_GEOM_ARG_UNSAFE(context, spatialdb, geomblob, 0);

  if (nbArgs == 1) {
    sqlite3_result_int(context, geomblob.srid);
  } else {
    FUNCTION_GET_INT_ARG(geomblob.srid, 1);
    if (binstream_seek(&FUNCTION_GEOM_ARG_STREAM(geomblob), 0) != SQLITE_OK) {
      sqlite3_result_error(context, "Error writing geometry blob header", -1);
      goto exit;
    }
    if (spatialdb->write_blob_header(&FUNCTION_GEOM_ARG_STREAM(geomblob), &geomblob, FUNCTION_ERROR) != SQLITE_OK) {
      if (error_count(FUNCTION_ERROR) == 0) {
        error_append(FUNCTION_ERROR, "Error writing geometry blob header");
      }
      goto exit;
    }
    binstream_seek(&FUNCTION_GEOM_ARG_STREAM(geomblob), 0);
    sqlite3_result_blob(context, binstream_data(&FUNCTION_GEOM_ARG_STREAM(geomblob)), (int) binstream_available(&FUNCTION_GEOM_ARG_STREAM(geomblob)), SQLITE_TRANSIENT);
  }

  FUNCTION_END(context);
  FUNCTION_FREE_GEOM_ARG(geomblob);
}
开发者ID:boundlessgeo,项目名称:libgpkg-mobile,代码行数:29,代码来源:spatialdb.c


示例13: geo_polyline_decode

void geo_polyline_decode(sqlite3_context *context,int argc,sqlite3_value **argv)
{
	if(argc >= 1 && sqlite3_value_type(argv[0]) == SQLITE_TEXT)
	{ 
		GEOSGeometry* geometry;
		const unsigned char* data = sqlite3_value_text(argv[0]);
		int point = 1;
		size_t size = 0;

		if(argc > 1)
		{
			point = sqlite3_value_int(argv[1]);
		}

		_init_geos();
		geometry = polyline_decode(data,point);
		if(geometry != 0)
		{
			unsigned char* wkb = GEOSGeomToWKB_buf(geometry,&size);
			if(wkb != NULL)
			{
				sqlite3_result_blob(context,wkb,size,SQLITE_TRANSIENT);
				GEOSFree(wkb);
			}
		}
		GEOSGeom_destroy(geometry);
		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:29,代码来源:extfunction.c


示例14: my_load_file

extern void  my_load_file(sqlite3_context * context,
                          int               argc,
                          sqlite3_value  ** argv) {

   struct stat    statbuf;
   char          *fname;
   unsigned char *blob;
   FILE          *fp;
   size_t         nread;

   _ksu_null_if_null_param(argc, argv);
   fname = (char *)sqlite3_value_text(argv[0]);
   if (stat((const char *)fname, &statbuf) == -1) {
     sqlite3_result_null(context);
     return;
   }
   if ((blob = (unsigned char *)sqlite3_malloc((int)statbuf.st_size))
            == (unsigned char *)NULL) {
     sqlite3_result_error_nomem(context);
     return;
   }
   if ((fp = fopen(fname, "r")) != (FILE *)NULL) {
      nread = fread((void *)blob, sizeof(unsigned char),
                                  (size_t)statbuf.st_size, fp);
      fclose(fp);
      sqlite3_result_blob(context, (const void *)blob,
                          (int)nread, sqlite3_free);
   } else {
      sqlite3_free(blob);
      sqlite3_result_null(context);
   }
}
开发者ID:sfaroult,项目名称:sqlite_libs,代码行数:32,代码来源:my_load_file.c


示例15: OGR2SQLITE_Transform

static
void OGR2SQLITE_Transform(sqlite3_context* pContext,
                          int argc, sqlite3_value** argv)
{
    if( argc != 3 )
    {
        sqlite3_result_null (pContext);
        return;
    }

    if( sqlite3_value_type (argv[0]) != SQLITE_BLOB )
    {
        sqlite3_result_null (pContext);
        return;
    }

    if( sqlite3_value_type (argv[1]) != SQLITE_INTEGER )
    {
        sqlite3_result_null (pContext);
        return;
    }

    if( sqlite3_value_type (argv[2]) != SQLITE_INTEGER )
    {
        sqlite3_result_null (pContext);
        return;
    }

    int nSrcSRSId = sqlite3_value_int(argv[1]);
    int nDstSRSId = sqlite3_value_int(argv[2]);

    OGRSQLiteExtensionData* poModule =
        (OGRSQLiteExtensionData*) sqlite3_user_data(pContext);
    OGRCoordinateTransformation* poCT =
        poModule->GetTransform(nSrcSRSId, nDstSRSId);
    if( poCT == NULL )
    {
        sqlite3_result_null (pContext);
        return;
    }

    GByte* pabySLBLOB = (GByte *) sqlite3_value_blob (argv[0]);
    int nBLOBLen = sqlite3_value_bytes (argv[0]);
    OGRGeometry* poGeom = NULL;
    if( OGRSQLiteLayer::ImportSpatiaLiteGeometry(
                pabySLBLOB, nBLOBLen, &poGeom ) == CE_None &&
            poGeom->transform(poCT) == OGRERR_NONE &&
            OGRSQLiteLayer::ExportSpatiaLiteGeometry(
                poGeom, nDstSRSId, wkbNDR, FALSE,
                FALSE, FALSE, &pabySLBLOB, &nBLOBLen ) == CE_None )
    {
        sqlite3_result_blob(pContext, pabySLBLOB, nBLOBLen, CPLFree);
    }
    else
    {
        sqlite3_result_null (pContext);
    }
    delete poGeom;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:59,代码来源:ogrsqlitesqlfunctions.cpp


示例16: sqlite3_result_blob

void context::result(const blob &value, bool copy) {
	if (value.data) {
		sqlite3_result_blob(handle, value.data, value.length, (copy ? SQLITE_TRANSIENT : SQLITE_STATIC));
	}
	else {
		sqlite3_result_zeroblob(handle, value.length);
	}
}
开发者ID:ImportantProjects,项目名称:sqxx,代码行数:8,代码来源:context.cpp


示例17: substrFunc

/*
** Implementation of the substr() function.
**
** substr(x,p1,p2)  returns p2 characters of x[] beginning with p1.
** p1 is 1-indexed.  So substr(x,1,1) returns the first character
** of x.  If x is text, then we actually count UTF-8 characters.
** If x is a blob, then we count bytes.
**
** If p1 is negative, then we begin abs(p1) from the end of x[].
*/
static void substrFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const unsigned char *z;
  const unsigned char *z2;
  int len;
  int p0type;
  i64 p1, p2;

  assert( argc==3 || argc==2 );
  p0type = sqlite3_value_type(argv[0]);
  if( p0type==SQLITE_BLOB ){
    len = sqlite3_value_bytes(argv[0]);
    z = sqlite3_value_blob(argv[0]);
    if( z==0 ) return;
    assert( len==sqlite3_value_bytes(argv[0]) );
  }else{
    z = sqlite3_value_text(argv[0]);
    if( z==0 ) return;
    len = 0;
    for(z2=z; *z2; len++){
      SQLITE_SKIP_UTF8(z2);
    }
  }
  p1 = sqlite3_value_int(argv[1]);
  if( argc==3 ){
    p2 = sqlite3_value_int(argv[2]);
  }else{
    p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
  }
  if( p1<0 ){
    p1 += len;
    if( p1<0 ){
      p2 += p1;
      p1 = 0;
    }
  }else if( p1>0 ){
    p1--;
  }
  if( p1+p2>len ){
    p2 = len-p1;
  }
  if( p0type!=SQLITE_BLOB ){
    while( *z && p1 ){
      SQLITE_SKIP_UTF8(z);
      p1--;
    }
    for(z2=z; *z2 && p2; p2--){
      SQLITE_SKIP_UTF8(z2);
    }
    sqlite3_result_text(context, (char*)z, z2-z, SQLITE_TRANSIENT);
  }else{
    if( p2<0 ) p2 = 0;
    sqlite3_result_blob(context, (char*)&z[p1], p2, SQLITE_TRANSIENT);
  }
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:68,代码来源:func.c


示例18: OGR2SQLITE_ogr_geocode_set_result

static
void OGR2SQLITE_ogr_geocode_set_result(sqlite3_context* pContext,
                                       OGRLayerH hLayer,
                                       const char* pszField)
{
    if( hLayer == NULL )
        sqlite3_result_null (pContext);
    else
    {
        OGRLayer* poLayer = (OGRLayer*)hLayer;
        OGRFeatureDefn* poFDefn = poLayer->GetLayerDefn();
        OGRFeature* poFeature = poLayer->GetNextFeature();
        int nIdx = -1;
        if( poFeature == NULL )
            sqlite3_result_null (pContext);
        else if( strcmp(pszField, "geometry") == 0 &&
                 poFeature->GetGeometryRef() != NULL )
        {
            GByte* pabyGeomBLOB = NULL;
            int nGeomBLOBLen = 0;
            if( OGRSQLiteLayer::ExportSpatiaLiteGeometry(
                        poFeature->GetGeometryRef(), 4326, wkbNDR, FALSE, FALSE, FALSE,
                        &pabyGeomBLOB,
                        &nGeomBLOBLen ) != CE_None )
            {
                sqlite3_result_null (pContext);
            }
            else
            {
                sqlite3_result_blob (pContext, pabyGeomBLOB, nGeomBLOBLen, CPLFree);
            }
        }
        else if( (nIdx = poFDefn->GetFieldIndex(pszField)) >= 0 &&
                 poFeature->IsFieldSet(nIdx) )
        {
            OGRFieldType eType = poFDefn->GetFieldDefn(nIdx)->GetType();
            if( eType == OFTInteger )
                sqlite3_result_int(pContext,
                                   poFeature->GetFieldAsInteger(nIdx));
            else if( eType == OFTInteger64 )
                sqlite3_result_int64(pContext,
                                     poFeature->GetFieldAsInteger64(nIdx));
            else if( eType == OFTReal )
                sqlite3_result_double(pContext,
                                      poFeature->GetFieldAsDouble(nIdx));
            else
                sqlite3_result_text(pContext,
                                    poFeature->GetFieldAsString(nIdx),
                                    -1, SQLITE_TRANSIENT);
        }
        else
            sqlite3_result_null (pContext);
        delete poFeature;
        OGRGeocodeFreeResult(hLayer);
    }
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:56,代码来源:ogrsqlitesqlfunctions.cpp


示例19: geo_bound

void geo_bound(sqlite3_context *context,int argc,sqlite3_value **argv)
{
	if(argc >= 1)
	{
		const unsigned char* ogc;
		unsigned char* ret_geo_buf;
		size_t size;
		double x1,x2,y1,y2;
		GEOSCoordSequence* seq = 0;
		GEOSGeometry* geometry = 0;
		GEOSGeometry* middle_geo = 0;
		
		_init_geos();
		if(argc == 1 && sqlite3_value_type(argv[0]) == SQLITE_BLOB)
		{
			size = sqlite3_value_bytes(argv[0]);
			ogc = (const unsigned char*)sqlite3_value_blob(argv[0]);
			middle_geo = _geo_from_wkb(ogc,size);
		}
		else if(argc == 1 && sqlite3_value_type(argv[0]) == SQLITE_TEXT)
		{
			ogc = sqlite3_value_text(argv[0]);
			middle_geo = _geo_from_wkt(ogc);
		}
		else if(argc == 4)
		{
			x1 = sqlite3_value_double(argv[0]);
			y1 = sqlite3_value_double(argv[1]);
			x2 = sqlite3_value_double(argv[2]);
			y2 = sqlite3_value_double(argv[3]);

			seq = GEOSCoordSeq_create(2,2);
			GEOSCoordSeq_setX(seq,0,x1);
			GEOSCoordSeq_setY(seq,0,y1);
			GEOSCoordSeq_setX(seq,1,x2);
			GEOSCoordSeq_setY(seq,1,y2);

			middle_geo = GEOSGeom_createLineString(seq);
		}

		if(middle_geo != 0)
		{
			geometry = GEOSEnvelope(middle_geo);
			if(geometry != 0)
			{
				ret_geo_buf = GEOSGeomToWKB_buf(geometry,&size);
				sqlite3_result_blob(context,ret_geo_buf,size,SQLITE_TRANSIENT);
				GEOSGeom_destroy(geometry);
				GEOSFree(ret_geo_buf);
			}
			GEOSGeom_destroy(middle_geo);
		}

		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:56,代码来源:extfunction.c


示例20: fnct_gpkgMakePoint

GEOPACKAGE_DECLARE void
fnct_gpkgMakePoint (sqlite3_context * context, int argc UNUSED,
		    sqlite3_value ** argv)
{
/* SQL function:
/ gpkgMakePoint(x, y)
/
/ Creates a GeoPackage geometry POINT
/
/ returns nothing on success, raises exception on error
*/
    unsigned int len;
    int int_value;
    unsigned char *p_result = NULL;
    double x;
    double y;
    GEOPACKAGE_UNUSED ();	/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_FLOAT)
      {
	  x = sqlite3_value_double (argv[0]);
      }
    else if (sqlite3_value_type (argv[0]) == SQLITE_INTEGER)
      {
	  int_value = sqlite3_value_int (argv[0]);
	  x = int_value;
      }
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
    if (sqlite3_value_type (argv[1]) == SQLITE_FLOAT)
      {
	  y = sqlite3_value_double (argv[1]);
      }
    else if (sqlite3_value_type (argv[1]) == SQLITE_INTEGER)
      {
	  int_value = sqlite3_value_int (argv[1]);
	  y = int_value;
      }
    else
      {
	  sqlite3_result_null (context);
	  return;
      }
    gpkgMakePoint (x, y, GEOPACKAGE_DEFAULT_UNDEFINED_SRID, &p_result, &len);
    if (!p_result)
      {
	  sqlite3_result_null (context);
      }
    else
      {
	  sqlite3_result_blob (context, p_result, len, free);
      }
}
开发者ID:gfbipnet,项目名称:amigoclient,代码行数:55,代码来源:gpkgMakePoint.c



注:本文中的sqlite3_result_blob函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ stats_init函数代码示例发布时间:2022-05-31
下一篇:
C++ socketError函数代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap