Ticket #17736: 17736_gis_precision.diff
File 17736_gis_precision.diff, 1.6 KB (added by , 12 years ago) |
---|
-
django/contrib/gis/geos/tests/test_geos.py
381 381 p = Polygon.from_bbox( bbox ) 382 382 self.assertEqual(bbox, p.extent) 383 383 384 # Testing numerical precision when using `from_bbox` 385 x = 3.14159265358979323 386 B = (0, 0, 1, x) 387 p = Polygon.from_bbox(B) 388 y = p.extent[-1] 389 self.assertEqual(format(x, '.13f'), format(y, '.13f')) 390 384 391 prev = fromstr('POINT(0 0)') 385 392 for p in self.geometries.polygons: 386 393 # Creating the Polygon, testing its properties. -
django/contrib/gis/geos/polygon.py
55 55 def from_bbox(cls, bbox): 56 56 "Constructs a Polygon from a bounding box (4-tuple)." 57 57 x0, y0, x1, y1 = bbox 58 return GEOSGeometry( 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % ( 59 x0, y0, x0, y1, x1, y1, x1, y0, x0, y0) ) 58 for z in bbox: 59 if not isinstance(z, (int, long, float)): 60 return GEOSGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % 61 (x0, y0, x0, y1, x1, y1, x1, y0, x0, y0)) 62 return Polygon(((x0, y0), (x0, y1), (x1, y1), (x1, y0), (x0, y0))) 60 63 61 64 ### These routines are needed for list-like operation w/ListMixin ### 62 65 def _create_polygon(self, length, items):