AreaField
Wrapper for Area values.
Attributes
| Attribute | Type | Description |
|---|---|---|
| geo_field | models.Field | The 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
| Name | Type | Description |
|---|---|---|
| geo_field | Any | The geographic field associated with this area measurement. |
Signature
def AreaField(
geo_field: django.contrib.gis.db.models.fields.GeometryField
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| geo_field | django.contrib.gis.db.models.fields.GeometryField | The 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
| Name | Type | Description |
|---|---|---|
| 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
| Type | Description |
|---|---|
[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
| Name | Type | Description |
|---|---|---|
| value | [Area](../../../../measure/area.md?sid=django_contrib_gis_measure_area) | The Area measurement object to prepare for database insertion |
| connection | django.db.backends.base.base.BaseDatabaseWrapper | The current database connection used to resolve backend-specific area attributes |
| prepared | boolean = false | A flag indicating whether the value has already been prepared for the database |
Returns
| Type | Description |
|---|---|
float | The 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
| Name | Type | Description |
|---|---|---|
| value | `float | Decimal` |
| expression | django.db.models.expressions.Expression | The query expression that produced the value |
| connection | django.db.backends.base.base.BaseDatabaseWrapper | The current database connection used to determine the correct area units for the field |
Returns
| Type | Description |
|---|---|
[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
| Type | Description |
|---|---|
string | The string literal "AreaField" |