B4A Library Navigation Library

Here is a library to help in navigation tasks:
Convert GEO coordinates to UTM and vice versa.
Calculate the length of a route (a sequence of waypoints)
Calculate the area of a polygon defined by a sequence of waypoints, and btw
Calculate distance and bearing from one point to the other.

The sets of point can be defined either as an array or by a list.
The file contains a demo program.

Have fun :)

Edit: Ver 1.1 with two additional methods, GeoNextPoint and UTMNextPoint.
Edit: Version 1.2 fixes a bug in SphericalArea and SphericalArea2 methods.
 

Attachments

  • Navigation_example.zip
    8.6 KB · Views: 1,143
  • Navigation_1.2.zip
    6.7 KB · Views: 646
Last edited:

nitinb4a

Member
Licensed User
Longtime User
Navigation tutorials and Gps sample program issue

Hi Erel,

I am referring the B4A sample programs from "GPS tutorials" and "Navigation Library" threads and running GPS.apk file outdoors on my mobile but it is not showing results for Lat & Lon. I have a Micromax Ninja A89 android 4.2.2 duel core phone and all Location services (Google's Location service, GPS Satellites,Location & Google search etc.) are enabled.

I have installed same GPS.APK on my colleagues Samsung Galaxy Grand android phone & it is running fine and giving lat,lon,speed & satellites.

Pls. suggest another way to getLocation(Lat,Lon) like GPS or WiFi/Triangulation and suggest sample B4A programs or documentations which will be helpful to me.

Best Regards
Nitin :sign0085:
 

nitinb4a

Member
Licensed User
Longtime User
LocationManager Library

Hi Erel,
I am running LocationManager Library example.zip
http://www.b4x.com/forum/additional...al-updates/13337-locationmanager-library.html
It is not giving Latitude and longitude on android phone the code is as follows.
-----------------------------------------------------
Sub Globals
Dim lm As LocationManager
End Sub
Sub Activity_Create(FirstTime As Boolean)
lm.Initialize("Location")
Activity.AddMenuItem("Update location","mnuLocation")
Activity.AddMenuItem("Stop Listening","mnuStopListening")
End Sub
Sub mnuLocation_Click
lm.requestLocation
End Sub
Sub mnuStopListening_Click
lm.stopListening
End Sub
Sub Location_LocationChanged (Longitude As Double, Latitude As Double, Altitude As Double, Accuracy As Float, Bearing As Float, Provider As String, Speed As Float, Time As Long)
Msgbox("Longitude: " & Longitude & CRLF & "Latitude: " & Latitude & CRLF & "Altitude: " & Altitude & CRLF & "Accuracy: " & Accuracy & CRLF & "Bearing: " & Bearing & CRLF & "Speed: " & Speed,"Location")
End Sub
Sub Location_ProviderDisabled (Provider As String)
Msgbox("Provider","Provider Disabled")
End Sub
Sub Location_ProviderEnabled (Provider As String)
Msgbox("Provider","Provider Enabled")
End Sub
Sub Location_StatusChanged (Provider As String, Status As Int)
Msgbox("Provider: " & Provider & CRLF & "Status: " & Status,"Status Changed")
End Sub
-----------------------------
Suggest the solution to get location details.
BR
Nitin:sign0085:
 

nitinb4a

Member
Licensed User
Longtime User
Location area code and name or address using CellID

Hello Erel,

Using below url for BGCellLocation v1.0 - Location using CellID

http://www.b4x.com/forum/additional...ion-v1-0-location-using-cellid.html#post65103

I got the location area code now I want to find out the Location area name or address using same "location area code"

kindly suggest a b4a sample project for finding same or explain step to implement

BR
Nitin:sign0085:
 

nitinb4a

Member
Licensed User
Longtime User
GeoCoder library Missing parameter error

He Erel,

I am trying to run B4A sample program for GeoCoder library url given below and copied the button click code given by "WARWOUND" and it is giving below error.
------------------------------------------------------------------------
http://www.b4x.com/forum/additional...updates/17115-geocoder-library.html#post97857

Parsing code. 0.00
Compiling code. Error
Error compiling program.
Error description: Missing parameter.
Occurred on line: 69
Results=Geocoder1.GetFromLocation(Latitude, Longitude, MaxResults)
Word: )
--------------------------------------------------------------------------
What value should I pass as TAG?

BR
Nitin:sign0085:
 

iancasey

Member
Licensed User
Longtime User
Derez, nice library, I will use it. I did find that there is a small error in the LatLonToUTM function, the error is almost a constant 0.52m on the points I tested with on both the X + Y of the UTM with the values you provided in kineret.txt and some local values in utm15N
The Distance values checked out fine :)

