Select to view content in your preferred language

Get Average GPS location with Applet

2313
6
04-06-2010 04:16 AM
NathanEide
Emerging Contributor
Since the old ArcPad forum is disappearing (not quite sure how I feel about that), I decided I'd post my question here.  What I'd like to do is, while I have an applet form open, collect the average GPS location in a variable and then, when the form closes, store that location in a table.  I have a lot of experience programming ArcPad forms (VBS and JS) so what I really need to know is how to get the average GPS X and Y coordinates into a variable when the form is opened.

Thanks for any advice
Tags (3)
0 Kudos
6 Replies
TOMBELL
Emerging Contributor
I'm not sure exactly what you need.  You can set the number of GPS sentences to average in your GPS Preferences tab.  When the form opens, the averaging begins and if you try to close the form before it reaches the number you have specified you will get a warning message.  When the form is closed, the averaged GPS is the position of the point.  It then is available by querying that point.  Or, you can get the northing and easting directly from the GPS.

Here is a simple VBS code block to get the coordinates directly from the GPS.  Note that the northing and easting are saved to a global variable that you can use elsewhere including insertion into a file, database record, form, etc.

  Dim dblX, dblY
  If Application.GPS.IsOpen Then
    dblX = GPS.X
    dblY = GPS.Y
    Application.UserProperties("LOCx")=dblX
    Application.UserProperties("LOCy")= dblY
  Else
    dblX = map.pointerX
    dblY = map.pointerY
  End If
0 Kudos
NathanEide
Emerging Contributor
Thanks for the help, I wish it were that easy (and maybe it is).

I'm using an applet form and thus averaging isn't started when the form opens.  The applet is a stand alone form not connected to any specific layer.  The average GPS location I want will be stored in a .dbf.  I'd be happy if there were a way to tell ArcPad to start averaging, but I suspect I'll have to do it using the onsentance or onlocation method.
0 Kudos
BillCrawford
Emerging Contributor
I'm no coder, but does "OnAverageStart Event" work, it's in the help. If you have the GPS active and averaging set in preferences, I don't see how you are not collecting an average.
0 Kudos
NathanEide
Emerging Contributor
I'm no coder, but does "OnAverageStart Event" work, it's in the help. If you have the GPS active and averaging set in preferences, I don't see how you are not collecting an average.


Unfortunately, as far as I can tell, the OnAverageStart event is called when you open an Edit Form.  I'm opening an applet form that doesn't call this event.  Bummer!
0 Kudos
BillCrawford
Emerging Contributor
Wouldn't you call an event script once a Form button is tapped? Look under "Adding event handling scripts" in Help menu.
0 Kudos
NathanEide
Emerging Contributor
I can't figure out how to initiate ArcPad to start averaging with an applet form.  It's easy with an edit form - have the average location option turned on and open an edit form.  However, with an applet form, ArcPad doesn't know to start the OnAverage event.  I could be mistaken (hopefully)!
0 Kudos