Changes between Version 104 and Version 105 of GeoDjango


Ignore:
Timestamp:
Dec 8, 2007, 9:53:50 PM (17 years ago)
Author:
jbronn
Comment:

Updated FAQ.

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjango

    v104 v105  
    9292   * Geographic queries require {{{GeoManager}}}, even if the model does not have a geographic field itself (in the case of a foreign key to a geo-field).  The reply in the discussion gives detail into why.
    9393 * '''Q:''' Why are the OGRGeometry methods {{{transform}}} and {{{transform_to}}} separate?
    94    * Because these map to the separate OGR routines [http://www.gdal.org/ogr/ogr__api_8h.html#59a5b3f954b11cfbf6e78807c28d6090 OGR_G_Transform] and [http://www.gdal.org/ogr/ogr__api_8h.html#43af4c2127cea0a5059692a62c0feb63 OGR_G_TransformTo].  Specifically, the {{{transform}}} routine takes a !CoordTransform object as a parameter, whereas the {{{transform_to}}} routine takes a !SpatialReference object.  The {{{transform_to}}} "function requires internal creation and initialization of [a CoordTransform] object [and] it is significantly more expensive to use this function to transform many geometries than it is to create the [CoordTransform object] in advance, and call transform() with that transformation. This function exists primarily for convenience when only transforming a single geometry."
     94   * They are no longer separate, as `transform` now accepts `CoordTransform` and `SpatialReference` objects, as well as string WKT and integer SRID values (`transform` checks the input type and dispatches to the correct routine).  The former reason for the separation was that each mapped to the separate OGR routines [http://www.gdal.org/ogr/ogr__api_8h.html#59a5b3f954b11cfbf6e78807c28d6090 OGR_G_Transform] and [http://www.gdal.org/ogr/ogr__api_8h.html#43af4c2127cea0a5059692a62c0feb63 OGR_G_TransformTo].  For better performance use `CoordTransform` objects when you will be performing the same transformation repeatedly.
     95 * '''Q:''' Why don't `Q` objects work?
     96   * `Q` object functionality is for use with models that use `QuerySet`.  Because !GeoDjango models use `GeoQuerySet`, use the `GeoQ` object instead:
     97{{{
     98>>> from django.contrib.gis.db.models import GeoQ
     99>>> from geoapp.models import City, Country, State # See django.contrib.gis.tests.geoapp
     100>>> tx = Country.objects.get(name='Texas')
     101>>> ks = State.objects.get(name='Kansas')
     102>>> City.objects.filter(GeoQ(point__within=tx.mpoly) | GeoQ(point__within=ks.poly))
     103[<City: Houston>, <City: Dallas>, <City: Lawrence>]
     104}}}
    95105
    96106== Example ==
Back to Top