o a>@sBdZddlmZmZddlmZGdddeZGdddZdS) a The GDAL/OGR library uses an Envelope structure to hold the bounding box information for a geometry. The envelope (bounding box) contains two pairs of coordinates, one for the lower left coordinate and one for the upper right coordinate: +----------o Upper right; (max_x, max_y) | | | | | | Lower left (min_x, min_y) o----------+ ) Structurec_double) GDALExceptionc@s,eZdZdZdefdefdefdefgZdS) OGREnvelopez&Represent the OGREnvelope C Structure.MinXMaxXMinYMaxYN)__name__ __module__ __qualname____doc__r_fields_rrB/usr/lib/python3/dist-packages/django/contrib/gis/gdal/envelope.pyrsrc@seZdZdZddZddZddZdd Zd d Ze d d Z e ddZ e ddZ e ddZ e ddZe ddZe ddZe ddZdS)Envelopez The Envelope object is a C structure that contains the minimum and maximum X, Y coordinates for a rectangle bounding box. The naming of the variables is compatible with the OGR Envelope structure. cGst|dkr@t|dtr|d|_nFt|dttfr6t|ddkr.tdt|d||dn#tdt |dt|dkrQ|dd|Dntdt||j |j krctd |j |j krmtd d S) z The initialization function may take an OGREnvelope structure, 4-element tuple or list, or 4 individual arguments. r(Incorrect number of tuple elements (%d).Incorrect type of argument: %scSsg|]}t|qSr)float).0arrr :sz%Envelope.__init__..#Incorrect number (%d) of arguments.zEnvelope minimum X > maximum X.zEnvelope minimum Y > maximum Y.N)len isinstancer _envelopetuplelistr_from_sequence TypeErrortypemin_xmax_xmin_ymax_y)selfargsrrr__init__%s     zEnvelope.__init__cCst|tr|j|jko|j|jko|j|jko|j|jkSt|trDt|dkrD|j|dkoC|j|dkoC|j|dkoC|j|dkStd)zx Return True if the envelopes are equivalent; can compare against other Envelopes and 4-tuples. rrrz4Equivalence testing only works with other Envelopes.) rrr#r%r$r&rrr)r'otherrrr__eq__Ds     zEnvelope.__eq__cCs t|jS)z,Return a string representation of the tuple.)strrr'rrr__str__Rs zEnvelope.__str__cCs<t|_|d|j_|d|j_|d|j_|d|j_dS)z@Initialize the C OGR Envelope structure from the given sequence.rrr*r+N)rrrrrr )r'seqrrrr Vs    zEnvelope._from_sequencecGst|dkrt|dtr||djSt|ddr7t|ddr7||dj|dj|dj|djSt|dttfrt|ddkra||dd|dd|dd|ddfSt|ddkr|d\}}}}||j j kr{||j _ ||j j kr||j _ ||j j kr||j _ ||j j kr||j _ d Sd Stdt|dtdt|dt|dkr||d|d|d|dfSt|dkr||Std t|d) z Modify the envelope to expand to include the boundaries of the passed-in 2-tuple (a point), 4-tuple (an extent) or envelope. rrxyr*rrrrN)rrrexpand_to_includerhasattrr2r3rrrrrr rr!r")r'r(minxminymaxxmaxyrrrr4^s4 (2      "  zEnvelope.expand_to_includecC|jjS)z-Return the value of the minimum X coordinate.)rrr/rrrr#zEnvelope.min_xcCr:)z-Return the value of the minimum Y coordinate.)rrr/rrrr%r;zEnvelope.min_ycCr:)z-Return the value of the maximum X coordinate.)rrr/rrrr$r;zEnvelope.max_xcCr:)z-Return the value of the maximum Y coordinate.)rr r/rrrr&r;zEnvelope.max_ycC |j|jfS)z"Return the upper-right coordinate.)r$r&r/rrrur z Envelope.urcCr<)z!Return the lower-left coordinate.)r#r%r/rrrllr>z Envelope.llcCs|j|j|j|jfS)z)Return a tuple representing the envelope.)r#r%r$r&r/rrrrszEnvelope.tuplec Cs0d|j|j|j|j|j|j|j|j|j|jf S)z4Return WKT representing a Polygon for this envelope.z(POLYGON((%s %s,%s %s,%s %s,%s %s,%s %s)))r#r%r&r$r/rrrwkts z Envelope.wktN)r r r r r)r-r0r r4propertyr#r%r$r&r=r?rr@rrrrrs.*       rN)r ctypesrrdjango.contrib.gis.gdal.errorrrrrrrrs