I checked the UTM values with Blue Marble convertor and this website:
http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html

Your result 737,831.64 3,631.415.30
BM result 737,831.12 3,631,414.82
web page 737,831.12 3,631,414.80
I didn't test the area functions as I don't need them yet.

Regards
Ian
 

derez

Expert
Licensed User
Longtime User
I have found the algorithm somewhere in the internet (long ago, I don't remember where) and I'm not able to correct half a meter error. If you think it is a bias - correct it in your application.
 

deneus

Member
Licensed User
Longtime User
Hello very interesting library.
I wonder if you have a practical example of a map that you can share?
Thanks in advance.

Hola muy interesante la librería.
Me gustaría saber si tienes algún ejemplo practico sobre un mapa que puedas aportar?
Gracias de antemano.
 

derez

Expert
Licensed User
Longtime User
The library is not specific to any map, except that it enables coordinates conversions and calculations.
Practical map is something related to where you want to use it...
 

daniedb

Active Member
Licensed User
Longtime User
Hi Derez
Using your Navigation Library, which have most of the calcs I'm looking for.
This is my code, but it return the complete wrong distance/bearing, Any Ideas?
B4X:
' Test Input  fields, will later been retrieved from External GPS connected via Bluetooth

  lattxt.Text="-26.172439"
   lontxt.Text= "26.187221"
   lat2txt.Text="-26.166447"
   lon2txt.Text=" 26.183402"

sub CalcDistBearBtn_Click

   Dim l1 As Double :l1 = lattxt.Text
   Dim lo1 As Double :lo1 = lontxt.Text
   Dim l2 As Double :l2 = lat2txt.Text
   Dim lo2 As Double :lo1 = lon2txt.Text
  
   Dim retnd() As Double
   nav.
  
   retnd  =nav.GeoDistanceBearing(l1,lo1,l2,lo2)
   Distancelabel.Text=retnd(0)
   Log("dist: "&retnd(0))
   bearinglabel.Text=retnd(1)
   Log("bearing: "&retnd(1))

End Sub

Thanks
Danie
 
Last edited:

derez

Expert
Licensed User
Longtime User
B4X:
 Dim l1 As Double :l1 = lattxt.Text
   Dim lo1 As Double :l1 = lontxt.Text
   Dim l2 As Double :l1 = lat2txt.Text
   Dim lo2 As Double :l1 = lon2txt.Text
You have done copy-paste but forgot to change - only l1 value is set !!!!
 

daniedb

Active Member
Licensed User
Longtime User
SH*t, thats Very Late nights these last few days... sorry about that. STUPID/SIMPLE problem.
Always nice that the Pro's show you out these dum stuff
Thankyou Sir :)
 

daniedb

Active Member
Licensed User
Longtime User
Wow its working :) stupid me!!!!

Is there a Way that I can use your library, and draw a polygon (4 locations), and for example divide that up into 300m strips east to west or north to south, for a Grid type of Display.

Thank you
 

derez

Expert
Licensed User
Longtime User
I suggest to translate the 4 points to UTM and then work with it using the simple grid.
 

AngeloR

New Member
Licensed User
Hi,
I have encountered the following problems using the Navigation library: by drawing a polygon with the dido when the polygon straddles the UTM zone 32 and 33 the calculation of the 'FlatArea' function is incorrect, while if it calculates in one area the calculation is correct. As for the calculation with the same coordinates wgs84 with the 'SphericalArea' function, the calculation is incorrect. I attach file with coordinates and pdf with polygons.
 

Attachments

  • Area.pdf
    510.3 KB · Views: 278
  • UTM.txt
    7 KB · Views: 260
  • WGS84.txt
    3.5 KB · Views: 262

derez

Expert
Licensed User
Longtime User
Hi,
I have encountered the following problems using the Navigation library: by drawing a polygon with the dido when the polygon straddles the UTM zone 32 and 33 the calculation of the 'FlatArea' function is incorrect, while if it calculates in one area the calculation is correct. As for the calculation with the same coordinates wgs84 with the 'SphericalArea' function, the calculation is incorrect. I attach file with coordinates and pdf with polygons.
The UTM calculation should not be expected to calculate area which is in two UTM zones !
The spherical calculation - check with less points and see the result.
 

AngeloR

New Member
Licensed User
Il calcolo sferico


My app should calculate polygon areas in different UTM zones, in different parts of the world, it is possible to correct the library. As for the spherical calculation, the points are the result of a design made with the finger of polygons of different shapes and therefore removing points is complicated. Thanks
 
Top