Changes between Version 2 and Version 3 of GeoDjangoDatabaseAPI
- Timestamp:
- Jul 14, 2007, 11:54:50 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GeoDjangoDatabaseAPI
v2 v3 100 100 = Extra Instance Methods = 101 101 102 A model with geometry fields will get the following methods, substitute {{{GEOM}}} with the name of the geometry field: 102 A 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. 103 105 104 106 == get_GEOM_ogr == … … 124 126 (10.0, 10.0) 125 127 }}} 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 #!python132 >>> from django.contrib.gis.geos import GEOSGeometry # Where to import from133 >>> dist = District.objects.get(name='Houston ISD')134 >>> geom = dist.get_poly_geos()135 >>> print geom.centroid.wkt136 POINT(-95.231713 29.723235)137 >>> print geom.area138 0.08332139 >>> print geom.geom_type140 Polygon141 >>> print geom.centroid.geom_type142 Point143 >>> print geom.intersects(GEOSGeometry('POINT(-95.395223 29.798088)'))144 False145 }}}146 147 == get_GEOM_srid ==148 149 Returns the SRID (source reference identifier) for the geometry.150 128 151 129 == get_GEOM_srs == … … 176 154 }}} 177 155 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 159 Returns 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 167 POINT(-95.231713 29.723235) 168 >>> print geom.area 169 0.08332 170 >>> print geom.geom_type 171 Polygon 172 >>> print geom.centroid.geom_type 173 Point 174 >>> print geom.intersects(GEOSGeometry('POINT(-95.395223 29.798088)')) 175 False 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 182 Returns the SRID (source reference identifier) for the geometry. 183 178 184 == 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)}}}. 179 187 180 188 Returns the OGC WKT (Well Known Text) for the geometry. For example (using the {{{School}}} model from the [wiki:GeoDjango#Example example]): … … 189 197 == get_GEOM_centroid == 190 198 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 191 201 This routine will return the centroid of the geometry. For example (using the {{{District}}} model from above): 192 202 … … 200 210 == get_GEOM_area == 201 211 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 202 214 This routine will return the area of the geometry field. 203 215