virtualair
contact us
Air traffic simulation and visualization platform.

Airspace Visualization

This module provides functions for 3D visualization of airspaces. It supports:
  • Custom airspace modeling;
  • Import of airspace database data; particularly importing the AIXM 4.5 files and the EAD SDO reports;
  • Development of import filters for custom airspace databases.

Note: The module requires functional planet representation from the Earth Visualization module.

../_images/py_airspace1s.png ../_images/py_airspace2s.png

Custom Airspace Modeling

The airspace is created by setting its shape, altitudes, label and color. After the setup the user should call method airspace.create(). Then the airspace is added to the planet visualization.

Main property of the airspace is its shape. The shape of the airspace can be circular, polygonal or general. The following example shows you the technique of the airspace creation on general and circular airspace.

Example of airspace shape types:

from _airspace import airspace
from _ossimPlanet import ossimPlanet

globe = ossimPlanet()
globe.addGeoid("share/ossimPlanet/geoid/egm96.grd")
globe.addTerrain(1.0)
globe.addImage("share/ossimPlanet/low-res image/earth.jpg")

# Part of the CCAE airspace in the Canada with the general shape
general = airspace(globe)
general.setShape((52.77, -111.49),    # One point of the airspace
  (52.93, -112.41),                   # Start point of the arc
  (53.19, -113.87, 101860.0, 'CWA'),  # Center of the arc with radius and direction
  (53.53, -115.29),                   # End of the arc
  (54.16, -111.95),
  (54.41, -110.3, 111120.0, 'CCA'),
  (53.72, -111.52),
  (52.77, -111.49))
general.setAltitudes((0, 'AGL'), ('FL 120', 'AMSL'))
general.setLabel('CCAE', 'Canada', 'PART')
general.setColor(0.1, 0.9, 0.0, 0.2)
general.create()

# The circular airspace over the Hawaii
circular = airspace(globe)
circular.setShape((19.63, -155.5, 100000),) # Center of the circle with radius
circular.setAltitudes((0, 'AGL'), ('FL 120', 'AMSL'))
circular.setLabel('TMA', 'Hawaii', 'E')
circular.setColor(1.0, 0.5, 0.0, 0.1)
circular.create()

while not globe.renderDone():
  globe.renderFrame()

Class airspace

class _airspace.airspace(planet)
The airspace provides visualization of an aeronautic airspace. In the constructor is used the planet parameter. This is an instance of the ossimPlanet class from the Earth Visualization.

airspace instances have the following methods:

airspace.create()
Create the airspace model and place it to the planet visualization. This method must be called after setting up at least the airspace shape by method airspace.setShape()
airspace.setShape(tuple)

Set the shape of the aeronautical airspace. The airspace can have circular, polygonal or general shape. The parameter is always an tuple with items in the following format

(latitude, longitude[, radius[, direction]])

Parameters latitude and longitude are geodetic coordinates. These coordinates represents a point in the shape. In case when the optional parameter radius is used then these coordinates represents a center of a circle or an arc in the shape. The optional parameter direction is used with the arc definition. The value represents a defined direction of the arc. If this parameter isn’t used then the direction is automatically computed.

parameter value
latitude Geodetic latitude as a decimal number between -90.0 and 90.0. Negative value is for south latitude positive value is for north latitude
longitude Geodetic longitude as a decimal number between -180.0 and 180.0. Negative value is for west longitude positive value is for east longitude
radius Decimal number representing the circle/arc radius in meters.
direction String with value of 'CWA', 'CCA' representing the arc direction.
'CWA' represents the clockwise direction
'CCA' represents the counter clockwise direction

For example on setting the airspace shape see the Custom Airspace Modeling.

airspace.setAltitudes(lower, upper)

Set the lower and upper altitude of the airspace. The format of the altitude is a pair of the altitude value and the altitude type:

(integer | 'FL integer', 'AGL' | 'AMSL')

The altitude values are also used in the label.

