ThinkGeo.com    |     Documentation    |     Premium Support

Rotating MapPrinterLayer

Hi all,

I’m trying to plot a map. The user should be able to rotate the to fit paper best way…
Therefore I’m using the code :

'Define a Rotation Projection
Public rotateProjection As New RotationProjection

'Load the MapLayer to be printed
'the Map will be build by a GeoTiffLayer with Projection (EPSG=25832)
MyMapLayer = LoadGeoTiffLayer("c:\Users\ht\Documents\gisme.tif", BaseSrid)
mapPrinterLayer.Layers.Add(MyMapLayer)

'When map is loaded the user will rotate the map
rotateProjection.Angle = rotation.Text
MyMapLayer.ImageSource.Projection = rotateProjection
winformsMap1.Refresh()

My question: The Map doesn’t rotate.
What’s wrong?

Do you have a snipet for rotating and printing a RasterLayer.

Regards
Hardy

Hi Hardy,

I guess that maybe related with the data, because I tried our sample data in our sample, it works well.

9054.zip (1.2 MB)

Regards,

Ethan

Hi Ethan,

I have done several checks with the data: Using world.tif works well.
But using any other TIF File (with compression or not, size from 1.5MB to 400MB) will crash when setting the RotationProjection.
After setting the Rotation the map can’t be refreshed. MapSuite will crash in different exceptions. Most “the layer has no bounding box”.

It seems to me that there is a bug in MapSuite handling Raster with Rotation.

Data.zip (1.4 MB)

Please try with one of my files.

Regards
Hardy

Hi Hardy,

Thanks for your data and your research. I reproduce that and finally found that’s because we need to set another property here:

rotationProjection.PivotCenter = layer.GetBoundingBox().GetCenterPoint();

The default value is 0,0 and that’s why the world.tif works well because its center point is just the 0,0.

But it looks the property is not easy to be used, please see my code as below:

  GeoTiffRasterLayer layer = new GeoTiffRasterLayer(@"..\..\AppData\tmp.tif", @"..\..\AppData\tmp.tfw");
        layer.Open();
        rotationProjection.PivotCenter = layer.GetBoundingBox().GetCenterPoint();
        layer.Close();


        layer.ImageSource.Projection = rotationProjection;
        layer.Open();

        winformsMap1.CurrentExtent = layer.GetBoundingBox();

Or you can set rotationProjection.Open(); instead of close the layer and open it again, that will works also.

Please notice, you should want to get the center point before assign rotation projection, or else the value is incorrect because.

I will let our developer know it and see whether they can enhancement the RotationProjection in future.

Regards,

Ethan

Ethan,
it’s working fine.
Thank you for support.

Regards
Hardy

Hi Hardy,

It’s glad to hear that works fine.
If there is any issue when using MapSuite, please feel free to let us know that.

Thanks
Mark