Skip to main content

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

AttributeTypeDescription
namestring = "Extent"The internal name of the aggregate function used for identification within the database backend.
is_extentstring = "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

NameTypeDescription
expressionAnyThe SQL expression or field to aggregate.
**extradictAdditional 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

NameTypeDescription
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.
**extradictAdditional 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

NameTypeDescription
valueAnyThe 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.
connectionDatabaseConnectionThe current database connection providing backend-specific conversion logic.

Returns

TypeDescription
tupleA four-item tuple representing the (xmin, ymin, xmax, ymax) coordinates of the extent.