Inconsistencies and missing information when parsing CIM objects

165
3
2 weeks ago
marco_vertigis
New Contributor III

Hi there,

I digged a bit deeper into the behaviour of map graphics and their CIM representation in a MapDocument and LayerDocument and found probably some bugs or atleast inconsistencies when working with them.

The map graphic binary reference is lost when parsing a .mapx file back to a CIMMapDocument instance.

// map needs to have a graphic layer with graphics ofc
map.SaveAsFile("C:\\temp\\temp.mapx", true);
var json = File.ReadAllText("C:\\temp\\temp.mapx");
var mapDoc = CIMMapDocument.FromJson(json);
// BUG :: BinaryReference.Object is null. Should be instance of CIMElementStorage
var binaryRefs = mapDoc.BinaryReferences.Where(br => br.Object is CIMElementStorage).ToList(); // returns none

Same behaviour can be observed when doing this with a .lyrx file.

var layerDoc = new LayerDocument(graphicLayer);
layerDoc.Save("C:\\temp\\temp.lyrx");
// The .lyrx file contains the CIMElementStorage object
var json = File.ReadAllText("C:\\temp\\temp.lyrx");
// BUG: BinaryReference.Object (CIMElementStorage) is null, although it does exist in the .lyrx file json
var cimLayerDoc2 = CIMLayerDocument.FromJson(json);

This two are probably just some parsing errors but the last one just does not make any sense to me. If I get the CIMLayerDocument in memory the CIMElementStorage object exists, but somehow the coordinates of the different graphic geometries are manipulated/odd in comparison when I do a proper save to .lyrx file.

var layerDoc = new LayerDocument(graphicLayer);
// BUG: The resulting geometries within the CIMElementStorage have completely different geometries, see image below
// geometries are broken
var cimLayerDoc = layerDoc.GetCIMLayerDocument();
// geometries are ok
layerDoc.Save("C:\\temp\\temp.lyrx");

 

Left the geometry saved as .lyrx and right the in memory create CIMLayoutDocument. The source is exactly the same.

difference-save-to-lyrx-and-inmemory.PNG

Any explanations or hints on this would be appreciated!

0 Kudos
3 Replies
AlfredBaldenweck
MVP Regular Contributor

Weird. I wonder if the coordinate system used between both formats is different?

0 Kudos
marco_vertigis
New Contributor III

The spatial reference is actually the exact same. Its the same source map and the same source geometry.

0 Kudos
RichardDaniels
Occasional Contributor III
If you found a repeatable inconsistency, I would encourage you to place a bug report with Esri. That is the only way to get this addressed. The bug is either in the help documents for the LayerDocument(graphicLayer) object OR an unexplained behavior in the CIMLayerDocument object.
0 Kudos