Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

 

CommCare has several geospatial features that allow for calculating distances between geographic coordinates, sorting case lists by distance from you, and displaying case location data in a map view. 

Collecting location data with CommCare

Adjusting accuracy and timeout of GPS capture

As of CommCare 2.33, advanced users can adjust the accuracy and timeouts for GPS capture question widget and GPS auto-capture.

This is done by enabling the "Allow users to add arbitrary custom properties to their application" feature flag and adding any of the following property key/values:

  • cc-gps-auto-capture-accuracy: Auto-capture accuracy in meters
  • cc-gps-auto-capture-timeout: Elapse time (in minutes) before GPS auto-capture gives up on acquiring an accurate location. 
  • cc-gps-widget-good-accuracy: The accuracy value in meters needed for the question widget to store the location and auto-close
  • cc-gps-widget-acceptable-accuracy: The accuracy value in meters needed for the question widget to start recording location values
  • cc-gps-widget-timeout-secs: The elapse time, in seconds, needed before the question widget will start recording location values regardless of accuracy. (not sure exactly why we have this)

After activating the feature flag, there will be a new section in the Application Settings that allows you to enter these keys/values. Only Dimagi staff can activate this feature flag.

Distance calculations in CommCare

As of CommCare 2.26, the distance between two geographic coordinates (latitude and longitude pairs) can be calculated using the distance() function. This function takes in two geopoints and returns the distance, in meters between them, taking into account the curvature of the earth's surface.

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

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

Map Case List

If your 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 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.

Calculating distance traveled by mobile worker

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.

 

 

  • No labels