Field Portal under the hood: a packed asset map and forms as data
How we fitted an electricity network onto an iPad and let the business design its own field forms: a packed binary asset index, custom compression and a versioned form designer.
In 2016 we started building Field Portal for Essential Energy: an iPad and iPhone app, a web back office and an API, to take line crews off paper. Two requirements shaped almost every line of code. The crews needed the whole network in their hands with no signal, and the business needed to change its forms without waiting for a developer.
We have written about the people side in From paper Work Packs to iPad and about offline patterns in Offline-first is a promise, not a feature. This post is the engineering underneath: how the asset map got small enough to carry, and how a form became data instead of code.
The constraint
An electricity distribution network is enormous. Poles, conductors, streetlights, premises, substations and switchable devices, each with attributes a crew might need, plus customer hazards and life-support flags. A single working area could hold tens of thousands of poles; one area synced 36,767 of them.
That data starts life as GeoJSON exported from the GIS. GeoJSON is a fine interchange format and a poor thing to put on an iPad: verbose text, long decimal coordinates, and property names repeated on every feature. Parse a big file on the device and you wait, burn battery and run out of memory.
Forms had the opposite problem. They change constantly. A safety team adds a question, an audit needs a new section, a business unit wants its own checklist. If each change means an app release through mobile device management, the forms fall behind the work.
Architecture
iPad / iPhone app (native)
offline asset store + tile index form engine renders JSON designs
| |
+------------- HTTPS REST ----------------+
|
Node / Express API (Azure Web App)
|-- document database: form designs, submissions, drafts, IDs
|-- blob storage: photos, alert PDFs, packed asset files
|-- notification hub: push to devices and groups
|-- identity and integration services
React / Redux back office + web form designer - Assets flow one way: GIS export, server-side packing, blob storage, device download per region.
- Form designs are JSON documents with a version. Devices ask for designs updated since their last sync and pick up new forms on the next connection.
- Submissions flow back up through the same API, keyed by human-readable form IDs.
Shrinking the asset map
We designed custom compression for the GeoJSON asset data so a whole working area of poles, wires, premises and hazards would fit on the iPad and load quickly. One piece of that work is worth showing in detail, followed by the general techniques this kind of compression draws on.
A packed, seekable index
On the server, a packer streams each GeoJSON file line by line, so it never holds a huge file in memory, and writes a compact binary index beside it. The file starts with a schema version byte. Each feature then gets a length-prefixed asset ID, the byte offset and length of that feature in the original GeoJSON, its longitude and latitude, and a few short labels such as the feeder.
// Asset Id
const id = assetHelpers.generateAssetId(assetType, geojsonFeature);
bufOffset += writeUInt8(buf, id.length, bufOffset);
bufOffset += write(buf, id, bufOffset);
// geoJson file seekTo and numBytes
bufOffset += writeUInt32LE(buf, seekOffset, bufOffset); // seekTo;
bufOffset += writeUInt32LE(buf, line.length, bufOffset); // numBytes
// long + lat
bufOffset += writeDoubleLE(buf, geojsonFeature.geometry.coordinates[longitudeGeometryIndex], bufOffset);
bufOffset += writeDoubleLE(buf, geojsonFeature.geometry.coordinates[latitudeGeometryIndex], bufOffset); The trick is the seekTo and numBytes pair. The device keeps the small index in memory and searches it by location. When a crew member taps a pole, the app seeks straight to that feature's bytes in the big file and parses one line of JSON, not the whole thing. The version byte meant we could change the layout (version 3 added asset IDs and feeder details) and old files were still recognisable. As the network grew, files were split by region so each download matched a working area.
On the iPad, the index fed a custom quadtree, our "asset tile tree", and map clustering, so tens of thousands of points rendered smoothly at any zoom.
How this kind of compression works
Compression for geographic data like this rests on a handful of ideas, and each one attacks a different kind of waste in GeoJSON:
- Quantise coordinates. A longitude written to fourteen decimal places claims precision far below a millimetre. Fix the precision you actually need, scale to an integer, and a coordinate fits in far fewer bytes.
- Delta-encode. Points along a conductor, or poles sorted by location, sit close together. Store the first point in full and each later one as a small difference from the last.
- Variable-length integers. Small numbers should take small space. A varint, or the similar polyline encoding, spends one or two bytes on a small delta instead of eight on a double.
- Property dictionaries. Values such as voltage, material and pole function repeat thousands of times. Store each distinct string once and refer to it by a short index.
- Tile by working area. Nobody needs the whole state on one iPad. Cut the data along the boundaries crews work in, so each device downloads and decodes only its own area.
The result is a file the device can download over a patchy connection and query by location without a long parse.
Forms as data: the form designer
We built a form designer that defines the digital field forms in Field Portal. A form is not a screen in the app. It is a JSON design: a code, a name, a status, a version, an owner, approval rules and an ordered list of sections, each holding fields.
The designer offered a set of field types: text, date, choice, filtered choice, image, location, asset (picked from the map), employee, employee and customer signatures, static text and clickable links. Every field carries a code, a mandatory flag and a description. Sections and fields can be repeatable, so a crew can add another pole or another worker without a designer predicting how many.
Conditional logic came in two layers. The simple layer is a precondition: show this section or field only when another field's value is in a list, not in a list, or within a numeric range.
function Precondition(sectionId, fieldId, operator, value) {
this.sectionId = sectionId;
this.fieldId = fieldId;
this.operator = operator;
if(operator == 'in' || operator == 'notin') {
if (!(value instanceof Array)) {
this.value = value.split(",");
}
} else if(operator == 'range'){
this.value = { min: parseFloat(value.min), max: parseFloat(value.max) };
}
} A filtered choice builds on the same idea: the options in one list depend on the answer to another, with a default set when nothing matches.
The second layer is a script editor. Each design can carry a small script with a handleEvent function that receives load, change and finish events and can call getValue, setValue, setFieldVisible, setSectionVisible and isFormValid. Most forms never need it; the complex ones get real logic without a new app build.
Around the design sits the lifecycle that makes it safe to let the business publish its own forms:
- Versions and rollback. Designs are versioned, and an earlier version can be fetched or restored.
- Locking. Opening a design for edit takes a lock in the editor's name, so two people can't overwrite each other.
- Promotion. A design is built and tested in a lower environment and then copied to production.
- Delta delivery. Devices request designs updated since their last sync, so a published form reaches the field on the next connection.
On the device, the form engine renders the JSON design natively and works entirely offline: fields, preconditions and scripts run on the iPad, and the completed form is queued until the server answers. We use the same approach in Knowby today, where content is structured data that the apps render, not something baked into a release.
Small things that stop big problems
Two details from the sync layer show how field reality leaks into an API. A retry on a weak signal could create a duplicate form, so the save endpoint recognises a retry and reuses the existing form ID. And because crews talk about forms out loud, each submission gets a human-readable ID built from the form's code and a per-design counter. Ten test files cover that ID logic alone: a duplicate ID in a safety record is not a cosmetic bug.
Where AI fits
There was no machine learning in this codebase; it was built between 2016 and 2021, before the tools we use now. But the forms-as-data decision is exactly what makes AI useful later. A form defined as a typed schema, with field types, mandatory flags and conditions, is something a model can be asked to fill, check or draft, and the result can be validated against the schema before anyone relies on it. Free-form screens can't be checked that way. Structure first, intelligence second, is a pattern we still follow.
What it taught us
The form designer changed who could ship. Business units designed their own forms and workflows, and over time more than 3,000 paper forms and workflows were removed. The engineering lesson is that a good platform moves work away from developers on purpose. Our job became keeping the designer safe: versions, locks, rollback and promotion, so a mistake in a form never became a mistake in the field.
The codebase also grew beyond us. Other developers joined it over the years, and the things that helped them most were dull: a README with every environment, a four-stage release pipeline, and tests around the parts where a bug would hurt.
Why it still matters
Most field apps still fail in the same two places: the data is too big to carry and the forms are too hard to change. Both are design decisions you make in the first month. If your people work where the signal doesn't reach, see our mobile and field apps work, or the Field Portal case study.