Changes between Version 2 and Version 3 of GeoDjangoDatabaseAPI


Ignore:
Timestamp:
07/14/2007 11:54:50 AM (8 years ago)
Author:
jbronn
Comment:

updated with info about deprecated extra instance methods

Legend:

Unmodified
Added
Removed
Modified
  • GeoDjangoDatabaseAPI

    v2 v3  
    100100= Extra Instance Methods =
    101101
    102 A model with geometry fields will get the following methods, substitute {{{GEOM}}} with the name of the geometry field:
     102A model with geometry fields will get the following methods, substitute {{{GEOM}}} with the name of the geometry field.
     103
     104'''Update:''' All of the extra instance methods below (except {{{get_GEOM_ogr}}} and {{{get_GEOM_srs}}}) have been deprecated in r5657 due to lazy geometry support.  In other words, these properties may be directly accessed as attributes from the geometry field.  As part of the deprecation process, [http://docs.python.org/lib/module-warnings.html warnings] are issued when such methods are invoked so that users have notice to change their code before these methods disappear in the future.
    103105
    104106== get_GEOM_ogr ==
     
    124126(10.0, 10.0)
    125127}}}
    126 
    127 == get_GEOM_geos ==
    128 Returns a {{{GEOSGeometry}}} instance for the geometry.  For example (using the {{{District}}} model from the [wiki:GeoDjango#Example example]):
    129 
    130 {{{
    131 #!python
    132 >>> from django.contrib.gis.geos import GEOSGeometry # Where to import from
    133 >>> dist = District.objects.get(name='Houston ISD')
    134 >>> geom = dist.get_poly_geos()
    135 >>> print geom.centroid.wkt
    136 POINT(-95.231713 29.723235)
    137 >>> print geom.area
    138 0.08332
    139 >>> print geom.geom_type
    140 Polygon
    141 >>> print geom.centroid.geom_type
    142 Point
    143 >>> print geom.intersects(GEOSGeometry('POINT(-95.395223 29.798088)'))
    144 False
    145 }}}
    146 
    147 == get_GEOM_srid ==
    148 
    149 Returns the SRID (source reference identifier) for the geometry.
    150128
    151129== get_GEOM_srs ==
     
    176154}}}
    177155
     156== get_GEOM_geos ==
     157'''Update:''' This extra instance method was deprecated in r5657 -- and may now be accessed directly through the attribute name of the geometry field -- ''e.g.'', {{{dist.poly}}} returns a {{{GEOSGeometry}}} instance for the {{{PolygonField}}} of the {{{District}}} model.
     158
     159Returns a {{{GEOSGeometry}}} instance for the geometry.  For example (using the {{{District}}} model from the [wiki:GeoDjango#Example example]):
     160
     161{{{
     162#!python
     163>>> from django.contrib.gis.geos import GEOSGeometry # Where to import from
     164>>> dist = District.objects.get(name='Houston ISD')
     165>>> geom = dist.get_poly_geos()
     166>>> print geom.centroid.wkt
     167POINT(-95.231713 29.723235)
     168>>> print geom.area
     1690.08332
     170>>> print geom.geom_type
     171Polygon
     172>>> print geom.centroid.geom_type
     173Point
     174>>> print geom.intersects(GEOSGeometry('POINT(-95.395223 29.798088)'))
     175False
     176}}}
     177
     178== get_GEOM_srid ==
     179
     180'''Update:''' This extra instance method was deprecated in r5657 -- and may now be accessed directly through the attribute name of the geometry field -- ''e.g.'', {{{dist.poly.srid}}}.
     181
     182Returns the SRID (source reference identifier) for the geometry.
     183
    178184== get_GEOM_wkt ==
     185
     186'''Update:''' This extra instance method was deprecated in r5657 -- and may now be accessed directly through the attribute name of the geometry field -- ''e.g.'', {{{skool.point.wkt}}}, or simply {{{str(skool.point)}}}.
    179187
    180188Returns the OGC WKT (Well Known Text) for the geometry.  For example (using the {{{School}}} model from the [wiki:GeoDjango#Example example]):
     
    189197== get_GEOM_centroid ==
    190198
     199'''Update:''' This extra instance method was deprecated in r5657 -- and may now be accessed directly through the attribute name of the geometry field -- ''e.g.'', {{{dist.poly.centroid.wkt}}}.
     200
    191201This routine will return the centroid of the geometry.  For example (using the {{{District}}} model from above):
    192202
     
    200210== get_GEOM_area ==
    201211
     212'''Update:''' This extra instance method was deprecated in r5657 -- and may now be accessed directly through the attribute name of the geometry field -- ''e.g.'', {{{dist.poly.area}}}.
     213
    202214This routine will return the area of the geometry field.
    203215
Back to Top