<s> import warnings <EOL> from ctypes import c_uint <EOL> from django . contrib . gis . geos import prototypes as capi <EOL> from django . contrib . gis . geos . error import GEOSException <EOL> from django . contrib . gis . geos . geometry import GEOSGeometry <EOL> from django . utils import six <EOL> from django . utils . deprecation import RemovedInDjango20Warning <EOL> from django . utils . six . moves import range <EOL> class Point ( GEOSGeometry ) : <EOL> _minlength = <NUM_LIT:2> <EOL> _maxlength = <NUM_LIT:3> <EOL> has_cs = True <EOL> def __init__ ( self , x = None , y = None , z = None , srid = None ) : <EOL> """<STR_LIT>""" <EOL> if x is None : <EOL> coords = [ ] <EOL> elif isinstance ( x , ( tuple , list ) ) : <EOL> coords = x <EOL> elif isinstance ( x , six . integer_types + ( float , ) ) and isinstance ( y , six . integer_types + ( float , ) ) : <EOL> if isinstance ( z , six . integer_types + ( float , ) ) : <EOL> coords = [ x , y , z ] <EOL> else : <EOL> coords = [ x , y ] <EOL> else : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> point = self . _create_point ( len ( coords ) , coords ) <EOL> super ( Point , self ) . __init__ ( point , srid = srid ) <EOL> def _create_point ( self , ndim , coords ) : <EOL> """<STR_LIT>""" <EOL> if not ndim : <EOL> return capi . create_point ( None ) <EOL> if ndim < <NUM_LIT:2> or ndim > <NUM_LIT:3> : <EOL> raise TypeError ( '<STR_LIT>' % str ( ndim ) ) <EOL> cs = capi . create_cs ( c_uint ( <NUM_LIT:1> ) , c_uint ( ndim ) ) <EOL> i = iter ( coords ) <EOL> capi . cs_setx ( cs , <NUM_LIT:0> , next ( i ) ) <EOL> capi . cs_sety ( cs , <NUM_LIT:0> , next ( i ) ) <EOL> if ndim == <NUM_LIT:3> : <EOL> capi . cs_setz ( cs , <NUM_LIT:0> , next ( i ) ) <EOL> return capi . create_point ( cs ) <EOL> def _set_list ( self , length , items ) : <EOL> ptr = self . _create_point ( length , items ) <EOL> if ptr : <EOL> capi . destroy_geom ( self . ptr ) <EOL> self . _ptr = ptr <EOL> self . _set_cs ( ) <EOL> else : <EOL> raise GEOSException ( '<STR_LIT>' ) <EOL> def _set_single ( self , index , value ) : <EOL> self . _cs . setOrdinate ( index , <NUM_LIT:0> , value ) <EOL> def __iter__ ( self ) : <EOL> "<STR_LIT>" <EOL> for i in range ( len ( self ) ) : <EOL> yield self [ i ] <EOL> def __len__ ( self ) : <EOL> "<STR_LIT>" <EOL> if self . empty : <EOL> return <NUM_LIT:0> <EOL> if self . hasz : <EOL> return <NUM_LIT:3> <EOL> else : <EOL> return <NUM_LIT:2> <EOL> def _get_single_external ( self , index ) : <EOL> if index == <NUM_LIT:0> : <EOL> return self . x <EOL> elif index == <NUM_LIT:1> : <EOL> return self . y <EOL> elif index == <NUM_LIT:2> : <EOL> return self . z <EOL> _get_single_internal = _get_single_external <EOL> @ property <EOL> def x ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _cs . getOrdinate ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> @ x . setter <EOL> def x ( self , value ) : <EOL> "<STR_LIT>" <EOL> self . _cs . setOrdinate ( <NUM_LIT:0> , <NUM_LIT:0> , value ) <EOL> @ property <EOL> def y ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _cs . getOrdinate ( <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> @ y . setter <EOL> def y ( self , value ) : <EOL> "<STR_LIT>" <EOL> self . _cs . setOrdinate ( <NUM_LIT:1> , <NUM_LIT:0> , value ) <EOL> @ property <EOL> def z ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _cs . getOrdinate ( <NUM_LIT:2> , <NUM_LIT:0> ) if self . hasz else None <EOL> @ z . setter <EOL> def z ( self , value ) : <EOL> "<STR_LIT>" <EOL> if not self . hasz : <EOL> raise GEOSException ( '<STR_LIT>' ) <EOL> self . _cs . setOrdinate ( <NUM_LIT:2> , <NUM_LIT:0> , value ) <EOL> def get_x ( self ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> return self . x <EOL> def set_x ( self , value ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> self . x = value <EOL> def get_y ( self ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> return self . y <EOL> def set_y ( self , value ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> self . y = value <EOL> def get_z ( self ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> return self . z <EOL> def set_z ( self , value ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> self . z = value <EOL> @ property <EOL> def tuple ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _cs . tuple <EOL> @ tuple . setter <EOL> def tuple ( self , tup ) : <EOL> "<STR_LIT>" <EOL> self . _cs [ <NUM_LIT:0> ] = tup <EOL> def get_coords ( self ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> return self . tuple <EOL> def set_coords ( self , tup ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , <NUM_LIT:2> <EOL> ) <EOL> self . tuple = tup <EOL> coords = tuple </s>
