Esri / military-features-data

Source data for Esri defense and intelligence feature templates. This data is used to create features and derived data products using military symbology.
Apache License 2.0
46 stars 32 forks source link

Add GetSymbolImage/GeneratePreview to Pro SDK CIMDictionaryRenderer #206

Closed csmoore closed 8 years ago

csmoore commented 8 years ago

Our military symbol SDK users often have the need to create a “Complete Preview Symbol” for military symbols*. These are useful for a number of Military Symbol scenarios that don't involve drawing on a map - for example:

  1. So the user can see the full/completed symbol (in a custom SDK plugin) to verify it is correct before adding to the map as done in this app/repo (Internal)
  2. To use this completed preview image elsewhere (either in an SDK or external app)
  3. In test/verification apps where the symbols are checked for correctness

* Note: A Military Symbol is a CIMDictionaryRenderer CIMSymbol (a multilayer CIM symbol that has multiple parts instead of just the single style component)

In order to accomplish this, we would like to propose adding a method to ArcGIS.Core.CIM.CIMDictionaryRenderer :

System.Windows.Media.ImageSource 
   GeneratePreview ( 
    System.Collections.Generic.Dictionary<string, string> dictionaryAttributeSet,
    int patchHeight, int patchWidth);

To allow a Pro SDK user to export a complete CIMDictionaryRenderer Symbol Preview/Image

This is similar to the current ArcGIS Runtime Client SDK requirement/capability SymbolDictionary.GetSymbolImage - Runtime SDK Documentation for this in WPF, [Java](http://resources.arcgis.com/en/help/runtime-java/apiref/com/esri/core/symbol/advanced/SymbolDictionary.html#getSymbolImage%28java.lang.String, int, int%29)

Here is a complete code sample of using this proposed method:

//Get the feature layer currently selected in the Contents pane
var selectedLayers = MapView.Active.GetSelectedLayers();
FeatureLayer ftrLayer = selectedLayers[0] as FeatureLayer;

await QueuedTask.Run(() =>
{
    //Get CIM renderer from feature layer
    CIMRenderer currentRenderer = ftrLayer.GetRenderer() as CIMRenderer;
    CIMDictionaryRenderer dictionaryRenderer = currentRenderer as CIMDictionaryRenderer;

    Dictionary<string, string> attributeSet = new Dictionary<string, string>();

    attributeSet["context"] = "10";
    attributeSet["identity"] = "3";
    attributeSet["symbolset"] = "10";
    attributeSet["symbolentity"] = "110100";

    // ===> Proposed New Method:
    System.Windows.Media.ImageSource completeCIMRendererImage =  
       dictionaryRenderer .GeneratePreview ( attributeSet, 512, 512 );
}); 

Here is an example of the difference between complete CIMDictionaryRenderer symbol/preview and just a StyleItem symbol/preview:

image

We realize that a MapControl capability may be added to the Pro SDK at 10.3, but we still feel that having the ability to export an ImageSource will greatly simplify and enhance the SDK user experience for this scenario. This capability may also be part of the 3D billboard implementation/fix

One Additional Note: during testing we tried StyleItem.GeneratePreview(StyleItem item, int patchHeight, int patchWidth) and we were unable to get higher resolution images with the CIM Style components - this always returned a low res image (shown in the image above).

csmoore commented 8 years ago

@jeconley - sorry this is a somewhat complicated one, but we were wondering if you can add this CR as a 1.3 request. This is for the Pro SDK so I'm not sure if there is anything we need to do differently.

@tlauver - can you also look this over (& feel free to edit the original issue if you notice any errors)

jeconley commented 8 years ago

@csmoore We will take a look. I will talk to @mbriat and make sure it is feasible.

csmoore commented 8 years ago

@jeconley - thanks again - I was hoping this issue/work would be related to and/or able to be combined with the work to get 3D images and rotation working by treating these markers as a single discrete/cached image (like I believe Runtime does)

jeconley commented 8 years ago

CR331592 has been added.

Additional information from Charlie Macleoad regarding the best approach for adding this to SDK: We have a capability for symbol preview already on the style item so we definitely want to use that. The trick, if you will, is getting “the” symbol to preview. We already have a static factory class “SymbolFactory” that is capable of generating symbols so we will modify ~that~ to be capable of generating a symbol for a dictionary renderer. The generated symbol would be passed to the Style Item (via SymbolStyleItem) to generate a preview (at the correct resolution – not low res – MarcO thinks that is a bug).

Changing the renderer (eg to add the GeneratePreview method) has ramifications for the other renderers and would look odd just being on the dictionary renderer. The ideal implementation probably has ~all~ renderers being capable of generating a preview but that is beyond this scope and is more an issue for us on the Pro side to figure out for future releases. SymbolFactory is a convenient place to expose this capability without us having to deal with the larger issue of supporting preview on other renderers at 1.3.

csmoore commented 8 years ago

@jeconley - many thanks for the update & CR - changing the design/implementation sounds fine. The original method/example was mainly to motivate the user requirement of being able to generate a high-res preview for a composed(with all its parts-frame, icons, etc.) military symbol.

We have a workaround for this (just draw them from the source SVGs ourselves) - but we do feel this will be an important end-user requirement so wanted to get this in the queue.

jeconley commented 8 years ago

Fix has been installed and will be available in build 5717 or later. @csmoore when the build is available can you verify that everything is working as expected. I am not able to easily verify this and will need someone to do the testing so I can verify the CR. Thanks.

csmoore commented 8 years ago

Sure - I'll give it a test out early this week (hopefully today) - thanks for getting this in & letting us know

csmoore commented 8 years ago

This has been added to Pro 1.3 SDK - we have a separate issue (Update Added CR# - CR 340886) raised to be able to export images >64 pixels but we can close this one