How to process messages
There are 4 steps to setup the military message processing in a Java SE application:
- Create the MessageGroupLayer to be used by the Message Processor
- Create the Message
- Populate the Message
- Process the Message
- Create the MessageGroupLayer to be used by the Message Processor
When messages are processed, they will be displayed in a MessageGroupLayer. This layer needs to be added to a map after a map service, specifying the Symbol Dictionary which is to be used. The following code shows an example of a MessageGroupLayer which processes and displays MIL-STD-2525C symbology.
ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer( "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); map.getLayers().add(tiledLayer); MessageGroupLayer msgGroupLayer = new MessageGroupLayer(SymbolDictionary.DictionaryType.Mil2525C); map.getLayers().add(msgGroupLayer);
- Create the Message
Once the message group layer is fully initialized, messages can be processed using the message processor. The workflow for this is to first create and populate a Message (com.esri.core.symbol.advanced.Message).
Messages are based on a Dictionary <String, String> and will contain entries based on chosen military symbology (SymbolDictionary.DictionaryType) which was set in the MessageGroupLayer constructor.
Message message = new Message();
- Populate the Message
The message can then be processed using the MessageProcessor which is associated with the MessageGroupLayer create above.
message.setID("1879"); message.setProperty("_type", "position_report"); message.setProperty("_action", "update"); message.setProperty("_control_points", "7843536.41455,4088224.16202"); message.setProperty("_WKID", 3857); message.setProperty("sic","GFGPOPP-------X"); message.setProperty("UniqueDesignation", "1");
- Process the Message
Call the processMessage method. This message once processed will be visible in the map.
msgGroupLayer.getMessageProcessor().processMessage(message);
In the example above, the message has been supplied in the WGS_1984_Web_Mercator_Auxiliary_Sphere (wkid = 3857) spatial reference. If the spatial reference of the message is not supplied, then the default spatial reference of the MessageProcessor will be used.