{
  "docVersion": 1,
  "id": "blog-gis-4",
  "name": "Geofencing — is this point inside the zone?",
  "purpose": "Delivery areas and surge zones are polygons. ST_Contains(zone, point) answers 'is this address serviceable?' in one indexed query.",
  "nodes": {
    "addr": {
      "type": "mobile",
      "label": "Customer address",
      "x": 40,
      "y": 240,
      "w": 140,
      "h": 86,
      "runtime": "drops a pin"
    },
    "q": {
      "type": "search",
      "label": "ST_Contains(zone, point)",
      "x": 320,
      "y": 240,
      "w": 210,
      "h": 86,
      "color": "blue",
      "runtime": "point-in-polygon"
    },
    "z1": {
      "type": "geo",
      "label": "Zone A — free delivery",
      "x": 640,
      "y": 80,
      "w": 190,
      "h": 86,
      "color": "green",
      "runtime": "polygon"
    },
    "z2": {
      "type": "geo",
      "label": "Zone B — surge ×1.5",
      "x": 640,
      "y": 240,
      "w": 190,
      "h": 86,
      "color": "amber",
      "runtime": "polygon"
    },
    "z3": {
      "type": "geo",
      "label": "outside all zones",
      "x": 640,
      "y": 400,
      "w": 190,
      "h": 86,
      "color": "red",
      "style": "dashed",
      "runtime": "not serviceable"
    },
    "out": {
      "type": "k8s",
      "label": "quote + eligibility",
      "x": 960,
      "y": 240,
      "w": 140,
      "h": 86,
      "color": "green"
    }
  },
  "edges": {
    "e1": {
      "from": "addr",
      "to": "q",
      "fromSide": "right",
      "toSide": "left",
      "animated": true
    },
    "e2": {
      "from": "q",
      "to": "z1",
      "fromSide": "right",
      "toSide": "left",
      "label": "inside?",
      "style": "dashed"
    },
    "e3": {
      "from": "q",
      "to": "z2",
      "fromSide": "right",
      "toSide": "left",
      "label": "inside?",
      "style": "dashed"
    },
    "e4": {
      "from": "q",
      "to": "z3",
      "fromSide": "right",
      "toSide": "left",
      "label": "inside?",
      "style": "dashed",
      "color": "red"
    },
    "e5": {
      "from": "z2",
      "to": "out",
      "fromSide": "right",
      "toSide": "top",
      "label": "match → apply surge",
      "color": "amber",
      "animated": true
    }
  },
  "boxes": {},
  "texts": {
    "t1": {
      "x": 40,
      "y": 380,
      "text": "same primitive powers: 'are you in our delivery radius?', surge pricing zones,\n'notify me when I enter/leave this area', regulatory boundaries. one GiST index,\nmany products. the polygon can be a neighborhood, a city, or a hand-drawn area.",
      "color": "gray",
      "size": 12
    }
  },
  "meta": {
    "createdAt": "2026-07-21T09:00:00.000Z",
    "modifiedAt": "2026-07-21T09:00:00.000Z"
  }
}