Features / Assets & land

Geofencing

Captures the boundary of a land parcel or crop block as a KML polygon, by walking with GPS, tapping points, drawing in Google Earth or uploading a KML file.

FactsheetAssets & land
Who uses it
Cadre user
How you get here
Geofence button on a Land row, on a Crop Actual card, or on an ATM item. Compact-block screens reuse the map read-only.
Tables
farmerassets, ie_asset, portfolio_portfoliolineitem, farming_model
APIs
7 calls today, 8 App Service operations
Offline
OSM capture works offline (map tiles cached about 3 months). The KML is saved under files/geofencing/ and uploaded later; Google Earth and downloading an existing URL KML need the respective app/internet.

Screens

ScreenWhat it doesSource
Geofencing optionsShows target id and existing geofence; pick a capture method or preview.app/src/main/java/org/platformcommons/urvi/view/geofencing/GeofencingOptionsActivity.kt
Geofencing mapOpenStreetMap capture (fixed, motion, tap) and read-only preview.app/src/main/java/org/platformcommons/urvi/view/geofencing/GeofencingMapActivity.kt
Geofencing view modelWrites the KML and queues the upload.app/src/main/java/org/platformcommons/urvi/view/geofencing/GeofencingViewModel.kt

What it captures

FieldTypeRequiredValidationOptions from
Capture methodChoiceYesOSM Fixed (drag marker, Add point at each corner), OSM Motion (GPS every 2 s, a point each time the user moves more than 5 m), OSM Tap (Capture location drops the current GPS fix), Google Earth (draw and export KML), Upload KML (file picker).Each method switched on/off by reference data
Use existing / Capture newChoiceIf a Crop Actual target has no geofence but its land does"Use existing" copies the land KML.Land geofence

Rules

Conditions from the code, rewritten as plain decision rules.

WhenThen
Geofencing for assets is switched offThe Land row geofence button is hidden.
The land has 0 acresThe geofence button refuses to open.
The target is ATM and has no Tile IdThe screen does not open.
No geofence exists yetA consent dialog "Do you want to capture geofencing?" appears first; Cancel closes the screen.
The stored geofence is a URLThe KML is downloaded first; without internet: "Internet not available" or "Unable to download file".
The user stops captureThe loop is closed by repeating the first point; with zero points: "No geofencing added".
The user stops capture with pointsA dialog offers Save, Restart or Preview.
A land geofence is savedIt is auto-applied to every current-season, current-month Crop Actual block and every ATM on that land that has no geofence yet.
A land geofence is queuedIts upload waits until the farmer create and the land create have synced.
Land row geofence stateGreen tick = synced, yellow cloud = captured not synced, red = none.

API contracts

Each call opens to its use case, headers, request and response bodies, and errors.

App Service v2: operationUse
GET /configTyped config bundle (ETag)
GET /farmers/snapshotCursor-paged hydrated farmer snapshot
GET /farmers/{farmerId}/landsA farmer's land parcels
POST /sync/batchApply an ordered batch of offline mutations
POST /filesCreate a file upload (resumable or single-shot)
GET /files/{fileId}File metadata and signed download URL
PATCH /files/{fileId}Append a chunk to a resumable upload
HEAD /files/{fileId}Current offset of a resumable upload

Behaviour notes

  • KML file name: <id or IE alias>_<millis>_<MODULE>_<OSM|googleEarth>.kml, coordinates stored as lon,lat,0.
  • Privacy the KML embeds the farmer name and village (plus device and ids) in plain text in its description.
  • Possible bug · unverified there is no minimum point count, so a 1-point "polygon" can be saved.
  • Possible bug · unverified there is no GPS accuracy threshold, no area calculation, no comparison with declared acres and no self-intersection check.

Improve in the rewrite

  • Require at least 3 points, reject fixes worse than about 10-15 m accuracy, compute area and warn when it differs a lot from declared acres.
  • Show live accuracy, point count, area and perimeter; allow undo of the last point.
  • Remove personal data from the KML; send it as metadata if needed.
  • Replace "Preview" as the dialog's negative button with a clear Cancel.