Extent
This class represents a geographic aggregate used to compute the bounding box of a set of geometries. It initializes with a 2D extent specification and utilizes a specialized field type to handle the resulting spatial data. The class also provides a mechanism to convert database-specific extent values into a standardized format via the connection's operations.
Attributes
| Attribute | Type | Description |
|---|---|---|
| name | string = "Extent" | The internal name of the aggregate function used for identification within the database backend. |
| is_extent | string = "2D" | A flag indicating the spatial dimensionality of the extent calculation, set to 2D for standard bounding boxes. |
Constructor
Signature
def Extent(
expression: Any,
**extra: dict
)
Parameters
| Name | Type | Description |
|---|---|---|
| expression | Any | The SQL expression or field to aggregate. |
| **extra | dict | Additional keyword arguments for the aggregate function. |
Signature
def Extent(
expression: [Expression](../../../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression),
**extra: dict
)
Parameters
| Name | Type | Description |
|---|---|---|
| expression | [Expression](../../../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression) | The field name or expression representing the geometries to be aggregated into a bounding box. |
| **extra | dict | Additional keyword arguments to be passed to the parent GeoAggregate constructor. |
Methods
convert_value()
@classmethod
def convert_value(
value: Any,
expression: [Expression](../../../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression),
connection: DatabaseConnection
) - > tuple
Converts the raw database value into a format suitable for the Extent field using the backend-specific operations.
Parameters
| Name | Type | Description |
|---|---|---|
| value | Any | The raw value returned from the database driver. |
| expression | [Expression](../../../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression) | The expression that produced the value being converted. |
| connection | DatabaseConnection | The current database connection providing backend-specific conversion logic. |
Returns
| Type | Description |
|---|---|
tuple | A four-item tuple representing the (xmin, ymin, xmax, ymax) coordinates of the extent. |