Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel1
maxLevel2
outlinefalse
styledefault
typelist
printabletrue

GPS

CommCare supports a feature called Automatic GPS Capture to help you automatically capture GPS locationstwo options to capture GPS locations: automatically, using the Automatic GPS Capture feature, and manually, through the use of the GPS question.

Automatic GPS Capture

This feature will allow forms filled out on CommCare for Android to automatically capture a GPS location with no intervention from the mobile user.  

...

  1. Automatically capturing GPS from a form. This will include the location data as part of the form’s metadata

  2. If unsuccessful at getting a GPS location accurate with in 10 meters after 2 minutes, GPS location capture stops (to manage battery life). Below version 2.29 the cutoffs are 5 meters and 5 minutes, which caused issues with battery life.

  3. Configuration of automatic GPS capture on a per-app level (turn it on and off per application)

  4. Configuration of automatic GPS on a per-form level (if not set at the app level, can individually configure it per form)

  5. Ability to access the automatic GPS captured data in a form export

  6. Starting to capture GPS as soon as a form is opened that has a GPS questionautomatic GPS capture enabled is opened

When a form is set up to automatically capture a GPS location, it will do the following:

...

Setting up Automatic GPS Capture

  1. Make sure that your the application is running the appropriate versions of CommCare. Both the client and the application content must be updated:

    1. The CommCare client version from the Play Store must be 2.14 or greater. See https://dimagi.atlassian.net/wiki/x/vQXKfw.

    2. Your application version on the settings page for your application must also be set to 2.14. More information found at https://dimagi.atlassian.net/wiki/x/bzPKfw.

  2. Turn on Auto GPS Capture on CommCareHQ

    1. For all forms (when GPS capture will be active in all forms in an application)

      1. Navigate to the application settings page

      2. Under Android settings check the box for "Auto Capture Location (all forms)" and save

    2. For one form (when GPS capture will be active in only some forms in an application)

      1. Navigate to the specific form that you wish needs to auto capture GPS location

      2. Click the check box "Auto Capture Location (all forms)" and save

  3. Make a new version of your the application and deploy it to your a phone.  Your  The phone will now attempt to automatically capture GPS locations for the forms you have selected.

Configuration at the app level

Configuration at form specific level

956b5b84-285a-46b0-909a-5e7fa2c21bf3.png

f537f74a-9923-4f07-9185-7a12fd9aaec2.png

Manual GPS Capture

To enable the manual GPS capture the first step is to add a GPS question to the form. To do that follow the steps below:

  1. Go to CommCareHQ and navigate to the form where GPS coordinates need to be captured

    1. This should enable form builder

  2. In the middle section of the form builder, go to the top right corner and click Add Question, move the cursor over the Advanced submenu and select GPS

...

  1. To understand how to capture GPS coordinates using the GPS question, follow the steps described here

Saving GPS data to the case

...

One can use the standard Export Forms routine to export GPS data. To do so, select Show Advanced Settings in the Export Settings page and then include the Location field. To further break down the location and include latitude, longitude, altitude and accuracy in separate columns of the export, enable tick the Expand Checkbox Questions box.

Understanding GPS Data

Deciphering GPS Data

...

  1. Export data from CommCareHQ into Excel

  2. If all of the coordinates are in one cell, select the GPS coordinates field and use the Excel "text to columns" feature to separate the GPS field into its 4 component fields (latitude, longitude, elevation, precision). You can delete the elevation and precision columns for a basic map.

...

  1. Alternatively, use the following formulas to extract latitude and longitude

...

  1. :

Latitude: = LEFT(H2,SEARCH(" ",H2,1))

Longitude:  = MID(H2,SEARCH(" ",H2,1)+1,SEARCH(" ",H2,SEARCH(" ",H2,1)+1)-SEARCH(" ",H2,1))

In this example, H2 is the cell that contains the full GPS coordinates. Replace H2 with whatever cell contains the GPS coordinates

  1. Copy the latitude and longitude fields into a clean Excel file. The first number is latitude. Label the two columns in the top rows at latitude and longitude respectively.

    1. For a basic map, elevation and precision columns are not needed.

  2. Create additional columns with other information

...

  1. needed in the map (i.e. name, ID, etc.)

  2. Save the Excel file as a xls (Excel 97-2003 Workbook)

...

  1. or xlsx.

  2. Upload the file into the converter.

  3. Open the resulting kml file in Google Earth.

Extracting GPS Components

The location returned by a GPS question is a string composed of the latitude, longitude, altitude and accuracy, each separated by a space. In your export configuration, if you choose "Expand Checkbox Questions" then the GPS data will automatically be split into four columns. 

If all of the coordinates are in one cell, the following expression will extract the latitude from the location: if(/data/location = '', '', selected-at(/data/location, 0))

Similarly, for longitude: if(/data/location = '', '', selected-at(/data/location, 1))When using the Auto-Location capture feature, that GPS location is available through /data/meta/location and can be accessed by enabling "Show Advanced Questions" in a form export.

