B4A Library Spatialite

Spatialite wraps the splite-android project enabling you to create databases with geo-spatial features and make queries using geo-spatial functions.

Spatialite is an enhancement of the SQLite database.
It has dedicated column data types for spatial features: Points, Polylines and Polygons, and various query functions that enable fast and efficient retrieval of spatial data from the database.
The official reference for version 3.0.0 of spatialite can be found here: http://www.gaia-gis.it/gaia-sins/spatialite-sql-3.0.0.html.
(The B4A spatialite library is based on version 3.0.1 of spatialite).

Spatialite
Comment:
Spatialite is an SQLite extension for the Android platform.
Currently version 3.0.1 of Spatialite is wrapped by this library.
Spatialite is compiled using geos v3.3.6 and proj4 v4.8.0 patched.
Version: 1.10
  • Spatialite_Blob
    Methods:
    • Close
    • IsInitialized As Boolean
  • Properties:
    • InputStream As InputStreamWrapper [read only]
      Return InputStream for this blob.
    • OutputStream As OutputStreamWrapper [read only]
      Return OutputStream for this blob.
  • Spatialite_Callback
    Events:
    • Columns (ColumnData() As String)
    • NewRow (RowData() As String) As Boolean
    • Types (TypeData() As String)
  • Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
  • Spatialite_Constants
    Fields:
    • SQLITE_OPEN_AUTOPROXY As Int
    • SQLITE_OPEN_CREATE As Int
    • SQLITE_OPEN_DELETEONCLOSE As Int
    • SQLITE_OPEN_EXCLUSIVE As Int
    • SQLITE_OPEN_FULLMUTEX As Int
    • SQLITE_OPEN_MAIN_DB As Int
    • SQLITE_OPEN_MAIN_JOURNAL As Int
    • SQLITE_OPEN_MASTER_JOURNAL As Int
    • SQLITE_OPEN_NOMUTEX As Int
    • SQLITE_OPEN_PRIVATECACHE As Int
    • SQLITE_OPEN_READONLY As Int
    • SQLITE_OPEN_READWRITE As Int
    • SQLITE_OPEN_SHAREDCACHE As Int
    • SQLITE_OPEN_SUBJOURNAL As Int
    • SQLITE_OPEN_TEMP_DB As Int
    • SQLITE_OPEN_TEMP_JOURNAL As Int
    • SQLITE_OPEN_TRANSIENT_DB As Int
    • SQLITE_OPEN_URI As Int
    • SQLITE_OPEN_WAL As Int
  • Spatialite_Database
    Methods:
    • BusyTimeout (Milliseconds As Int)
      Set the timeout for waiting for an SQLite table to become unlocked.
    • Close
      Close the SpatiaLite database file.
    • CreateAggregate (FunctionName As String, NumberArgs As Int, Function1 As Function)
      Create aggregate user defined function.
    • CreateFunction (FunctionName As String, NumberArgs As Int, Function1 As Function)
      Create regular user defined function.
    • ErrorMessage As String
      Return last error message of SQLite3 engine.
    • Exec (Query As String, Callback1 As CallbackImpl)
      The Callback events never seem to get raised, check if this is executing on a non UI thread.
      Or catch the exception in this method to debug...
    • GetTable (Query As String) As TableResult
    • GetTable2 (Query As String, MaxRows As Int) As TableResult
    • Initialize
    • IsInitialized As Boolean
    • LastError As Int
      Return the code of the last error that occurred in any of the Exec methods.
    • LastInsertRowId As Long
      Return the row identifier of the last inserted row.
    • Open (DatabasePath As String, DatabaseFileName As String, OpenMode As Int)
      Open a SpatiaLite database file.
    • OpenBlob (DatabaseName As String, TableName As String, ColumnName As String, Row As Long, ReadWrite As Boolean) As Blob
      Open an SQLite3 blob.
      The returned Blob will not be initialized if an error occurs.
    • Prepare (Query As String) As Stmt
      Prepare and return SQLite3 statement for SQL.
    • SetEncoding (Encoding As String)
      Set character encoding.
  • Spatialite_Function
    Events:
    • Function (FunctionContext1 As FunctionContext, Arguments() As String)
    • LastStep (FunctionContext1 As FunctionContext)
    • Step (FunctionContext1 As FunctionContext, Arguments() As String)
  • Methods:
    • Initialize (EventName As String)
      Initialize this user defined Function.
      Raises the events:
      Function(FunctionContext1 As FunctionContext, Arguments() As String).
      LastStep(FunctionContext1 As FunctionContext).
      Step(FunctionContext1 As FunctionContext, Arguments() As String).
    • IsInitialized As Boolean
  • Spatialite_FunctionContext
    Methods:
    • Count As Int
      Retrieve number of rows for aggregate function.
    • IsInitialized As Boolean
    • SetError (Error As String)
      Set function result from error message.
    • SetResultBytes (Result() As Byte)
      Set function result from byte array.
    • SetResultDouble (Result As Double)
      Set function result from double.
    • SetResultInt (Result As Int)
      Set function result from integer.
    • SetResultString (Result As String)
      Set function result from string.
    • SetResultZeroBlob (Size As Int)
      Set function result as empty blob given size.
  • Spatialite_Stmt
    Methods:
    • BindBytes (Position As Int, Bytes() As Byte)
      Bind positional byte array to compiled statement.
    • BindDouble (Position As Int, Double1 As Double)
      Bind positional double value to compiled statement.
    • BindInt (Position As Int, Integer1 As Int)
      Bind positional integer value to compiled statement.
    • BindLong (Position As Int, Long1 As Long)
      Bind positional long value to compiled statement.
    • BindNull (Position As Int)
      Bind positional SQL null to compiled statement.
    • BindParameterCount As Int
      Return number of parameters in compiled statement.
    • BindParameterIndex (Name As String) As Int
      Return index of named parameter in compiled statement.
    • BindParameterName (Position As Int) As String
      Return name of parameter in compiled statement.
    • BindString (Position As Int, String1 As String)
      Bind positional String to compiled statement.
    • BindZeroBlob (Position As Int, Length As Int)
      Bind positional zero'ed blob to compiled statement.
    • ClearBindings
      Clear all bound parameters of the compiled statement.
    • Close
      Close the compiled statement.
    • Column (ColumnIndex As Int) As Object
      Retrieve column data as Object from exec'ed statement.
    • ColumnBytes (ColumnIndex As Int) As Byte[]
      Retrieve blob column from exec'ed statement.
    • ColumnCount As Int
      Retrieve number of columns of exec'ed statement.
    • ColumnDatabaseName (ColumnIndex As Int) As String
      Return database name of column of statement.
    • ColumnDeclaredType (ColumnIndex As Int) As String
      Return declared column type of statement.
    • ColumnDouble (ColumnIndex As Int) As Double
      Retrieve double column from exec'ed statement.
    • ColumnInt (ColumnInt As Int) As Int
      Retrieve integer column from exec'ed statement.
    • ColumnLong (ColumnIndex As Int) As Long
      Retrieve long column from exec'ed statement.
    • ColumnName (ColumnIndex As Int) As String
      Return column name of column of statement.
    • ColumnOriginalName (ColumnIndex As Int) As String
      Return origin column name of column of statement.
    • ColumnString (ColumnIndex As Int) As String
      Retrieve string column from exec'ed statement.
    • ColumnTableName (ColumnIndex As Int) As String
      Return table name of column of statement.
    • ColumnType (ColumnIndex As Int) As Int
      Retrieve column type from exec'ed statement.
    • IsInitialized As Boolean
    • Prepare As Boolean
      Prepare the next SQL statement for the Stmt instance.
    • Reset
      Reset the compiled statement without clearing parameter bindings.
    • Status (Op As Int, Flag As Boolean) As Int
      Return statement status information.
    • Step As Boolean
      Perform one step of compiled statement.
  • Spatialite_StringEncoder
    Methods:
    • Decode (String1 As String) As Byte[]
      Decodes the given string that is assumed to be a valid encoding of a byte array.
      Typically the given string is generated by the StringEncoder Encode method.
    • Encode (Bytes() As Byte) As String
      Encodes the given byte array into a string that can be used by the SQLite database.
      The database cannot handle null (0x00) and the character '\'' (0x27).
      The encoding consists of escaping these characters with a reserved character (0x01).
    • EncodeX (Bytes() As Byte) As String
      Encodes the given byte array into SQLite3 blob notation, ie X'..'
  • Spatialite_TableResult
    Methods:
    • AtMaxRows As Boolean
      Flag to indicate MaxRows condition.
    • Clear
    • IsInitialized As Boolean
  • Properties:
    • Column() As String [read only]
      Column names of the result set.
    • MaxRows As Int [read only]
      Maximum number of rows to hold in the table.
    • NumberColumns As Int [read only]
      Number of columns in the result set.
    • NumberRows As Int [read only]
    • Rows() As String [read only]
      Rows of the result set.
      Returns an Array of String Arrays, where each String Array represents a row of the result.
    • Types() As String [read only]
      Types of columns of the result set or Null.

