|
| 1 | +# Settlemaker measured village water |
| 2 | + |
| 3 | +FMG implements the sender side of Settlemaker's `water-context-v1` contract |
| 4 | +(`settlemaker/docs/water-context-v1.md`, revision `8ebc23a`). The renderer must |
| 5 | +implement that contract before this mode is enabled. |
| 6 | + |
| 7 | +## Rollout |
| 8 | + |
| 9 | +`VITE_SETTLEMAKER_WATER_CONTEXT_URL` is a build-time opt-in. Leave it unset for |
| 10 | +normal production builds until a deployed Settlemaker release explicitly supports |
| 11 | +water-context v1 for villages. An old decoder ignores the new field and can still |
| 12 | +invent a nearby shore from the legacy bearing. |
| 13 | + |
| 14 | +To exercise a supporting local renderer: |
| 15 | + |
| 16 | +```sh |
| 17 | +VITE_SETTLEMAKER_WATER_CONTEXT_URL=http://127.0.0.1:5173/fmg npm run dev |
| 18 | +``` |
| 19 | + |
| 20 | +Production endpoints must use HTTPS and the `/fmg` path, without a query or |
| 21 | +fragment. Pin the supporting renderer release in the deployment and configure |
| 22 | +its endpoint when building FMG. This option routes both embedded and external |
| 23 | +village previews to the same URL. Population 1–1000 uses the new contract; |
| 24 | +cities continue using the existing production URL and payload. |
| 25 | + |
| 26 | +## Sender behavior |
| 27 | + |
| 28 | +- Survey a 3 km radius around the actual burg coordinates, independent of port |
| 29 | + status. Export the enclosing 6 km square as simple filled water pieces, with |
| 30 | + islands retained as dry land. Always include `coastlineGeometry`, including |
| 31 | + an explicit empty array for a dry survey. No simple-coast approximation is used. |
| 32 | +- Use `Coastline.getFeaturePath`, shared with drawing and saving. Loading adopts |
| 33 | + the saved SVG boundary; surveying does not regenerate or mutate it. Map changes, |
| 34 | + coastline edits and coastline settings invalidate the geometry cache/index. |
| 35 | +- Convert map coordinates once using the selected distance unit. Flatten curves |
| 36 | + adaptively within 0.2 m; report a conservative combined `geometryErrorM` of |
| 37 | + 0.5 m. Do not round or simplify exported coordinates. Reject ambiguous narrow |
| 38 | + or crossing curved shores instead of silently changing local topology. |
| 39 | +- Measure exposed real shores from the same flattened boundary that supplies |
| 40 | + the polygons. Shared piece edges and survey-square closures are not banks. |
| 41 | + If real shores lie beyond coverage, search the canonical full boundary. |
| 42 | +- Unsupported custom units produce `unknown-units`, with no metric geometry. |
| 43 | + FMG currently has no custom metres-per-unit setting. |
| 44 | +- Local river widths are unavailable from the burg context. Omit river surveys |
| 45 | + and identify context rivers through `omittedRivers`; never substitute the |
| 46 | + kilometre-valued river mouth width for the width beside the burg. |
| 47 | +- Keep the compressed `i` envelope. If the encoded payload exceeds 8192 bytes, |
| 48 | + compression fails, or geometry cannot be surveyed safely, show the failure |
| 49 | + in the burg editor and on an external-open attempt. Do not discard measured |
| 50 | + state by falling back to a flat URL. |
| 51 | + |
| 52 | +Surveys extending beyond the map rectangle fail explicitly; wrapped geography |
| 53 | +is not inferred. Very detailed coasts can exceed the URL budget. There is no |
| 54 | +automatic simplification or resurvey in this implementation. |
| 55 | + |
| 56 | +## Renderer handoff and validation |
| 57 | + |
| 58 | +Settlemaker owns water-union bank queries, metric layout, bounded planning, |
| 59 | +frame/coverage validation, input precedence and visible iframe diagnostics. |
| 60 | +The FMG sender does not implement those renderer behaviors or an iframe message |
| 61 | +protocol. Before enabling production, verify those behaviors against the |
| 62 | +supporting release in both embedded and external-open flows. |
| 63 | + |
| 64 | +Focused tests cover distance/units, finite lakes and islands, peninsula geometry, |
| 65 | +curve inclusion and precision, narrow channels, union shore measurement, crop |
| 66 | +closures, unknown units, missing local river widths, saved geometry invalidation, |
| 67 | +URL-budget failures, and population 1000/1001 rollout boundaries. The 11,115 m |
| 68 | +Tarrimas-Ha case is synthetic geography reproducing the measured distance; it |
| 69 | +does not replay the original Borteland save. |
| 70 | + |
| 71 | +Browser validation with the sender enabled covered 394 generated villages: |
| 72 | +391 encoded successfully, including 34 with water, and three correctly failed |
| 73 | +the URL budget. Saving/reloading with hidden water layers retained the exact |
| 74 | +saved boundary and surveying left displayed paths untouched. These checks used |
| 75 | +a local URL target to inspect payloads, not a running measured-water renderer. |
| 76 | +The older 1.112.1 map fixture also retained its saved boundary through loading |
| 77 | +and a subsequent measured survey. |
0 commit comments