AgentMaps/docs/global.html
noncomputable bb1ef70be0 Updates
2018-08-31 02:02:42 -04:00

2229 lines
28 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="agentmap"><span class="type-signature"></span>agentmap<span class="type-signature"></span></h4>
<div class="description">
Generates an agentmap for the given map.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agentmap.js.html">agentmap.js</a>, <a href="agentmap.js.html#line252">line 252</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="agent"><span class="type-signature"></span>agent<span class="signature">(lat_lng, options, agentmap)</span><span class="type-signature"></span></h4>
<div class="description">
Returns an agent object.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>lat_lng</code></td>
<td class="type">
<span class="param-type"><a href="global.html#LatLng">LatLng</a></span>
</td>
<td class="description last">A pair of coordinates to locate the agent at.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">An array of options for the agent, namely its layer.</td>
</tr>
<tr>
<td class="name"><code>agentmap</code></td>
<td class="type">
<span class="param-type"><a href="Agentmap.html">Agentmap</a></span>
</td>
<td class="description last">The agentmap instance in which the agent exists.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line665">line 665</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getIntersections"><span class="type-signature"></span>getIntersections<span class="signature">(arr_a, arr_b, ids)</span><span class="type-signature"> &rarr; {Array.&lt;Array.&lt;(number|Object.&lt;number, number>)>>}</span></h4>
<div class="description">
Given two coordinate arrays, get their intersection.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>arr_a</code></td>
<td class="type">
<span class="param-type">array.&lt;array.&lt;number>></span>
</td>
<td class="description last">Array of coordinate pairs.</td>
</tr>
<tr>
<td class="name"><code>arr_b</code></td>
<td class="type">
<span class="param-type">array.&lt;array.&lt;number>></span>
</td>
<td class="description last">Array of coordinate pairs.</td>
</tr>
<tr>
<td class="name"><code>ids</code></td>
<td class="type">
<span class="param-type">array.&lt;number></span>
</td>
<td class="description last">2-element array whose elements are IDs for arr_a and arr_b respectively.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line84">line 84</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- 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.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Array.&lt;(number|Object.&lt;number, number>)>></span>
</dd>
</dl>
<h4 class="name" id="isPointCoordinates"><span class="type-signature"></span>isPointCoordinates<span class="signature">(array)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<div class="description">
Given an array, check whether it can represent the coordinates of a point.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">Array to check.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line36">line 36</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Whether the array can be the coordinates of a point.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="pointToCoordinateArray"><span class="type-signature"></span>pointToCoordinateArray<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<div class="description">
Given either a GeoJSON feature, L.latLng, or coordinate array containing the coordinates of a point,
return an array of the coordinates.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line53">line 53</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Array of the point's coordinates. I.e.: [lng, lat].
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id="reversedCoordinates"><span class="type-signature"></span>reversedCoordinates<span class="signature">(coordinates)</span><span class="type-signature"> &rarr; {Array.&lt;(number|Array.&lt;(number|Array.&lt;number>)>)>}</span></h4>
<div class="description">
Given a geoJSON geometry object's coordinates, return the object, but with
all the coordinates reversed. <br /point.geometry && point.geometry.coordinates && >
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.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>coordinates</code></td>
<td class="type">
<span class="param-type">Array.&lt;(number|Array.&lt;(number|Array.&lt;number>)>)></span>
</td>
<td class="description last">GeoJSON coordinates for a point, (multi-)line, or (multi-)polygon.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line16">line 16</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Reversed geoJSON coordinates for a point, (multi-)line, or (multi-)polygon.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;(number|Array.&lt;(number|Array.&lt;number>)>)></span>
</dd>
</dl>
<h4 class="name" id="setupStreetFeatures"><span class="type-signature"></span>setupStreetFeatures<span class="signature">(OSM_data, street_options)</span><span class="type-signature"></span></h4>
<div class="description">
Generate and setup streets based on the provided GeoJSON data.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>OSM_data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">A GeoJSON Feature Collection object containing the OSM features inside the bounding box.</td>
</tr>
<tr>
<td class="name"><code>street_options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">An object containing the Leaflet styling options for streets.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="buildings.js.html">buildings.js</a>, <a href="buildings.js.html#line37">line 37</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setupUnitFeatures"><span class="type-signature"></span>setupUnitFeatures<span class="signature">(bounding_box, OSM_data, unit_options)</span><span class="type-signature"></span></h4>
<div class="description">
Generate and setup building units based on the provided GeoJSON data.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>bounding_box</code></td>
<td class="type">
<span class="param-type">Array.&lt;Array.&lt;number>></span>
</td>
<td class="description last">The map's top-left and bottom-right coordinates.</td>
</tr>
<tr>
<td class="name"><code>OSM_data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">A GeoJSON Feature Collection object containing the OSM features inside the bounding box.</td>
</tr>
<tr>
<td class="name"><code>unit_options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">An object containing the Leaflet & AgentMaps styling options for units.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="buildings.js.html">buildings.js</a>, <a href="buildings.js.html#line131">line 131</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Type Definitions</h3>
<h4 class="name" id="agentFeatureMaker"><span class="type-signature"></span>agentFeatureMaker<span class="signature">(i)</span><span class="type-signature"> &rarr; {<a href="global.html#Point">Point</a>}</span></h4>
<div class="description">
A user-defined callback function that returns a feature with appropriate geometry and properties to represent an agent.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>i</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">A number used to determine the agent's coordinates and other properties.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line669">line 669</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- a GeoJSON Point feature with properties and coordinates for agent i, including
a "place" property that will set the agent's initial <a href="global.html#Place">Place</a> 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 <a href="https://leafletjs.com/reference-1.3.2.html#circlemarker">https://leafletjs.com/reference-1.3.2.html#circlemarker</a> for all possible layer options.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#Point">Point</a></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>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
]
}
} </code></pre>
<h4 class="name" id="Feature">Feature</h4>
<div class="description">
A GeoJSON feature object.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Should be "Feature".</td>
</tr>
<tr>
<td class="name"><code>properties</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">Non-geometric properties of the feature.</td>
</tr>
<tr>
<td class="name"><code>geometry</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">Geometric properties of the feature (a GeoJSON spec of the feature's geometry).
<h6>Properties</h6>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The feature's GeoJSON geometry type.</td>
</tr>
<tr>
<td class="name"><code>coordinates</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">The coordinates specifying the feature's geometry.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jsdocs.js.html">jsdocs.js</a>, <a href="jsdocs.js.html#line13">line 13</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="http://geojson.org/">http://geojson.org/</a></li>
</ul>
</dd>
</dl>
<h4 class="name" id="LatLng">LatLng</h4>
<div class="description">
Represents a latitude/longitude pair. Preferably an instance of L.LatLng:
<a href="https://leafletjs.com/reference-1.3.2.html#latlng">https://leafletjs.com/reference-1.3.2.html#latlng</a>.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>lat</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last">A decimal latitude.</td>
</tr>
<tr>
<td class="name"><code>lng</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last">A decimal longitude.</td>
</tr>
<tr>
<td class="name"><code>new_place</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Place">Place</a></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">A place (unit or street) associated with this LatLng.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jsdocs.js.html">jsdocs.js</a>, <a href="jsdocs.js.html#line3">line 3</a>
</li></ul></dd>
</dl>
<h4 class="name" id="Place">Place</h4>
<div class="description">
A object describing a location.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Either "street", "unit", or "unanchored".</td>
</tr>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">The ID of either a street or unit in the appropriate layer group, if the place is "street" or "unit".</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jsdocs.js.html">jsdocs.js</a>, <a href="jsdocs.js.html#line32">line 32</a>
</li></ul></dd>
</dl>
<h4 class="name" id="Point">Point</h4>
<div class="description">
A GeoJSON <a href="global.html#Feature">Feature</a> specifically for individual points.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="global.html#Feature">Feature</a></span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>geometry.coordinates</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">A single array with 2 elements: [longitude, latitude].</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jsdocs.js.html">jsdocs.js</a>, <a href="jsdocs.js.html#line25">line 25</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Agent.html">Agent</a></li><li><a href="Agentmap.html">Agentmap</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-quickstart.html">quickstart</a></li></ul><h3>Global</h3><ul><li><a href="global.html#agent">agent</a></li><li><a href="global.html#agentmap">agentmap</a></li><li><a href="global.html#getIntersections">getIntersections</a></li><li><a href="global.html#isPointCoordinates">isPointCoordinates</a></li><li><a href="global.html#pointToCoordinateArray">pointToCoordinateArray</a></li><li><a href="global.html#reversedCoordinates">reversedCoordinates</a></li><li><a href="global.html#setupStreetFeatures">setupStreetFeatures</a></li><li><a href="global.html#setupUnitFeatures">setupUnitFeatures</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Aug 31 2018 01:45:53 GMT-0400 (Eastern Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>