> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloneable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pole & midspan measurement data

> Complete guide to `measurement_data`, how pole and attachment heights work, calibrated photos, and merging Cable Tracing annotations.

When a fielder captures a pole or midspan in Cloneable Field (iOS), the app stores the complete measurement document in the data object's **`measurement_data`** field. When an office engineer traces or refines heights in Cloneable Office (Cable Tracing / Pole Inspect), those edits are stored in the **`annotations`** field on the same object.

## How pole measurements work

1. **Field capture (iOS):** The fielder photographs the pole with a scale target or LiDAR/calibrated reference. Cloneable Field computes the calibrated pole line (`referenceLine`), camera intrinsics, lens distortion tables, pole height, and any field-marked attachments, writing them into `measurement_data` and uploading the raw photo + calibration sidecar (`scalingData`) to R2.
2. **Office tracing & refinement:** In Cloneable Office, engineers can place or adjust attachments, wires, crossarms, and heights on the calibrated photo. Those measured annotations live in the `annotations` field (`{ version: 1, annotations: [...] }`) and can supersede an earlier field attachment via `superseded_attachment_id`.
3. **Units:** Every stored height, distance from pole top, and midspan clearance is in **meters** (`1 m = 3.28084 ft`). Convert to feet/inches only at display time.

> [!WARNING]
>
> **Documented-only vs measured poles:** A pole with the `collected_without_measurement` sentinel (or only detail photos and no `measurement_data` payload) was visited in the field without taking a calibrated height measurement. Do not treat it as a `0 m` pole height.

## Top-level structure of `measurement_data`

Fetch a full pole record with `GET /data-object/{id}` and locate the field where `name === "measurement_data"`.

```json theme={null}
{
  "high_accuracy": true,
  "capture_mode": "target",
  "pole_orientation": 142.5,
  "tilt_bypassed": false,
  "pole_information": {
    "height": 12.19,
    "lean_angle": 1.4,
    "location": {
      "latitude": 35.7796,
      "longitude": -78.6382,
      "altitude": 96.2,
      "accuracy": 0.45
    }
  },
  "attachments": [
    {
      "id": "att-001",
      "type": "wire",
      "classification": "Primary",
      "owner": "Duke Energy",
      "height": 11.43,
      "calculatedHeight": 11.43,
      "manualHeight": null,
      "isManualMeasurement": "false",
      "distanceFromPoleTop": 0.76,
      "heading": 88.0,
      "relatedSpans": ["span-uuid-1"],
      "relatedGuys": [],
      "inventoryClass": {
        "name": "Primary Conductor",
        "subcategories": { "voltage": "12.47kV" }
      }
    }
  ],
  "images": [
    {
      "id": "img-001",
      "image": "9f8e7d6c-5b4a-4321-8765-123456789abc",
      "imageWidth": 3024,
      "imageHeight": 4032,
      "referenceLine": { "...": "calibrated ground-to-top pole line" },
      "cameraIntrinsics": { "focalLengthX": 2810.4 },
      "lensDistortion": { "...": "forward/inverse LUTs" },
      "scalingData": "sidecar-file-uuid"
    }
  ],
  "midspan": {
    "height": 6.85
  }
}
```

## Field-by-field reference

### `pole_information`

| Field | Type | Unit / Notes |
| - | - | - |
| `height` | `number` | Measured pole height above groundline in **meters**. |
| `lean_angle` / `leanAngle` | `number` | Pole tilt/lean angle in **degrees** (both snake\_case and camelCase appear across captures). |
| `location` | `object` | Capture GPS fix (`latitude`, `longitude`, optional `altitude` and horizontal `accuracy` in meters). |
| `pole_attachments` | `array` | **Legacy** home for attachments on older captures. Always fall back to `pole_information.pole_attachments` when top-level `attachments` is absent. |

### `attachments[]`

| Field | Type | Unit / Notes |
| - | - | - |
| `id` | `string` | Attachment identifier. Used by `annotations[].superseded_attachment_id` when office tracing replaces a field measurement. |
| `type` | `string` | Category such as `"wire"`, `"guy"`, `"attachment"`, `"equipment"`. |
| `classification` | `string` | Customer/utility label (e.g., `"Primary"`, `"Neutral"`, `"Comms"`, `"Transformer"`). |
| `owner` | `string` | Attaching utility or company name (e.g., `"AT&T"`, `"Spectrum"`). |
| `height` | `number` | Final attachment height above groundline in **meters**. |
| `manualHeight` | `number` | Manually entered or overridden height in **meters** (when `isManualMeasurement` is `"true"`). |
| `calculatedHeight` | `number` | Photogrammetry-calculated height in **meters**. |
| `distanceFromPoleTop` | `number` | Distance measured down from the top of the pole in **meters**. |
| `heading` | `number \| null` | Compass bearing / azimuth in **degrees** (`0–360`). |
| `relatedSpans` / `relatedGuys` | `string[]` | IDs of connected span or guy objects. |
| `inventoryClass` | `object` | Structured equipment class (`{ name, subcategories }`). |

> [!TIP]
>
> **Height precedence:** Resolve an attachment's height as `height ?? manualHeight ?? calculatedHeight`. Never read `images[].imageHeight` — that is the camera photo's pixel height (e.g., `4032 px`), not a pole height.

### `images[]` (Calibrated overview photos)

