Global

Members

agentmap

Generates an agentmap for the given map.
Source:

Methods

agent(lat_lng, options, agentmap)

Returns an agent object.
Parameters:
Name Type Description
lat_lng LatLng A pair of coordinates to locate 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.
Source:

getIntersections(arr_a, arr_b, ids) → {Array.<Array.<(number|Object.<number, number>)>>}

Given two coordinate arrays, get their intersections.
Parameters:
Name Type Description
arr_a array.<array.<number>> Array of coordinate pairs.
arr_b array.<array.<number>> Array of coordinate pairs.
ids array.<number> 2-element array whose elements are IDs for arr_a and arr_b respectively.
Source:
Returns:
- Array whose elements are the intersections' cooridinate-pairs if ids is empty, or otherwise whose elements are arrays each of whose first element is an intersection's coordinate-pair and whose second element is an object mapping each array's ID (supplied by ids) to the index of the intersection's coordinate-pair in that array.
Type
Array.<Array.<(number|Object.<number, number>)>>

getPathFinder(graph) → {object}

Given a street network (graph), return a pathfinder that can operate on it. Useful if you modify the street graph during the simulation.
Parameters:
Name Type Description
graph object An ngraph graph representing an OSM street network.
Source:
Returns:
- An A* pathfinder for the graph.
Type
object

isPointCoordinates(array) → {boolean}

Given an array, check whether it can represent the coordinates of a point.
Parameters:
Name Type Description
array Array Array to check.
Source:
Returns:
- Whether the array can be the coordinates of a point.
Type
boolean

pointToCoordinateArray(point) → {Array.<number>}

Given either a GeoJSON feature, L.latLng, or coordinate array containing the coordinates of a point, return an array of the coordinates.
Parameters:
Name Type Description
point Point | Array.<number> | LatLng The data containing the point's coordinates (latitude & longitude).
Source:
Returns:
- Array of the point's coordinates. I.e.: [lng, lat].
Type
Array.<number>

reversedCoordinates(coordinates) → {Array.<(number|Array.<(number|Array.<number>)>)>}

Given a geoJSON geometry object's coordinates, return the object, but with all the coordinates reversed.
Why? GeoJSON coordinates are in lngLat format by default, while Leaflet uses latLng. L.geoJSON will auto-reverse the order of a GeoJSON object's coordinates, as it expects geoJSON coordinates to be lngLat. However, normal, non-GeoJSON-specific Leaflet methods expect Leaflet's latLng pairs and won't auto-reverse, so we have to do that manually if we're preprocessing the GeoJSON data before passing it to L.geoJSON.
Parameters:
Name Type Description
coordinates Array.<(number|Array.<(number|Array.<number>)>)> GeoJSON coordinates for a point, (multi-)line, or (multi-)polygon.
Source:
Returns:
- Reversed geoJSON coordinates for a point, (multi-)line, or (multi-)polygon.
Type
Array.<(number|Array.<(number|Array.<number>)>)>

setupStreetFeatures(OSM_data, street_options, street_layersopt)

Generate and setup streets based on the provided GeoJSON data.
Parameters:
Name Type Attributes Description
OSM_data object A GeoJSON Feature Collection object containing the OSM street features inside the bounding box.
street_options object An object containing the Leaflet styling options for streets.
street_layers object <optional>
If you want to load a previously generated AgentMaps.streets object instead of generating one from scratch: A GeoJSON Feature Collection of an AgentMaps.streets featureGroup.
Source:

setupUnitFeatures(bounding_box, OSM_data, unit_options, unit_layersopt)

Generate and setup building units based on the provided GeoJSON data.
Parameters:
Name Type Attributes Description
bounding_box Array.<Array.<number>> The map's top-left and bottom-right coordinates.
OSM_data object A GeoJSON Feature Collection object containing the OSM street features inside the bounding box.
unit_options object An object containing the Leaflet & AgentMaps styling options for units.
unit_layers object <optional>
If you want to load a previously generated AgentMaps.units object instead of generating one from scratch: A GeoJSON Feature Collection of an AgentMaps.units featureGroup.
Source:

streetsToGraph(streets) → {Object}

Convert a layerGroup of streets into a graph. Useful if you modify the street layers during the simulation and want routing to work with the new street network.
Parameters:
Name Type Description
streets LayerGroup A Leaflet layerGroup of streets, forming a street network.
Source:
Returns:
- A graph representing the street network, operable by the ngraph pathfinder.
Type
Object

streetToGraph(graph, street)

Process a street layer and add it into a graph.
Parameters:
Name Type Description
graph ngraph.graph An ngraph.graph representing a street network.
street L.Polyline A Leaflet Polyline layer for a street.
Source:

Type Definitions

agentFeatureMaker(id) → {Point}

A user-defined callback function that returns a feature with appropriate geometry and properties to represent an agent.
Parameters:
Name Type Description
id number The agent's Leaflet layer ID.
Source:
Returns:
- A GeoJSON Point object with geometry and other properties for the agent, including a "place" property that will set the agent's initial Place and a "layer_options" property that will specify the feature's Leaflet options (like its color, size, etc.). All other provided properties will be transferred to the Agent object once it is created. See https://leafletjs.com/reference-1.3.2.html#circlemarker for all possible layer options.
Type
Point
Example
let point = {					
	"type": "Feature",				 
	"properties": {					
		"layer_options": {			
			"color": "red",			
			"radius": .5,			
		},					
		"place": {				
			"type": "unit",			
			"id": 89			
		},					
							
		age: 72,				
		home_city: "LA"				
	},						
	"geometry" {					
		"type": "Point",			
		"coordinates": [			
			14.54589,			
			57.136239			
		]					
	}						
}							

Feature

A GeoJSON feature object.
Type:
  • object
Properties:
Name Type Description
type string Should be "Feature".
properties object Non-geometric properties of the feature.
geometry object Geometric properties of the feature (a GeoJSON spec of the feature's geometry).
Properties
Name Type Description
type string The feature's GeoJSON geometry type.
coordinates Array The coordinates specifying the feature's geometry.
Source:
See:

LatLng

Represents a latitude/longitude pair. Preferably an instance of L.LatLng: https://leafletjs.com/reference-1.3.2.html#latlng.
Type:
  • object
Properties:
Name Type Attributes Description
lat number A decimal latitude.
lng number A decimal longitude.
new_place Place <optional>
A place (unit or street) associated with this LatLng.
Source:

Place

A object describing a location.
Type:
  • object
Properties:
Name Type Description
type string Either "street", "unit", or "unanchored".
id number The ID of either a street or unit in the appropriate layer group, if the place is "street" or "unit".
Source:

Point

A GeoJSON Feature specifically for individual points.
Type:
Properties:
Name Type Description
geometry.coordinates Array A single array with 2 elements: [longitude, latitude].
Source: