I've been working with Jeff LeProwse's AddXYZ+ applet to record GPS metadata with each point collected. I'm at the point where I'm in over my head as far as figuring out the coding.
I've set up ArcPad 10.2.2 to average 30 seconds of observations per point.
Problems with the script:
1. The applet uses onFeatureAdded which means the GPS metadata is recorded when OK is pressed to create the new point and not when the GPS finishes collecting the coordinates. So if you stand in the road for 30 seconds while the GPS collects the point and then move to the side of the road for 5 minutes filling in forms and press OK the GPS metadata is recorded for wherever you were standing at that moment, not out in the road.
2. For existing points the GPS metadata is updated onFeatureUpdated regardless of whether GPS is used to update the position. If the GPS is enabled and I move a point with the mouse the GPS metadata will update.
To get around this I've gone to calling the applet on GPS onAverageStop, which works when moving existing points, but doesn't for new points because there isn't an existing RecordSet to update(?) so I think populating the open EditForm is the way to go but can't get the code to work.
Summary: I'd like the script to record GPS metadata at the moment the GPS finishes averaging and records the position when adding new points with AddGPSPoint and moving existing points with MovePointToGPS only. Also needs to factor in the possibility of toggling between editing several point layers and a polyline layer with the QuickCapture toolbar.
Some code (which doesn't work):
<?xml version="1.0" encoding="UTF-8"?>
<ArcPad compiled="true">
<APPLET name="AddXYZ+_RCE_fields">
<SYSTEMOBJECTS>
<GPS onAverageStop="Call UpdateGPSFields"/>
</SYSTEMOBJECTS>
</APPLET>
<SCRIPT language="VBScript">Option Explicit
Sub UpdateGPSFields
'Define attributes
Dim MyCoordSys, objRS, f, strMessage, fCount, objForm, editPointLayer
'Get current edit point layer
Set editPointLayer = Map.EditLayer(1)
'Get current edit point layer EDITFORM
Set objForm = editPointLayer.Forms("EditForm")
'Check to see if the EDITFORM is open (3)
'If not open, assume Move to GPS operation on selected point
If objForm.Mode = 3 Then
Application.StatusBar.Text = "EDITFORM is open"
Else
'Get current coordinate system
Set MyCoordSys = Application.Map.CoordinateSystem
'Get the RecordSet of the currently selected feature's layer
'SelectionLayer returns layer of currently selected feature
Set objRS = Map.Selectionlayer.Records
'Bookmark the currently selected record
objRS.Bookmark = ThisEvent.Bookmark
'Check if the current shape is a point
If Right(objRS.Fields.ShapeType, 1) = 1 Then
'Check what the coordinate system is
If MyCoordSys.GeographicName = "GCS_WGS_1984" Then
'Loop through the current layer's fields
For Each f in objRS.Fields
Select Case Ucase(f.name)
Case "GPS_X"
f.Value = GPS.x
fCount = fCount + 1
Case "GPS_Y"
f.Value = GPS.y
fCount = fCount + 1
Case "GPS_LAT"
f.Value = GPS.Latitude
fCount = fCount + 1
...