locking GPS coordinates

Discussions about CSEntry
sjonabro

locking GPS coordinates

Post by sjonabro »

Hi Josh, and others.

I was wondering if there is a way to automatically lock GPS coordinates.
we are currently pre-testing an instrument, and the enumerator has to visit both farm and residence of the respondent. They take the GPS coordinates at the farm.

After field level data had been entered, and the enumerator was at the placse of residence finishing the survey, that they had to go back to change something earlier on, and when they did that the tablet automatically tried to get a new GPS reading, however, since they were no longer at the farm this resulted in a new set of (wrong) farm coordinates.

I would like to know if there is a way to get the GPS values automatically locked in place (I could create new variables and have the enumerator transcribe the values, but would like to automate the process if possible)

Thank you!
Aniseh
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: locking GPS coordinates

Post by josh »

After the GPS has been taken the first time you can set the fields to be protected using the set attributes command. Look under set attributes in the online help.
sjonabro

Re: locking GPS coordinates

Post by sjonabro »

Thank you Josh,
I am not able to use Set attributes the way I need it to (or understand it well enough)

I have my 4 variables: V1, GPS, LAT, LON. GPS calls the gps function when the respondent selects "yes" and skips LAT and LON if the respondent answers no.
I have protected LAT and LON so that they can never be manually entered.

My syntax looks like this:
PROC GPS
if GPS=1 then
set attributes (GPS) protect;
if gps(open)and gps(read, 60) then
LAT=gps(latitude);
LON=gps(longitude);
endif;
gps(close);
endif;

But if I come back to V1, and hit "next question" the tablet begins reading the GPS coordinates again...
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: locking GPS coordinates

Post by josh »

The proc will still get called even if the field is protected. In your logic you need to avoid calling gps(open) and gps(read) in your proc if have already collected the coordinates.
sjonabro

Re: locking GPS coordinates

Post by sjonabro »

josh wrote:The proc will still get called even if the field is protected. In your logic you need to avoid calling gps(open) and gps(read) in your proc if have already collected the coordinates.
Thank you Josh, how can I collect coordinates and avoid calling gps(open) and gps(close) at the same time?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: locking GPS coordinates

Post by josh »

If the coordinates have been collected then the value of lat/lon will be non-blank. So if lat is non-blank (<> notappl) then don't call gps(open) and gps(read). Since you would do this check before you get to the field you would need to use visualvalue() (assuming you are in system control mode).

Code: Select all

PROC GPS
if visualvalue(LAT) = notappl and GPS=1 then
  if gps(open)and gps(read, 60) then
    LAT=gps(latitude);
    LON=gps(longitude);
  endif;
  gps(close);
endif;
sjonabro

Re: locking GPS coordinates

Post by sjonabro »

PERFECT! that worked so well.. thank you so much.
Aniseh
sjonabro

Re: locking GPS coordinates

Post by sjonabro »

After further testing this code, I found that it works well for single occurrence records (HH level), but not for multiple occurrence records (plot level).
Do you know why?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: locking GPS coordinates

Post by josh »

For multiple occurrence records you will need to add a subscript when you use visualvalue.

Code: Select all

visualvalue(LAT(curocc())) = notappl
This is because normally when you are in the proc for a multiplying occurring item CSPro automatically uses curocc() as the current occurrence but when you use visualvalue for a lookahead it does not.
sjonabro

Re: locking GPS coordinates

Post by sjonabro »

Thanks Josh - you have been so helpful through this entire process (preparing the instrument for the field).
Aniseh
Post Reply