Android Question Esri Shape Files

Terradrones

Active Member
Licensed User
Hi All

I need help\push again please.

Is there a library to read Esri Shapefiles with B4A? I have looked on the Forum but cannot find anything.

Regards
Michael
 

drgottjr

Expert
Licensed User
Longtime User
is this going to be another case of you getting a number of members to help you regarding some problem only to have you disappear and leave us hanging? at least in my case, i spent a lot of time looking into your mount point problem. i'm not very inclined to help you with shapefiles and then have you disappear yet again.
 
Upvote 0

Terradrones

Active Member
Licensed User
Hi Drgottjr, I am not disappearing. I have used your ideas and also used your IP address with the Port no and I can access the Mount points without a problem. But when I insert the IP address and Port no of Trignet, nothing happens. I will post my latest code onto the Forum as soon as I am back at my computer.

I am also busy fine tuning my routines to import and export DXF files.
 
Upvote 0

Terradrones

Active Member
Licensed User
Hi Drgottjr

Here is my code that works for your link, but it does not work for the NTRIPP here in South Africa.

B4X:
Sub cmbMountPoints_SelectedIndexChanged (index As Int)
    CmbCorrType.Text=CGlobals.MntPnts(CmbMountPoints.SelectedIndex).Corr
    Label67.Text=CGlobals.MntPnts(CmbMountPoints.SelectedIndex).Sat
    
    CGlobals.DF(71)=CmbMountPoints.SelectedItem
    CGlobals.DF(72)=CmbCorrType.Text
    CGlobals.DF(99)=Label67.Text
    SendGGA.Checked=False
End Sub

Sub FindMountPoints
    Dim su As StringUtils
    Dim HttpClient As HttpJob
    HttpClient.Initialize("NTRIP", Me)
    
    CmbMountPoints.cmbBox.Visible=True
    Label68.Visible=False
    
    ' Set the NTRIP caster URL and credentials
    Dim IPAddress As String = CGlobals.DF(64)
    Dim Port As String = CGlobals.DF(65)
'    Dim NTRIP_URL As String = "http://" & IPAddress & ":" & Port '& "/caster" 'This does not work..the IP adress for www.Trignet.co.za is 196.15.132.2 and the Port is 2101
    Dim NTRIP_URL As String = "http://rtk2go.com:2101"        'This works
    Dim Username As String = CGlobals.DF(66)
    Dim Password As String = CGlobals.DF(67)
    
    ProgressDialogShow2("Searching For Mount Points...", True)
    
    Dim AuthString As String = Username & ":" & Password
    Dim AuthHeader As String = "Basic " & su.EncodeBase64(AuthString.GetBytes("UTF8"))
    HttpClient.Download(NTRIP_URL)
    
'    Set headers before sending the request
    HttpClient.GetRequest.SetHeader("Authorization", AuthHeader)
    HttpClient.GetRequest.SetHeader("User-Agent", "Ceaser")
    HttpClient.GetRequest.SetHeader("Accept", "*/*")
    HttpClient.GetRequest.SetHeader("Host", IPAddress)
    HttpClient.GetRequest.SetHeader("Connection", "close")
    
    ' Send the request
'    HttpClient.Download(NTRIP_URL)
End Sub

Sub JobDone (Job As HttpJob)
    CmbMountPoints.cmbBox.Clear
    Dim Items8 As List
    Items8.Initialize
    If Job.Success Then
        Dim response As String = Job.GetString
        '        Log("NTRIP Response: " & response)
        
        ' Process the NTRIP data here to extract mount points
'        Dim MountPoints As List
'        MountPoints.Initialize
        i=0
        Dim Lines() As String = Regex.Split(CRLF, response)
        For Each Line As String In Lines
'            Log(Line)
            If Line.StartsWith("STR") And i<1950 Then
                Dim Mnt() As String = Regex.Split(";", Line)
                Sleep(0)
                Try
                    CGlobals.MntPnts(i).MntPnt=Mnt(2)
                    CGlobals.MntPnts(i).Corr=Mnt(3)
                    CGlobals.MntPnts(i).Sat=Mnt(6)
                    Items8.Add(Mnt(2))
                    i=i+1
                Catch
                    Log(LastException)
                End Try

            End If
        Next
        
        Dim cs As CSBuilder
        Dim l8 As List
        l8.Initialize
        For i = 0 To Items8.Size -1
            l8.Add(cs.Initialize.size(18).Typeface(Typeface.DEFAULT_BOLD).Append(Items8.Get(i)).PopAll)
        Next
        CmbMountPoints.SetItems(l8)
        CmbCorrType.Text=""
        Label67.Text=""
'        If CGlobals.DF(71)<>0 Then
'           
'        End If
'        CmbMountPoints.SetItems(l8)
'        CmbMountPoints.SelectedIndex=CGlobals.DF(71)
'        CmbCorrType.Text=CGlobals.DF(72)
'        Label67.Text=CGlobals.DF(99)
    Else
        Log("Job failed: " & Job.ErrorMessage)
        Log("HTTP Status Code: " & Job.Response.StatusCode) ' Log the status code for more details
        Log(Job.Response.ErrorResponse)
        '        Log("Full Response: " & Job.GetString) ' Log the full response to understand why it fails
        '        MsgboxAsync("Mount Points Are Not Available" & CRLF & "The Server Might Be Down", "No Mount Points")
    End If
    Job.Release
    ProgressDialogHide
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
but it does not work for the NTRIPP here in South Africa
How is NTRIP related to .DXF-Files /ESRI Files)? Looks like you are mixing two different threads :-/
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Hi All

I need help\push again please.

Is there a library to read Esri Shapefiles with B4A? I have looked on the Forum but cannot find anything.

Regards
Michael

I have some REALLY OLD code written in VB6 that reads shape files. I'll be glad to share it with you if you are interested. The format of shape files has not changed for decades so it may help if you are willing to dig into it.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Try this, should work on Android as its pure Java;

 
Upvote 0

Terradrones

Active Member
Licensed User
I have some REALLY OLD code written in VB6 that reads shape files. I'll be glad to share it with you if you are interested. The format of shape files has not changed for decades so it may help if you are willing to dig into it.
Hi Aminoacid, I would really appreciate it if you could share those files with me.
 
Upvote 0
Top