Select to view content in your preferred language

Inconsistencies and missing information when parsing CIM objects

460
3
04-24-2024 04:05 AM
marco_vertigis
Occasional Contributor

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
Occasional Contributor

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

0 Kudos
RichardDaniels
Frequent Contributor
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