1

I am at the end of my sanity trying to get spatialite to compile with xcode 4.5 for iOS6 (or any other version). Actually, I can get it to compile using a technique based on Build a static library for iOS - specifically spatialite where the console returns that all is oK but when I run a query such as

"select pk_uid from uk_highways order by GLength(geometry) limit 2" the statement won't prepare.

Running the query "select pk_uid from uk_highways limit 2" will return 2 id's i.e. taking out the spatial function - works fine (and yes, there is a geometry column in the table)

I have been banging my head for 3 days now and really need some help, I hate to say it but I think I even need an "idiots guide" if there is one out there.

EDIT: not sure why I didn't include this first time round:

-(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;
}
Community
  • 1
  • 1
hamishkeith
  • 186
  • 2
  • 5
  • "won't prepare" is rather vague. – CL. Nov 04 '12 at 18:45
  • Thanks - you are right (never type when frustrated!). It doesn't help much but catching the error from the sqlite database gives "sqliteTest2[6441:c07] could not prepare statement: no such function: GLength" which is perhaps what you would expect. The annoying thing is that this is after the database has told me the following.SpatiaLite version ..: 2.3.1 Supported Extensions: - 'VirtualShape' [direct Shapefile access] - 'VirtualText [direct CSV/TXT access] - 'VirtualNetwork [Dijkstra shortest path] - 'RTree' [Spatial Index - R*Tree] .... (truncated due to char limit on replies) – hamishkeith Nov 04 '12 at 18:58
  • Does `SELECT spatialite_version()` work? – CL. Nov 05 '12 at 07:40
  • Are you linking with SQLite or SpatialLte or both? – CL. Nov 05 '12 at 07:40
  • Hi. I am linking with Both and select spatiality_version() gives me 2.3.1 (which I know is an old version but actually is the only one I can get working at all). – hamishkeith Nov 05 '12 at 08:40
  • Hi. I have the same problem here: http://stackoverflow.com/questions/16516654/error-no-such-function-geomfromtext. I don't know if I have to link only with SpatiaLite or with Spatialite and SQLite. – VansFannel May 13 '13 at 07:20
  • No GLength() implies a build without GEOS. – BradHards Jan 07 '14 at 22:46

0 Answers0