@jibestream-dev/jmap-navigation-kit
Version:
Kit for the Jibestream SDK to create Navigation Instructions based on a wayfinding path
426 lines (307 loc) • 18.2 kB
Markdown
## Classes
<dl>
<dt><a href="#Direction">Direction</a></dt>
<dd><p>Returns an English direction, given three waypoints with which to calculate</p>
</dd>
<dt><a href="#Instruction">Instruction</a></dt>
<dd><p>Returns an Instruction, given a Direction object</p>
</dd>
<dt><a href="#InstructionFactory">InstructionFactory</a></dt>
<dd><p>Returns an Instruction Factory, which can be used to create an empty or populated Instruction</p>
</dd>
<dt><a href="#NavigationKit">NavigationKit</a></dt>
<dd><p>Returns a NavigationKit, which can be used to generate Directions and Instructions</p>
</dd>
<dt><a href="#SurroundingDefinition">SurroundingDefinition</a></dt>
<dd><p>Returns a SurroundingDefinition</p>
</dd>
<dt><a href="#SurroundingElements">SurroundingElements</a></dt>
<dd><p>Returns a SurroundingElements object</p>
</dd>
<dt><a href="#SurroundingIcon">SurroundingIcon</a></dt>
<dd><p>Returns a SurroundingIcon</p>
</dd>
<dt><a href="#SurroundingItem">SurroundingItem</a></dt>
<dd><p>Returns a SurroundingItem</p>
</dd>
<dt><a href="#SurroundingShape">SurroundingShape</a></dt>
<dd><p>Returns a SurroundingShape</p>
</dd>
</dl>
<a name="Direction"></a>
## Direction
Returns an English direction, given three waypoints with which to calculate
**Kind**: global class
* [Direction](#Direction)
* [new Direction(a, b, c, [threshold], [uTurnThreshold])](#new_Direction_new)
* [.getValue()](#Direction+getValue) ⇒ <code>String</code>
<a name="new_Direction_new"></a>
### new Direction(a, b, c, [threshold], [uTurnThreshold])
Creates a Direction
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| a | <code>jmap.core.Waypoint</code> | | The first waypoint in the series of three waypoints |
| b | <code>jmap.core.Waypoint</code> | | The second waypoint in the series of three waypoints |
| c | <code>jmap.core.Waypoint</code> | | The third waypoint in the series of three waypoints |
| [threshold] | <code>Number</code> | <code>20</code> | The threshold for deciding between forward and left/right |
| [uTurnThreshold] | <code>Number</code> | <code>45</code> | The threshold for deciding a U-Turn |
<a name="Direction+getValue"></a>
### direction.getValue() ⇒ <code>String</code>
- Returns the English direction for the current instance of a Direction
**Kind**: instance method of [<code>Direction</code>](#Direction)
**Returns**: <code>String</code> - - The English direction for the current instance of a Direction
**Access**: public
<a name="Instruction"></a>
## Instruction
Returns an Instruction, given a Direction object
**Kind**: global class
<a name="new_Instruction_new"></a>
### new Instruction(direction)
Creates an Instruction
| Param | Type | Description |
| --- | --- | --- |
| direction | [<code>Direction</code>](#Direction) | The direction that will be used to generate the instruction |
<a name="InstructionFactory"></a>
## InstructionFactory
Returns an Instruction Factory, which can be used to create an empty or populated Instruction
**Kind**: global class
* [InstructionFactory](#InstructionFactory)
* [new InstructionFactory(direction)](#new_InstructionFactory_new)
* _instance_
* [.createFromDirection(direction)](#InstructionFactory+createFromDirection) ⇒ [<code>Instruction</code>](#Instruction)
* [.setSurroundingElements(instruction)](#InstructionFactory+setSurroundingElements)
* [.setSurroundingDefinition(instruction)](#InstructionFactory+setSurroundingDefinition)
* _static_
* [.createEmpty()](#InstructionFactory.createEmpty) ⇒ [<code>Instruction</code>](#Instruction)
<a name="new_InstructionFactory_new"></a>
### new InstructionFactory(direction)
Creates an Instruction
| Param | Type | Description |
| --- | --- | --- |
| direction | [<code>Direction</code>](#Direction) | The direction that will be used to generate the instruction |
<a name="InstructionFactory+createFromDirection"></a>
### instructionFactory.createFromDirection(direction) ⇒ [<code>Instruction</code>](#Instruction)
- Sets the distance of the Instruction, based on two Waypoints
**Kind**: instance method of [<code>InstructionFactory</code>](#InstructionFactory)
**Returns**: [<code>Instruction</code>](#Instruction) - - The Instruction generated with the specified Direction
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| direction | [<code>Direction</code>](#Direction) | The direction with which to create the Instruction |
<a name="InstructionFactory+setSurroundingElements"></a>
### instructionFactory.setSurroundingElements(instruction)
- Sets the surrounding elements of the navigation kit, based on the specified instruction
**Kind**: instance method of [<code>InstructionFactory</code>](#InstructionFactory)
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| instruction | [<code>Instruction</code>](#Instruction) | The Instruction with which to calculate the surrounding elements |
<a name="InstructionFactory+setSurroundingDefinition"></a>
### instructionFactory.setSurroundingDefinition(instruction)
- Sets the surrounding definition of the specified instruction
**Kind**: instance method of [<code>InstructionFactory</code>](#InstructionFactory)
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| instruction | [<code>Instruction</code>](#Instruction) | The instruction that will have its surrounding definition updated |
<a name="InstructionFactory.createEmpty"></a>
### InstructionFactory.createEmpty() ⇒ [<code>Instruction</code>](#Instruction)
- Returns an empty Instruction
**Kind**: static method of [<code>InstructionFactory</code>](#InstructionFactory)
**Returns**: [<code>Instruction</code>](#Instruction) - - The Instruction generated with the specified Direction
**Access**: public
<a name="NavigationKit"></a>
## NavigationKit
Returns a NavigationKit, which can be used to generate Directions and Instructions
**Kind**: global class
* [NavigationKit](#NavigationKit)
* [new NavigationKit(control, options)](#new_NavigationKit_new)
* _instance_
* [.setAngleThreshold(threshold)](#NavigationKit+setAngleThreshold)
* [.setUTurnThreshold([uTurnThreshold])](#NavigationKit+setUTurnThreshold)
* [.getSurroundingElements(definition)](#NavigationKit+getSurroundingElements) ⇒ <code>Array.<SurroundElements></code>
* [.createInstructionsFromPath(pathPerFloor)](#NavigationKit+createInstructionsFromPath) ⇒ [<code>Array.<Instruction></code>](#Instruction)
* [.hasUserVeeredOffRoute(route)](#NavigationKit+hasUserVeeredOffRoute) ⇒ <code>Number</code>
* [.drawPathWithInstructions(pathPerFloor, [pathStyle], [popupStyle], [fontStyle])](#NavigationKit+drawPathWithInstructions) ⇒ <code>Object</code>
* _static_
* [.getMovedPoint(origin, angle, distance)](#NavigationKit.getMovedPoint) ⇒ <code>Array.<Number></code>
* [.doBoundsIntersect(a, b)](#NavigationKit.doBoundsIntersect) ⇒ <code>Boolean</code>
* [.isSegmentInCircle(p1, p2, circle)](#NavigationKit.isSegmentInCircle) ⇒ <code>Boolean</code>
* [.segmentInPolygon(segment, gazePolygon)](#NavigationKit.segmentInPolygon) ⇒ <code>Boolean</code>
<a name="new_NavigationKit_new"></a>
### new NavigationKit(control, options)
Creates a NavigationKit
| Param | Type | Description |
| --- | --- | --- |
| control | <code>JController</code> | The controller for the currently rendered map |
| options | <code>Object</code> | The options with which to configure the NavigationKit |
| options.visualLimitLeft | <code>Number</code> | How many degrees counter-clockwise from the gaze direction shall we consider when calculating surrounding elements |
| options.visualLimitRight | <code>Number</code> | How many degrees clockwise from the gaze direction shall we consider when calculating surrounding elements |
| options.layersOfInterest | <code>Array.<String></code> | That layers that shall be considered when looking for surrounding elements |
| options.visualObstacles | <code>Array.<String></code> | That layers that shall be considered when looking for obstacles |
| options.visualRange | <code>Number</code> | How far into the distance a user is able to percieve shapes/icons |
| options.angleThreshold | <code>Number</code> | The threshold for deciding between forward and left/right |
<a name="NavigationKit+setAngleThreshold"></a>
### navigationKit.setAngleThreshold(threshold)
- Sets the angle threshold for determining whether a direction is straight or left/right
**Kind**: instance method of [<code>NavigationKit</code>](#NavigationKit)
**Access**: public
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| threshold | <code>Number</code> | <code>20</code> | The angle threshold for determining whether a direction is straight or left/right |
<a name="NavigationKit+setUTurnThreshold"></a>
### navigationKit.setUTurnThreshold([uTurnThreshold])
- Sets the angle threshold for determining whether a direction is a U-Turn
**Kind**: instance method of [<code>NavigationKit</code>](#NavigationKit)
**Access**: public
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [uTurnThreshold] | <code>Number</code> | <code>45</code> | The angle threshold for determining whether a direction is a U-Turn |
<a name="NavigationKit+getSurroundingElements"></a>
### navigationKit.getSurroundingElements(definition) ⇒ <code>Array.<SurroundElements></code>
- Sets the distance of the Instruction, based on two Waypoints
**Kind**: instance method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Array.<SurroundElements></code> - - The surrounding elements for a given surrounding definition
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| definition | [<code>SurroundingDefinition</code>](#SurroundingDefinition) | The first waypoint that defines a line |
<a name="NavigationKit+createInstructionsFromPath"></a>
### navigationKit.createInstructionsFromPath(pathPerFloor) ⇒ [<code>Array.<Instruction></code>](#Instruction)
- Returns an array of instructions, given a specific path
**Kind**: instance method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: [<code>Array.<Instruction></code>](#Instruction) - - An array of Instructions, based on the wayfinding path
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| pathPerFloor | <code>Array.<Object></code> | The first waypoint that defines a line |
<a name="NavigationKit+hasUserVeeredOffRoute"></a>
### navigationKit.hasUserVeeredOffRoute(route) ⇒ <code>Number</code>
- Checks if user location is within the threshold from the closest line in the
wayfinding path, returns true if outside threshold and false otherwise.
**Kind**: instance method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Number</code> - threshold - Millimeter value used to define acceptable distance from
wayfinding path
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| route | <code>Array.<pathPerFloor></code> | An array of JMapPathPerFloor objects to compare with user's location |
<a name="NavigationKit+drawPathWithInstructions"></a>
### navigationKit.drawPathWithInstructions(pathPerFloor, [pathStyle], [popupStyle], [fontStyle]) ⇒ <code>Object</code>
Draws a path on the relevant maps, with instructions on whether to turn left/right/uturn
**Kind**: instance method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Object</code> - The JController associated with this navigation kit
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| pathPerFloor | <code>Array.<Object></code> | An array of JMapPathPerFloor objects to compare with user's location |
| [pathStyle] | <code>jmap.Style</code> | A style object to style the generated path on the map |
| [popupStyle] | <code>jmap.Style</code> | A style object to style the popup element |
| [fontStyle] | <code>jmap.Font</code> | A font object to style the popup elements' text |
<a name="NavigationKit.getMovedPoint"></a>
### NavigationKit.getMovedPoint(origin, angle, distance) ⇒ <code>Array.<Number></code>
- Returns the position of a point when moved at a specified angle for a specified
distance
**Kind**: static method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Array.<Number></code> - - The new position of the point
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| origin | <code>Array.<Number></code> | The original position of the point |
| angle | <code>Number</code> | The angle in whicht the point should be moved |
| distance | <code>Number</code> | How far the point should be moved |
<a name="NavigationKit.doBoundsIntersect"></a>
### NavigationKit.doBoundsIntersect(a, b) ⇒ <code>Boolean</code>
- Returns whether two bounds intersect in any way
**Kind**: static method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Boolean</code> - - Whether the bounds intersect
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| a | <code>jmap.Bounds</code> | The first bounding box |
| b | <code>jmap.Bounds</code> | The second bounding box |
<a name="NavigationKit.isSegmentInCircle"></a>
### NavigationKit.isSegmentInCircle(p1, p2, circle) ⇒ <code>Boolean</code>
- Returns whether a segment is partially or fully within a circle
**Kind**: static method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Boolean</code> - - Whether the segment is either partially or fully within the circle
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| p1 | <code>Array.<Number></code> | The first point that defines a segment |
| p2 | <code>Array.<Number></code> | The second point that defines a segment |
| circle | <code>jmap.jungle.shape.Circle</code> | The circle shape that we're checking against |
<a name="NavigationKit.segmentInPolygon"></a>
### NavigationKit.segmentInPolygon(segment, gazePolygon) ⇒ <code>Boolean</code>
- Returns whether a segment is partially or fully within a polygon
**Kind**: static method of [<code>NavigationKit</code>](#NavigationKit)
**Returns**: <code>Boolean</code> - - Whether the segment is either partially or fully within the polgon
**Access**: public
| Param | Type | Description |
| --- | --- | --- |
| segment | <code>Array.<Array></code> | The segment we are testing with |
| gazePolygon | <code>jmap.jungle.shape.Polygon</code> | The polygon we are checking against |
<a name="SurroundingDefinition"></a>
## SurroundingDefinition
Returns a SurroundingDefinition
**Kind**: global class
<a name="new_SurroundingDefinition_new"></a>
### new SurroundingDefinition(options)
Creates a SurroundingDefinition
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | <code>Object</code> | | The options with which to configure the SurroundingDefinition |
| options.map | <code>global.jmap.core.Map</code> | | The map on which the surrounding elements should be generated from |
| options.point | <code>Array.<Number></code> | | The point from which the surrounding elements should be calculated (as [x, y]) |
| options.gazeDirection | <code>Number</code> | | The angle (in degrees) between the x-axis and the gaze direction |
| [options.visualRange] | <code>Number</code> | <code>250</code> | How far a person can see (in pixels) |
| options.visualLimitLeft | <code>Number</code> | | How many degrees counter-clockwise from the gaze direction shall we consider when calculating surrounding elements |
| options.visualLimitRight | <code>Number</code> | | How many degrees counter-clockwise from the gaze direction shall we consider when calculating surrounding elements |
| options.layersOfInterest | <code>Array.<String></code> | | The layers that should be considered when generating the surround elements |
<a name="SurroundingElements"></a>
## SurroundingElements
Returns a SurroundingElements object
**Kind**: global class
<a name="new_SurroundingElements_new"></a>
### new SurroundingElements(options)
Creates a SurroundingElements object
| Param | Type | Description |
| --- | --- | --- |
| options | <code>Object</code> | The options with which to configure the SurroundingDefinition |
| options.icons | <code>global.jungle.Icon</code> | The icons that were deemed to be a surrounding element |
| options.shapes | <code>global.jungle.Shape</code> | The shapes that were deemed to be a surrounding element |
<a name="SurroundingIcon"></a>
## SurroundingIcon
Returns a SurroundingIcon
**Kind**: global class
<a name="new_SurroundingIcon_new"></a>
### new SurroundingIcon(icon, distance, layerName)
Creates a SurroundingIcon
| Param | Type | Description |
| --- | --- | --- |
| icon | <code>global.jungle.Icon</code> | The icon deemed to be a surrounding element |
| distance | <code>Number</code> | The distance between the decision point and the icon |
| layerName | <code>String</code> | The layer on which the icon is |
<a name="SurroundingItem"></a>
## SurroundingItem
Returns a SurroundingItem
**Kind**: global class
<a name="new_SurroundingItem_new"></a>
### new SurroundingItem(distance, layerName)
Creates a SurroundingItem
| Param | Type | Description |
| --- | --- | --- |
| distance | <code>Number</code> | The distance between the decision point and the surrounding item |
| layerName | <code>String</code> | The layer on which the surrounding item is |
<a name="SurroundingShape"></a>
## SurroundingShape
Returns a SurroundingShape
**Kind**: global class
<a name="new_SurroundingShape_new"></a>
### new SurroundingShape(shape, distance, layerName)
Creates a SurroundingIcon
| Param | Type | Description |
| --- | --- | --- |
| shape | <code>global.jungle.Shape</code> | The shape deemed to be a surrounding element |
| distance | <code>Number</code> | The distance between the decision point and the icon |
| layerName | <code>String</code> | The layer on which the icon is |