no such function 'geomfromtext'

19 views
Skip to first unread message

Muhammad Rowaha

unread,
1:50 AM (9 hours ago) 1:50 AM
to SpatiaLite Users
I am working on porting spatialite to android for a .NET MAUI app and I have managed to achieve the following:
  • compiled spatialite v4.4.0 into libspatialite.so
  • replaced the default sqlite engine with libspatialite.so using the following code
    SQLitePCL.SQLite3Provider_dynamic_cdecl.Setup("libspatialite", new CustomSqliteAdapter("libspatialite"));
    SQLitePCL.raw.SetProvider(new SQLite3Provider_dynamic_cdecl());

this works perfectly as a replacement for the default sqlite: e.g. i can successfully run all queries that the default sqlite can. However, whenever i try to run a spatialite query, it does not work. To be precise, if i run the following code:
var insertQuery = @" INSERT INTO places (name, geom) VALUES (?, GeomFromText(?, 4326));"; var pointWKT = $"Point({-122.4194} {37.7749})"
await connection.ExecuteAsync(insertQuery, "Sample Point", pointWKT);

I get the following error: SQLiteException: 'no such function: GeomFromText'

a.fu...@lqt.it

unread,
2:56 AM (8 hours ago) 2:56 AM
to spatiali...@googlegroups.com
On Mon, 15 Jul 2024 22:46:20 -0700 (PDT), Muhammad Rowaha wrote:
> I am working on porting spatialite to android for a .NET MAUI app and
> I have managed to achieve the following:
>
> * compiled spatialite v4.4.0 into libspatialite.so
>
> * replaced the default sqlite engine with libspatialite.so using the
> following code
> SQLitePCL.SQLite3Provider_dynamic_cdecl.Setup("libspatialite", new
> CustomSqliteAdapter("libspatialite"));
> SQLitePCL.raw.SetProvider(new SQLite3Provider_dynamic_cdecl());
>
> this works perfectly as a replacement for the default sqlite: e.g. i
> can successfully run all queries that the default sqlite can.
> However,
> whenever i try to run a spatialite query, it does not work. To be
> precise, if i run the following code:
> _var insertQuery = @" INSERT INTO places (name, geom) VALUES (?,
> GeomFromText(?, 4326));"; var pointWKT = $"Point({-122.4194}
> {37.7749})"; _
> _await connection.ExecuteAsync(insertQuery, "Sample Point",
> pointWKT);_
>
> I get the following error: SQLITEEXCEPTION: 'NO SUCH FUNCTION:
> GEOMFROMTEXT'
>

Hi Muhammad,

I'm not an Android expert and I don't know .NET MAUI at all,
but the meaning of that "no suche function" error is very clear.

It can't mean anything other than the dynamic loading of the
SpatiaLite extension failed for some reason.
Your code should always check whether SQLite commands
succeed or fail, possibly reporting some appropriate
error message.

I notice you are trying to load "libspatialite", but since
version 4.2 the dynamic extension has become "mod_spatialite"

please see:
https://www.gaia-gis.it/fossil/libspatialite/wiki?name=mod_spatialite

I hope that this very general information can be useful
to you.

best regards,
Sandro


Reply all
Reply to author
Forward
0 new messages