Skip to main content
Question

Bounding box ratio

  • September 27, 2019
  • 4 replies
  • 125 views

simonhume
Participant
Forum|alt.badge.img+1

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

 

4 replies

redgeographics
Celebrity
Forum|alt.badge.img+48

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
Evangelist
  • 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
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • 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
  • 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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings