
TQc           @@  s  d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 m Z m Z m Z m Z m Z m Z d  d l m Z m Z m Z m Z m Z m Z m Z d  d l m Z d  d	 l m Z m Z d
 d l m Z m  Z  m! Z! m" Z" m# Z# d
 d l$ m% Z% d
 d l& m' Z' d
 d l( m) Z) e sQd
 d l m* Z* m+ Z+ n  d e f d     YZ, d e f d     YZ- d e f d     YZ. d S(   i    (   t   absolute_importN(   t
   connection(   t   DatabaseError(   t   gdal(   t   fromstrt   GEOSGeometryt   Pointt
   LineStringt
   LinearRingt   Polygont   GeometryCollection(   t   no_mysqlt	   no_oraclet   no_spatialitet   mysqlt   oraclet   postgist
   spatialite(   t   TestCase(   t   sixt   unittesti   (   t   Countryt   Cityt   PennsylvaniaCityt   Statet   Track(   t   GeoFeedTest(   t   GeoRegressionTests(   t   GeoSitemapTest(   t   Featuret   MinusOneSRIDt   GeoModelTestc           B@  sY   e  Z d    Z d   Z e d    Z d   Z e d    Z e d    Z	 d   Z
 RS(   c         C@  sO   |  j  d t j j    |  j  d t j j    |  j  d t j j    d S(   s6   Testing geographic model initialization from fixtures.i   i   N(   t   assertEqualR   t   objectst   countR   R   (   t   self(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_fixtures   s    c         C@  s  t  d d  } t d d d |  } | j   xN d d t d d  g D]4 } y | | _ Wn t k
 rm qG X|  j d  qG Wt  d d	  } | | _ |  j d
 | j j  | j   |  j | t j	 j
 d d  j  d	 | j _ d | j _ |  j t  d	 d  t j	 j
 d d  j  | j   |  j t  d	 d  t j	 j
 d d  j  | j   t d d d d d  } t d d d d d  } t | |  } t d d d |  } |  j d
 | j j  | j   t j	 j
 d d  }	 |  j | |	 j  t j r|  j t t |	 j j t j   |  j |	 j j |	 j j j  |  j t t |	 j j t j   |  j d |	 j j j  n  t d  d! d" d# d$  }
 |
 |	 j d <|
 | d <|  j d
 |	 j j  |	 j   |  j | t j	 j
 d d  j  |	 j   d S(%   s8   Testing Lazy-Geometry support (using the GeometryProxy).i    t   namet   NullCityt   pointi   g       @i   s   Should throw a TypeErrori   i  id   i(   i<   t	   NullStatet   polys   WGS 84i   iF   N(   i    i    (   i   i   (   i    i    (   i    id   (   id   id   (   id   i    (   i    i    (   i(   i(   (   i(   i<   (   i<   i<   (   i<   i(   (   i(   i(   (   i   i   (   i   iF   (   iF   iF   (   iF   i   (   i   i   (   R   R   t   saveR   R'   t	   TypeErrort   failR    t   sridR!   t   gett   xt   yt   assertNotEqualt   deleteR   R	   R   R)   R   t   HAS_GDALt   Truet
   isinstancet   ogrt   OGRGeometryt   wkbt   srst   SpatialReferenceR%   (   R#   t   pntt   nullcityt   badt   newt   shellt   innert   plyt	   nullstatet   nst	   new_inner(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt
   test_proxy#   sP    
	
"+
+

	""

"c   	      C@  sD  d } t  | d d } t r- d } d } n d } d } t  | d | } t ri t j j d |  } n t j j d	 |  } |  j d
 | j  t j j d d d |  } t j j d d  } |  j	 | j
 | j j
 d  |  j	 | j | j j d  t s@t d t d d d d  } | j   |  j d | j j  n  d S(   s4   Testing automatic transform for lookups and inserts.s   POINT (-98.493183 29.424170)R-   i  s)   POINT (300662.034646583 5416427.45974934)iŠ  s7   POINT (1645978.362408288754523 6276356.025927528738976)i  t   mpoly__containst   mpoly__intersectst   TexasR%   s   San AntonioR'   i   t   geomi   i   iN(   R   R   R   R!   R.   R    R%   R   t   createt   assertAlmostEqualR/   R'   R0   R   R   R   R*   RI   R-   (	   R#   t   sa_4326t   wgs_pntt   nad_wktt   nad_sridt   nad_pntt   txt   sat   m1(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_lookup_insert_transformg   s(    	
c         C@  s    t    } |  j | j d  d S(   s=   Testing creating a model instance and the geometry being NoneN(   R   R    R'   t   None(   R#   t   c(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_createnull   s    	c         C@  s  t  d d d t d d   j   t  d d d t d d d   j   t  d d d t t d d d d d    j   t  d d	 d t t d
 d
  t d d  t t d d d d d     j   t  j j d d  } |  j	 t
 t | j t   |  j	 d | j j  t  j j d d  } |  j	 t
 t | j t   |  j	 d d  d! f | j j  t  j j d d  } |  j	 t
 t | j t   t  j j d d	  } |  j	 t
 t | j t   |  j	 | j | j d
  d S("   s"   Testing the general GeometryField.R%   R   RI   i   R   i    i   R	   R
   i   g      ?g        g      @N(   i    i    (   i   i   (   i   i   (   i    i    (   i    i   (   i   i   (   i   i    (   i    i    (   i    i    (   i   i   (   i    i    (   i    i   (   i   i   (   i   i    (   i    i    (   g      ?g      ?(   g        g        (   g      ?g      ?(   g      @g      @(   R   R   R*   R   R	   R   R
   R!   R.   R    R4   R5   RI   t   tuple(   R#   t   f_1t   f_2t   f_3t   f_4(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_geometryfield   s"    "%1(c         C@  st   t  j j d d d d d d  } t  j j d  } |  j d | j    x$ | D] } |  j d | j j  qP Wd	 S(
   s6   Test GeoQuerySet methods on inherited Geometry fields.R%   t	   Mansfieldt   countyt   TiogaR'   s   POINT(-77.071445 41.823881)i}  i   N(   R   R!   RJ   t	   transformR    R"   R'   R-   (   R#   t	   mansfieldt   qst   pc(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_inherited_geofields   s
    ! c         C@  sz   t  j j   } t r d n d } t  j j d |  } |  j t |  t t |    |  j t	 | d j
 t   d S(   s   Testing raw SQL query.t	   ST_AsTextt   asTexts+   select id, name, %s(point) from geoapp_cityi    N(   R   R!   t   allR   t   rawR    t   lent   listt
   assertTrueR5   R'   R   (   R#   t   cities1t   as_textt   cities2(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_raw_sql_query   s
    "(   t   __name__t
   __module__R$   RE   R   RT   RW   R   R]   Re   Rp   (    (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyR      s   		D-	t   GeoLookupTestc           B@  s   e  Z e d     Z d   Z e e e d      Z d	 e j	 j
 k oV d
 k n rm e j e  Z n  d   Z e d    Z e d    Z RS(   c         C@  s   t  j j d d  } t  j j d | j  } |  j d | j    t j j d | j  } |  j d | j    |  j d | d j  d	 S(
   s#   Testing the `disjoint` lookup type.R%   t   Pueblot   point__disjointi   t   poly__disjointi   t   Kansasi    N(	   R   R!   R.   t   filterR'   R    R"   R   R%   (   R#   t   ptownt   qs1t   qs2(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_disjoint_lookup   s    c         C@  s,  t  j j d d  } t s t j j d | j  } |  j d | j    d d d g } x* | D] } |  j t	 | j
 | k  q_ Wn  t j j d d  } t j j d d  } t j j d d	  } t j j d d  } t j j d d
  }	 t  j j d | j  }
 t  j j d | j j  } |  j d |
 j
  |  j d | j
  t s{t j j d |	 j  } |  j d | j
  n  |  j d t t  j j d | j    |  j t rd pd t t  j j d | j j    t s(t  j j d | j  } |  j d t |   |  j d | d j
  n  d S(   sC   Testing the 'contained', 'contains', and 'bbcontains' lookup types.R%   RH   t   point__containedi   t   Houstont   Dallass   Oklahoma Cityt
   WellingtonRt   t   LawrenceRF   s   New Zealandt   poly__containsRw   i    i   t   mpoly__bbcontainsN(   R   R!   R.   R   R   Rx   t   mpolyR    R"   R4   R%   R'   t   hexR   R   Rj   R   t   wkt(   R#   t   texasRc   t   citiesRV   t   houstont
   wellingtont   pueblot   okcityt   lawrenceRQ   t   nzt   ks(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_contains_contained_lookups   s4      ("c         C@  s  t  j j d d  j } t  j j d d  j } d d d d d d	 g } t j j d
 |  } |  j d t |   x' | D] } |  j t | j	 | k  qz Wd d	 g } t j j d
 |  } |  j d t |   x' | D] } |  j t | j	 | k  q Wt j j d |  } |  j d | j	  d d g } t j j d |  } |  j d t |   x' | D] } |  j t | j	 | k  qdWd S(   s,   Testing the 'left' and 'right' lookup types.R%   t   ColoradoRw   R~   R   s   Oklahoma CityR   t   ChicagoR   t   point__righti   i   t   point__leftt   VictoriaRt   N(
   R   R!   R.   R)   R   Rx   R    Rj   R4   R%   (   R#   t	   co_bordert	   ks_borderR   Rc   RV   t   vic(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_left_right_lookups  s(    
	   i   i    i   c         C@  s   t  d d d } t j j d |  } t j j d |  } t j j d |  } x* | | | g D] } |  j d | j  qa Wd S(	   s0   Testing the 'same_as' and 'equals' lookup types.s   POINT (-95.363151 29.763374)R-   i  R'   t   point__same_ast   point__equalsR~   N(   R   R   R!   R.   R    R%   (   R#   R;   t   c1t   c2t   c3RV   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_equals_lookups1  s     c         C@  sN  t  j j d d  t  j j d t  } t  j j d t  } |  j d t |   |  j d | d j  |  j d t |   g  | D] } | j ^ q } |  j t d | k  |  j t d | k  t  j j d d	 d
 d  } |  j | j
 d  d | _
 | j   t  j j d d	  j d
 d  |  j d t  j j d d	  j
  d S(   s<   Testing NULL geometry support, and the `isnull` lookup type.R%   s   Puerto Ricot   poly__isnulli   i    i   R   Rw   s   Northern Mariana IslandsR)   s   POLYGON((0 0,1 0,1 1,1 0,0 0))N(   R   R!   RJ   Rx   R4   t   FalseR    Rj   R%   RU   R)   R*   t   updateR.   (   R#   t   nullqst   validqst   st   state_namest   nmi(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_null_geometries9  s    	
c   
      C@  s  t  d d d } t  d d d } |  j t t j j d d x] | d	 f t f | d
 d	 f t f g D]4 \ } } t j j d |  } |  j | | j  qh Wt s t r d
 } d } d } n t	 r d } d } d } n  |  j
 d t j j d | | f  j  |  j
 d t j j d | | f  j  t j j d d  }	 |  j
 d t j j d |	 j | f  j  t	 s|  j
 d t j j d | | f  j  |  j
 d t j j d | | f  j  |  j
 d t j j d |	 j | f  j  n  d S(   s!   Testing the 'relate' lookup type.s&   POINT (649287.0363174 4177429.4494686)R-   i  s)   POINT(-98.4919715741052 29.4333344025053)i  t   mpoly__relatei   t   fooi    s	   T*T***FF*s	   T*F**F***s	   T********t   containst   insidet   overlapbdyintersectRH   R%   Rw   R   t   point__relateN(   i   R   (   R   t   assertRaisest
   ValueErrorR   R!   Rx   R"   R   R   R   R    R.   R%   R   R   R)   (
   R#   t   pnt1t   pnt2t   bad_argst   eRc   t   contains_maskt   within_maskt   intersects_maskR   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_relate_lookupW  s,    4		((+(((   i   i    i    (   i   i    i   (   Rq   Rr   R   R|   R   R   R   R   R   t   opst   spatial_versionR   t   expectedFailureR   R   R   (    (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyRs      s   	.)"	t   GeoQuerySetTestc           B@  s[  e  Z e d     Z e d    Z e e d     Z e e e d      Z e e e d      Z	 d   Z
 d   Z d   Z e e e d      Z e d	    Z e e d
     Z e d    Z e e d     Z e e d     Z e e e d      Z d   Z e d    Z e e d     Z e d    Z RS(   c         C@  sy   t  j j d t  j   } t r* d } n t r9 d } n d } x3 | D]+ } |  j t | j j j	 | j |   qF Wd S(   s*   Testing the `centroid` GeoQuerySet method.R   g?gư>g&.>N(
   R   R!   t   excludeR4   t   centroidR   R   R    R)   t   equals_exact(   R#   Rc   t   tolR   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_centroid  s    		c         C@  s  t  d d  } d } t j j   j |  j |  j |  } t rZ | j d d  } n | j	 |  } x | D] } t
 r qp |  j | j j |  | j  t s |  j | j j	 |  | j	  n  |  j | j j |  | j  |  j | j j |  | j  qp Wd S(   s\   Testing the `difference`, `intersection`, `sym_difference`, and `union` GeoQuerySet methods.i   i   i   R%   RH   N(   R   R   R!   Rh   t
   differencet   sym_differencet   unionR   R   t   intersectionR   R    R   (   R#   RI   R   Rc   RV   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_diff_intersection_union  s    *"c         C@  s^   d
 } t  j j d d  } | j   } x0 t | |  D] \ } } |  j | | d  q7 Wd	 S(   s(   Testing the `extent` GeoQuerySet method.g   M3Xg_l=@g=Wgd@@t   name__inR~   R   i   N(   g   M3Xg_l=@g=Wgd@@(   s   Houstons   Dallas(   R   R!   Rx   t   extentt   zipRK   (   R#   t   expectedRc   R   t   valt   exp(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_extent  s
    c         C@  s   d	 d
 d d f d d d d f f } d d d d f d d d d f f } t  j j d d d t |    t  j j   j d d  } |  j | | j j  d S(   s    Testing GeoQuerySet.force_rhr().i    i   i   i   R%   t   FooR)   N(   i    i    (   i   i    (   i    i   (   i    i    (   i   i   (   i   i   (   i   i   (   i   i   (   i    i    (   i    i   (   i   i    (   i    i    (   i   i   (   i   i   (   i   i   (   i   i   (   R   R!   RJ   R	   t	   force_rhrR.   R    t   coords(   R#   t   ringst	   rhr_ringsR   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_force_rhr  s    c         C@  s   t  j j s d Sd } t j j   j d d  } t j j d d  j d d  } |  j | | j  |  j | d  | j  d S(   s   Testing GeoQuerySet.geohash().Nt   9vk1mfq8jx0c8e0386z6R%   R~   t	   precisioni   (   R   R   t   geohashR   R!   R.   R    (   R#   t   ref_hasht   h1t   h2(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_geohash  s     !c      
   C@  sj  t  j j s2 |  j t t j j   j d d d Sd } d } d } d } t rw t  j j	 d k  rw d } d } d } n t
 r d } n  |  j t t j j d d |  j | t j j   j d d  j  |  j | t j j d t d d  j d d  j  |  j | t j j d t  j d d  j  |  j | t j j d t d t d d  j d d  j  d S(   sE   Testing GeoJSON output from the database using GeoQuerySet.geojson().t
   field_nameR   Ns6   {"type":"Point","coordinates":[-104.609252,38.255001]}sm   {"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[-95.363151,29.763374]}ss   {"type":"Point","bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],"coordinates":[-123.305196,48.462611]}s   {"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[-87.65018,41.85039,-87.65018,41.85039],"coordinates":[-87.65018,41.85039]}i   i   i    s:   {"type":"Point","coordinates":[-104.60925200,38.25500100]}sj   {"type":"Point","crs":{"type":"EPSG","properties":{"EPSG":4326}},"coordinates":[-95.36315100,29.76337400]}sw   {"type":"Point","bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],"coordinates":[-123.30519600,48.46261100]}sk   {"type":"Point","bbox":[-123.305196,48.462611,-123.305196,48.462611],"coordinates":[-123.305196,48.462611]}R   R   R%   Rt   t   crst	   model_attt   jsonR~   t   bboxR   i   R   (   i   i   i    (   R   R   t   geojsonR   t   NotImplementedErrorR   R!   Rh   R   R   R   R+   R   R    R.   R4   R   (   R#   t   pueblo_jsont   houston_jsont   victoria_jsont   chicago_json(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_geojson  s$    "		(4.c      	   C@  s}  t  s t r? t j j r? |  j t t j j	   j d d d St
 j j	   } |  j t | j d d t
 j j d d d d  j d d  } t
 j j d d  j d d  } t r t j d	  } n9 t r t j j d k  r t j d  } n t j d  } x- | | g D] } |  j | j | j   qWt ryt j j d k ry|  j d t
 j j d d
  j d d  j  n  d S(   s=   Testing GML output from the database using GeoQuerySet.gml().R   R   NR%   R'   R   i	   Rt   s   ^<gml:Point srsName="SDO:4326" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="\." cs="," ts=" ">-104.60925\d+,38.25500\d+ </gml:coordinates></gml:Point>i   i    s   ^<gml:Point SrsName="EPSG::4326"><gml:coordinates decimal="\." cs="," ts=" ">-104.609251\d+,38.255001</gml:coordinates></gml:Point>sh   ^<gml:Point srsName="EPSG:4326"><gml:coordinates>-104\.60925\d+,38\.255001</gml:coordinates></gml:Point>i   i   s   <gml:pos srsDimension="2">t   version(   i   i    i    (   i   i   i    (   R   R   R   R   t   gmlR   R   R   R!   Rh   R   R+   R.   R   t   ret   compileR   Rl   t   matchR   t   assertIn(   R#   Rc   t   ptown1t   ptown2t	   gml_regexRy   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_gml  s"    "'!	c         C@  s   t  p t o t j j s> |  j t t j j	   j d d d St
 j j	   } |  j t | j d  t j j d k r~ d } n d } t
 j j d d	 d
 d  j d d  } t
 j j d
 d  j d d  } x' | | g D] } |  j | | j  q Wd S(   s=   Testing KML output from the database using GeoQuerySet.kml().R   R)   NR%   i   i   s?   <Point><coordinates>-104.609252,38.255001</coordinates></Point>sA   <Point><coordinates>-104.609252,38.255001,0</coordinates></Point>R'   R   i	   Rt   (   i   i   i   (   R   R   R   R   t   kmlR   R   R   R!   Rh   R   R+   R   R.   R    (   R#   Rc   t   ref_kmlR   R   Ry   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_kml   s    "	'!c         C@  s[   |  j  t t j j  |  j  t t j j  t d d d } |  j | t j j    d S(   s+   Testing the `make_line` GeoQuerySet method.s   LINESTRING(-95.363151 29.763374,-96.801611 32.782057,-97.521157 34.464642,174.783117 -41.315268,-104.609252 38.255001,-95.23506 38.971823,-87.650175 41.850385,-123.305196 48.462611)R-   i  N(	   R   R+   R   R!   t	   make_lineR   R   R    R   (   R#   t   ref_line(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_make_line:  s    c         C@  s   x* t  j j   D] } |  j d | j  q Wxa t j j d t  j   D]D } t rz t j	 j
 d k  rz |  j | j  qI |  j d | j  qI Wd S(   s*   Testing the `num_geom` GeoQuerySet method.i   t   point__isnulli    i   N(   i   i    i    (   R   R!   t   num_geomR    R   Rx   R   R   R   R   R   t   assertIsNone(   R#   RV   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_num_geomG  s    "c         C@  sm   x0 t  j j   D] } |  j | j j | j  q Wt si x- t j j   D] } |  j d | j  qI Wn  d S(   s,   Testing the `num_points` GeoQuerySet method.i   N(   R   R!   t
   num_pointsR    R   R   R   (   R#   RV   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_num_pointsW  s
     c         C@  s   t  r5 i t d d d d 6t d d d d 6} nM t sA t r i t j j d d  j j d 6t j j d d  j j d 6} n  xR t j j   D]A } t r d } n d	 } |  j	 t
 | | j j | j |   q Wd
 S(   s2   Testing the `point_on_surface` GeoQuerySet method.s   POINT (174.616364 -36.100861)R-   i  s   New Zealands   POINT (-103.002434 36.500397)RH   R%   gh㈵>g&.>N(   R   R   R   R   R   R!   R.   R   t   point_on_surfaceR    R4   R%   R   (   R#   t   refRV   R   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_point_on_surfaceb  s    "	c         C@  s   d	 d
 g } t  j j d d d t |   t  j j   j d d  } | j   |  j t |  | j j	  t
 r |  j t t j j  n  d S(   s#   Testing GeoQuerySet.reverse_geom().g =Wg|zl=@gWgd˻=@R%   R   t   lineN(   g =Wg|zl=@(   gWgd˻=@(   R   R!   RJ   R   t   reverse_geomR.   t   reverseR    RX   R   R   R   R+   R   (   R#   R   t   t(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_reverse_geom{  s    
c         C@  s   d	 \ } } d } t  j j | | d d } x | D] } x t | j | j  D] \ } } x t | |  D]p \ } }	 xa t | j |	 j  D]J \ }
 } |  j |
 d | | d |  |  j |
 d | | d |  q Wql WqP Wq4 Wd S(
   s'   Testing the `scale` GeoQuerySet method.i   i   i   R   t   scaledi    i   N(   i   i   (   R   R!   t   scaleR   R   R  R   RK   (   R#   t   xfact   yfacR   Rc   RV   t   p1t   p2t   r1t   r2R   R   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt
   test_scale  s    ""c         C@  s  x< d t  d  t  d  f D] } |  j t t j j |  q WxH d d t t t	 j
 t  d    f D] } |  j t t j j |  qg Wd } t j j d d d	 t |   } d
 } t d  } |  j | j t j j d  j d d  j |   t d  } |  j | j t j j d d  j d d  j |   t d  } |  j | j t j j d d d d  j d d  j |   d S(   s#   Testing GeoQuerySet.snap_to_grid().i   i   s   1.0g      ?i   s  MULTIPOLYGON(((12.41580 43.95795,12.45055 43.97972,12.45389 43.98167,12.46250 43.98472,12.47167 43.98694,12.49278 43.98917,12.50555 43.98861,12.51000 43.98694,12.51028 43.98277,12.51167 43.94333,12.51056 43.93916,12.49639 43.92333,12.49500 43.91472,12.48778 43.90583,12.47444 43.89722,12.46472 43.89555,12.45917 43.89611,12.41639 43.90472,12.41222 43.90610,12.40782 43.91366,12.40389 43.92667,12.40500 43.94833,12.40889 43.95499,12.41580 43.95795)))R%   s
   San MarinoR   g&.>s=   MULTIPOLYGON(((12.4 44,12.5 44,12.5 43.9,12.4 43.9,12.4 44)))g?sJ   MULTIPOLYGON(((12.4 43.93,12.45 43.93,12.5 43.93,12.45 43.93,12.4 43.93)))g?gq=
ףp?s_   MULTIPOLYGON(((12.4 43.87,12.45 43.87,12.45 44.1,12.5 44.1,12.5 43.87,12.45 43.87,12.4 43.87)))g      ?g(\?N(    (   s   1.0(   g      ?N(   t   rangeR   R   R   R!   t   snap_to_gridRU   RX   t   mapR   t	   text_typeR+   RJ   R   Rl   R   R.   (   R#   R   R   t   smR   R   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_snap_to_grid  s    ".!47c         C@  s   t  s t r& |  j t t j j  d S|  j t t j j d d d } | j d d  } |  j	 | t j j   j
 d d  j  |  j	 | t j j d	 d
  j
 d d  j  d S(   s+   Testing SVG output using GeoQuerySet.svg().NR   R   s    cx="-104.609252" cy="-38.255001"RV   t    R%   Rt   t   relativei   (   R   R   R   R   R   R!   t   svgR+   t   replaceR    R.   (   R#   t   svg1t   svg2(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_svg  s    (c         C@  sV  t  d d d } t  d d d } d } t s t j j | j  j d d  } |  j d | j j  |  j	 | j
 | j j
 |  |  j	 | j | j j |  n  t j j | j d	 d
 j d d  } t j j d | j  j d d  } xb | | g D]T } |  j d | j j  |  j	 | j
 | j j
 |  |  j	 | j | j j |  q Wd S(   s+   Testing the transform() GeoQuerySet method.s(   POINT(1947516.83115183 6322297.06040572)R-   i  s(   POINT(992363.390841912 481455.395105533)i
  i   R%   R~   R   R'   Rt   N(   R   R   R   R!   Ra   R-   R.   R    R'   RK   R/   R0   (   R#   t   htownRy   t   prect   hR	  R
  t   p(    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_transform  s    !'$c         C@  s   d \ } } t  j j | | d d } x | D] } x t | j | j  D] \ } } x t | |  D]p \ } } xa t | j | j  D]J \ }	 }
 |  j |	 d | |
 d d  |  j |	 d | |
 d d  q Wqf WqJ Wq. Wd S(	   s+   Testing the `translate` GeoQuerySet method.i   iR   t
   translatedi    i   N(   i   i(   R   R!   t	   translateR   R   R   R   RK   (   R#   R  R  Rc   RV   R	  R
  R  R  R   R   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_translate  s    ""c   	      C@  s
  t  j j d d  j } t d  } t d  } t j j d |  } |  j t | j	 d  | j	 d d  } | j
 d  j	   } d } t r | } n | } |  j t | j | |   |  j t | j | |   t j j d d  } |  j d	 | j	 d d   d	 S(
   s<   Testing the `unionagg` (aggregate union) GeoQuerySet method.R%   RH   s5   MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)t   point__withinR   R'   gh㈵>t   NotACityN(   R   R!   R.   R   R   R   Rx   R   R+   t   unionaggt   order_byR   R    R4   R   RU   (	   R#   RQ   t   union1t   union2Rc   t   u1t   u2R   R   (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   test_unionagg  s    	(   Rq   Rr   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  R"  R+  (    (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyR     s@   	'		
%	(/   t
   __future__R    R   t	   django.dbR   t   django.db.utilsR   t   django.contrib.gisR   t   django.contrib.gis.geosR   R   R   R   R   R	   R
   t   django.contrib.gis.tests.utilsR   R   R   R   R   R   R   t   django.testR   t   django.utilsR   R   t   modelsR   R   R   R   R   t
   test_feedsR   t   test_regressR   t   test_sitemapsR   R   R   R   Rs   R   (    (    (    s>   ../Django//lib/python/django/contrib/gis/tests/geoapp/tests.pyt   <module>   s"   44(