AnsweredAssumed Answered

Assign SpatialReference to Map

Question asked by HimBromBeere on Dec 3, 2019
Latest reply on Dec 4, 2019 by HimBromBeere

I have a map containign some layers in a user-defined spatial-reference (some version of the German DE_DHDN_3GK2). As of the docs my map gets the spatial-reference of ther very first layer, which is identical to the mentioned one. 

 

However when I assign another reference-sytem to my map, nothing happens:

 

var myMap = ((IMxDocument)myApp.Document).FocusMap;
myMap.SpatialReference = anotherWorkspace.SpatialReference;

 

In particular when I query the properties of the maps spatial-reference I get its old values:

 

((ISpatialReferenceResolution)myMap.SpatialReference).get_XYResolution(false);

The same applies when I use this:

 

((ISpatialReference)myMap.SpatialReference).GetFalseOriginAndUnits(out var falseX, out var falseY, out var xyUnits);

So I wonder if assigning a spatial-reference to a map has any purpose at all.

 

When I compare the spatial references using 

 

var transformEqual = ((IClone)myMap.SpatialReference).IsEqual((IClone)anotherWorkspace.SpatialReference);
myMap.SpatialReference.IsPrecisionEqual(anothrWorkspace.SpatialReference, out var precisionEqual);

I get true for transformEqual and false for precisionEqual, which makes me assume that the setter for IMap.SpatialReference checks for IClone.IsEqual first and does nothing in case of true.

 

The above code runs in an AddIn on ArcMap 10.6.1.

Outcomes