new Agent(lat_lng, options, agentmap)
Constructor for the Agent class, using Leaflet class system.
Parameters:
| Name | Type | Description |
|---|---|---|
lat_lng |
LatLng | A pair of coordinates to place the agent at. |
options |
Object | An array of options for the agent, namely its layer. |
agentmap |
Agentmap | The agentmap instance in which the agent exists. |
Properties:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
feature.AgentMap_id |
number | The agent's instance id, so it can be accessed from inside the Leaflet layer. To avoid putting the actual instance inside the feature object. | |||||||||||||||||||||||||||||||||
agentmap |
Agentmap | The agentmap instance in which the agent exists. | |||||||||||||||||||||||||||||||||
place |
Place | A place object containing the id of the place (unit, street, etc.) where the agent is currently at. | |||||||||||||||||||||||||||||||||
travel_state |
Object | Properties detailing information about the agent's trip that change sometimes, but needs to be accessed by future updates.
Properties
|
|||||||||||||||||||||||||||||||||
update_func |
function |
<nullable> |
Function to be called on each update. |
Methods
(private, static) moveDirectly(rAF_time)
Continue to move the agent directly from one point to another, without regard for streets,
according to the time that has passed since the last movement. Also simulate intermediary movements
during the interval between the current call and the last call to moveDirectly, by splitting that interval
up with some precision (agentmap.settings.movement_precision) into some number of parts (steps_inbetween)
and moving slightly for each of them, for more precise collision detection than just doing it after each
call to moveDirectly from requestAnimationFrame (max, 60 times per second) would allow. Limiting movements to
each requestAnimationFrame call was causing each agent to skip too far ahead at each call, causing moveDirectly
to not be able to catch when the agent is within 1 meter of the goal_point... splitting the interval since the last
call up and making intermediary calls fixes that.
Parameters:
| Name | Type | Description |
|---|---|---|
rAF_time |
number | The time when the browser's most recent animation frame was released. |
(private, static) newTripStartPlace() → {Place}
Given the agent's currently scheduled trips (its path), get the place from which a new trip should start (namely, the end of the current path).
That is: If there's already a path in queue, start the new path from the end of the existing one.
Returns:
- The place where a new trip should start.
- Type
- Place
(private, static) resetTravelState()
Stop the agent from traveling, reset all the properties of its travel state.
(private, static) setTravelAlongStreet(goal_lat_lng, goal_place)
Schedule the agent to travel to a point along the streets, via streets.
Parameters:
| Name | Type | Description |
|---|---|---|
goal_lat_lng |
LatLng | The coordinates of a point on a street to which the agent should travel. |
goal_place |
Place | The place to which the agent will travel. Must be of form {"street": street_id}. |
(private, static) setTravelInUnit(goal_lat_lng)
Schedule the agent to travel to a point within the unit he is in.
Parameters:
| Name | Type | Description |
|---|---|---|
goal_lat_lng |
LatLng | LatLng coordinate object for a point in the same unit the agent is in. |
(private, static) setTravelOnSameStreet(start_lat_lng, goal_lat_lng, street_feature, street_id)
Schedule the agent to travel between two points on the same street.
Parameters:
| Name | Type | Description |
|---|---|---|
start_lat_lng |
LatLng | The coordinates of the point on the street from which the agent will be traveling. |
goal_lat_lng |
LatLng | The coordinates of the point on the street to which the agent should travel. |
street_feature |
Feature | A GeoJSON object representing an OpenStreetMap street. |
street_id |
number | The ID of the street in the streets layerGroup. |
(private, static) setTravelOnStreetNetwork(start_lat_lng, goal_lat_lng, start_int_lat_lng, goal_int_lat_lng)
Schedule the agent up to travel between two points on a street network.
Parameters:
| Name | Type | Description |
|---|---|---|
start_lat_lng |
LatLng | The coordinates of the point on the street from which the agent will be traveling. |
goal_lat_lng |
LatLng | The coordinates of the point on the street to which the agent should travel. |
start_int_lat_lng |
LatLng | The coordinates of the nearest intersection on the same street at the start_lat_lng. |
goal_int_lat_lng |
LatLng | The coordinates of the nearest intersection on the same street as the goal_lat_lng. |
(static) setTravelToPlace(goal_lat_lng, goal_place, replace_trip)
Schedule the agent to travel directly from any point (e.g. of a street or unit) to a point (e.g. of another street or unit).
Parameters:
| Name | Type | Description |
|---|---|---|
goal_lat_lng |
LatLng | The point within the place to which the agent is to travel. |
goal_place |
Place | The place to which the agent will travel. Must be of form {"unit": unit_id} or {"street": street_id}. |
replace_trip |
Boolean | Whether to empty the currently scheduled path and replace it with this new trip; false by default (the new trip is simply appended to the current scheduled path). |
(private, static) startTrip()
Start a trip along the path specified in the agent's travel_state.
(private, static) travelTo(goal_point)
Set the agent to travel to some point on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
goal_point |
LatLng | The point to which the agent should travel. |
(private, static) update(rAF_time)
Make the agent proceed with whatever it's doing and update its properties before the browser draws the next frame.
Parameters:
| Name | Type | Description |
|---|---|---|
rAF_time |
number | The time when the browser's most recent animation frame was released. |