coverage_reservations
coverage_reservations
#
Per-user location reservations — spread a crowd across a survey area.
The spatial sibling of
ReservationBook:
each user leases a place out of a batch, and a place is retired once a capture
lands within threshold of it.
DEFAULT_LEASE = timedelta(minutes=30)
module-attribute
#
How long a handout is held before, absent a covering capture, it recycles.
CoverageBook
#
Bases: ImpureState
The persistent book of location leases.
batch holds the un-handed-out survey locations; held maps each user
to their [Lease][]. The struct IS the format: changing its shape starts a
fresh book (no migration).
Source code in capturegraph-lib/capturegraph/scheduling/organize/coverage_reservations.py
release(user_id)
#
Drop this user's hold, without returning its location to the batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The user giving up their location. |
required |
Source code in capturegraph-lib/capturegraph/scheduling/organize/coverage_reservations.py
reserve(user_id, *, distance, at=None, fulfilled_by=(), threshold=1.0, lease=DEFAULT_LEASE, refill=None, now=None)
#
The location this user holds, leasing one from the batch if none.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The user asking for a location. |
required |
distance
|
Callable[[Location, Location], float]
|
A distance between two |
required |
at
|
Location | None
|
The requester's current location, if known. The batch location closest to it is leased; without it, the batch is leased in insertion order (FIFO). |
None
|
fulfilled_by
|
Sequence[Location]
|
Captured locations; a reservation or batch location within
|
()
|
threshold
|
float
|
A reservation is released once a capture lies within this
distance of it, in the units |
1.0
|
lease
|
timedelta
|
How long a handout is held before, absent a covering capture, the location returns to the batch. Defaults to 30 minutes. |
DEFAULT_LEASE
|
refill
|
Sequence[Location] | None
|
Locations to install as the batch when it is exhausted. Ignored while the batch still has locations to hand out. |
None
|
now
|
datetime | None
|
The reference time; defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Location | None
|
The user's reserved location, or |
Location | None
|
and the user holds nothing. |