Exercise 1: Annotate a photo

Annotating a photo may be desirable when a field worker is conducting a condition assessment of assets. A photo would be taken of the asset (for example a pole), and the field worker annotates areas requiring urgent attention on the photo. This exercise describes the behaviour demonstrated in the following two samples available for download on ArcGIS Online. Download and view these samples to follow along with the steps described in this exercise.

ArcPad sample for Windows Mobile devices: http://www.arcgis.com/home/item.html?id=388f1dfe0ac24fcd8f858958a7cb7fad

ArcPad sample for Tablets/PC: http://www.arcgis.com/home/item.html?id=40d995dbb74442eb9f7eb6af0e06ec12

Calling the Sketch extension in your edit form, to enable annotation of a photo

In the sample project, the sketch extension is called from the onclick event of the IMAGEBOX control on the Condition page of the poles edit form.

In ArcPad Studio, open the Poles edit form of the WorkArea_C.axf.

Steps:
  1. On the Condition tab of the form, double click the IMAGEBOX to view the controls properties.
  2. The two important properties on this dialog are Field and Click Action. Field must be assigned to a text field (in this case PHOTOHYPERLINK) and the Click Action must be set to None.

    Control properties for IMAGEBOX

  3. On the onclick event, the function EditPhoto (shown below) is called.

    Call the EditPhoto function

Annotate a photo in ArcPad

The steps to annotate a photo in ArcPad (using this customized form) are

Steps:
  1. Select the existing feature in ArcPad, and open the feature properties dialog.

    Select feature and open the feature properties

  2. Select the Condition tab of the form and tap the Capture button. The photo capture window will display, and allow you to capture a photo. Capture a photo and tap OK.

    Photo in form with no annotation

  3. Now tap on the photo within the form to launch the sketch extension and annotate the photo.

    Photo with annotation

  4. Tap the sketch ok button (the green tick) to commit the sketch changes to file, and then tap OK to commit the feature attribute change (in this case the new image file name) to the AXF.

The function EditPhoto determines whether the sketch extension is installed, and reports to the user if it is not. It also saves the sketch image as a new file using the field name and a date time stamp to uniquely identify it (without deleting the previous file).

NoteNote:

Only the last sketch image is referenced in the feature (any previous images are still stored on disk).

EditPhoto function used to call the Sketch extension to annotate a photo.

Sub EditPhoto
  If editingPhoto Then
    Exit Sub
  End If
  Dim file
  Set file = Application.CreateAppObject("FILE")
  Dim imgPhoto
  Set imgPhoto = ThisEvent.Object
  Dim editLayer
  Set editLayer = Map.EditLayer(1)
  Dim extSketch
  Set extSketch = Extensions("@SKT")
  If extSketch is Nothing Then
    Application.MessageBox "ArcPad Sketch extension not installed"
    Exit Sub
  End If
  Dim origFileName, folder
  Dim prefix, newFileName, ymd, hms
  Dim pos, nextpos
  Dim relative
  origFileName = photoFileName
  folder = ""
  If IsNull(origFileName) or origFileName = "" Then
    Exit Sub
  End If
  pos = InStr(origFileName, "\")
  relative = (pos > 0)
  If pos > 0 Then
    nextpos = InStr(pos + 1, origFileName, "\")
    While nextpos > 0
      pos = nextpos
      nextpos = InStr(pos + 1, origFileName, "\")
    Wend
    folder = Left(origFileName, pos - 1)
    origFileName = Mid(origFileName, pos + 1)
  End If
  If folder = "" Then
    folder = editLayer.FilePath
    pos = InStr(folder, "\")
    If pos > 0 Then
      nextpos = InStr(pos + 1, folder, "\")
      While nextpos > 0
        pos = nextpos
        nextpos = InStr(pos + 1, folder, "\")
      Wend
      folder = Left(folder, pos - 1)
    End If
  End If
  ymd = "" & (Year(Now) * 10000 + Month(Now) * 100 + Day(Now))
  hms = Right(1000000 + Hour(Now) * 10000 + Minute(Now) * 100 + Second(Now), 6)
  prefix = imgPhoto.Field.Name + "_"
  If Left(origFileName, Len(prefix)) = prefix Then
    Dim ch
    ch = Mid(origFileName, Len(prefix) + 5, 1)
    If ch = "." or ch = "_" Then
      prefix = Left(origFileName, Len(prefix) + 4) & "_"
    End If
  End If
  newFileName = prefix + ymd + "_" + hms + ".jpg"
  If not file.Copy(folder + "\" + origFileName, folder + "\" + newFileName) Then
    MsgBox "Failed copying " + origFileName + " to " + newFileName + "!"
    Exit Sub
  End If
  editingPhoto = True
  Dim photoTaken
  photoTaken = extSketch.Escape(folder + "\" + newFileName)
  editingPhoto = False
  If photoTaken Then
    If relative Then
      imgPhoto.Value = newFileName
      imgPhoto.Field.Value = newFileName
      photoFileName = newFileName
    Else
      imgPhoto.Value = folder + "\" + newFileName
      imgPhoto.Field.Value = folder + "\" + newFileName
      photoFileName = folder + "\" + newFileName
    End If
  Else
    Call file.Delete(folder + "\" + newFileName)
  End If
End Sub
7/23/2013