anboralabs / spatia-room

Implementation of spatia lite database to android component Room
MIT License
41 stars 4 forks source link

NOT SUPPORT 'Azimuth' function #28

Closed minsu-kim-skyautonet closed 1 year ago

minsu-kim-skyautonet commented 2 years ago

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.

dalgarins commented 2 years 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.

minsu-kim-skyautonet commented 2 years ago

I Use @SkipQueryVerification 스크린샷 2022-08-02 오전 9 13 25

and this query works with spatialite_gui

스크린샷 2022-08-02 오전 9 11 12

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 -----
dalgarins commented 2 years ago

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?

minsu-kim-skyautonet commented 2 years ago

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', ...

minsu-kim-skyautonet commented 2 years ago

same problem with QGIS. check android sqlite version. https://developer.android.com/reference/android/database/sqlite/package-summary

QGIS versions 스크린샷 2022-08-02 오후 4 51 31

spatialite_gui versions

스크린샷 2022-08-02 오후 5 02 14
dalgarins commented 2 years ago

@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.

minsu-kim-skyautonet commented 2 years ago

OK. I hope the new version is released quickly.

minsu-kim-skyautonet commented 2 years ago

'RTreeIntersects' also not supported

no such function: RTreeIntersects.

but it is old way. so i think no need to recompile for this function.

thomasbakonyi commented 1 year ago

@dalgarins Any eta on when the LWGEOM functions will be enabled?

dalgarins commented 1 year ago

@thomasbakonyi working on it, if someone wants to help I accept PR.

dalgarins commented 1 year ago

@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'

hcauqnwahs commented 1 year ago

@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:

https://github.com/sevar83/android-spatialite

dalgarins commented 1 year ago

@hcauqnwahs it is possible: implementation 'com.github.dalgarins:android-spatialite:2.1.0-alpha'