# 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](https://pypi.org/project/military-symbol/1.0.0/).
### Usage
Command line usage examples:
```bash
# 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:
```Python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/nwroyer/Python-Military-Symbols",
"name": "military-symbol",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.6",
"maintainer_email": null,
"keywords": "military, NATO, symbol, APP-6D, MIL-STD-2525D, map",
"author": "Nicholas Royer",
"author_email": "nick.w.royer@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/ce/a3/5361c415be9eb9b08a0a39cea762257c2ca81db164c8e83bd35f3a9a9129/military_symbol-1.0.9.tar.gz",
"platform": null,
"description": "# Python military symbols\n\nThis 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:\n\n- Headquarters, task force, mobility, and echelon indicators\n- Automatic checking of modifier and entity types for congruence\n- Symbol sets to indicate land units and installations, air, space, sea surface, subsurface, signals intelligence, and cyber units, tracks, and activities\n- Status indicators in both standard and alternate forms\n- Construction of SVGs in light, medium, dark, and unfilled styles\n\nControl measure graphics are not yet implemented.\n\nAvailable as a [Python package](https://pypi.org/project/military-symbol/1.0.0/). \n\n### Usage\n\nCommand line usage examples:\n\n```bash\n# Create a set of symbols by name, using variant symbols if available, in the current directory\nmilitary_symbol --use-variants --by-name -o . \"Friendly artillery company\" \"Destroyed Enemy PSYOP section\"\n\n# Create a single symbol at the designated path by name\nmilitary_symbol -o platoon.svg -n \"Friendly infantry platoon\"\n\n# Print a set of symbols by name, in unfilled style, to STDOUT\nmilitary_symbol -s unfilled -n \"Friendly infantry platoon\" \"Enemy anti-air battery\"\n\n# Create the same set of symbols as above, but by SIDC\nmilitary_symbol -o . -n 10031000141211000000 10041000141211000000\n```\n\nPython module usage:\n\n```Python\nimport os\n\nimport military_symbol\n\nif __name__ == '__main__':\n # Print symbol generated from a name to STDOUT\n print(military_symbol.get_symbol_svg_string_from_name(\"enemy infantry platoon\"))\n\n # Add a symbol template and write it to a file adjacent to this script\n example_template_directory = os.path.dirname(__file__)\n military_symbol.add_symbol_template_set(os.path.join(example_template_directory, 'example_template.json'))\n military_symbol.write_symbol_svg_string_from_name(\"T-82\", out_filepath=os.path.join(example_template_directory,\n 'T-82.svg'), auto_name=False)\n\n shapes = [\n 'friendly infantry',\n 'friendly cavalry',\n 'friendly artillery'\n ]\n for shape in shapes:\n military_symbol.write_symbol_svg_string_from_name(shape, out_filepath=example_template_directory)\n\n # Generate a list of symbols from names and write them as SVG files in specific\n # styles, named according to a user-defined pattern and using variant symbols where available\n examples = [\n ('Enemy armor company', 'light'),\n (\"Dummy damaged neutral hospital\", 'medium'),\n (\"Friendly fighter\", 'dark'),\n (\"Destroyed neutral artillery task force headquarters\", 'unfilled'),\n (\"Suspected CBRN section\", 'light')\n ]\n\n for example_name, example_style in examples:\n example_symbol: src.military_symbol.individual_symbol.MilitarySymbol = military_symbol.get_symbol_class_from_name(example_name)\n print('Exporting symbol \"{}\"'.format(example_symbol.get_name()))\n\n output_filename = '{} ({}).svg'.format(example_symbol.get_sidc(), example_style)\n with open(output_filename, 'w') as output_file:\n output_file.write(example_symbol.get_svg(style=example_style, pixel_padding=4, use_variants=True))\n```\n\n## License\n\nThis project is licensed under the MIT license. \n \n",
"bugtrack_url": null,
"license": null,
"summary": "Lightweight library for producing SVGs of NATO standard military symbols from NATO sidcs or natural-language descriptions",
"version": "1.0.9",
"project_urls": {
"Homepage": "https://github.com/nwroyer/Python-Military-Symbols",
"PyPI": "https://pypi.org/project/military-symbol/1.0.0/"
},
"split_keywords": [
"military",
" nato",
" symbol",
" app-6d",
" mil-std-2525d",
" map"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "75dbb507dd6918175fc8e24bf3d0ccfd7f87d0f9b1a364b31b604a125c038d47",
"md5": "d41ce3d80d5649a2ad57489fdc1de7cd",
"sha256": "7a1d315ab8105e857aa2e755439ddbd2ef59d40feffa6c19eba0e788b88673f6"
},
"downloads": -1,
"filename": "military_symbol-1.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d41ce3d80d5649a2ad57489fdc1de7cd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.6",
"size": 666762,
"upload_time": "2024-08-03T13:33:44",
"upload_time_iso_8601": "2024-08-03T13:33:44.004313Z",
"url": "https://files.pythonhosted.org/packages/75/db/b507dd6918175fc8e24bf3d0ccfd7f87d0f9b1a364b31b604a125c038d47/military_symbol-1.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cea35361c415be9eb9b08a0a39cea762257c2ca81db164c8e83bd35f3a9a9129",
"md5": "5a1a3ed853ee76e951d8e1c087a043b7",
"sha256": "50726ad3048e7938a52e6a40058030c285dcabd8e72d30db92c71bbbc5d7b6d9"
},
"downloads": -1,
"filename": "military_symbol-1.0.9.tar.gz",
"has_sig": false,
"md5_digest": "5a1a3ed853ee76e951d8e1c087a043b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.6",
"size": 659473,
"upload_time": "2024-08-03T13:33:46",
"upload_time_iso_8601": "2024-08-03T13:33:46.264078Z",
"url": "https://files.pythonhosted.org/packages/ce/a3/5361c415be9eb9b08a0a39cea762257c2ca81db164c8e83bd35f3a9a9129/military_symbol-1.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-03 13:33:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nwroyer",
"github_project": "Python-Military-Symbols",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "military-symbol"
}