-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Esri/antt0000-MilitarySymbology
Antt0000 military symbology
- Loading branch information
Showing
29 changed files
with
2,449 additions
and
3 deletions.
There are no files selected for viewing
Submodule samples-data
updated
from 929ded to 1fe3e8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Desktop/ArcGISRuntimeSDKDotNet_DesktopSamples/Assets/SampleDescriptions.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
...ktop/ArcGISRuntimeSDKDotNet_DesktopSamples/Samples/Symbology/MessageProcessingSample.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<UserControl x:Class="ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.Symbology.MessageProcessingSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" d:DesignWidth="300"> | ||
<Grid> | ||
<esri:MapView x:Name="mapView"> | ||
<esri:Map> | ||
<esri:Map.InitialExtent> | ||
<esri:Envelope XMin="-245200" YMin="6665900" XMax="-207000" YMax="6687300"> | ||
<esri:Envelope.SpatialReference> | ||
<esri:SpatialReference Wkid="102100"></esri:SpatialReference> | ||
</esri:Envelope.SpatialReference> | ||
</esri:Envelope> | ||
</esri:Map.InitialExtent> | ||
<esri:ArcGISTiledMapServiceLayer ID="Basemap" | ||
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> | ||
<esri:MessageLayer SymbolDictionaryType="Mil2525C" /> | ||
</esri:Map> | ||
</esri:MapView> | ||
|
||
<Border Background="White" BorderBrush="Black" BorderThickness="2" Margin="30" | ||
HorizontalAlignment="Right" VerticalAlignment="Top"> | ||
<StackPanel Margin="30,20"> | ||
<TextBlock Text="Click on the button below to run the message processor. It will read simulated messages from an XML file and display military symbols on the map using Mil2525C Symbols." | ||
FontSize="14" Width="400" TextAlignment="Left" TextWrapping="Wrap" /> | ||
<Button x:Name="processMessagesBtn" | ||
IsEnabled="False" | ||
Content="Process messages" | ||
HorizontalAlignment="Center" | ||
Margin="12,12,12,0" | ||
Click="ProcessMessagesButton_Click"/> | ||
</StackPanel> | ||
</Border> | ||
</Grid> | ||
</UserControl> |
115 changes: 115 additions & 0 deletions
115
...p/ArcGISRuntimeSDKDotNet_DesktopSamples/Samples/Symbology/MessageProcessingSample.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using Esri.ArcGISRuntime; | ||
using Esri.ArcGISRuntime.AdvancedSymbology; | ||
using Esri.ArcGISRuntime.Layers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Xml.Linq; | ||
|
||
namespace ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.Symbology | ||
{ | ||
/// <summary> | ||
/// Sample shows how to read and process Mil2525C message data from XML file. | ||
/// </summary> | ||
/// <title>Message Processor</title> | ||
/// <category>Symbology</category> | ||
/// <subcategory>Advanced</subcategory> | ||
public partial class MessageProcessingSample : UserControl | ||
{ | ||
private const string DATA_PATH = @"..\..\..\..\..\samples-data\symbology\Mil2525CMessages.xml"; | ||
|
||
private MessageLayer _messageLayer; | ||
|
||
public MessageProcessingSample() | ||
{ | ||
InitializeComponent(); | ||
mapView.ExtentChanged += mapView_ExtentChanged; | ||
} | ||
|
||
// Load data - enable functionality after layers are loaded. | ||
private async void mapView_ExtentChanged(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
mapView.ExtentChanged -= mapView_ExtentChanged; | ||
|
||
// Wait until all layers are loaded | ||
await mapView.LayersLoadedAsync(); | ||
|
||
_messageLayer = mapView.Map.Layers.OfType<MessageLayer>().First(); | ||
processMessagesBtn.IsEnabled = true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show(ex.Message, "Message Processing Sample"); | ||
} | ||
} | ||
|
||
private void ProcessMessagesButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
try | ||
{ | ||
// This function simulates real time message processing by processing a static set of messages from an XML document. | ||
/* | ||
* |== Example Message ==| | ||
* | ||
* <message> | ||
* <_type>position_report</_type> | ||
* <_action>update</_action> | ||
* <_id>16986029-8295-48d1-aa6a-478f400a53c0</_id> | ||
* <_wkid>3857</_wkid> | ||
* <sic>GFGPOLKGS-----X</sic> | ||
* <_control_points>-226906.99878,6679149.88998;-228500.51759,6677576.8009;-232194.67644,6675625.78198</_control_points> | ||
* <uniquedesignation>DIRECTION OF ATTACK</uniquedesignation> | ||
* </message> | ||
*/ | ||
|
||
var file = new FileInfo(DATA_PATH); | ||
|
||
// Load the XML document | ||
XDocument xmlDocument = XDocument.Load(file.FullName, LoadOptions.None); | ||
|
||
// Create a collection of messages | ||
IEnumerable<XElement> messagesXml = from n in xmlDocument.Root.Elements() | ||
where n.Name == "message" | ||
select n; | ||
|
||
// Iterate through the messages passing each to the ProcessMessage method on the MessageProcessor. | ||
// The MessageGroupLayer associated with this MessageProcessor will handle the creation of any | ||
// GraphicsLayers and Graphic objects necessary to display the message. | ||
foreach (XElement messageXml in messagesXml) | ||
{ | ||
Message message = new Message(from n in messageXml.Elements() select new KeyValuePair<string, string>(n.Name.ToString(), n.Value)); | ||
_messageLayer.ProcessMessage(message); | ||
} | ||
|
||
/* | ||
* Alternatively you can programmatically construct the message and set the attributes. | ||
* e.g. | ||
* | ||
* // Create a new message | ||
* Message msg = new Message(); | ||
* | ||
* // Set the ID and other parts of the message | ||
* msg.Id = messageID; | ||
* msg.Add("_type", "position_report"); | ||
* msg.Add("_action", "update"); | ||
* msg.Add("_control_points", X.ToString(CultureInfo.InvariantCulture) + "," + Y.ToString(CultureInfo.InvariantCulture)); | ||
* msg.Add("_wkid", "3857"); | ||
* msg.Add("sic", symbolID); | ||
* msg.Add("uniquedesignation", "1"); | ||
* | ||
* // Process the message using the MessageProcessor within the MessageGroupLayer | ||
* _messageLayer.ProcessMessage(msg); | ||
*/ | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show(ex.Message, "Message Processing Sample"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.