Versions Compared

Key

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

 

Table of Contents

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


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.

Image Removed
Image Added
Image Removed
Image Added

...

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.

Image Removed
Image Added
Image Removed
Image Added

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.

...