| Field | Type | Notes |
| - | - | - |
| `image` | `string \| { fileId }` | File UUID in Cloneable Files. Pass this UUID to `GET /file/{id}/download-url` to fetch the image bytes. |
| `imageWidth` / `imageHeight` | `number \| string` | Image pixel dimensions (may arrive as a quoted numeric string on older iOS captures). |
| `referenceLine` | `object` | Calibrated pole axis from groundline to pole top used to project clicks to metric heights. |
| `cameraIntrinsics` / `lensDistortion` | `object` | Focal length and forward/inverse distortion lookup tables (LUTs). |
| `scalingData` | `string` | File UUID of the calibration sidecar JSON stored in R2. |

### `midspan` & capture metadata

| Field | Type | Notes |
| - | - | - |
| `midspan.height` | `number` | Lowest wire clearance above ground at midspan in **meters**. |
| `high_accuracy` | `boolean \| "true"` | Whether the capture used high-accuracy calibration (may be boolean or string `"true"`). |
| `capture_mode` | `string` | Capture workflow mode used in Cloneable Field. |
| `pole_orientation` | `number` | Pole/camera orientation angle in **degrees**. |
| `tilt_bypassed` | `boolean` | True if the fielder bypassed the device tilt warning during capture. |

## Merging `measurement_data` with `annotations` (Cable Tracing)

If your organization uses **Cable Tracing** or the web map annotator, office-measured heights are written to the pole's **`annotations`** field (`{ version: 1, annotations: [...] }`). To match what Cloneable Office exports:

1. Start with `measurement_data.attachments ?? measurement_data.pole_information?.pole_attachments ?? []`.
2. Collect every `superseded_attachment_id` from `annotations.annotations[]` and drop any legacy attachment with a matching `id`.
3. Append every annotation in `annotations.annotations[]` that has a `measure` block (reading `measure.height_m` for the final height and `measure.computed_height_m` for the calculated height; `measure.method === "manual"` marks a manual override).

## Tolerant parsing & write-safety rules

* **Double-encoded JSON:** `stored_value` on the wire is always a string, and some iOS captures double-stringify `measurement_data`. Parse in a loop while `typeof value === "string"`.
* **String-or-number fields:** Numeric fields inside `images[]` and `annotations[]` can arrive as quoted strings (e.g., `"3024"`). Coerce with `Number()` / `float()` and check `Number.isFinite`.
* **Never schema-strip on write:** If you update `measurement_data` via `POST /data-object/{id}/fields`, read-modify-write the full blob and preserve all unknown keys verbatim (LUTs, `cameraIntrinsics`, `referenceLine`, `scalingData`), or photo calibration and exports will break.
* **Don't parse on bulk lists:** Use `GET /data-object-sync/filtered-data-objects` to list/filter poles, then call `GET /data-object/{id}` when you need the full `measurement_data` payload.

```ts TypeScript theme={null}
function parseMeasurementData(storedValue: unknown): Record<string, any> | null {
  let cur: unknown = storedValue
  for (let i = 0; i < 3 && typeof cur === 'string'; i++) {
    try { cur = JSON.parse(cur) } catch { return null }
  }
  return cur && typeof cur === 'object' ? (cur as Record<string, any>) : null
}

function getPoleSummary(obj: { fields: Array<{ name: string; stored_value?: string }> }) {
  const raw = obj.fields.find((f) => f.name === 'measurement_data')?.stored_value
  const md = parseMeasurementData(raw)
  if (!md || md.collected_without_measurement) return null

  const attachments = (md.attachments ?? md.pole_information?.pole_attachments ?? []).map((a: any) => ({
    id: a.id,
    classification: a.classification,
    owner: a.owner,
    height_m: Number(a.height ?? a.manualHeight ?? a.calculatedHeight),
  }))

  return {
    pole_height_m: Number(md.pole_information?.height),
    lean_deg: Number(md.pole_information?.lean_angle ?? md.pole_information?.leanAngle),
    photo_file_ids: (md.images ?? []).map((i: any) => (typeof i.image === 'string' ? i.image : i.image?.fileId)).filter(Boolean),
    attachments,
  }
}
```

```python Python theme={null}
import json

def parse_measurement_data(stored_value):
    cur = stored_value
    for _ in range(3):
        if isinstance(cur, str):
            try:
                cur = json.loads(cur)
            except ValueError:
                return None
    return cur if isinstance(cur, dict) else None

def get_pole_summary(obj):
    raw = next((f.get("stored_value") for f in obj.get("fields", []) if f.get("name") == "measurement_data"), None)
    md = parse_measurement_data(raw)
    if not md or md.get("collected_without_measurement"):
        return None

    pole_info = md.get("pole_information") or {}
    raw_atts = md.get("attachments") or pole_info.get("pole_attachments") or []
    return {
        "pole_height_m": pole_info.get("height"),
        "lean_deg": pole_info.get("lean_angle") or pole_info.get("leanAngle"),
        "photo_file_ids": [
            i["image"] if isinstance(i.get("image"), str) else (i.get("image") or {}).get("fileId")
            for i in (md.get("images") or [])
        ],
        "attachments": [
            {
                "id": a.get("id"),
                "classification": a.get("classification"),
                "owner": a.get("owner"),
                "height_m": a.get("height") or a.get("manualHeight") or a.get("calculatedHeight"),
            }
            for a in raw_atts
        ],
    }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.