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
| Attribute | Type | Description |
|---|---|---|
| _klass | class | The Geometry or Raster class used to instantiate or validate spatial objects retrieved from the database. |
| _load_func | callable | The 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
| Name | Type | Description |
|---|---|---|
| klass | class | The 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_func | callable = None | An 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
| Name | Type | Description |
|---|---|---|
| klass | type | The 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_func | callable = None | An optional factory function used to load the spatial data; defaults to the provided class. |