airspace.setLabel(type, name, class)
This method sets values for an airspace label. Parameters are strings. These values are used for the label. If the label is enabled then it is displayed above the airspace. If the label wasn’t set then the default values are used.
airspace.setColor(R, G, B, A)
The color of the airspace is set by this method. Parameters are decimal numbers for each color channel (RGB) and for alpha (A) channel. The range of values is [0.0, 1.0].
airspace.computeCaps()
This method can disable computational intensive creating of the airspace caps. The creating of airspace caps can slow down the visualization on the single-core processors. Airspace caps are enabled by default. Suitable values are 1 for enabling the labels and 0 for disabling them.
airspace.enableLabels()
This method will enable or disable displaying of airspace labels. Labels are enabled by default. Suitable values are 1 for enabling the labels and 0 for disabling them.

Import of Airspace Database Data

Currently there are supported AIXM airspace files in the AIXM 4.5 format and the SDO Reports from the European AIS Database (EAD).

“The Aeronautical Information Exchange Model (AIXM) is a specification designed to enable the encoding and the distribution in digital format of the aeronautical information, which has to be provided by the national Aeronautical Information Services (AIS) in accordance with the ICAO Convention.” [EC2009]

For example:

airspaces = []

from parse_AIXM45 import AIXM45
aixm45 = AIXM45("aixmBorders.xml")
aixmFiles = dict(ase = "ase.xml", abd = "abd.xml")
aixm45.parse(aixmFiles, airspaces)

from world_borders import WorldBorders
from parse_EAD_SDO import EADSDO
world = WorldBorders("worldborders.shp")
eadsdo = EADSDO(world)
eadsdo.parse("sdoReport.xml", airspaces)

for airspace in airspaces:
  airspace.addToVisualization(globe)

Importing EAD SDO Reports

Static Data Operation (SDO) service provides world wide data from the EAD. The format used in SDO reports is based on the AICM/AIXM data format. These reports can be obtained at http://www.ead.eurocontrol.int/. After registration you can obtain data by generating airspace vertex report in the SDO Reporting application.

Importing EAD SDO reports requires world borders for proper representation of state border used in airspace definitions. File with world borders in SHP file format can be obtained at http://thematicmapping.org/downloads/world_borders.php. The downloaded world border file is then loaded into instance of the WorldBorders class.

from world_borders import WorldBorders

world = WorldBorders("worldborders.shp")

The downloaded SDO report xml file is then used as data source for the EAD SDO parser. This parser is represented by the class EADSDO. In the class constructor is used as a parameter an instance of the WorldBorder class. Then is needed to initialize empty list for storing airspaces. The parsing is executed by calling method EADSDO.parse(xmlFile, airspaces). The method parse all airspace records in the supplied xml file. Each airspace in the record is stored as an instance of the class AIXMAirspace and added to the airspaces list.

from parse_EAD_SDO import EADSDO

eadsdo = EADSDO(world)
airspaces = []
eadsdo.parse("sdoReport.xml", airspaces)

The variable airspaces now contains airspaces prepared for adding into the visualization of the Earth Visualization. This is done via method AIXMAirspace.addToVisualization() with the globe parameter. It is an instance of the Earth Visualization.

for airspace in airspaces:
  airspace.addToVisualization(globe)

Importing AIXM 4.5 Files

Import of AIXM files is similar to the EAD SDO ones. The parser for the AIXM 4.5 format is contained in the class AIXM45. For load the AIXM airspace is needed to have three files.

The first one contains political borders with coordinates. This file is used as a parameter for the constructor of the AIXM45 class.

from parse_AIXM45 import AIXM45

aixm45 = AIXM45("aixmBorders.xml")

The file aixmBorders.xml has the following structure:

<AIXM-Snapshot>
  <Gbr>
    <GbrUid>
      <txtName>STATE-A_STATE-B</txtName>
    </GbrUid>
    <Gbv>
      <codeType>GRC</codeType>
      <geoLat>503039N</geoLat>
      <geoLong>0191040E</geoLong>
    </Gbv>
  </Gbr>
</AIXM-Snapshot>

The second file contains Ase elements. These elements contains aeronautical information about the airspace. There is defined lower and upper altitude of the airspace. The ase.xml has following structure:

