ThinkGeo.com    |     Documentation    |     Premium Support

Finding extent of rotated rectangle

I have a print layer that I allow users to rotate. I also let them scale it. For instance, they tell me paper size and feet/inch. I then set the scale of the rectangle that will fit in the page. When I use a “flat” rectangle, so it has a 0 degree rotation, this works well. However, when they rotate it say 40 degrees to follow a road, I am having trouble getting the extent needed to display it properly on the print layer.

var boundBox = SheetBound.GetBoundingBox();
RectangleShape rs = projection.GetUpdatedExtent(boundBox);

my expectation is that above would give me the correct extents using the RotationProjection I have setup. What I am getting instead, is the exact same rectangleshape as if I didn’t use a rotation projection at all.

This is the base drawing, with the rectangle drawn

Here is my print screen

Here is a print screen when I don’t have to rotate the rectangle, this is what it should look like above as well:

Hi Jake,

I am confused about your question, if I misunderstand you please let me know:

  1. RotationProjection.GetUpdatedExtent don’t works well. I tested it and found it’s don’t works here, I need to double check that with the developer to see whether it’s used for this scenario.

  2. From your 3 screen shots, I hadn’t found where is the problem, does the extent with rotationProjection hadn’t put in it’s correct position? Or just the current extent is not the best one which mentioned by question 1?

Regards,

Don

The difference is clearest when comparing the last 2 screen shots. The last screen shot is using a rectangle that is parallel to the equator, what I call “flat”. When using this flat rectangle I can zoom to its extents and get my 1 inch = 100 feet scale.

When I rotate that rectangle 45 degrees, using the rotateprojection and then try to find that updated extent, when I zoom to that extent I get 1 inch = 309ft. My expectation would be 1 inch = 100ft.

In other words, I need that rotated rectangle to be centered and fill the screen, which it currently is not doing.

Hi Jake,

Sorry I hadn’t get response about this question, it looks there is a workaround for it, you can try to get the updated extent like this:

RotationProjection rotation = new RotationProjection(90);
rotation.Open();
RectangleShape rect = new RectangleShape(10, 20, 20, 10);
RectangleShape rect2 = rotation.ConvertToExternalProjection(rect);

I think directly call ConvertToExternalProjection can instead to use GetUpdatedExtent. Please notice after rectangleshape is rotated, it should be a polygon now.

Wish that’s helpful.

Regards,

Don