B4A Library Verso - Offline Reverse Geo

DonManfred

Expert
Licensed User
This is a wrap for this github-project

minSdkVersion 15
Verso is a offline reverse geocode library based in OfflineReverseGeocode and optimized to be used on Android.
Verso is capable to return the "city name", "country name" and the "country code" from a latitude and longitude provided.
Verso is a singleton and use a internal data text file where all the geo info is located.


Verso
Author:
DonManfred (wrapper)
Version: 1
  • GeoInfo
    Methods:
    • Initialize (EventName As String, geoinfo As String)
    • IsInitialized As Boolean
    • isMajorPlace As Boolean
    Properties:
    • CityName As String [read only]
    • CountryCode As String [read only]
    • CountryName As String [read only]
    • Latitude As Double [read only]
    • Longitude As Double [read only]
  • Verso
    Events:
    • geoinfo (geo As Object)
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • getGeoInfo (latitude As Double, longitude As Double)

Setup:
- Download VersoVx.y.zip and extract the content to your additional libs folder
- Download the file offlineData.zip from HERE. Copy the file AS IS into your projects files folder. Do not extract...
 

Attachments

awakenblueheart

Member
Licensed User
Hi, I tried the example but got this error below. I put the offlineData.zip in "Files" folder.

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Verso_geoinfo()
main_verso_geoinfo (java line: 382)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String de.donmanfred.GeoInfoWrapper.getCityName()' on a null object reference
    at b4a.example.main._verso_geoinfo(main.java:382)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5383)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:939)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:734)
 

DonManfred

Expert
Licensed User
try it with this code please
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    verso.Initialize("Verso")
    verso.getGeoInfo(50.8293765,6.4325835)
End Sub
Sub Verso_geoinfo(geo As GeoInfo)
    Log($"Verso_geoinfo(${geo})"$)
    If geo <> Null Then
        Log(geo.CityName)
        Log(geo.CountryCode)
        Log(geo.CountryName)
        Log(geo.isMajorPlace)
    End If
End Sub
 

scsjc

Well-Known Member
Licensed User
Hello DonManfred nice work

Is possible do a reverse too?

I want a create a list of cities with a gps positions, and i think it's possible do a reverse with this library ... is posible?

Thanks for you work!
 

Syd Wright

Well-Known Member
Licensed User
This looks interesting. So far I have used http://www.geonames.org/
I have the impression that this lib use cities1000.txt which is a rather basic list.
More countries lists can be found here: http://download.geonames.org/export/dump/
Here the largest file is called cities15000.zip which I feel is still not complete enough and also rather large to distribute with an app for offline usage.
These list can be stripped and reduced in size by deleting unnessary data. They can also be used in both directions, i.e. to find Lat-Lon for a a specific city or to find the nearest city for a given Lat-Lon position.
Google offers a very good (online) reverse geocoding API.
 
Top