SymbolDictionary.GetSymbolImage returning unknown

4430
7
11-11-2014 04:26 PM
KeithMacIntyre
New Contributor III

No matter what symbolID I pass in, I only get an unknown image returned.  When I use the military layer, the symbol is rendered correctly.

SymbolDictionary mil2525Symbols = new SymbolDictionary(SymbolDictionaryType.Mil2525c);

WriteableBitmap imageSource = mil2525Symbols.GetSymbolImage("SHGPEVATM-MQ---", size, size) as WriteableBitmap;

List<MapPoint> points = new List<MapPoint>();

points.Add(new MapPoint(500000, 500000));

MilitaryMessage message = new MilitaryMessage("1", MilitaryMessageType.PositionReport, MilitaryMessageAction.Update, points);

message.SicCode = "SHGPEVATM-MQ---";

MessageLayer.ProcessMessage(message);

0 Kudos
7 Replies
AnttiKajanus1
Regular Contributor II

What do you mean by unknown image in this context? You mean that you get some image from SymbolDictionary but it's incorrect?

0 Kudos
KeithMacIntyre
New Contributor III

Yes. It always returns the yellow unknown empty symbol.

0 Kudos
KeithMacIntyre
New Contributor III

I've attached a sample project showing the problem.

0 Kudos
AnttiKajanus1
Regular Contributor II

Yep, it's a bug. Thanks for reporting this Keith. I have logged issue as a bug and hopefully we will get it fixed soon.

0 Kudos
AnttiKajanus1
Regular Contributor II

Here's another way to do get the symbol if you need that

SymbolDictionary dictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);

IEnumerable<SymbolProperties> symbols = dictionary.FindSymbols(new List<string>() { "SHGPEVATM-" });

var symbolSource = symbols.First().GetImage(128, 128);

JpegBitmapEncoder encoder = new JpegBitmapEncoder();

encoder.Frames.Add(BitmapFrame.Create(symbolSource as WriteableBitmap));

PictureMarkerSymbol symbol = new PictureMarkerSymbol();

MemoryStream ms = new MemoryStream();

encoder.Save(ms);

symbol.SetSource(ms.ToArray());

ms.Close();

Graphic g = new Graphic(new MapPoint(0, 0), symbol);

GraphicsLayer.Graphics.Add(g)

0 Kudos
AnttiKajanus1
Regular Contributor II

Small update to this : Actually issue that is reported originally should be using "name" instead of "SicCode" when finding the symbol.

WriteableBitmap image = dictionary.GetSymbolImage("Tank Medium H", 128, 128) as WriteableBitmap;

returns symbol correctly but the symbol that you are seeing is returned when symbol is not found (ie. when trying to use SIC). I think that the bug here is that we don't tell that no results were found and return an image.

See my previous comment how to find symbols based on the SIC values.

0 Kudos
KeithMacIntyre
New Contributor III

Using the other method in the previous version we would get a symbol returned with an echelon and/or mobility indicator.  It looks like to get the symbol we need we will have to pass in the first 10 characters of the symbol ID, then, get another image with the mobility or other modifiers and build the symbol ourselves.  It would be nice if the GetSymbolImage was implemented so we can get a fully formed symbol from the function with the full symbol ID

0 Kudos