o a@sPddlmZddlmZddlmZddlmZddl m Z Gddde Z dS) )c_uint)gdal) prototypes) GEOSException) GEOSGeometrycseZdZdZdZdZd'fdd ZfddZfd d Zfd d Z e d dZ e ddZ ddZ ddZddZddZddZeZeddZejddZeddZejd dZed!d"Zejd#d"Zed$d%Zejd&d%ZeZZS)(PointTNcs|durg}n.t|ttfr|}n$t|ttfr1t|ttfr1t|ttfr,|||g}n ||g}ntd|t||}tj ||ddS)a The Point object may be initialized with either a tuple, or individual parameters. For example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individual parameters Nz2Invalid parameters given for Point initialization.)srid) isinstancetuplelistfloatint TypeError _create_pointlensuper__init__)selfxyzr coordspoint __class__?/usr/lib/python3/dist-packages/django/contrib/gis/geos/point.pyrs   zPoint.__init__cs|jrdStSN)emptyr_to_pickle_wkbrrrrr!+zPoint._to_pickle_wkbcs|dur|St|Sr) _create_emptyr_from_pickle_wkb)rwkbrrrr%.zPoint._from_pickle_wkbcs|jr tjjStSr)r r geometriesrr$r_ogr_ptrr"rrrr)1r'zPoint._ogr_ptrcCs |ddSr)r)clsrrrr$4s zPoint._create_emptycCs|stdS|dks|dkrtd|ttdt|}t|}t|dt|t|dt||dkrBt |dt|t|S)zO Create a coordinate sequence, set X, Y, [Z], and create point Nrr zInvalid point dimension: %sr) capi create_pointr create_csritercs_setxnextcs_setycs_setz)r*ndimrcsirrrr8s   zPoint._create_pointcCsJ|||}|r!|j}t|j||_|dur||_|dStd)Nz3Geometry resulting from slice deletion was invalid.)rr r, destroy_geomptr_ptr _post_initr)rlengthitemsr8r rrr _set_listLs   zPoint._set_listcCs|j|d|dS)Nr_cs setOrdinate)rindexvaluerrr _set_singleYr#zPoint._set_singleccs"tt|D]}||VqdS)z'Iterate over coordinates of this Point.N)ranger)rr6rrr__iter__\s zPoint.__iter__cCs|jrdS|jr dSdS)zBReturn the number of dimensions for this Point (either 0, 2 or 3).rr r)r haszr"rrr__len__as z Point.__len__cCs.|dkr|jS|dkr|jS|dkr|jSdS)Nrr+r)rrr)rrArrr_get_single_externaljszPoint._get_single_externalcCs|jddS)z$Return the X component of the Point.rr? getOrdinater"rrrrtzPoint.xcCs|jdd|dS)z!Set the X component of the Point.rNr>rrBrrrrycCs|jddS)z$Return the Y component of the Point.r+rrIr"rrrr~rKzPoint.ycCs|jdd|dS)z!Set the Y component of the Point.r+rNr>rLrrrrrMcCs|jr |jddSdS)z$Return the Z component of the Point.rrN)rFr?rJr"rrrrszPoint.zcCs"|jstd|jdd|dS)z!Set the Z component of the Point.zCannot set Z on 2D Point.rrN)rFrr?r@rLrrrrscCs|jjS)zReturn a tuple of the point.)r?r r"rrrr sz Point.tuplecCs||jd<dS)z6Set the coordinates of the point with the given tuple.rN)r?)rtuprrrr rK)NNNN)__name__ __module__ __qualname__ _minlength _maxlengthhas_csrr!r%r) classmethodr$rr=rCrErGrH_get_single_internalpropertyrsetterrrr r __classcell__rrrrr sF                rN) ctypesrdjango.contrib.gisrdjango.contrib.gis.geosrr,django.contrib.gis.geos.errorr django.contrib.gis.geos.geometryrrrrrrs