Skip To Content ArcGIS for Developers Sign In Dashboard

Constructing a military message

In many cases military messages will be taken directly from the wire format and passed into the message class for processing. In some situations an application may need to create a message itself. You can create the message and then set each parameter individually or more simply use the AGSMPMessageHelper class.

Create a military message providing the key-value codes

Message contain properties that are used by the message processor to place a messge with the correct symbology at the correct location. Apart from the messageID, all of the properties can be defined using key-value coding. As a minimum you must ensure that you have set the messageID, _Type,_Action,_Control_Points and sic properties.

Note that the message can have a different spatial reference to the map. The message processor will reproject the message to the correct location. If the message does not set a _WKID then the messageprocessor will use the spatial reference of the map that contains the group layer.

let message = AGSMPMessage()
message.messageId = "ABC123"
message.setProperty("position_report", forKey:"_Type")
message.setProperty("add", forKey:"_Action")
message.setProperty("7843536.41455,4088224.16202", forKey:"_Control_Points")
message.setProperty("GFGPOPP-------X", forKey:"SIC")
message.setProperty("1", forKey:"UniqueDesignation")

If you wish to locate the message above call the AGSMapView:zoomtoEnvelope method.

let envelope = AGSEnvelope(xmin: -222000, ymin:6580000, xmax:-218000, ymax:6620000, spatialReference:AGSSpatialReference(WKID: 3857))
self.mapView.zoomToEnvelope(envelope, animated: true)

Create a military message using the message helper class

Alternatively you can use the more explicit AGSMPMessageHelper class.

let point = AGSPoint(x:-220000, y:6600000, spatialReference:AGSSpatialReference(WKID: 3857))
let messageControlPoints = [point]
let messageProperties = ["sic": "GFGPOPP-------X", "UniqueDesignation": "1"]
 messageType: "position_report", 
 controlPoints: messageControlPoints, 
 properties: messageProperties, 
 spatialReference: AGSSpatialReference(WKID: 3857))