Interface: Context

Context

Context is an interface to handle a context, which allows Mizar : Mizar owns different contexts:
SkyContext A context representing a sky
PlanetContext A context representing a planet
In addition to the two contexts, the client can define two sub-contexts :
  • The planet without backgound
  • The planet with the sky background
In addition to the classes, a factory is available to help for creating context. Once the context is created, the client can handle it by the use of its interface.
See:

Methods


getContextConfiguration()

Returns the context Configuration
Returns:
- see options.skyContext or options.planetContext for {Mizar}
Type
Object

getMizarConfiguration()

Returns the mizar Configuration
Returns:
- see options.configuration for {Mizar}
Type
Object

getPositionTracker()

Returns the position tracker.
Returns:
Type
PositionTracker

getElevationTracker()

Returns the elevation tracker.
Returns:
Type
ElevationTracker

setCompassVisible(divName, visible)

Sets the compass to visible or not.
Parameters:
Name Type Description
divName string Name of the compass div
visible boolean Visible or not

setComponentVisibility(componentId, isVisible)

Sets the UI component visibility.
Parameters:
Name Type Description
componentId string Id of the component
isVisible boolean Sets to True when the component must be visible

showComponents()

Shows components in the current state given by this.components.

show()

Start Navigation and "Show" sky or planet component.

hideComponents(uiArray)

Hide components
Parameters:
Name Type Description
uiArray Array of components,which must not be hide.

hide()

Stop navigation and hide sky or planet components.

showAdditionalLayers()

Shows the additional layers.

hideAdditionalLayers()

Hides the additional layers.

getLonLatFromPixel(x, y)

Returns the lon-lat from a pixel. The pixel is expressed in the canvas frame, i.e. (0,0) corresponds to the lower-left corner of the pixel
Parameters:
Name Type Description
x int the x pixel coordinate
y int the y pixel coordinate
Returns:
an array of two numbers [lon,lat] or null if the pixel is not on the globe
Type
Array.<float>

getPixelFromLonLat(longitude, latitude)

Returns the pixel coordinates from longitude/latitude in decimal degree.
Parameters:
Name Type Description
longitude float lonitude in decimal degree in the current coordinate reference system
latitude float latitude in decimal degree in the current coordinate reference system
Returns:
pixels coordinates in the canvas
Type
Array.<int>

getElevation(lon, lat)

Returns the elevation at a geo position.
Parameters:
Name Type Description
lon float the longitude in degree
lat float the latitude in degree
Returns:
the elevation in meter at the position [lon,lat]
Type
float

getLayers()

Returns the layers of a specific context.
Returns:
an array of layers
Type
Array.<Layer>

getLayerByID(layerId)

Returns the layer based on its ID. Looks through each value in the layer list, returning the first one that matches the ID, or undefined if no value passes the test. The function returns as soon as it finds an acceptable element, and doesn't traverse the entire list.
Parameters:
Name Type Description
layerId string the layer identifier
Returns:
the layer
Type
Layer | undefined

getLayerByName(layerName)

Returns the layer based on its name. Looks through the list of layers and returns the first value that matches the name of the layer. If no match is found, undefined will be returned.
Parameters:
Name Type Description
layerName string Name of the layer
Returns:
the layer
Type
Layer | undefined

setBackgroundLayer(survey)

Sets the background survey.
Parameters:
Name Type Description
survey string The name of the layer
Fires:
Returns:
the layer which has been added to the background
Type
Layer | undefined

setBackgroundLayerByID(surveyID)

Sets the background survey by layer ID.
Parameters:
Name Type Description
surveyID string The name of the layer
Returns:
the layer which has been added to the background
Type
Layer | undefined

getAdditionalLayers()

Returns the additional layers.
Returns:
the additional layers by opposition to the background layers
Type
Array.<Layer>

addLayer(mizarDescription)

Registers a new layer to globe to be visualized on the globe. When layerPlanet is defined, the layer is added to the layerPlanet otherwise the layer is added to the globe. According to the attributes of the layer, the layer is either added as background or as additional layer.
Parameters:
Name Type Description
mizarDescription Object See the base properties AbstractLayer.configuration and specific properties for specific layers
Fires:
  • Context#backgroundLayer:add
  • Context#additionalLayer:add
Returns:
the created layer
Type
Layer

removeLayer(layerID)

Removes a layer based on its identifier
Parameters:
Name Type Description
layerID string the layer identifier
Returns:
the removed layer
Type
Layer

removeAllLayers()

Removes all layers.

addDraw(layer)

Adds a temporary draw as a layer on the globe.
A temporary draw is used to create a subLayer or a simple draw. This added layer is not searchable and does not subscribe to "visibility:changed" by configuration
Parameters:
Name Type Description
layer Layer

removeDraw(layer)

Removes the temporary draw on the globe.
Parameters:
Name Type Description
layer Layer

getRenderContext()

Returns the rendering context.
Returns:
The rendering context
Type
RenderContext

getMode()

Returns the mode of the globe
Returns:
the mode of the globe
Type
CONTEXT

setCoordinateSystem(cs)

Sets the coordinate reference system.
Parameters:
Name Type Description
cs the coordinate reference system
Fires:
Throws:
"incompatible coordinate reference system with globe context (e.g : sky, planet)"

getCoordinateSystem()

Returns the reference coordinate system.
Returns:
the coordinate reference system
Type
Crs

getNavigation()

Returns the navigation.
Returns:
navigation
Type
Navigation

addAnimation(anim)

Adds an animation.
Parameters:
Name Type Description
anim Animation the animation to add

removeAnimation(anim)

Removes an animation.
Parameters:
Name Type Description
anim Animation the animation to remove

getTileManager()

Returns the tile manager.
Returns:
Type
TileManager

dispose()

Cleans up every reference to gl objects and unloads all tiles of the current context.

refresh()

Refreshes rendering, must be called when canvas size is modified.

destroy()

Destroys the globe of the current context. The globe is destroyed by :
  • cleaning up every reference to gl objects and unloads all tiles
  • Removing the renderer from all the tiles

disable()

Disables the globe of the current context.

enable()

Enables the globe of the current context.

Events


modifiedNavigation

Camera view event.
Called when the view of the camera has changed (pan, rotate, ...)
Listeners of This Event:

startNavigation

Start navigation.
Called when navigation is started (by the user or through animation)

endNavigation

End navigation.
Called when navigation is ended (by the user or through animation)

startLoad

startLoad.
Called when a layer start to be loaded
Type: Layer

endLoad

endLoad.
Called when layer end loading
Type: Layer

backgroundLayer

backgroundLayer.
Called when a layer is loaded as background
Type: Layer

backgroundSurveyError

backgroundSurveyError.
Called when a layer could not be loaded as background
Type: string

baseLayersError

baseLayersError.
Type: Layer

baseLayersReady

baseLayersReady.
Type: Layer | boolean
Listeners of This Event:

startBackgroundLoad

startBackgroundLoad.
Called when background layers (imagery and/or elevation) start to be loaded

endBackgroundLoad

endBackgroundLoad.
Called when background layers (imagery and/or elevation) end loading

features:added

features:added.
Called when data coming from a GeoJSON are added
Type: Object
Properties:
Name Type Description
layer Layer
features Object

layer:add

layer:add.
Called when a layer is added
See:

layer:remove

layer:remove.
Called when a layer is removed
See:

modifiedCrs

modifiedCrs.
Called when a CRS changes
Type: Crs