Skip to main content

Lightweight library for producing SVGs of NATO standard military symbols from NATO sidcs or natural-language descriptions

Project description

Python military symbols

This is a lightweight Python module, including a command-line script, to generate NATO APP-6(D) compliant military symbol icons in SVG format. These SVGs can be generated from inputs formatted as NATO SIDCs (Symbol identification codes) or as natural-language names for symbols, i.e. "friendly infantry platoon" or "enemy mortar section." Features supported include:

  • Headquarters, task force, mobility, and echelon indicators
  • Automatic checking of modifier and entity types for congruence
  • Symbol sets to indicate land units and installations, air, space, sea surface, subsurface, signals intelligence, and cyber units, tracks, and activities
  • Status indicators in both standard and alternate forms
  • Construction of SVGs in light, medium, dark, and unfilled styles

Control measure graphics are not yet implemented.

Available as a Python package.

Usage

Command line usage examples:

# Create a set of symbols by name, using variant symbols if available, in the current directory
military_symbol --use-variants --by-name -o . "Friendly artillery company" "Destroyed Enemy PSYOP section"

# Create a single symbol at the designated path by name
military_symbol -o platoon.svg -n "Friendly infantry platoon"

# Print a set of symbols by name, in unfilled style, to STDOUT
military_symbol -s unfilled -n "Friendly infantry platoon" "Enemy anti-air battery"

# Create the same set of symbols as above, but by SIDC
military_symbol -o .  -n 10031000141211000000 10041000141211000000

Python module usage:

import os

import military_symbol

if __name__ == '__main__':
    # Print symbol generated from a name to STDOUT
    print(military_symbol.get_symbol_svg_string_from_name("enemy infantry platoon"))

    # Add a symbol template and write it to a file adjacent to this script
    example_template_directory = os.path.dirname(__file__)
    military_symbol.add_symbol_template_set(os.path.join(example_template_directory, 'example_template.json'))
    military_symbol.write_symbol_svg_string_from_name("T-82", out_filepath=os.path.join(example_template_directory,
                                                                                        'T-82.svg'), auto_name=False)

    shapes = [
        'friendly infantry',
        'friendly cavalry',
        'friendly artillery'
    ]
    for shape in shapes:
        military_symbol.write_symbol_svg_string_from_name(shape, out_filepath=example_template_directory)

    # Generate a list of symbols from names and write them as SVG files in specific
    # styles, named according to a user-defined pattern and using variant symbols where available
    examples = [
        ('Enemy armor company', 'light'),
        ("Dummy damaged neutral hospital", 'medium'),
        ("Friendly fighter", 'dark'),
        ("Destroyed neutral artillery task force headquarters", 'unfilled'),
        ("Suspected CBRN section", 'light')
    ]

    for example_name, example_style in examples:
        example_symbol: src.military_symbol.individual_symbol.MilitarySymbol = military_symbol.get_symbol_class_from_name(example_name)
        print('Exporting symbol "{}"'.format(example_symbol.get_name()))

        output_filename = '{} ({}).svg'.format(example_symbol.get_sidc(), example_style)
        with open(output_filename, 'w') as output_file:
            output_file.write(example_symbol.get_svg(style=example_style, pixel_padding=4, use_variants=True))

License

This project is licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

military_symbol-1.0.3.tar.gz (587.5 kB view details)

Uploaded Source

Built Distribution

military_symbol-1.0.3-py3-none-any.whl (594.1 kB view details)

Uploaded Python 3

File details

Details for the file military_symbol-1.0.3.tar.gz.

File metadata

  • Download URL: military_symbol-1.0.3.tar.gz
  • Upload date:
  • Size: 587.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.7

File hashes

Hashes for military_symbol-1.0.3.tar.gz
Algorithm Hash digest
SHA256 98dc2ff44f2eb8f8b45f278a3be4803427b3a11a17607b962b9846da5df740ee
MD5 b5e20202db4b55c6a53b9894e3822aad
BLAKE2b-256 585e56ef90e3513e4991fb7f681edb912f8c211ded1619090b932f3b31ad5c8f

See more details on using hashes here.

Provenance

File details

Details for the file military_symbol-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: military_symbol-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 594.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.7

File hashes

Hashes for military_symbol-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 09483f721906d57095c32364056694919d5594c257b8e2dc6921f78402c35337
MD5 5b0f5501f975d405b494dc963234a7bb
BLAKE2b-256 4a078abc1f7db4d9e03364e1f5f29e4bc436e8a882e6b10afa4465f04644e948

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page