How to initialize a world file with rotation


SummaryThis article discusses the new IWorldFileSettings2.MapRotation interface. By using this interface, a world file can be created for image exports that contain rotation parameters.

Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime

Additional Requirements
  • docExport is already an initialized IExport object—the code assumes the use of the HookHelper object to obtain the active view.

Initializing a world file with rotation

The following code example sets up a world file for a given IExport passed in as docExport. It assumes that a HookHelper object has been set up to obtain the active view. If the docExport is not coming from IExportFileDialog, the mapWorldFileSettings.OutputWorldFile parameter must be set to true for a world file to be output.
 

[C#]
private void InitWorldFile(IExport docExport)
{
IWorldFileSettings mapWorldFileSettings;
IWorldFileSettings2 mapWorldFileSettings2;
//Use the new IWorldFileSettings2 interface to write the rotation to the world file.
if (docExport is IExportImage && m_pHookHelper.ActiveView is IMap)
{
//Cast these two world file settings variables to docExport.
mapWorldFileSettings = docExport as IWorldFileSettings;
mapWorldFileSettings2 = docExport as IWorldFileSettings2;
//The mapWorldFileSettings.OutputWorldFile is set by the dialog.
mapWorldFileSettings.MapExtent = m_GraphicsExtentEnv;
//The mapWorldFileSettings2.MapRotation must be copied for the world file to properly reflect rotation.
mapWorldFileSettings2.MapRotation = m_ActiveView.ScreenDisplay.DisplayTransformation.Rotation;
}

}

[VB.NET]
Private  Sub InitWorldFile(ByVal docExport As IExport)
Dim mapWorldFileSettings As IWorldFileSettings
Dim mapWorldFileSettings2 As IWorldFileSettings2
'Use the new IWorldFileSettings2 interface to write the rotation to the world file.
If TypeOf docExport Is IExportImage And m_pHookHelper.ActiveView Is IMap Then
'Cast these two world file settings variables to docExport.
mapWorldFileSettings = docExport 
mapWorldFileSettings2 = docExport
'The mapWorldFileSettings.OutputWorldFile is set by the dialog.
mapWorldFileSettings.MapExtent = m_GraphicsExtentEnv
'The mapWorldFileSettings2.MapRotation must be copied for the world file to properly reflect rotation.
mapWorldFileSettings2.MapRotation = m_ActiveView.ScreenDisplay.DisplayTransformation.Rotation
End If

End Sub