Use the symbol dictionary

Using the ArcGIS Runtime SDK for Java, you can build an application to take military messages and convert them to specific military symbols to be displayed in a map control on a desktop or laptop device. A symbol dictionary controls the symbology that can be displayed, as well as any metadata associated with each symbol. Currently, the SDK supports two symbol dictionary types: the Department of Defense (DoD) MIL-STD-2525C symbol dictionary and the North Atlantic Treaty Organization (NATO) APP-6B symbol dictionary. Read on to find out how to use a symbol dictionary to search for symbols using keywords and filters, or start with the Display military messages topic to learn how to process military messages and display them on a map.

Symbol dictionary

The military symbols that are displayed using the MessageProcessor are stored in a SymbolDictionary class. The symbol dictionary is created along with the message processor and in the API, the MessageProcessor class exposes the SymbolDictionary instance. Each military symbol in the dictionary has metadata stored with it, which can be used to perform searches to find the appropriate symbol, for example, in a situation awareness update application.

Military symbols in the symbol dictionary can be searched using either keywords or filters. Typically, the results from the keywords and filters searches are used to populate graphical user interface (GUI) components, which allow users to search for symbols so they can make their own spot report.

Keyword search

Every symbol has a number of associated keywords such as "Trainer", "Volcanic Eruption", "Vip", and so on. All possible keywords used in the symbol dictionary can be obtained from the symbol dictionary.

Filter search

Every symbol has three attributes: Geometry Type, Category, and StyleFile. You can construct a filter using any of these attributes and their value combinations to locate a military symbol in the symbol dictionary.

The result of a symbol dictionary search can be displayed in a GUI for a user to select a chosen symbol. The chosen symbol identifier (SIC) can then be used to construct a new message using the MessageHelper class, and this message can be displayed in a map using the message processor.

Search a symbol dictionary

This section shows how to use keywords and filters to search for military symbols in a symbol dictionary. The first step is to create a SymbolDictionary instance, specifying the DictionaryType to use, for example, Mil2525C. Once you've created a symbol dictionary, you can obtain a list of keywords from the dictionary by calling the getKeywords method and a set of filters by calling the getFilters method. The filters and keywords obtained are typically used to populate GUI components for users to narrow their symbol search.

The following code sample show how to obtain keywords and filters for searching for symbols. The keywords are to be displayed in a list control, while the keywords are put into a tree control to be displayed to the user.

//create a symbol dictionary
symDictionary = new SymbolDictionary(SymbolDictionary.DictionaryType.Mil2525C);
		
//get the available keywords and put them in the selection list
List<String> keywords = new ArrayList<String>();
keywords = symDictionary.getKeywords();
lstKeywords.setListData(keywords.toArray());
		
//get the filters and their values and pop them into the tree view
Map<String, List<String>> filters;
filters = symDictionary.getFilters();
DefaultMutableTreeNode baseNode = new DefaultMutableTreeNode("Filters");
DefaultMutableTreeNode filterNode;		
		
//go through all filters
for (String flt : filters.keySet()){
 //test filter output
	System.out.println("filter: " + flt);
			
	//create filter for the tree
	filterNode = new DefaultMutableTreeNode(flt);
			
	//get the filter values for each of the filters
	List<String> filterValues;	
	filterValues = filters.get(flt);
	for(String val : filterValues){
	 //add the filter value to the tree
		filterNode.add(new DefaultMutableTreeNode(val));
	}
			
	//add filter section to tree
	baseNode.add(filterNode);
}
		
//apply filters to the tree control
treeFilters.setModel(new DefaultTreeModel(baseNode));

Once a user has chosen their search criteria using the GUI, the keywords and filters can be used to get a list of potential symbols the user can use. The following code example shows how to search using filters only. Using different overloads of the findSymbols method, it is also possible to search using keywords and filters, or keywords only.

//make a filter for Category=Atmospheric
Map<String,List<String>> selectedFilters = new HashMap<String,List<String>>();
		
//add the key so we can add to the list of filters
List<String> filterVals = new ArrayList<String>();
filterVals.add("Atmospheric");
selectedFilters.put("Category", filterVals);
		
//get the symbol properties for our filter
symbols = new ArrayList<SymbolProperties>();
		
try {
 symbols = symDictionary.findSymbols(selectedFilters);
} catch (IOException e) {
	e.printStackTrace();
}
		
//get the symbol names for Category=Atmospheric
List<String> symbolNames = new ArrayList<String>();
for (SymbolProperties symbolProps : symbols){
	System.out.println("Symbol Name : " + symbolProps.getName());
}

Sample code

To view interactive sample applications related to military messages and using the symbol dictionary, launch the ArcGIS Runtime SDK for Java sample viewer, installed with the SDK. Explore relevant samples and their source code in the Information display section.

For a larger demo application, explore Esri's Vehicle Commander template whose full Java source code is available on github.com.