o a@s|ddlmZmZddlmZmZmZddlmZddlm Z ddl m Z ddl mZGdddeZGd d d eZGd d d eZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZGd!d"d"eZGd#d$d$eZeeeeeeeeeeeeeed%Zd&d'eDZ d(S)))byrefc_int)datedatetimetime)GDALBase) GDALException)ds) force_strc@seZdZdZddZddZddZdd d Zd d Zd dZ e ddZ e ddZ e ddZ e ddZe ddZe ddZe ddZdS)FieldzL Wrap an OGR Field. Needs to be instantiated from a Feature object. cCs<||_||_t|j|}|std||_t|j|_dS)zq Initialize on the feature object and the integer index of the field within the feature. z/Cannot create OGR Field, invalid pointer given.N) _feat_indexcapiget_feat_field_defnptrr OGRFieldTypestype __class__)selffeatindexfld_ptrr?/usr/lib/python3/dist-packages/django/contrib/gis/gdal/field.py__init__szField.__init__cCst|jS)z.Return the string representation of the Field.)strvaluestriprrrr__str__%sz Field.__str__cCs|jr t|jj|jSdS)z/Retrieve the Field's value as a double (float).N)is_setrget_field_as_doubler rr rrrr as_double*szField.as_doubleFcCs<|r|jrt|jj|jSdS|jrt|jj|jSdS)z)Retrieve the Field's value as an integer.N)r rget_field_as_integer64r rr get_field_as_integer)ris_64rrras_int.sz Field.as_intcCs.|jsdSt|jj|j}t||jjddS)z'Retrieve the Field's value as a string.NTencoding strings_only)r rget_field_as_stringr rr r r()rstringrrr as_string5szField.as_stringc Cs|jsdSddtdD\}}}}}}}t|jj|jt|t|t|t|t|t|t| }|r>|||||||fStd)z@Retrieve the Field's value as a tuple of date & time components.NcSsg|]}tqSr)r).0irrr @sz%Field.as_datetime..z:Unable to retrieve date & time information from the field.) r rangerget_field_as_datetimer rr rr) ryymmddhhmnsstzstatusrrr as_datetime<s zField.as_datetimecCst|jj|jS)zCReturn True if the value of this field isn't null, False otherwise.)r is_field_setr rr rrrrr Jsz Field.is_setcCst|j}t||jjddS)zReturn the name of this Field.Tr')rget_field_namerr r r()rnamerrrr>Os z Field.namecC t|jS)z#Return the precision of this Field.)rget_field_precisionrrrrr precisionU zField.precisioncCr?)z"Return the OGR type of this Field.)rget_field_typerrrrrrZrBz Field.typecCr?)z.Return the OGR field type name for this Field.)rget_field_type_namerrrrr type_name_rBzField.type_namecC|S)zReturn the value of this Field.)r,rrrrrdsz Field.valuecCr?)zReturn the width of this Field.)rget_field_widthrrrrrwidthjrBz Field.widthN)F)__name__ __module__ __qualname____doc__rrr"r&r,r;propertyr r>rArrErrHrrrrr s,       r c@s(eZdZdZeddZeddZdS) OFTIntegerFcCs ||jS)z*Return an integer contained in this field.)r&_bit64rrrrrtrBzOFTInteger.valuecCsdS)z GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal. rrrrrrryszOFTInteger.typeN)rIrJrKrOrMrrrrrrrNqs  rNc@eZdZeddZdS)OFTRealcCrF)z'Return a float contained in this field.)r"rrrrrsz OFTReal.valueNrIrJrKrMrrrrrrQrQc@ eZdZdS) OFTStringNrIrJrKrrrrrUrUc@rT) OFTWideStringNrVrrrrrXrWrXc@rT) OFTBinaryNrVrrrrrYrWrYc@rP)OFTDatec CsFz|\}}}}}}}t|j|j|jWStttfy"YdSw)z4Return a Python `date` object for the OFTDate field.N)r;rr TypeError ValueErrorrrr3r4r5r6r7r8r9rrrrs z OFTDate.valueNrRrrrrrZrSrZc@rP) OFTDateTimec CsRz|\}}}}}}}t|j|j|j|j|j|jWStttfy(YdSw)z=Return a Python `datetime` object for this OFTDateTime field.N)r;rrr[r\rr]rrrrs  zOFTDateTime.valueNrRrrrrr^rSr^c@rP)OFTTimec CsDz|\}}}}}}}t|j|j|jWSttfy!YdSw)z5Return a Python `time` object for this OFTTime field.N)r;rrr\rr]rrrrs z OFTTime.valueNrRrrrrr_rSr_c@seZdZdZdS) OFTInteger64TN)rIrJrKrOrrrrr`sr`c@rT)OFTIntegerListNrVrrrrrarWrac@rT) OFTRealListNrVrrrrrbrWrbc@rT) OFTStringListNrVrrrrrcrWrcc@rT)OFTWideStringListNrVrrrrrdrWrdc@rT)OFTInteger64ListNrVrrrrrerWre)rr0 cCsi|]\}}||qSrr)r-numclsrrr srtN)!ctypesrrrrrdjango.contrib.gis.gdal.baserdjango.contrib.gis.gdal.errorr"django.contrib.gis.gdal.prototypesr rdjango.utils.encodingr r rNrQrUrXrYrZr^r_r`rarbrcrdreritemsROGRFieldTypesrrrrsJ    c