Hi All
I desperately need help. I see that my old Posting has been closed.
I need to convert from any Coordinade system to Lats\Longs and back again.
I have looked at Spatialite, but don't have a clue what is going on there...I think old-age is making me stupid.
Here is my code, which is a Class:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I desperately need help. I see that my old Posting has been closed.
I need to convert from any Coordinade system to Lats\Longs and back again.
I have looked at Spatialite, but don't have a clue what is going on there...I think old-age is making me stupid.
Here is my code, which is a Class:
			
				B4X:
			
		
		
		[/
Sub Class_Globals
    Private Spa As Spatialite_Database
    
'    Dim PI As Double = 3.1415926535897932385
'    Dim RADIAN As Double = 2.0 * PI / 360    
'    
'    Dim Local_srid As String
    'Dim Data_File As String
    Dim spconstants As Spatialite_Constants
'    Initialize(File.DirRootExternal & "/CEASER/Data/" ,Data_File,"READONLY")
'    Spa.Open(File.DirInternal, "mm.sqlite", spconstants.SQLITE_OPEN_READONLY)
End Sub
Public Sub Initialize '(DPATH As String ,DBASE As String , OPEN_STYLE As String)
    Dim DPath, DBase, Open_Style As String
    Spa.Initialize
    
    DPath=File.DirRootExternal & "/CEASER/Data"
    DBase="Projections.csv"
    'File looks like this:
    'EPSG    Continent    Country    Grid
    '5825    Oceania    AU-CT    AGD66 / ACT Standard Grid
    '20249    Oceania    AU-#M    AGD66 / AMG zone 49
    '20250    Oceania    AU-#M    AGD66 / AMG zone 50
    Open_Style="ReadOnly"
    'Initialize(DPath ,DBase,"READONLY")
    
    Spa.Open(DPath, DBase, spconstants.SQLITE_OPEN_READONLY)
    Select Open_Style
        Case "READWRITE"
            Spa.Open(DPath, DBase, spconstants.SQLITE_OPEN_READWRITE)
        Case "READONLY"
            Spa.Open(DPath, DBase, spconstants.SQLITE_OPEN_READONLY)
    End Select
End Sub
Sub Get_point_from_local( X As Double , Y As Double) As String
    Dim sqStm As Spatialite_TableResult
    Dim result As String
    Dim sql1 As String
    sql1 = "SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT("
    sql1 = sql1 & X & " " & Y & ")'," & CGlobals.EPSG & "),4326)) As trans_geom;"
    'Globals.EPSG =2048
    Try
        sqStm = Spa.GetTable(sql1)
        result = sqStm.Rows(0,0)
    Catch
        Log(LastException.Message)
        MsgboxAsync(LastException.Message & CRLF & "Wrong EPSG code" ,"ATTENTION")
        'Local_srid="2048"
        Return "0000000000000000000"
    End Try
    If result=Null Or result="" Then
        Return "0000000000000000000"
    End If
    Return result
End Sub
'''transform lat lon to local
Sub Get_point_to_Local( lat As Double , lon As Double) As String
    Dim sqStm As Spatialite_TableResult
    Dim result As String
    Dim sql1 As String
    sql1 = "SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT("
    sql1 = sql1 & lon & " " & lat & ")',4326),"
    sql1 = sql1 & CGlobals.EPSG & ")) As trans_geom;"
    sqStm = Spa.GetTable(sql1)
    result = sqStm.Rows(0,0)
    Return result
End Sub
] 
				 
 
		 
 
		 
						
					 
 
		 
 
		 
 
		 
 
		 
 
		