<AIXM-Snapshot>
  <Ase>
    <AseUid>
      <codeType>TYPE</codeType>
      <codeId>ICAO</codeId>
    </AseUid>
    <txtName>NAME</txtName>
    <codeMil>CIVIL</codeMil>
    <codeDistVerUpper>STD</codeDistVerUpper>
    <valDistVerUpper>60</valDistVerUpper>
    <uomDistVerUpper>FL</uomDistVerUpper>
    <codeDistVerLower>HEI</codeDistVerLower>
    <valDistVerLower>0</valDistVerLower>
    <uomDistVerLower>FT</uomDistVerLower>
  </Ase>
</AIXM-Snapshot>

The last one file contains vertex data of the airspace. These vertices are stored in Abd elements. The abd.xml file has the following structure:

<AIXM-Snapshot>
  <Abd>
    <AbdUid>
      <AseUid>
        <codeType>TYPE</codeType>
        <codeId>ICAO</codeId>
      </AseUid>
    </AbdUid>
    vertices data - Avx / Circle elements
  </Abd>
</AIXM-Snapshot>

Files ase.xml and abd.xml are passed as a parameter to the parser. The parser also requires parameter of the list type, where newly created airspaces are stored.

airspaces = []
aixmFiles = dict(ase = "ase.xml", abd = "abd.xml")
aixm45.parse(aixmFiles, airspaces)

When the parsing is finished the variable airspaces contains instances of the class AIXMAirspace. These can be added to the visualization by the method AIXMAirspace.addToVisualization(). The Earth Visualization is represented by the globe parameter.

for airspace in airspaces:
  airspace.addToVisualization(globe)

Parsing Custom Airspace Data Formats

This section describes classes that may be used to import airspace database data in a custom format.

AIXMAirspace

class _airspace.AIXMAirspace(ICAO, aType)

The AIXMAirspace provides wrapper for the class airspace. It provides features for easier manipulation with airspaces during parsing the AIXM data.

ICAO is a string with ICAO identifier of the airspace. aType is a type of the airspace.

In the initialization is set airspace color based on the parameter aType. There is also set default airspace name - “Airspace” and default airspace altitudes. The lower altitude is set to 0 ft AMSL and upper altitude is set to FL 120.

AIXMAirspace.addPoint(point)
Add one point to the airspace. Points have to be sorted in the clockwise direction. The point is added after the last one.
AIXMAirspace.getShape()
Returns a list of tuples with the actual shape of the airspace.
AIXMAirspace.setAltitudes(altitudes)
Set lower and upper altitude of the airspace
AIXMAirspace.setName(string)
Set name of the airspace.
AIXMAirspace.getName()
Returns name of the airspace.
AIXMAirspace.getICAO()
Returns ICAO of the airspace.
AIXMAirspace.getType()
Returns type of the airspace
AIXMAirspace.typeToColor()
Set color of the airspace based on its type.
AIXMAirspace.setState(string)
Set a name of the state where the airspace is situated.
AIXMAirspace.setUseLabels(boolean)
Enable or disable using af the airspace labels. Labels are enabled by default.
AIXMAirspace.setUseCaps(boolean)
Enable or disable using of the airspace caps. Caps are enabled by default.
AIXMAirspace.addToVisualization(globe)
Add previously defined AIXM airspace into the Earth Visualization. The visualization module is represented by the globe parameter. This method creates object of the class airspace which is added to the visualization.

Parsing EAD SDO reports

class _airspace.EADSDO(world)
This class provides parser for SDO reports obtained from the EAD. The world is an instance of the ossimPlanet from the Earth Visualization.
EADSDO.parse(filename, list)
Parse EAD SDO report supplied as a filename string. Newly created airspaces are added into the list.
EADSDO._handleAirspaceType(element)
Returns list with the airspace identification and type. The element is an ase element in the SDO report.
EADSDO._handlePointType(element, AIXMAirspace)
Parse the element containing the coordinates of the airspace vertex. The element is the Record element. The AIXMAirspace is currently processed airspace. If the parsed Record is start of the political border segement then the method will return name of the borders. In other cases it returns None.
EADSDO._handlePoint(element)
Returns geodetic latitude and longitude tuple in decimal format. These values are parsed from geoLat and geoLong elements. The element is the Record element.
EADSDO._handleArc(element, direction)

