Django

Code

Changeset 7407

Show
Ignore:
Timestamp:
04/07/08 17:20:58 (3 months ago)
Author:
jbronn
Message:

gis: Applied DRY to Oracle and MySQL geometry adaptors; the PostGISAdaptor now stores WKB in raw string form to support pickling; added an equivalence method to all adaptors.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/db/backend/__init__.py

    r7104 r7407  
    4848    SPATIAL_BACKEND = 'postgis' 
    4949elif settings.DATABASE_ENGINE == 'oracle': 
    50     from django.contrib.gis.db.backend.oracle.adaptor import \ 
    51         OracleSpatialAdaptor as GeoAdaptor 
     50    from django.contrib.gis.db.backend.adaptor import WKTAdaptor as GeoAdaptor 
    5251    from django.contrib.gis.db.backend.oracle.field import \ 
    5352        OracleSpatialField as GeoBackendField 
     
    5958    LIMITED_WHERE = ['relate'] 
    6059elif settings.DATABASE_ENGINE == 'mysql': 
    61     from django.contrib.gis.db.backend.mysql.adaptor import \ 
    62         MySQLAdaptor as GeoAdaptor 
     60    from django.contrib.gis.db.backend.adaptor import WKTAdaptor as GeoAdaptor 
    6361    from django.contrib.gis.db.backend.mysql.field import \ 
    6462        MySQLGeoField as GeoBackendField 
  • django/branches/gis/django/contrib/gis/db/backend/postgis/adaptor.py

    r6886 r7407  
    99class PostGISAdaptor(object): 
    1010    def __init__(self, geom): 
    11         "Initializes on the geometry and the SRID." 
    12         # Getting the WKB and the SRID 
    13         self.wkb = geom.wkb 
     11        "Initializes on the geometry." 
     12        # Getting the WKB (in string form, to allow easy pickling of 
     13        # the adaptor) and the SRID from the geometry. 
     14        self.wkb = str(geom.wkb) 
    1415        self.srid = geom.srid 
    1516 
     
    2122            raise Exception('Error implementing psycopg2 protocol. Is psycopg2 installed?') 
    2223 
     24    def __eq__(self, other): 
     25        return (self.wkb == other.wkb) and (self.srid == other.srid) 
     26 
    2327    def __str__(self): 
    2428        return self.getquoted() 
  • django/branches/gis/django/contrib/gis/db/models/query.py

    r7175 r7407  
    292292                if not isinstance(geo_field, PointField):  
    293293                    raise TypeError('Spherical distance calculation only supported on PointFields.') 
    294                 if not isinstance(GEOSGeometry(params[0].wkb), Point): 
     294                if not isinstance(GEOSGeometry(buffer(params[0].wkb)), Point): 
    295295                    raise TypeError('Spherical distance calculation only supported with Point Geometry parameters') 
    296296