area — Cartographie 04/07/2021 documentation

# `area`

## Module Contents

### Classes

`Category` | Enum where members are also (and must be) ints
`Area` |

### Attributes

`zone` |

class area.Category

  Bases: `enum.IntEnum`

  Enum where members are also (and must be) ints

  UNDEFINED = 0
  LAND = 1
  FIELD = 2
  FOREST = 3
  RIVER = 4
  LAKE = 5
  SEA = 6
  PARK = 7
  GARDEN = 8
  HOUSE = 10
  MANSION = 11
  MARKET = 12
  TOWNHALL = 13
  UNIVERSITY = 14
  FARM = 15
  CHURCH = 20
  CATHEDRAL = 21
  MONASTRY = 22
  FORT = 31
  CASTLE = 32
  WALL = 33
  STREET = 50
  BRIDGE = 51
  COMPOSITE = 90

class area.Area(polygon, category, sub_areas=[])
  _last_id = 0
  members = []
  static get_id()
  __del__(self)
  __repr__(self)

    Return repr(self).

  property identity(self)
  property polygon(self)
  setCategory(self, category)
  split(self, percentage, direction, inplace=True, new_category=Category.GARDEN)

    Split an area in two areas. Store result in self.sub_areas if inplace == True.

    Args:

      percentage: float - percentage of surface for first area, between 0 and 1 direction: int - side for first area (from center to 0 = North, 90 = East...) new_category: Category - category of the second area

    Returns: if inplace == False

      area1: Area area2: Area

    Tests:

          >>> surf = Area(Polygon([(0,0), (20,0), (20,40), (0,40)]), Category.HOUSE)
          >>> res = surf.split(0.25, 0, False)  # house takes 1/4 of surface and is north
          >>> res0 = Polygon([(0, 30), (0, 40), (20, 40), (20, 30), (0, 30)])
          >>> res0.symmetric_difference(res[0].polygon).area < 1
          True

  components(self)

area.zone