#17736: django.contrib.gis.geos.polygon from_bbox loss of floating-point 
accuracy
-------------------------+--------------------------------------
     Reporter:  tdihp@…  |                    Owner:  nobody
         Type:  Bug      |                   Status:  new
    Component:  GIS      |                  Version:  1.3
     Severity:  Normal   |               Resolution:
     Keywords:           |             Triage Stage:  Unreviewed
    Has patch:  0        |      Needs documentation:  0
  Needs tests:  0        |  Patch needs improvement:  0
Easy pickings:  0        |                    UI/UX:  0
-------------------------+--------------------------------------
Changes (by claudep):

 * needs_better_patch:   => 0
 * component:  Uncategorized => GIS
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 In any case, whenever you are using floating-point values, rounding will
 occur at some point. Currently, from_bbox uses the Python built-in str
 which defaults to 12 significant digits. Of course, you can always do the
 rounding yourself. For example, to keep 25 significant numbers:
 {{{
 >>> l,t,r,b = 0.0,0.0,format(math.pi, '.25f'), format(math.pi, '.25f')
 >>> Polygon.from_bbox((l,t,r,b)).coords
 (((0.0, 0.0),
   (0.0, 3.1415926535897931),
   (3.1415926535897931, 3.1415926535897931),
   (3.1415926535897931, 0.0),
   (0.0, 0.0)),)
 }}}

 So even with 25 significant numbers, it seems GEOS rounds to 16. Should
 from_bbox also default to 16 significant digits?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17736#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to