Please note that i have only tested a small number of the library objects, if you find any bugs please post a bug report and i'll do my best to fix it.

The Spatialite.jar library file is over 14MBs in size so too large to attach to a forum post.
So you can find the library files here: http://b4a.martinpearman.co.uk/spatialite/ (Spatialite_library_files_v2.20.zip).
Also available at that link is SpatialiteGUI - a small Windows utility that will likely be very handy for you developers.

Martin.
 
Last edited:

warwound

Expert
Licensed User
Longtime User
A bit of Googling suggests that the spatialite library should work in plain java - and therefore b4j.
But your exception shows that java fails to find and load the .so library file.

Can you find out what is the value of 'java.library.path' and then copy the .so file to this location?
 

gvoulg

Member
Licensed User
Longtime User
Hi Martin
You mean the libjsqlite.so file thats inside /lib/x86 directory in spatialite.jar?
Tried to copy it in different directories on my computer with no success.
I get 'java.library.path' with java -xshowsettings: properties in command line window
I get same error log
Regards
 

Lykaion

Member
Licensed User
Longtime User
Hi everybody, I have a little problem and I hope to find some help here :(
This is my code:

B4X:
Dim DBCon As Spatialite_Database
    Dim DBRec As Spatialite_TableResult
    Dim sqlcostanti As Spatialite_Constants
    'connessione all'archivio
    DBCon.Initialize()
    DBCon.Open(File.DirDefaultExternal, spatialite.nomedb, sqlcostanti.SQLITE_OPEN_READWRITE)
    DBRec = DBCon.GetTable("SELECT astext(ST_Transform(geomfromtext('POINT(11 40)', 4326),3857))")
        Log(DBRec.Rows(0,0))
    DBCon.Close

I think the code is ok, is really simple, but it give me always null values in the log and when i remove the ST_Transform it work fine.
I've tried to change each srids but the result not change...
If is useful, watching for my spatialite version the system response is 4.0.0, anyone had similar problems?
Every help is really apreciated :(
 

M6SOFT

Member
Licensed User
Longtime User
Hi everybody, I have a little problem and I hope to find some help here :(
This is my code:

B4X:
Dim DBCon As Spatialite_Database
    Dim DBRec As Spatialite_TableResult
    Dim sqlcostanti As Spatialite_Constants
    'connessione all'archivio
    DBCon.Initialize()
    DBCon.Open(File.DirDefaultExternal, spatialite.nomedb, sqlcostanti.SQLITE_OPEN_READWRITE)
    DBRec = DBCon.GetTable("SELECT astext(ST_Transform(geomfromtext('POINT(11 40)', 4326),3857))")
        Log(DBRec.Rows(0,0))
    DBCon.Close

I think the code is ok, is really simple, but it give me always null values in the log and when i remove the ST_Transform it work fine.
I've tried to change each srids but the result not change...
If is useful, watching for my spatialite version the system response is 4.0.0, anyone had similar problems?
Every help is really apreciated :(
Try
AsText(Transform(GeomFromText('POINT(11 40)',4326), 3857))
 

Lykaion

Member
Licensed User
Longtime User
Try
AsText(Transform(GeomFromText('POINT(11 40)',4326), 3857))

I've found the solution :D
I've tried to create the db from sqlite library, unfortunately with this way the system can't create the spatialite structure and relative tables, creating the db in my pc and after copy the file all works fine!
 

MrYang

New Member
Licensed User
Longtime User
Hi Martin
I used two libraries in the same project,LibGDX library and spatialite library.

B4X:
    Dim SpatialiteConstants As Spatialite_Constants
    Dim SpatialiteDatabase As Spatialite_Database
    Dim lgdx As LibGDX

    SpatialiteDatabase.Initialize
    SpatialiteDatabase.Open(DATABASE_PATH,DATABASE_FILENAME,SpatialiteConstants.SQLITE_OPEN_READWRITE)
    lgdx.Initialize("")

I got a problem:

PackageAdded: package:b4a.SpatialiteTest1
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 424)
java.lang.UnsatisfiedLinkError: No implementation found for void jsqlite.Database.internal_init() (tried Java_jsqlite_Database_internal_1init and Java_jsqlite_Database_internal_1init__)
at jsqlite.Database.internal_init(Native Method)
at jsqlite.Database.<clinit>(Database.java:1025)
at uk.co.martinpearman.b4a.spatialite.Database.Initialize(Database.java:76)
at b4a.SpatialiteTest1.main._activity_create(main.java:424)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.SpatialiteTest1.main.afterFirstLayout(main.java:104)
at b4a.SpatialiteTest1.main.access$000(main.java:17)
at b4a.SpatialiteTest1.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6360)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
 

PABLO2013

Well-Known Member
Licensed User
Longtime User
If you can change the target version......targetSdkVersion xx....sample 21 or 23...
 

warwound

Expert
Licensed User
Longtime User
Spatialite library updated to version 2.00

This update makes no changes to the library methods, instead it contains an updated version of the native C spatialite library.
Version 5.0.0 of spatialite native C library is wrapped, this version supports the following CPU architectures:

arm64-v8a
armeabi-v7a
x86_64

Download the latest version from:
 

synasir

Member
Licensed User
Longtime User
Spatialite wraps the splite-android project enabling you to create databases with geo-spatial features and make queries using geo-spatial functions.

Spatialite is an enhancement of the SQLite database.
It has dedicated column data types for spatial features: Points, Polylines and Polygons, and various query functions that enable fast and efficient retrieval of spatial data from the database.
The official reference for version 3.0.0 of spatialite can be found here: http://www.gaia-gis.it/gaia-sins/spatialite-sql-3.0.0.html.
(The B4A spatialite library is based on version 3.0.1 of spatialite).

Spatialite
Comment:
Spatialite is an SQLite extension for the Android platform.
Currently version 3.0.1 of Spatialite is wrapped by this library.
Spatialite is compiled using geos v3.3.6 and proj4 v4.8.0 patched.
Version: 1.10
  • Spatialite_Blob
    Methods:
    • Close
    • IsInitialized As Boolean
  • Properties:
    • InputStream As InputStreamWrapper [read only]
      Return InputStream for this blob.
    • OutputStream As OutputStreamWrapper [read only]
      Return OutputStream for this blob.
  • Spatialite_Callback
    Events:
    • Columns (ColumnData() As String)
    • NewRow (RowData() As String) As Boolean
    • Types (TypeData() As String)
  • Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
  • Spatialite_Constants
    Fields:
    • SQLITE_OPEN_AUTOPROXY As Int
    • SQLITE_OPEN_CREATE As Int
    • SQLITE_OPEN_DELETEONCLOSE As Int
    • SQLITE_OPEN_EXCLUSIVE As Int
    • SQLITE_OPEN_FULLMUTEX As Int
    • SQLITE_OPEN_MAIN_DB As Int
    • SQLITE_OPEN_MAIN_JOURNAL As Int
    • SQLITE_OPEN_MASTER_JOURNAL As Int
    • SQLITE_OPEN_NOMUTEX As Int
    • SQLITE_OPEN_PRIVATECACHE As Int
    • SQLITE_OPEN_READONLY As Int
    • SQLITE_OPEN_READWRITE As Int
    • SQLITE_OPEN_SHAREDCACHE As Int
    • SQLITE_OPEN_SUBJOURNAL As Int
    • SQLITE_OPEN_TEMP_DB As Int
    • SQLITE_OPEN_TEMP_JOURNAL As Int
    • SQLITE_OPEN_TRANSIENT_DB As Int
    • SQLITE_OPEN_URI As Int
    • SQLITE_OPEN_WAL As Int
  • Spatialite_Database
    Methods:
    • BusyTimeout (Milliseconds As Int)
      Set the timeout for waiting for an SQLite table to become unlocked.
    • Close
      Close the SpatiaLite database file.
    • CreateAggregate (FunctionName As String, NumberArgs As Int, Function1 As Function)
      Create aggregate user defined function.
    • CreateFunction (FunctionName As String, NumberArgs As Int, Function1 As Function)
      Create regular user defined function.
    • ErrorMessage As String
      Return last error message of SQLite3 engine.
    • Exec (Query As String, Callback1 As CallbackImpl)
      The Callback events never seem to get raised, check if this is executing on a non UI thread.
      Or catch the exception in this method to debug...
    • GetTable (Query As String) As TableResult
    • GetTable2 (Query As String, MaxRows As Int) As TableResult
    • Initialize
    • IsInitialized As Boolean
    • LastError As Int
      Return the code of the last error that occurred in any of the Exec methods.
    • LastInsertRowId As Long
      Return the row identifier of the last inserted row.
    • Open (DatabasePath As String, DatabaseFileName As String, OpenMode As Int)
      Open a SpatiaLite database file.
    • OpenBlob (DatabaseName As String, TableName As String, ColumnName As String, Row As Long, ReadWrite As Boolean) As Blob
      Open an SQLite3 blob.
      The returned Blob will not be initialized if an error occurs.
    • Prepare (Query As String) As Stmt
      Prepare and return SQLite3 statement for SQL.
    • SetEncoding (Encoding As String)
      Set character encoding.
  • Spatialite_Function
    Events:
    • Function (FunctionContext1 As FunctionContext, Arguments() As String)
    • LastStep (FunctionContext1 As FunctionContext)
    • Step (FunctionContext1 As FunctionContext, Arguments() As String)
  • Methods:
    • Initialize (EventName As String)
      Initialize this user defined Function.
      Raises the events:
      Function(FunctionContext1 As FunctionContext, Arguments() As String).
      LastStep(FunctionContext1 As FunctionContext).
      Step(FunctionContext1 As FunctionContext, Arguments() As String).
    • IsInitialized As Boolean
  • Spatialite_FunctionContext
    Methods:
    • Count As Int
      Retrieve number of rows for aggregate function.
    • IsInitialized As Boolean
    • SetError (Error As String)
      Set function result from error message.
    • SetResultBytes (Result() As Byte)
      Set function result from byte array.
    • SetResultDouble (Result As Double)
      Set function result from double.
    • SetResultInt (Result As Int)
      Set function result from integer.
    • SetResultString (Result As String)
      Set function result from string.
    • SetResultZeroBlob (Size As Int)
      Set function result as empty blob given size.
  • Spatialite_Stmt
    Methods:
    • BindBytes (Position As Int, Bytes() As Byte)
      Bind positional byte array to compiled statement.
    • BindDouble (Position As Int, Double1 As Double)
      Bind positional double value to compiled statement.
    • BindInt (Position As Int, Integer1 As Int)
      Bind positional integer value to compiled statement.
    • BindLong (Position As Int, Long1 As Long)
      Bind positional long value to compiled statement.
    • BindNull (Position As Int)
      Bind positional SQL null to compiled statement.
    • BindParameterCount As Int
      Return number of parameters in compiled statement.
    • BindParameterIndex (Name As String) As Int
      Return index of named parameter in compiled statement.
    • BindParameterName (Position As Int) As String
      Return name of parameter in compiled statement.
    • BindString (Position As Int, String1 As String)
      Bind positional String to compiled statement.
    • BindZeroBlob (Position As Int, Length As Int)
      Bind positional zero'ed blob to compiled statement.
    • ClearBindings
      Clear all bound parameters of the compiled statement.
    • Close
      Close the compiled statement.
    • Column (ColumnIndex As Int) As Object
      Retrieve column data as Object from exec'ed statement.
    • ColumnBytes (ColumnIndex As Int) As Byte[]
      Retrieve blob column from exec'ed statement.
    • ColumnCount As Int
      Retrieve number of columns of exec'ed statement.
    • ColumnDatabaseName (ColumnIndex As Int) As String
      Return database name of column of statement.
    • ColumnDeclaredType (ColumnIndex As Int) As String
      Return declared column type of statement.
    • ColumnDouble (ColumnIndex As Int) As Double
      Retrieve double column from exec'ed statement.
    • ColumnInt (ColumnInt As Int) As Int
      Retrieve integer column from exec'ed statement.
    • ColumnLong (ColumnIndex As Int) As Long
      Retrieve long column from exec'ed statement.
    • ColumnName (ColumnIndex As Int) As String
      Return column name of column of statement.
    • ColumnOriginalName (ColumnIndex As Int) As String
      Return origin column name of column of statement.
    • ColumnString (ColumnIndex As Int) As String
      Retrieve string column from exec'ed statement.
    • ColumnTableName (ColumnIndex As Int) As String
      Return table name of column of statement.
    • ColumnType (ColumnIndex As Int) As Int
      Retrieve column type from exec'ed statement.
    • IsInitialized As Boolean
    • Prepare As Boolean
      Prepare the next SQL statement for the Stmt instance.
    • Reset
      Reset the compiled statement without clearing parameter bindings.
    • Status (Op As Int, Flag As Boolean) As Int
      Return statement status information.
    • Step As Boolean
      Perform one step of compiled statement.
  • Spatialite_StringEncoder
    Methods:
    • Decode (String1 As String) As Byte[]
      Decodes the given string that is assumed to be a valid encoding of a byte array.
      Typically the given string is generated by the StringEncoder Encode method.
    • Encode (Bytes() As Byte) As String
      Encodes the given byte array into a string that can be used by the SQLite database.
      The database cannot handle null (0x00) and the character '\'' (0x27).
      The encoding consists of escaping these characters with a reserved character (0x01).
    • EncodeX (Bytes() As Byte) As String
      Encodes the given byte array into SQLite3 blob notation, ie X'..'
  • Spatialite_TableResult
    Methods:
    • AtMaxRows As Boolean
      Flag to indicate MaxRows condition.
    • Clear
    • IsInitialized As Boolean
  • Properties:
    • Column() As String [read only]
      Column names of the result set.
    • MaxRows As Int [read only]
      Maximum number of rows to hold in the table.
    • NumberColumns As Int [read only]
      Number of columns in the result set.
    • NumberRows As Int [read only]
    • Rows() As String [read only]
      Rows of the result set.
      Returns an Array of String Arrays, where each String Array represents a row of the result.
    • Types() As String [read only]
      Types of columns of the result set or Null.

Please note that i have only tested a small number of the library objects, if you find any bugs please post a bug report and i'll do my best to fix it.

The Spatialite.jar library file is over 14MBs in size so too large to attach to a forum post.
So you can find the library files here: http://b4a.martinpearman.co.uk/spatialite/ (Spatialite_library_files_v2.20.zip).
Also available at that link is SpatialiteGUI - a small Windows utility that will likely be very handy for you developers.

Martin.
Hi Martin,

I am using your Spatialite Library from http://b4a.martinpearman.co.uk/spatialite/ (Spatialite_library_files_v2.20.zip).

I think that there might be a bug in your library.

Here are my steps.

1. Downloaded spatialite_gui-NG-5.0.0-win-amd64.7z from https://www.gaia-gis.it/gaia-sins/windows-bin-amd64-latest/
2. Created a new sqlite db file which populated the spatial_ref_sys table.
3. Tested several WGS84 conversions using the spatialite_gui app.

SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(102.169998 3.405541)', 4326),3375))

POINT(463822.411401 376746.015235)


SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(112.960079 1.984808)', 4326),3376))

POINT(364271.879307 219602.859137)


SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(102.169998 3.405541)', 4326),3168)

POINT(464016.543346 376740.098876)

All are correct according to EPSG.IO.

Ran the scripts again in B4A.

The 4326 to 3375 and 3376 conversions are correct.

File.Copy(File.DirAssets,"db.sqlite", File.DirInternal, "db.sqlite")
Dim DBCon As Spatialite_Database
Dim DBRec As Spatialite_TableResult
Dim sqlcostanti As Spatialite_Constants
DBCon.Initialize()
DBCon.Open(File.DirInternal, "db.sqlite", sqlcostanti.SQLITE_OPEN_READONLY)


DBRec = DBCon.GetTable("SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(102.169998 3.405541)', 4326),3168))")
Log(DBRec.Rows(0,0))

However for the 4326 to 3168 conversions, I got this

POINT(463847.87424 376717.570411) - Incorrect

as compared to

POINT(464016.543346 376740.098876) - Correct


Also for your information, if I were to reverse the conversion from 3168 back to 4326 using the incorrect output, the WGS84 coordinate is correct.

Thanks for your time and effort for the great library.
 

DonManfred

Expert
Licensed User
Longtime User
Hi Warwound, any help with this issue?
You should ALWAYS create a NEW thread in the questions forum for any issue you have.
Posting to old threads is a mistake.
 
Top