Map rotation support in the Web ADF at SP 2

Rex Hansen wrote this thorough post about the new support for map rotation in version 9.2, Service Pack 2 of the Web ADF for the Microsoft® .NET Framework:

ArcGIS Server map services support the ability to serve a rotated data frame (map). In 9.2 SP 2, the .NET Web ADF has been enhanced to support map rotation. This involved a number of changes in many sections of the Web ADF. Each section is discussed below:

Map control

The Map control has a new Rotation property that can be used to specify, in degrees, the rotation of resources in the Map. A value of NaN means that the rotation of the PrimaryMapResource will be applied; 0 will unrotate rotated resources and leave other resources alone; values greater or less than 0 will rotate resources, throwing an exception if unrotatable resources are present. Map rotation is supported for ArcGIS Server (both Internet and Local) and Web ADF Graphics data sources.

If the Map control has a rotation value greater or less than 0:

  1. The presence of non-rotatable resources will return an exception in the Web page at runtime. The exception will indicate which resource does not support rotation.
  2. The ContinuousCallback and EnableTileCaching properties on the Map control will be disabled.

If the Map Rotation property is NaN, the rotation of the PrimaryMapResource (PMR) can be used. Since a Web ADF Graphics resource cannot be a PMR, only a rotation value specified for a data frame in an ArcGIS Server map service can be used.

Map rotation can also be set on the fly at runtime. As long as the resources in the Map control support rotation, Map contents will be updated. Again, if a resource does not support rotation, an exception will returned in the Web page indicating which resource.

The following code snippet illustrates how to change the Rotation property on a Map control:

            Map1.Reset();

            Map1.Rotation = 45;

Rotating an ArcGIS Server cached map service requires that dynamic map images are generated – the cached map tiles will not be used. As a result, many of the performance benefits of a cached map service are negated.

Web ADF controls that work with the Map have also been updated to support rotation, such as the Navigation, Magnifier, and OverviewMap controls.

TransformationParams and RotationParams classes

Two new classes have been introduced to support parameters used when transforming and rotating map content: TransformationParams and RotationParams.

TransformationParams stores parameters needed to convert coordinates between screen and map units. The Map control has a GetTransformationParams() method to return a TransformationParams instance set up using Map properties. The TransformationDirection enumeration allows you to select which direction the transformation will take place: either screen to map units (ToMap) or map to screen units (ToScreen).

The RotationParams class stores parameters associated with a rotated map extent. The TransformationParams class uses the RotatedParams class to account for rotation when converting coordinates between screen and map units.

In most cases, you’ll use an instance of TransformationParams when converting geometry to and from screen and map units. This is discussed in more detail in the next section.

Geometry conversion

A set of static methods on the Web ADF Geometry, Point and Envelope classes (in ESRI.ArcGIS.ADF.Web.Geometry) used to convert to and from screen and map units have been overloaded to support map rotation. Previous methods of the same name in 9.2 final and 9.2 sp1 have been marked obsolete because they do not support rotated maps. Obsolete methods will still work with unrotated map content. The new overloads provide a more efficient pattern for transforming Web ADF geometry. A single TransformationParams instance can be created from scratch or retrieved from a Map control and used in multiple geometry conversion calls. TransformationDirection.ToMap should be used for ToMap_ methods while TransformationDirection.ToScreen should be used with ToScreen_ methods. The overloaded methods are listed below:

In the ESRI.ArcGIS.ADF.Web.Geometry.Geometry class (inherited by concrete Web ADF geometry classes):

TransformGeometryToScreen(ESRI.ArcGIS.ADF.Web.Geometry.Geometry,

  ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)

In the ESRI.ArcGIS.ADF.Web.Geometry.Point class:

ToMapPoint(ESRI.ArcGIS.ADF.Web.Geometry.Point, ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)
 

ToMapPoint(int, int, ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)

ToScreenPoint(ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)

In the ESRI.ArcGIS.ADF.Web.Geometry.Envelope class:

ToMapEnvelope(System.Drawing.Rectangle, ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)

ToScreenRectangle(ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)

The following code snippet illustrates how to convert from a point in screen units to a Web ADF Point object in map units:

ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPoint.X, screenPoint.Y, Map1.GetTransformationParams(TransformationDirection.ToMap);

Manager

When building a Web application in Manager, the Map rotation property is set to a value of NaN and cannot be changed explicitly. Instead, the Primary Map Resource (PMR) can be used to define a rotation value. In Manager, the PMR is set in the Preview Layers dialog by selecting a resource in the drop down list under “Use coordinate system, rotation and extent of:”. If the PMR is rotated, you cannot use non-rotatable service types, such as ArcIMS and WMS, in the same map. Manager will provide an informative warning if this situation occurs. If you select a non-rotatable service as the PMR, the Web ADF will unrotate any rotated service so that it lines up with the non-rotatable service.

This entry was posted in Services and tagged , , . Bookmark the permalink.

Leave a Reply

4 Comments

  1. ajpfister06 says:

    Very Cool. Thanks for the heads up.

  2. Tappsi says:

    Thanks for the informative post. I’m sure it’ll come in handy down the road.

  3. PhilipThompson says:

    Are there any plans to have any of the WebADF controls work explicitly against the Rotation property (as opposed to working through developer code).

    I’d thought of doing something with a Navigation Control, making the points of the compass draggable, so that rotating it would automatically rotate the Map, but it didn’t seem workable till now.

  4. kerenc says:

    I do not understand why do we need to call this Map1.reset() method, but since it acts very bad with out calling it, I wanted to try and use it – but it just give the “Object reference not set to an instance of an object.” error!
    what did I do wrong?
    I tryed to add a command that will rotate the map, but I had to comment out the call to the reset method. I also wwante to rotate the navigation tool accordingly but could not do it without a full postback.
    Could anyone please look at my simple code and help?
    Following is the codw for the command:
    public void ServerAction(ToolbarItemInfo info)
    {
    ESRI.ArcGIS.ADF.Web.UI.WebControls.Map Map1 = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)info.BuddyControls[0];
    //Map1.Reset();
    Map1.Rotation = 145;
    Navigation Navigation1 = (Navigation)Map1.Page.FindControl(“form1″).FindControl(“Navigation_Panel”).FindControl(“Navigation1″);
    Navigation1.Refresh();
    Map1.CallbackResults.CopyFrom(Navigation1.CallbackResults);
    }
    Regards,
    Keren.