How To Force GPS Capturing

Overview

Sometimes GPS data might not be captured due to being indoor’s or having problematic GPS signal communication.
This ‘how to’ will show you how to force the GPS data to be captured in your survey and not to allow it to end, unless the GPS data is captured.

Step 1: Writing the needed code in the Advanced Scripts:
Step 2: Creating the needed validation question.

Step 1: Writing the needed code in the Advanced Scripts:

First you would need to write the following code in your ‘Advanced Scripts’ window:

function OnGPSUpdated(inLocation)
{
    if ((SubjectGPSLocation==null || !SubjectGPSLocation.IsValid) && inLocation!=null && inLocation.IsValid)
    {
        SubjectGPSLocation = inLocation;
    }
}
 
function myLocationDataValid ()
{
    var retVal = false;
    retVal = SubjectGPSLocation.IsValid;
    if (!retVal) {
        SubjectGPSLocation = GetGPSLocation();
        retVal = SubjectGPSLocation.IsValid;
        if (!retVal) {
            OpenGPS();
        }
    }
    return retVal;
}

 

Step 2: Creating the needed validation question.

Now create an empty question that has this text and this start script:
Start Script:
SetTextFormat(CurrQues,myLocationDataValid());

Question Body Text:
Was GPS captured until now: {0}
End of the survey. This question has a validation check to make sure the GPS location info was captured

* The question body test can be changed to your own text, as long as it has the ‘{0}’ as it would pipe inside it the current GPS data.

Now you should create the validation rule that will prevent the surveyor to continue, unless GPS data was captured:
Condition:
!myLocationDataValid()

Message:
* Whatever you want.
You can also add another empty question right after it, to let the surveyor know that the data was captured, for example:

Start Script:

SetTextFormat(CurrQues,SubjectGPSLocation.Longitude,SubjectGPSLocation.Latitude);

Question Body Text:

GPS coordinates were recorded:
Long: {0}
Lat: {1}
You can now safely finish the survey

That’s it!

 

Here is a demo survey using this method:

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.