How to initialize a world file with rotation


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

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. Note, the mapWorldFileSettings.OutputWorldFile parameter must be set to true for a world file to be output.
[Java]
static void initWorldFile(IExport docExport)throws Exception{
    //Use the new IWorldFileSettings2 interface to write the rotation to the worldfile
    if (docExport instanceof IExportImage && hookHelper.getActiveView()instanceof
        IMap){
        //cast these two worldfilesettings variables to docExport.
        IWorldFileSettings mapWorldFileSettings = (IWorldFileSettings)docExport;
        IWorldFileSettings2 mapWorldFileSettings2 = (IWorldFileSettings2)docExport;
        //mapWorldFileSettings.OutputWorldFile is set by the dialog.
        mapWorldFileSettings.setMapExtent(graphicsExtentEnv);
        mapWorldFileSettings.setOutputWorldFile(true);
        //mapWorldFileSettings2.MapRotation must be copied in order for world file to properly reflect rotation.
        mapWorldFileSettings2.setMapRotation(activeView.getScreenDisplay()
            .getDisplayTransformation().getRotation());
    }
}






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

Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine