Skip to main content
Question

Bounding box ratio

  • September 27, 2019
  • 4 replies
  • 179 views

simonhume
Contributor
Forum|alt.badge.img+2

Hi

I have generated a Convex Hull table for a address table, grouping by postcode in the address table.

I want to print individual maps for each of these postcode areas based on whether they would be better

off in Portrait or Landscape Orientation.

Can someone advise how i obtain the Bounding Box Ratio for each of the Hulls?

I've added the Bounds Extractor transformer into my workspace, but that doesn't seem to give me the ratio.

Is there a way of updating a new column (to indicate which orientation is best) using a calculation within FME?

Thanks for any assistance

 

Simon Hume

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3701 replies
  • September 27, 2019

Assuming you are not using a rotated bounding box you can use the BoundsExtractor. If the difference between xmax and xmin is larger than the difference between ymax and ymin it is a landscape orientation, otherwise it's portrait.


david_r
Celebrity
  • 8394 replies
  • September 27, 2019

Depends a bit on what you mean by ratio, but based on a BoundsExtractor you can do the following in e.g. an AttributeCreator:

ratio = @Evaluate((@Value(_xmax)-@Value(_xmin)) / (@Value(_ymax)-@Value(_ymin))):1

Result will e.g. be '2:1' for a rectangle that is twice as large as tall.


simonhume
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • 24 replies
  • September 27, 2019

Thanks very much to both of you for your prompt answers, i can now get what i need from your suggestions

 

Simon Hume


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • 2252 replies
  • September 27, 2019

@simonhume

You are trying to determine the aspectratio.

 

BoundingBoxReplacer (can also get the oriented BB and) has output attributes for longer and shorter side.

So you can check wich is longest and check with

Extract length, sort by length, sample 1 by length.

Pick the longest and check if it has angle 90.

This wil give you the required pageorientation, Portrait or Landscape.

 

If you use boundsextractor, you can do the same, be it you have to calculate it yourself. Like @david_r illustrates.