Question

Bounding box ratio

  • 27 September 2019
  • 4 replies
  • 22 views

Badge +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

Userlevel 4
Badge +25

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.

Userlevel 4

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.

Badge +1

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

 

Simon Hume

Badge +3

@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.

Reply