RAMANI Location-API (for Android)

RAMANI Location-API (for Android)

Ramani Location-API provides a custom Android framework to obtain geo-location information supporting Unassisted GPS and Assisted GPS conditions, incl. the ability to simulate positioning uncertainty in these use cases

Supported Platforms

With the RAMANI Location-API (for Android), you can build apps that target native 32-bit or 64-bit devices running Android 4.1 and later.

Developing an application with the RAMANI Location-API (for Android) requires the following:

  • Android Studio 3.0 or later.
  • Android SDK Tools 16 or later.

Getting the Documentation of RAMANI Location-API (for Android)

Documentation of RAMANI Location-API (for Android) is distributed as a Readme.md PDF file and google slides.

Core Functionality

Example App

Example Project

git clone https://team.ujuizi.com:6443/RAMANI/android-location-example.git

Screen Captures

Adding the RAMANI Location-API (for Android) to your project

  1. Launch Android Studio and either open an existing project, or create a new project.
  2. Go to your root build.gradle and copy this to your code.
allprojects {
        repositories {
            jcenter()
            maven {
                url 'http://archiva.ujuizi.com/repository/internal'
            }
        }
}
  1. Go to your app build.gradle and copy this to your code.
dependency{
    ....
    implementation 'com.ujuizi.ramani:location-api:0.0.1-alpha'
    ....
}

Reading Satellites/GNSS Status Data

Read the status Data of Satellites/GNSS data like Total Satellites, Elevation, azimuth, Altitude, Altitude Mean Sea Level, Dilution Of Precision, or etc.

//set up GPSStatusData
GPSStatusData gpsStatusData = new GPSStatusData(mActivity);    
    //call this to handle GPS Satellite Data Listener    
    gpsStatusData.addGpsStatusListener(new GPSStatusChangedListener() {    
            @Override    
            public void onGPSStatusEvent(int event, String status) {    
                Log.e("Satellites","Gps Status Event : "+status);    
            }    
            @Override    
            public void onGetSatelliteTypes(SatelliteType[] satelliteTypes, 
            int totalUsedInFixCount, int totalSv) {    
                    // read total satellites    
                    Log.e("Satellites","Total Satellite : "+totalSv);    
                    // read total satellites used in Fix    
                    Log.e("Satellites","Total Satellite : "+totalUsedInFixCount);    
                    // read satellites     
                    for (SatelliteType satelliteType: satelliteTypes){    
                        Log.e("Satellites",satelliteType.toString());    
                    }    
            }    
            @Override    
            public void onNmeaMessage(String message, long timestamp) {    
                    //Get Altitude Mean Sea Level    
                    if (message.startsWith("$GPGGA") || message.startsWith("$GNGNS")) {    
                        Double altitudeMsl = getAltitudeMeanSeaLevel(message);    
                    if (altitudeMsl != null) {    
                        Log.e("Satellites","AltitudeMSL : "+String.valueOf(altitudeMsl));    
                        }    
                    }    
                    //Get Dilution of Precision (DOP), Horizontal DOP, and Vertical DOP    
                    if (message.startsWith("$GNGSA") || message.startsWith("$GPGSA")) {    
                        DilutionOfPrecision dop = getDop(message);    
                        if (dop != null) {    
                            Log.e("Satellites","DOP : "+String.valueOf(dop.getPositionDop()));    
                            Log.e("Satellites","Horizontal and Vertical DOP : 
                            "+String.valueOf(dop.getHorizontalDop())+" , "+ 
                            String.valueOf(dop.getVerticalDop()));    
                        }    
                    }    
            }    
        });    
        //add this if you want to get NMea Message    
        gpsStatusData.addNmeaStatusListener();

Note: Make sure your project already synced with location manager in your build.gradle .

Setup Offline Routing Data

If setup offline Routing Data is ready, you will able to use the Snap-to-Road.

//Use this if you want to set in UI Thread    
OfflineRouting offlineRouting = new OfflineRouting("Your Path", 
new OfflineRouting.OfflineRoutingListener() {    
            @Override    
            public void onRoutingDone(boolean isReady) {    
                Log.e ("OfflineRouting","Routing ready : "+isReady);    
            }    
    });    
//use this if you want to set in background thread    
OfflineRouting offlineRouting = new OfflineRouting("Your Path");    
boolean status = offlineRouting.checkGraphStorage();  

Note : You can download the routing data here Indonesia, https://download.ujuizi.com/routing-data/netherlands_routing.zip,Ghana,South Africa.

Note : Or You can Deploy your routing data by following this instructions:

  1. Download .pbf file in Geofabrik and select your region.
  2. Download Graphopper projecT in github:
git clone git://github.com/graphhopper/graphhopper.git graphhopper

  1. go to your cloned directory and open using terminal:
cd graphhopper 

  1. and then import file pbf:
./graphhopper.sh import your-area.pbf

Snap-to-road

Enable snap-to-road (when poor geo-location provisioning inherent to certain smartphone user scenarios can be addressed by ‘snapping’ the received GPS-fix to the nearest infrastructure, e.g. road or pedestrian track (see this picture)

// use this if you want to use in UI Thread    
SnapToRoad snapToRoad = new SnapToRoad(offlineRouting);
snapToRoad.getSnapToRoadInBackground(location, new SnapToRoadListener(){    
    @Override    
    public void onSuccesSnapped(SnapToRoadModel snappedLocation) {    
    Log.e("SnapToRoad", "onSuccess : " + snappedLocation.toString());    
    }    
    @Override    
    public void onFailedSnapped(String failedMessage) {    
        Log.e("SnapToRoad", "onFailedSnapped : " + failedMessage);    
    }
});    
//call this if you want to call in Backgroundtask    
SnapToRoadModel snaptoroadModel = snaptoroad.getSnapToRoad(location);   

Note: Make sure Setup Routing is Ready, if not will get failed.

Mock Location

  1. Add this to Manifest.xml
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
  1. Add your list of locations
MockLocation mockLocation = new MockLocation(this);    
mockLocation.addLocations( 110.30841,-6.97261,0,0);    
mockLocation.addLocations( 110.30872,-6.97259,0,0);    
mockLocation.addLocations( 110.30894,-6.97257,0,0);   
mockLocation.addLocations( 110.31006,-6.97253,0,0);    
mockLocation.addLocations( 110.31037,-6.97251,0,0);    
mockLocation.addLocations( 110.31061,-6.97249,0,0);   
mockLocation.addLocations( 110.31145,-6.97242,0,0);   
mockLocation.addLocations(  110.3121,-6.97237,0,0);
mockLocation.addLocations( 110.31219,-6.97236,0,0);
mockLocation.addLocations(  110.3123,-6.97236,0,0);
mockLocation.addLocations( 110.31239,-6.97236,0,0);
mockLocation.enabled();

Note: Make sure to enabled Developer Options in Settings Android Device, and enabled mock location to your project app name.