Functional Weave
Code in Python

property.floor-area@1.0.1

README.md

1,596 bytes · view raw

# property.floor-area

The floor area of a property from its room measurements, as estate agents'
floor plans and EPCs quote it: every room's length × width, their total, and
the total in both square metres and square feet.

`floorArea([{name: "Lounge", length: "4", width: "3"}, {name: "Bed", length: "2.5", width: "2"}], "m", 2)`
gives rooms of 12 and 5 m², a total of 17 m², and 182.99 sq ft.

## Why decimal text

Dimensions are read as exact decimals, never floats, so 4.1 × 3.3 is 13.53,
not 13.529999999999999. Each room's area and the total are exact (up to six
decimal places, from dimensions with up to three), and the only rounding is
the final one to `decimals` places in each unit, done by `units.convert`
with the exact definition 1 ft = 0.3048 m (1 sq ft = 0.09290304 m²). The
total is rounded once, not the rooms: rounding each room first and adding can
be off in the last place.

## Edge cases and limits

- Rooms are rectangles. An L-shaped room is two entries; a bay is its own
  entry; deduct nothing, since the function never subtracts.
- Dimensions are greater than 0 and below 1000 of the unit, with at most 3
  decimal places (a millimetre in metres), and there may be at most 1000
  rooms. An empty list is an error, as is a room of zero size.
- Feet and inches must be converted to decimal feet first (10 ft 6 in is
  "10.5").
- This is the area of the rooms measured, not a RICS gross internal area:
  walls, stairs and circulation space count only if they are measured in.

1.0.1 fixes Python accepting a trailing newline in a room's length or width; adds tests.