Closed minsu-kim-skyautonet closed 1 year ago
@minsu-kim-skyautonet Could you share your code? your method is annotated with @SkipQueryVerification
? because seems to be executing the code in sqlite android.database.sqlite.SQLiteException
and not in spatialite.
I Use @SkipQueryVerification
and this query works with spatialite_gui
QUERY
SELECT Degrees(azimuth(MakePoint(129.296934, 36.760325, 4326), MakePoint(129.29694, 36.760312, 4326)))
EXCEPTION
2022-08-02 09:12:28.681 26329-26496 E/SQLiteLog: (1) no such function: azimuth
2022-08-02 09:12:28.682 26329-26496 E/TestRunner: failed: testFindRoad(com.skyautonet.tsdtg.LocationTest)
2022-08-02 09:12:28.682 26329-26496 E/TestRunner: ----- begin exception -----
2022-08-02 09:12:28.683 26329-26496 E/TestRunner: android.database.sqlite.SQLiteException: no such function: azimuth (code 1): , while compiling: SELECT Degrees(azimuth(MakePoint(129.296934, 36.760325, 4326), MakePoint(129.29694, 36.760312, 4326)))
at org.spatialite.database.SQLiteConnection.nativePrepareStatement(Native Method)
at org.spatialite.database.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:923)
at org.spatialite.database.SQLiteConnection.prepare(SQLiteConnection.java:526)
at org.spatialite.database.SQLiteSession.prepare(SQLiteSession.java:600)
at org.spatialite.database.SQLiteProgram.<init>(SQLiteProgram.java:59)
at org.spatialite.database.SQLiteQuery.<init>(SQLiteQuery.java:43)
at org.spatialite.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at org.spatialite.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1329)
at org.spatialite.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1305)
at co.anbora.labs.spatia.db.Database.query(Database.kt:107)
at co.anbora.labs.spatia.db.Database.query(Database.kt:97)
at androidx.room.RoomDatabase.query(RoomDatabase.java:530)
at androidx.room.util.DBUtil.query(DBUtil.java:86)
at com.skyautonet.dtglite.road_db.dao.RoadDao_Impl.testAzimuth(RoadDao_Impl.java:942)
at com.skyautonet.tsdtg.LocationTest.testFindRoad(LocationTest.kt:109)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:162)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:444)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2218)
2022-08-02 09:12:28.683 26329-26496 E/TestRunner: ----- end exception -----
are you migrating your db from sqlite to spatialite? did your app has sqlite before use spatia lite? could you share a repo with a proof of concept?
i was create db from this code. i use same db for test query in mac m1.
SpatiaRoom.databaseBuilder( it.applicationContext, RoadDatabase::class.java, DB_NAME ) .createFromAsset(DB_NAME)
and the db created from QGIS to spatialite. and i changed some table column format. float -> REAL, VARCHAR -> TEXT with https://sqlitebrowser.org/
other query works well. like 'intersects', 'intersection', 'distance', ...
same problem with QGIS. check android sqlite version. https://developer.android.com/reference/android/database/sqlite/package-summary
QGIS versions
spatialite_gui versions
@minsu-kim-skyautonet thanks to reporting the issue, yes, you are right, the function is not available, I found this in the google group for spatialite: google_group
I need to recompile the native library with LWGEOM functions enable.
OK. I hope the new version is released quickly.
'RTreeIntersects' also not supported
no such function: RTreeIntersects.
but it is old way. so i think no need to recompile for this function.
@dalgarins Any eta on when the LWGEOM functions will be enabled?
@thomasbakonyi working on it, if someone wants to help I accept PR.
@minsu-kim-skyautonet and @thomasbakonyi azimuth functions are available, you need to use this spatiaroom version:
implementation 'com.github.anboralabs:spatia-room:0.2.5-alpha'
@dalgarins Would it be possible to extract the library with the recent update which added support for LWGEOM functions? I am currently using the following library as an extension to my SQLite database from here:
@hcauqnwahs it is possible: implementation 'com.github.dalgarins:android-spatialite:2.1.0-alpha'
android.database.sqlite.SQLiteException: no such function: ST_Azimuth (code 1)
android.database.sqlite.SQLiteException: no such function: Azimuth (code 1)
http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.4.0.html#p10
env
os: android 11 model : samsung A60 spatia-room : 0.2.4
how can i solve this problem.