我在理智的尽头试图让 spatialite 使用适用于 iOS6(或任何其他版本)的 xcode 4.5 进行编译。实际上,我可以使用基于 Build a static library for iOS 的技术来编译它 - 特别是在控制台返回一切正常但当我运行诸如
"select pk_uid from uk_highways order by GLength(geometry) limit 2" 该语句不会准备。
运行查询“从 uk_highways 限制 2 中选择 pk_uid”将返回 2 个 id,即取出空间函数 - 工作正常(是的,表中有一个几何列)
我已经敲了 3 天了,真的需要一些帮助,我不想这么说,但我想我什至需要一个“白痴指南”,如果有的话。
编辑:不知道为什么我第一次不包括这个:
-(int)getStreetLength
{
int length;
NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"dhub_spatial" ofType:@"sqlite"];
sqlite3 *db;
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK)
{
NSLog(@"***** database opened ********");
spatialite_init(1);
char *sql = "SELECT pk_uid from united_kingdom_highways where pk_uid < 100 order by GLength(Geometry) limit 2;";
sqlite3_stmt *stmt;
if (sqlite3_prepare(db, sql, -1, &stmt, NULL) == SQLITE_OK)
{
NSLog(@"***** statement prepared ********");
while (sqlite3_step(stmt) == SQLITE_ROW)
{
NSLog(@"***** all the way throug to the while loop ********");
length = sqlite3_column_int(stmt, 0);
NSLog(@"the value of pkuid is %i",length);
}
}
else
{
NSLog(@"could not prepare statement: %s\n", sqlite3_errmsg(db)); //this returns no such function GLength
}
}
return length;
}