o 3Ûøa2 ã@s$dZddlmZGdd„deƒZdS)a The SpatialProxy object allows for lazy-geometries and lazy-rasters. The proxy uses Python descriptors for instantiating and setting Geometry or Raster objects corresponding to geographic model fields. Thanks to Robert Coup for providing this functionality (see #4322). é)ÚDeferredAttributecs4eZdZd‡fdd„ Zd‡fdd„ Zdd„Z‡ZS) Ú SpatialProxyNcs ||_|p||_tƒ |¡dS)zy Initialize on the given Geometry or Raster class (not an instance) and the corresponding field. N)Ú_klassÚ _load_funcÚsuperÚ__init__)ÚselfÚklassÚfieldÚ load_func©Ú __class__©úD/usr/lib/python3/dist-packages/django/contrib/gis/db/models/proxy.pyr s zSpatialProxy.__init__csŠ|dur|Sz |j|jj}Wntytƒ ||¡}Ynwt||jƒr*|}|S|dus2|dkr6d}|S| |¡}t ||jj|ƒ|S)zü Retrieve the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported. NÚ) Ú__dict__r ÚattnameÚKeyErrorrÚ__get__Ú isinstancerrÚsetattr)rÚinstanceÚclsÚ geo_valueÚgeo_objr rrrs  ÿ ù þzSpatialProxy.__get__cCs’|jj}|dkr|dust|tt|jfƒrn*t||jƒr'|jdur&|jj|_n|dus2t|ttfƒr3n td|j j |t |ƒfƒ‚||j |jj <|S)zñ Retrieve the proxied geometry or raster with the corresponding class specified during initialization. To set geometries, use values of None, HEXEWKB, or WKT. To set rasters, use JSON or dict values. ÚRASTERNz6Cannot set %s SpatialProxy (%s) with value of type: %s)r Ú geom_typerÚstrÚdictrÚsridÚ memoryviewÚ TypeErrorr Ú__name__Útyperr)rrÚvalueÚgtyperrrÚ__set__1s "   €ÿzSpatialProxy.__set__)N)r"Ú __module__Ú __qualname__rrr&Ú __classcell__rrr rr s rN)Ú__doc__Údjango.db.models.query_utilsrrrrrrÚs