Calculating Distances Between GPS Coordinates

CommCare now supports distance calculation via the distance XPath function on both J2ME and Android phones. For example, the following expression returns the distance between two locations in meters:

distance(/data/location1, /data/location2)

Since the distance function returns -1 if either argument is an empty string, a more robust way to display the distance is shown below:

if(/data/location1 = '', '', if(/data/location2 = '', '', distance(/data/location1, /data/location2)))

GPS Troubleshooting & Limitations

...

  • Almanac data: very coarse satellite position information, good it helps determine which satellites are available for positioning.

    • Good for 4 months and taking 12.5 minutes to download from a satellite; updated every 6 days

  • Ephemeris data: fine-grained satellite position information, good crucial for determining the exact position of a satellite at any given time.

    • Good for 4 hours and taking 18-36 seconds to download from a satellite; updated every 2 hours

  • A lock on 3+ satellites 

A cold "cold” start happens when the device was off for more than 4 hours and new ephemeris data needs to be downloaded. A "warm" start happens when the ephemeris data is still valid and the device simply needs to get a lock on satellites. A device is "hot" if it has that lock. To accelerate the "time to first fix" (time from turning on the device to getting coordinates), a variety of techniques get used: (http://en.wikipedia.org/wiki/Assisted_GPS).

  • A-GPS or assisted GPS 

    • The Mobile Station Based (MSB) - the phone downloads ephemeris data from the cell tower (MSB) The towers

    • Mobile Station Assisted (MSA) - the phone sends its captured GPS data to the cell tower, letting the tower perform the calculations (MSA)in a later stage

  • The phone uses cell tower triangulation, totally ignoring the phone's GPS functionality - accuracy is usually reported as being more than 1000m. 

...

Finally, new devices often support other navigation system such as GLONASS (Russia) and GALILEO (European Union), in addition to GPS. GLONASS is a Russian network and GALILEO are networks very similar to GPS . When and when combined, devices that support GLONASS and GPS will have very rapid satellite locks and high improve satellite locking and location accuracy. GLONASS particularly excels in high latitudes (very south or very north of the equator).

Speed and accuracy of getting a GPS lock is highly variable. For example, the Samsung Galaxy S10 has relatively good GPS hardware, including GLONASS, GALILEO and A-GPS support. However, it will still have issues when surrounded by concrete and getting a satellite lock will take longer when outside of cell network data coverage. It's not possible to "boost" the signal. However, you can it is possible to ensure that your the GPS unit is at the very least always "warm" and thereby reduce the acquisition time . For example, running something like Google's "MyTracks" app set to record the GPS location every 15 or 30 minutes should minimally impact the battery life but keep GPS should remain warm (Simply running MyTracks in the background is enough, it is not necessary to have it open all the time)by making use of activity tracking apps such as the Google Fit app. Making sure that the app is running in the background ensures that the GPS is continuously accessed and therefore “warm".

GPS FAQs

Generally, what is "accurate" in GPS captures?
There are two accuracy thresholds. 1600m is "acceptable" and 10m is "good." 

...

Aside from the fact that for the GPS question, the user has to trigger the attempt at GPS capture process, whereas for autocapture that happens automatically, there is no difference, notably in things like the accuracy of the capture or how long CommCare tries for the capture (2 minutes in both cases). For GPS questions, once the device gets a location that's "acceptable" it gets displayed to the user, but the GPS will keep querying until it reaches a "good" value (as it gets more accurate values, it'll keep updating the screen that says "Your location is ABC, do you want to save?"). For auto GPS capture, "acceptable" doesn't matter, the GPS just keeps querying until it hits a "good" value (or 2 minutes pass). So even if it never hits a "good" or even "acceptable" value, after 2 minutes, it saves whatever best value it has, regardless of how rough it is, notably because the accuracy is also stored with the location. 

...

Accuracy shouldn't depend on CommCare. It will depend on location, hardware, and proximity to wifi and mobile networks.

What happens if you move around after submitting the form? Say, drive in a car for the remaining 1.5 minutes after submitting a 30 second form? Does it try to find the location you submitted the form at (doubt this is possible?)?

...

Displaying and sorting by 'distance from current location' in the Case List 

If your the case data contains location data, you can now it is possible to display and sort the case list using distance from your the current location. This is accessible via the 'Distance from current location' format of the case list display properties.

...

For advanced users: in theory, it is now possible to determine how far a mobile worker has traveled over the course of a given time period by storing a few additional parameters in the case data and using the 'distance()' function to aggregate that data. You would need to store the total distance traveled and the location of last form submission in the case data and update those values accordingly on each new form submission.

Maps

Maps in Case List

If your the case list uses the 'Address' display property then the 'View on Map' option will be available in the case list settings drop down menu. Selecting this will display your the case list in a map view. While an internet connection is needed to download the map from Google Maps, it appears that those maps are cached and available, even without an internet connection, for some time afterwards.

...