# Global

##

### Members

#### agentmap

Generates an agentmap for the given map.

Source:
  - agentmap.js, line 278

### 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:
  - agents.js, line 665

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

Given two coordinate arrays, get their intersection.

##### 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:
  - utils.js, line 84

##### Returns:

- Array whose elements are the intersections' cooridinates if ids is empty, or otherwise whose elements are arrays each of whose first element is an intersection's coordinates and whose second element is an object mapping each array's ID (supplied by ids) to the index of the intersecting coordinate-pair in that array.

Type
  Array.<Array.<(number|Object.<number, number>)>>

#### 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:
  - utils.js, line 36

##### Returns:

- Whether the array can be the coordinates of a point.

Type
  boolean

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

Given either a GeoJSON feature, L.latLng, or coordinate array containing the coordinates of a point, return an array of the coordinates.

Source:
  - utils.js, line 53

##### 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:
  - utils.js, line 16

##### Returns:

- Reversed geoJSON coordinates for a point, (multi-)line, or (multi-)polygon.

Type
  Array.<(number|Array.<(number|Array.<number>)>)>

#### setupStreetFeatures(streets_data, street_options)

Generate and setup streets based on the provided GeoJSON data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`streets_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.

Source:
  - buildings.js, line 38

#### setupUnitFeatures(bounding_box, streets_data, unit_options, units_dataopt)

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.
`streets_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.
`units_data` | object | <optional> | If you want to load a previously generated AgentMaps.units object instead of generating one from scarch: A GeoJSON Feature Collection of an AgentMaps.units featureGroup.

Source:
  - buildings.js, line 138

#### streetToGraph()

Process a street layer and add it into a graph.

Source:
  - routing.js, line 32

### 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:
  - agents.js, line 669

##### Returns:

- a GeoJSON Point feature with properties and coordinates for the agent, including a "place" property that will set the agent's initial Place and an object "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:
  - jsdocs.js, line 13
See:
  - http://geojson.org/

#### 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:
  - jsdocs.js, line 3

#### 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:
  - jsdocs.js, line 32

#### Point

A GeoJSON Feature specifically for individual points.

##### Type:

- Feature

##### Properties:

Name | Type | Description
--- | --- | ---
`geometry.coordinates` | Array | A single array with 2 elements: [longitude, latitude].

Source:
  - jsdocs.js, line 25