Members
agentmap
Generates an agentmap for the given map.
- Source:
Methods
agentify(count, agentFeatureMaker)
Generate some number of agents and place them on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
count |
number | The desired number of agents. |
agentFeatureMaker |
agentFeatureMaker | A callback that determines an agent i's feature properties and geometry (always a Point). |
buildingify(bounding_box, OSM_data, OSM_data_URL)
Generate and setup the desired map features (e.g. streets, houses).
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. |
OSM_data_URL |
string | URL from which to download equivalent OSM_data. |
- Source:
(private) decodeCoordString(coord_string, place) → {LatLng}
Turn a string containing coordinates (a graph node's ID) into a LatLng object.
Parameters:
| Name | Type | Description |
|---|---|---|
coord_string |
string | A string containing coordinates in the format of "Latitude,Longitude". |
place |
object | An object specifying the place of the coordinate string. |
- Source:
Returns:
- The coordinates encoded by the coord_string.
- Type
- LatLng
(private) encodeLatLng(lat_lng) → {string}
Turn a LatLng object into a string representing its coordinates (to act as a graph node's ID).
Parameters:
| Name | Type | Description |
|---|---|---|
lat_lng |
LatLng | The coordinates to encode into a string. |
- Source:
Returns:
- A string containing coordinates in the format of "Latitude,Longitude".
- Type
- string
(private) generateUnitFeatures(unit_anchors, proposed_unit_features, street_feature_id) → {Array.<Feature>}
Given two anchors, find four nearby points on either side
of the street appropriate to build a unit(s) on.
Parameters:
| Name | Type | Description |
|---|---|---|
unit_anchors |
Array.<Array.<Feature>> | array of pairs of points around which to anchor units along a street. |
proposed_unit_features |
Array.<Feature> | array of features representing real estate units already proposed for construction. |
street_feature_id |
string | The Leaflet layer ID of the street feature along which the unit is being constructed.. |
- Source:
Returns:
unit_features - array of features representing real estate units.
- Type
- Array.<Feature>
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>)>>
(private) getPath(start_int_lat_lng, goal_int_lat_lng, start_lat_lng, goal_lat_lng, sparseopt) → {Array.<Array.<number>>}
Get a path between two points on a graph.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
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. | ||
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. | ||
sparse |
Boolean |
<optional> |
false | Whether to exclude intersections between the first and last along a street-specific path (which are superfluous for extracting the necessary sub-street). |
- Source:
Returns:
- An array of points along the graph, leading from the start to the end.
- Type
- Array.<Array.<number>>
(private) getPathFinder(graph) → {object}
Given an OSM street network (graph), return an A* pathfinder that can operate on it.
Parameters:
| Name | Type | Description |
|---|---|---|
graph |
object | An ngraph graph representing an OSM street network. |
- Source:
Returns:
- An A* pathfinder for the graph.
- Type
- object
(private) getStreetFeatures(OSM_data) → {Array.<Feature>}
Get all streets from the GeoJSON data.
Parameters:
| Name | Type | Description |
|---|---|---|
OSM_data |
Object | A GeoJSON Feature Collection object containing the OSM streets inside the bounding box. |
- Source:
Returns:
- array of street features.
- Type
- Array.<Feature>
(private) getUnitAnchors(street_feature) → {Array.<Array.<Feature>>}
Find anchors for potential units. chors are the pairs of start
and end points along the street from which units may be constructed.
Parameters:
| Name | Type | Description |
|---|---|---|
street_feature |
Feature | A GeoJSON feature object representing a street. |
- Source:
Returns:
- array of pairs of points around which to anchor units along a street.
- Type
- Array.<Array.<Feature>>
(private) getUnitFeatures(OSM_data) → {Array.<Feature>}
Get all appropriate units within the desired bounding box.
Parameters:
| Name | Type | Description |
|---|---|---|
OSM_data |
Object | A GeoJSON Feature Collection object containing the OSM features inside the bounding box. |
- Source:
Returns:
- array of features representing real estate units.
- Type
- Array.<Feature>
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
(private) noOverlaps(polygon_feature, polygon_feature_array) → {boolean}
Check whether a polygon overlaps with any member of an array of polygons.
Parameters:
| Name | Type | Description |
|---|---|---|
polygon_feature |
Feature | A geoJSON polygon feature. |
polygon_feature_array |
Array.<Feature> | array of geoJSON polygon features. |
- Source:
Returns:
- Whether the polygon_feature overlaps with any one in the array.
- 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>)>)>
(private) streetsToGraph(streets) → {Object}
Convert a layerGroup of streets into a graph.
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
(private) unitsOutOfStreets(unit_features, street_layers) → {Array.<Feature>}
Get an array of units excluding units that overlap with streets.
Parameters:
| Name | Type | Description |
|---|---|---|
unit_features |
Array.<Feature> | ray of features representing units. |
street_layers |
Array.<Layer> | ray of Leaflet layers representing streets. |
- Source:
Returns:
- unit_features, but with all units that intersect any streets removed.
- Type
- Array.<Feature>
Type Definitions
agentFeatureMaker(i) → (nullable) {Point}
User-defined callback that gives a feature with appropriate geometry and properties to represent an agent.
Parameters:
| Name | Type | Description |
|---|---|---|
i |
number | A number used to determine the agent's coordinates and other properties. |
Returns:
- Either a GeoJSON Point feature with properties and coordinates for agent i, including
a "place" property that will define the agent's initial agent.place; or null, which will cause agentify
to immediately stop its work & terminate.
- Type
- Point
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 place representing either a unit or a street.
Type:
- object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
street |
number |
<optional> |
The ID of a street in the agentmap's street layer group. |
unit |
number |
<optional> |
The ID of a unit in the agentmap's unit layer group. |
Point
A GeoJSON Feature specifically for individual points.
Type:
Properties:
| Name | Type | Description |
|---|---|---|
geometry.coordinates |
Array | A single array with 2 elements: [longitude, latitude]. |