Build a versioned spatial coverage service and evaluate it on a held-out district with boundary and stale-site cases.
Project: audit pickup-site coverage across changing zones
Prepare the geometry packet
Create pickup sites with stable IDs, longitude and latitude, coordinate reference, accuracy class, open status and effective time. Create zone polygons with version IDs, including two that share a border, one overlap and one invalid polygon. Add deliveries with immutable event IDs and one late location correction. The coordinate contract determines which records can enter spatial joins.
Build the coverage path
Validate geometry and transform to a suitable reference for exact zone tests. Use a bounding box only as a candidate filter, then apply an exact predicate with a documented border rule. Filter closed sites before ranking. Compare straight-line candidate distance with a travel-time label if available; do not call the former a route estimate.
Evaluate transfer
Hold out one district and a later week, reporting candidate recall, assignment conflicts, unmatched deliveries and distance error by region and boundary proximity. Compare with a random-row split to expose spatial leakage. Record support for sparse cells and avoid releasing fine-grained traces in the public summary. The holdout design should match the deployment claim.
Submit a serving trace
Publish a coherent version of sites and zones, then move one site and close another while the next index builds. Demonstrate that no response mixes versions or returns the closed site. Deliver raw fixture, validation report, query plan, index manifest, evaluation packet and one border-point trace showing the exact tie-break decision.
Implementation
def unique_open_site_ids(site_rows, snapshot_version):
return {site["site_id"] for site in site_rows
if site["snapshot_version"] == snapshot_version
and site["open"] and site["latitude"] is not None
and site["longitude"] is not None}Performance and operating cost
The fixture filter costs O(S) time and O(U) space for S site rows and U unique open sites. Exact spatial queries need geometry validation and an index; serving also requires snapshot and withdrawal gates.
Common Mistakes
- Do not equate a bounding-box hit with polygon membership.
- Do not rank closed sites or mix snapshot versions.
- Do not claim new-region quality from only a random-row split.
