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. |
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. |
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. |
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.
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.
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. |
Returns:
- Reversed geoJSON coordinates for a point, (multi-)line, or (multi-)polygon.
- Type
- Array.<(number|Array.<(number|Array.<number>)>)>
setupStreetFeatures(OSM_data, street_options)
Generate and setup streets based on the provided GeoJSON data.
Parameters:
Name | Type | Description |
---|---|---|
OSM_data |
object | A GeoJSON Feature Collection object containing the OSM features inside the bounding box. |
street_options |
object | An object containing the Leaflet styling options for streets. |
- Source:
setupUnitFeatures(bounding_box, OSM_data, unit_options)
Generate and setup building units based on the provided GeoJSON data.
Parameters:
Name | Type | 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 features inside the bounding box. |
unit_options |
object | An object containing the Leaflet & AgentMaps styling options for units. |
- 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. |
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
|
- 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. |
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". |
Point
A GeoJSON Feature specifically for individual points.
Type:
Properties:
Name | Type | Description |
---|---|---|
geometry.coordinates |
Array | A single array with 2 elements: [longitude, latitude]. |