Page 1 of 2

GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 11th, 2019, 4:42 am
by col Ar
Hello,
I have a big problem with GPS capturing.
I capture GPS well and good and stores the values such that they cant change.
My problem is that when GPS fails, nothing is stored and then I cant proceed unless I I put gibberish.
if I go back to the modify/verify mode and GPS is not captured, I would like at that point that the GPS is rerun in that mode and captures GPS when available.
My code is as below

Code: Select all

PROC GPS_LATITUDE
preproc
if demode()=add then
	gps(open);
	if gps(read,60,10,"Reading GPS, Please wait...") = 1 then   //read up to 60 seconds. if successful...
      //execsystem(maketext("gps:%f,%f", gps(latitude),gps(longitude)));
      if accept(maketext("Save this location? %f, %f",gps(latitude),gps(longitude)),"Yes","No") = 1 then   //if yes
      	GPS_LATITUDE = gps(latitude);
      	GPS_LONGITUDE = gps(longitude);
      	endif;
	elseif demode()=add then
	errmsg("Gps location failed, Please try again");
		GPS_LATITUDE = notappl;
		GPS_LONGITUDE = notappl;
		endif;
elseif demode()=(modify or verify) and (visualvalue($)=notappl or missing or -2) and (visualvalue(GPS_LONGITUDE)= notappl or missing or 1) then
gps(open);
	if gps(read,60,10,"Reading GPS, Please wait...") = 1 then   //read up to 60 seconds. if successful...
      //execsystem(maketext("gps:%f,%f", gps(latitude),gps(longitude)));
      if accept(maketext("Save this location? %f, %f",gps(latitude),gps(longitude)),"Yes","No") = 1 then   //if yes
         GPS_LATITUDE = gps(latitude);
         GPS_LONGITUDE = gps(longitude);
         endif;
	else
	errmsg("Gps location failed, Please try again");
gps(close);
      endif;
endif;

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 11th, 2019, 7:19 am
by josh
I would suggest adding a missing value to your value set for latitude and longitude in the dictionary and setting the variables to missing when the gps read fails. That way you can check if the value is missing and retry the gps if it is. You can use 999 as the missing value in the value set since it is not a valid latitude/longitude. The logic would be something like following. Note that there is no need to look at the demode, you simple check if the latitude is different from notappl (never taken) and missing (failed to be taken).
if visualvalue(GPS_LATITUDE) = notappl or visualvalue(GPS_LATITUDE) = missing then
    if gps(read,60,10,"Reading GPS, Please wait...") = 1
       and accept(maketext("Save this location? %f, %f",gps(latitude),gps(longitude)),"Yes","No") = 1 then
         GPS_LATITUDE = gps(latitude);
         GPS_LONGITUDE = gps(longitude);
    else
         GPS_LATITUDE = missing;
         GPS_LONGITUDE = missing;
    endif;
endif;

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 11th, 2019, 7:41 am
by col Ar
Dear Josh,
This solves half of the problem.
Remember that my aim is that if GPS fails to read, fill it with missing but allow me continue survey. Now, I get stuck at that level.
However, if I modify/verify the case and still the fields contain missing/999 then reread the GPS otherwise just leave alone the right readings I had previously. :( :(

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 11th, 2019, 9:23 am
by josh
That is exactly what this code doe. If the gps read fails then the values are filled with missing (999). When you come back to the field it will recapture the GPS if it is missing. I'm attaching a demo app.

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 11th, 2019, 12:16 pm
by col Ar
Hi Josh.
Thanks though I can't open v7. 2. I use v7. 1.3.
Meanwhile let me try with notepad++

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 11th, 2019, 5:05 pm
by josh
You can use the version shifter tool that you can download from here to turn it back to CSPro 7.1: http://www.csprousers.org/downloads/

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 12th, 2019, 12:44 am
by col Ar
Thanks.
Even if I try to downgrade with that tool, it shows[img]
Capture.PNG
Capture.PNG (19.89 KiB) Viewed 5372 times
[/img]

This is very frustrating. All my dictionaries cant open. except in version 7.2

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 12th, 2019, 10:19 am
by col Ar
Dear Josh,
Found a way to move to 7.1
however, the code still requires tweaking.
When I try it on phone, and GPS isn't available, it assigns the values yes.
Second, when I progress to the end and conclude a case, it cannot re-initiate the GPS search and just stuck on previous values entered. This is the point an really stressing. After concluding everything, then when I go back to that field for GPS, it should just start if the values are what were assigned when GPS not available

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 12th, 2019, 12:06 pm
by josh
I think you need to spell out EXACTLY what you want to happen in all the different scenarios: first time when GPS has not yet been taken, when GPS fails and they go back again, when GPS succeeds and they go back again... I don't understand the behavior that you require.

One way to handle the GPS is to give the user the choice of whether or not they want to take or re-take the GPS by adding a question to the questionnaire. I'm attaching an example here named "Listing.zip". This one was written in version 7.1.

Re: GPS STORAGE IN ENTRY, MODIFY AND VERIFY MODES

Posted: January 12th, 2019, 1:14 pm
by col Ar
Thanks Josh.
Will try this.
Just to clarify:
In add mode: GPS try, if no results, assign missing or - 90.
Then in modify mode, if assigned =missing/-90 try readi g again.
Previous code works upto assign missing in add mode. But if I exit application or partial save, these fields are skipped yet their values are faulty.
Sorry for too much work Josh.