Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and testing complete. (+13 squashed commits) #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/dictionaries/vickdw.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/qgis-milstd2525-plugin.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 67 additions & 6 deletions milstd2525/milstd2525symbology.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,24 @@ def symbolForCode(code, size):
for i in range(symbol.symbolLayerCount()):
symbol.takeSymbolLayer(0)

echelonCode = code[3] + code[8:10]
# Decode the sidc number to find the symbol
# Referenced https://explorer.milsymb.net/#/explore/ for the decoding
version = code[:2]
standard_identity = code[2:4]
symbol_set = code[4:6]
status = code[6]
hqtffd = code[7]
amplifier_descriptor = code[8:10]
entity = code[10:12]
entity_type = code[12:14]
entity_subtype = code[14:16]
sector_one_modifier = code[16:18]
sector_two_modifier = code[18:20]

# From Symbol Set, identify which Folder our image is in.
image_dir = getDirectoryFromSymbolSet(symbol_set)

echelonCode = '1' + amplifier_descriptor
echelonLayer = getSymbolLayer('Echelon', echelonCode, size)
if echelonLayer is not None:
symbol.insertSymbolLayer(0, echelonLayer)
Expand Down Expand Up @@ -76,23 +93,37 @@ def symbolForCode(code, size):
# log.debug('oca: %s %s' % (ocaCode, str(ocaLayer is not None)))

mainCode = code[4:6] + code[10:16]
mainLayer = getSymbolLayer('Appendices', mainCode, size)
mainLayer = getSymbolLayer(image_dir, mainCode, size)
if mainLayer is not None:
symbol.insertSymbolLayer(0, mainLayer)
else:
mainCode = code[4:6] + code[10:16] + '_' + code[4]
mainLayer = getSymbolLayer(image_dir, mainCode, size)
if mainLayer is not None:
symbol.insertSymbolLayer(0, mainLayer)
# log.debug('main: %s %s' % (mainCode, str(mainLayer is not None)))

modifier1Code = code[4:6] + code[16:18] + '1'
modifier1Layer = getSymbolLayer('Appendices', modifier1Code, size)
modifier1Layer = getSymbolLayer(image_dir + '/mod1', modifier1Code, size)
if modifier1Layer is not None:
symbol.insertSymbolLayer(0, modifier1Layer)

modifier2Code = code[4:6] + code[18:20] + '2'
modifier2Layer = getSymbolLayer('Appendices', modifier2Code, size)
modifier2Layer = getSymbolLayer(image_dir + '/mod2', modifier2Code, size)
if modifier2Layer is not None:
symbol.insertSymbolLayer(0, modifier2Layer)

frameCode = '%s_%s_%s' % (code[2], code[3:6], code[0])
frameLayer = getSymbolLayer('Frames', frameCode, size)
if int(status) > 1:
frameCode = '%s_%s_%s' % (code[2], code[3:6], '0')
else:
frameCode = '%s_%s_%s' % (code[2], code[3:6], status)
if int(code[2] == 1):
frameLayer = getSymbolLayer('Frames/Exercise', frameCode, size)
elif int(code[2] == 2):
frameLayer = getSymbolLayer('Frames/Sim', frameCode, size)
else:
frameLayer = getSymbolLayer('Frames', frameCode, size)

if frameLayer is not None:
symbol.insertSymbolLayer(0, frameLayer)
# log.debug('frame: %s %s' % (frameCode, str(frameLayer is not None)))
Expand All @@ -105,6 +136,35 @@ def symbolForCode(code, size):
return symbol


# noinspection PyPep8Naming
def getDirectoryFromSymbolSet(symbol_set):
image_path = 'Appendices'
if symbol_set in ['01', '02']:
return image_path + '/Air'
if symbol_set in ['05', '06']:
return image_path + '/Space'
if symbol_set in ['10', '11', '15', '20']:
return image_path + '/Land'
if symbol_set in ['25']:
return image_path + '/ControlMeasures'
if symbol_set in ['30']:
return image_path + '/SeaSurface'
if symbol_set in ['35', '36']:
return image_path + '/SeaSubsurface'
if symbol_set in ['40']:
return image_path + '/Activities'
if symbol_set in ['45']:
return image_path + '/METOC/Atmospheric'
if symbol_set in ['46']:
return image_path + '/METOC/Oceanographic'
if symbol_set in ['50', '51', '52', '53', '54']:
return image_path + '/SigInt'
if symbol_set in ['60']:
return image_path + '/Cyberspace'

return image_path


# noinspection PyPep8Naming
def getSymbolLayer(folder, svg, size):
svg = svg + '.svg'
Expand All @@ -116,6 +176,7 @@ def getSymbolLayer(folder, svg, size):
filepath = os.path.join(base, matching[0])
break
if filepath is not None:
print('filepath: ' + filepath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best not to issue print() commands from a plugin, except for when debugging inside of QGIS, which I'm guessing this is for.

symbolLayer = QgsSvgMarkerSymbolLayer(filepath)
symbolLayer.setSizeUnit(3)
symbolLayer.setSize(size)
Expand Down
Loading