o a@srddlmZddlmZddlmZddlmZm Z ddl m Z ddl m Z Gddde eZGd d d eZd S) ) prototypes) GEOSCoordSeq) GEOSException) GEOSGeometryLinearGeometryMixin)Point)numpycseZdZejZdZdZfddZddZ ddZ d d Z e Z d d Z d dZddZeddZeZddZeddZeddZeddZeddZZS) LineStringTcst|dkr |d}n|}t|ttfs trt|tjs td|d}t|}|s8tj | d|ddS||j krIt d|j j|j |ft|ttf }|rl|j}t|dkr`td ||d|d}n+d}|D]&} t| tttfs~td |durt| }||qpt| |krtd qptt||t|d kd } |d kr| jn| j} t|D]#} |r|| ddf} nt|| tr|| j} n|| } | | | qtj | | j|ddS)a Initialize on the given sequence -- may take lists, tuples, NumPy arrays of X,Y pairs, or Point objects. If Point objects are used, ownership is _not_ transferred to the LineString object. Examples: ls = LineString((1, 1), (2, 2)) ls = LineString([(1, 1), (2, 2)]) ls = LineString(array([(1, 1), (2, 2)])) ls = LineString(Point(1, 1), Point(2, 2)) rz-Invalid initialization input for LineStrings.sridN)r z'%s requires at least %d points, got %s.r zToo many dimensions.z4Each coordinate should be a sequence (list or tuple)Dimension mismatch.z)len isinstancetuplelistrndarray TypeErrorgetsuper__init__ _init_func _minlength ValueError __class____name__shape _checkdimrrcapi create_csbool _set_point_3d _set_point_2drangeptr)selfargskwargscoordsr ncoords numpy_coordsrndimcoordcs point_setteri point_coordsrD/usr/lib/python3/dist-packages/django/contrib/gis/geos/linestring.pyrsZ          zLineString.__init__ccs"tt|D]}||VqdS)z%Allow iteration over this LineString.N)r&r)r(r2r5r5r6__iter__\s zLineString.__iter__cCs t|jS)z/Return the number of points in this LineString.)r_csr(r5r5r6__len__as zLineString.__len__cCs |j|SNr8)r(indexr5r5r6_get_single_externales zLineString._get_single_externalc Cs|jj}|jj}|j}tt|||d}t|D]\}}|||<q||j } | r@t |j | |_ |dur:||_| dSt d)Nrz3Geometry resulting from slice deletion was invalid.) r8dimshaszr rr!r" enumeraterr' destroy_geom _post_initr) r(lengthitemsr.r@r r0r2cr'r5r5r6 _set_listjs    zLineString._set_listcCs||j|<dSr;r<)r(r=valuer5r5r6 _set_singleszLineString._set_singlecCs|dvrtddS)N)r rr )r)r(dimr5r5r6r szLineString._checkdimcCs|jjS)zDReturn a tuple version of the geometry from the coordinate sequence.)r8rr9r5r5r6rszLineString.tuplecs,fddtt|D}trt|S|S)z{ Return a sequence (list) corresponding with the given function. Return a numpy array if possible. csg|]}|qSr5r5).0r2funcr5r6 sz'LineString._listarr..)r&rrarray)r(rMlstr5rLr6_listarrs zLineString._listarrcC||jjS)z(Return a numpy array for the LineString.)rQr8 __getitem__r9r5r5r6rOzLineString.arraycCrR)z/Return a list or numpy array of the X variable.)rQr8getXr9r5r5r6xrTz LineString.xcCrR)z/Return a list or numpy array of the Y variable.)rQr8getYr9r5r5r6yrTz LineString.ycCs|jsdS||jjS)z/Return a list or numpy array of the Z variable.N)r@rQr8getZr9r5r5r6rsz LineString.z)r __module__ __qualname__r!create_linestringrrhas_csrr7r:r>_get_single_internalrGrIr propertyrr+rQrOrVrXr __classcell__r5r5r4r6r s0 N    r c@s"eZdZdZejZeddZdS) LinearRingcCs|jrtd|jjS)Nz8Orientation of an empty LinearRing cannot be determined.)emptyrr8is_counterclockwiser9r5r5r6rds zLinearRing.is_counterclockwiseN) rrZr[rr!create_linearringrr_rdr5r5r5r6ras raN)django.contrib.gis.geosrr! django.contrib.gis.geos.coordseqrdjango.contrib.gis.geos.errorr django.contrib.gis.geos.geometryrrdjango.contrib.gis.geos.pointrdjango.contrib.gis.shortcutsrr rar5r5r5r6s    )