Skip to main content

AreaField

Wrapper for Area values.

Attributes

AttributeTypeDescription
geo_fieldmodels.FieldThe geographic field associated with this area measurement, used to determine the appropriate unit attribute for database operations.

Constructor

Signature

def AreaField(
geo_field: Any
)

Parameters

NameTypeDescription
geo_fieldAnyThe geographic field associated with this area measurement.

Signature

def AreaField(
geo_field: django.contrib.gis.db.models.fields.GeometryField
) - > null

Parameters

NameTypeDescription
geo_fielddjango.contrib.gis.db.models.fields.GeometryFieldThe geographic field used to determine the appropriate area units for database operations

Methods


get_prep_value()

@classmethod
def get_prep_value(
value: [Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)
) - > [Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)

Validates that the provided value is an Area measurement object before it is used in a query.

Parameters

NameTypeDescription
value[Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)The measurement object to be validated; must be an instance of the Area class

Returns

TypeDescription
[Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)The validated Area measurement object

get_db_prep_value()

@classmethod
def get_db_prep_value(
value: [Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area),
connection: django.db.backends.base.base.BaseDatabaseWrapper,
prepared: boolean = false
) - > float

Converts the Area object into a raw numerical value formatted for the specific database backend's area unit requirements.

Parameters

NameTypeDescription
value[Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)The Area measurement object to prepare for database insertion
connectiondjango.db.backends.base.base.BaseDatabaseWrapperThe current database connection used to resolve backend-specific area attributes
preparedboolean = falseA flag indicating whether the value has already been prepared for the database

Returns

TypeDescription
floatThe numerical area value extracted from the Area object based on the connection's unit attribute

from_db_value()

@classmethod
def from_db_value(
value: float|Decimal,
expression: django.db.models.expressions.Expression,
connection: django.db.backends.base.base.BaseDatabaseWrapper
) - > [Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)

Converts a numerical value retrieved from the database into a Python Area measurement object, ensuring Decimals are cast to floats.

Parameters

NameTypeDescription
value`floatDecimal`
expressiondjango.db.models.expressions.ExpressionThe query expression that produced the value
connectiondjango.db.backends.base.base.BaseDatabaseWrapperThe current database connection used to determine the correct area units for the field

Returns

TypeDescription
[Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area)An Area object initialized with the database value and the appropriate unit attribute

get_internal_type()

@classmethod
def get_internal_type() - > string

Returns the internal identifier for this field type, used by Django to map fields to database column types.

Returns

TypeDescription
stringThe string literal "AreaField"