blocksnet.models.service_type

Classes

ServiceBrick(*, capacity, area, ...)

Represents a typical service module or unit used in urban development.

ServiceType(*, code, name, accessibility, demand)

Represents a category of service entity, such as schools, and its parameters.

class blocksnet.models.service_type.ServiceBrick(*, capacity: int, area: float, is_integrated: bool, parking_area: float)[source]

Bases: BaseModel

Represents a typical service module or unit used in urban development.

Parameters:
  • capacity (int) – Maximum number of people that can be accommodated or served by this service module.

  • area (float) – Area occupied by the service module in square meters.

  • is_integrated (bool) – Indicates whether the service module is integrated within a living building.

  • parking_area (float) – Required parking area in square meters for the service module.

capacity: int
area: float
is_integrated: bool
parking_area: float
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class blocksnet.models.service_type.ServiceType(*, code: str, name: str, accessibility: int, demand: int, land_use: list[blocksnet.models.land_use.LandUse] = [], bricks: list[blocksnet.models.service_type.ServiceBrick] = [])[source]

Bases: BaseModel

Represents a category of service entity, such as schools, and its parameters.

Parameters:
  • code (str) – Code identifying the service type.

  • name (str) – Unique name of the service type.

  • accessibility (int, optional) – Average accessibility time in minutes to reach the service unit. Must be equal or greater than 0.

  • demand (int, optional) – Demand per 1000 population for the service type. Must be equal or greater than 0.

  • land_use (list[LandUse], optional) – List of land use categories associated with the service type. Default is an empty list.

  • bricks (list[ServiceBrick], optional) – List of service bricks or modules available for the service type. Default is an empty list.

code: str
name: str
accessibility: int
demand: int
land_use: list[blocksnet.models.land_use.LandUse]
bricks: list[blocksnet.models.service_type.ServiceBrick]
get_bricks(is_integrated: bool = False) list[blocksnet.models.service_type.ServiceBrick][source]

Retrieve service bricks or modules associated with the service type.

Parameters:

is_integrated (bool, optional) – Filter by whether the brick may be integrated within a living building. Default is False.

Returns:

List of ServiceBrick objects matching the filter criteria.

Return type:

list[ServiceBrick]

validate_bricks() list[blocksnet.models.service_type.ServiceBrick][source]

Validate and convert the bricks field into a list of ServiceBrick objects.

Parameters:

value (list) – List of dictionaries or ServiceBrick objects.

Returns:

List of validated ServiceBrick objects.

Return type:

list[ServiceBrick]

validate_land_use() list[blocksnet.models.land_use.LandUse][source]

Validate and convert the land_use field into a list of LandUse objects.

Parameters:

value (list) – List of strings or LandUse objects.

Returns:

List of validated LandUse objects.

Return type:

list[LandUse]

calculate_in_need(population: int) int[source]

Calculate the estimated number of people in need of this service type based on population.

Parameters:

population (int) – Total population.

Returns:

Estimated number of people in need of this service type.

Return type:

int

__hash__() int[source]

Compute the hash value of the ServiceType object based on its name.

Returns:

Hash value of the ServiceType object.

Return type:

int

__str__() str[source]

Return a string representation of the ServiceType object.

Returns:

String containing basic information about the ServiceType object.

Return type:

str

to_dict()[source]

Convert the ServiceType object into a dictionary representation.

Returns:

Dictionary representation of the ServiceType object.

Return type:

dict

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.