Skip to main content

SpatialProxy

This class acts as a descriptor for spatial fields, providing lazy loading and initialization for geometry and raster objects. It handles the retrieval and conversion of field data into specific spatial types like GEOS, OGR, or GDALRaster instances. Additionally, it manages type validation and SRID assignment when setting spatial values on model instances.

Attributes

AttributeTypeDescription
_klassclassThe Geometry or Raster class used to instantiate or validate spatial objects retrieved from the database.
_load_funccallableThe callable used to transform raw field data into a spatial object, defaulting to the class specified in _klass.

Constructor

Signature

def SpatialProxy(
klass: class,
field: [Field](../../../../../forms/fields/field.md?sid=django_forms_fields_field),
load_func: callable = None
)

Parameters

NameTypeDescription
klassclassThe Geometry or Raster class to be used for the proxy.
field[Field](../../../../../forms/fields/field.md?sid=django_forms_fields_field)The corresponding field instance.
load_funccallable = NoneAn optional function used to load the spatial data; defaults to the provided klass if not specified.

Signature

def SpatialProxy(
klass: type,
field: [Field](../../../../../forms/fields/field.md?sid=django_forms_fields_field),
load_func: callable = None
) - > null

Parameters

NameTypeDescription
klasstypeThe Geometry or Raster class used to instantiate spatial objects.
field[Field](../../../../../forms/fields/field.md?sid=django_forms_fields_field)The model field instance associated with this proxy.
load_funccallable = NoneAn optional factory function used to load the spatial data; defaults to the provided class.