In case the parameter direction is “CCA” or “CWA” then is returned tuple with geodetic latitude and longitude of the arc center, its radius in meters and direction of the arc. In case the parameter direction is “CIR” then is returned tuple with geodetic latitude and longitude of the circle center and its radius in meters. The element is the Record element.

direction meaning returned value
CWA clockwise arc (lat, long, radius, “CWA”)
CCA counter clockwise arc (lat, long, radius, “CCA”)
CIR circle (lat, long, radius)
EADSDO._makeBorders(start, end, state, AIXMAirspace)
In case the point that defines border segment is found then there are inserted points of the political borders between states. The start is a tuple with the first point of the segment and the end is the last one of the segment. The segment is added directly to the AIXMAirspace instance.
EADSDO._handleLat(lat)
Returns float latitude parsed from lat string.
EADSDO._handleLon(lon)
Returns float longitude parsed from lon string.
EADSDO._handleArcRadius(element)
Returns float radius of an arc in meters. The element contains tags valRadiusArc and uomRadiusArc.
EADSDO._parseNumber(num)
Retruns float or int number parsed from string num.
EADSDO._convertUnitToM(num, unit)
Returns float number in meters converted from number num in unit. The unit parameter is an string representing length unit (NM, FT, KM, MI).

Parsing AIXM 4.5 files

class _airspace.AIXM45(borderFile[, borderLOD = 5])
Initialize parser with a string file path to the political border file. This is an XML file that contains Gbr elements. The optional parameter borderLOD is used for simplifying the border shape. The integer number assigned to this parameter means that only each nth point will be used in the border. Defualt value is 5.
AIXM45.parse(xmlFiles, list)
Parse AIXM 4.5 XML files form the dictionary xmlFiles. The dictionary has two entries. The ase is for the XML file containing airspace name and altitudes in Ase elements. The abd is used for the XML file containing airspace vector data in Abd elements. Newly created airspaces are added to the parameter list. Created airspaces are instances of the AIXMAirspace.
AIXM45._handleAirspaceShape(element, AIXMAirspace)
This method processes Abd element passed as the parameter element. This element contains Avx sub-elements with airspace vertices. Each vertex is added to the AIXMAirspace shape.
AIXM45._findElement(elementTree, identifier, path)
Returns the first element containing text string from the ìdentifier. The element is searched in the elementTree at a defined path. Or returns None if the element wasn’t found.
AIXM45._handleAirspaceName(element)
Returns string name of the airspace parsed from the tag txtName. If name isn’t found then string "Airspace" is returned.
AIXM45._handleAltitudes(element)
Returns tuple with lower and upper altitude of an airspace. The element is an Ase element that contains tags with altitudes. The format of the returned tuple is ‘’(lower, upper)’’ where lower and upper has following format (integer | 'FL XXX', 'AGL' | 'AMSL')
AIXM45._handleGbr(start, end, states, AIXMAirspace)
This method will find segment of political borders between start` and end point. This border is between states. This parameter contains a string in the format of STATEA_STATEB. The border segment is directly added into the AIXMAirspace shape. If border isn’t found then the segment is replaced by a great circle line between the start and end.
AIXM45._pointToBorderDistance(point, borders)
Returns index of a point in borders which is nearest to the point.

The others methods are nearly the same as these in the class EADSDO. These methods are:

  • _handleAirspaceType(element)
  • _handlePoint(element)
  • _handleArc(element, direction), _handleCircle(element)
  • _handleLat(lat), _handleLon(lon)
  • _handleArcRadius(element)
  • _convertUnitToM(num, unit), _convertUnitToFt(num, unit)
  • _parseNumber(num)

References

[EC2009]EUROCONTROL. Aeronautical Information Exchange Model (AIXM) [Online]. © Eurocontrol 2009. Available online at: <http://www.eurocontrol.int/aim/public/standard_page/aixm.html>.