Re: [Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-14 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
--+--
 Reporter:  django@…  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  GIS   |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by Claude Paroz ):

 In [changeset:"ec2f0417364050aed3e8c2aa1948915d08c39514"]:
 {{{
 #!CommitTicketReference repository=""
 revision="ec2f0417364050aed3e8c2aa1948915d08c39514"
 [1.7.x] Complemented dwithin docs about using geographic geometries

 Refs #22830. Thanks dja...@gfairchild.com for the suggestion.
 Backport of c281831a5c from master.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.1977e11b47170fec3dee2c09acad98b4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-14 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
--+--
 Reporter:  django@…  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  GIS   |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by Claude Paroz ):

 In [changeset:"c281831a5cb20a31cb080ff7b4af4bcfc83fcf3d"]:
 {{{
 #!CommitTicketReference repository=""
 revision="c281831a5cb20a31cb080ff7b4af4bcfc83fcf3d"
 Complemented dwithin docs about using geographic geometries

 Refs #22830. Thanks dja...@gfairchild.com for the suggestion.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.1188ae9ffbf4cec8ff624b2b416261bf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-14 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
--+--
 Reporter:  django@…  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  GIS   |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by django@…):

 Replying to [comment:3 claudep]:
 > Would something like that be clear enough for you?
 >
 > {{{
 > diff --git a/docs/ref/contrib/gis/geoquerysets.txt
 b/docs/ref/contrib/gis/geoquerysets.txt
 > index 957a049..dd2dfe8 100644
 > --- a/docs/ref/contrib/gis/geoquerysets.txt
 > +++ b/docs/ref/contrib/gis/geoquerysets.txt
 > @@ -613,8 +613,11 @@ SpatiaLite  ``Distance(poly, geom) <= 5``
 >  dwithin
 >  ---
 >
 > -Returns models where the distance to the geometry field from the
 > -lookup geometry are within the given distance from one another.
 > +Returns models where the distance to the geometry field from the lookup
 > +geometry are within the given distance from one another. Note that you
 can only
 > +provide :class:`~django.contrib.gis.measure.Distance` objects if the
 targeted
 > +geometries are in a projected system. For geographic geometries, you
 should use
 > +units of the geometry field (e.g. degrees for ``WGS84``) .
 >
 >  Example::
 > }}}

 Yes, that would be excellent!

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.892464622825df18b20c8d49eb575f68%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-14 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
--+--
 Reporter:  django@…  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  GIS   |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by claudep):

 Would something like that be clear enough for you?

 {{{
 diff --git a/docs/ref/contrib/gis/geoquerysets.txt
 b/docs/ref/contrib/gis/geoquerysets.txt
 index 957a049..dd2dfe8 100644
 --- a/docs/ref/contrib/gis/geoquerysets.txt
 +++ b/docs/ref/contrib/gis/geoquerysets.txt
 @@ -613,8 +613,11 @@ SpatiaLite  ``Distance(poly, geom) <= 5``
  dwithin
  ---

 -Returns models where the distance to the geometry field from the
 -lookup geometry are within the given distance from one another.
 +Returns models where the distance to the geometry field from the lookup
 +geometry are within the given distance from one another. Note that you
 can only
 +provide :class:`~django.contrib.gis.measure.Distance` objects if the
 targeted
 +geometries are in a projected system. For geographic geometries, you
 should use
 +units of the geometry field (e.g. degrees for ``WGS84``) .

  Example::
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.531e62241483a1047ac30fcbfa439577%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-14 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
--+--
 Reporter:  django@…  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  GIS   |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by django@…):

 Replying to [comment:1 claudep]:
 > The error message is pretty clear. As your objects are in geographic
 coordinates (geometry fields default to WGS84), you have to provide the
 distance as degree units. This is for example matching the PostGIS
 definition:
 > {{{
 > boolean ST_DWithin(geometry g1, geometry g2, double precision
 distance_of_srid);
 > }}}
 > `distance_of_srid` being degrees for WGS84. So the `5` that works in
 your example means 5 degrees, not 5 km!
 >
 > You could argue that !GeoDjango could automatically cast geographic
 fields to geometry types when distance is a `Distance` object. It is
 unfortunately not as smart currently. See #17635 for a similar feature
 request (but in the opposite direction).

 The error may be clear, but the cause isn't (which is why I had to submit
 this bug report). Either GeoDjango should correctly handle `Distance`
 objects in all cases, or the documentation should be edited to make it
 clear that `Distance` objects don't work in all cases. Since #17635 has
 been open for 2 years without any progress, I'd opt for the latter. I
 don't see anywhere in the documentation that even hints that `Distance`
 objects can't be used for the dwithin query in certain cases.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.2360dec35b394665e0c264a088975310%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-14 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
--+--
 Reporter:  django@…  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  GIS   |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 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):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => invalid
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 The error message is pretty clear. As your objects are in geographic
 coordinates (geometry fields default to WGS84), you have to provide the
 distance as degree units. This is for example matching the PostGIS
 definition:
 {{{
 boolean ST_DWithin(geometry g1, geometry g2, double precision
 distance_of_srid);
 }}}
 `distance_of_srid` being degrees for WGS84. So the `5` that works in your
 example means 5 degrees, not 5 km!

 You could argue that !GeoDjango could automatically cast geographic fields
 to geometry types when distance is a `Distance` object. It is
 unfortunately not as smart currently. See #17635 for a similar feature
 request (but in the opposite direction).

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.fae887a8ba4c97ac2c3ef5f6cb7a1d49%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D

2014-06-13 Thread Django
#22830: GeoDjango dwithin errors when using django.contrib.gis.measure.D
+
 Reporter:  django@…|  Owner:  nobody
 Type:  Bug | Status:  new
Component:  GIS |Version:  1.6
 Severity:  Normal  |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0   |  UI/UX:  0
+
 First off, I started a StackOverflow thread
 [http://stackoverflow.com/questions/24194710/geodjango-dwithin-error-
 argument-of-type-geoqueryset-is-not-iterable here] but haven't come up
 with an answer yet. I think there may be a bug in Django somewhere.

 Versions: Python 2.7.6, Django 1.6.5, Postgres 9.3.4, PostGIS 2.1.3,
 psycopg2 2.5.3 on RHEL 6.5

 Here's the model I'm using:

 {{{
 #!python
 class Location(models.Model):
 name = models.CharField(max_length=255)
 geometry = models.MultiPolygonField(blank=True, default=None,
 null=True)
 objects = models.GeoManager()  # override the default manager with a
 GeoManager instance
 parent = models.ForeignKey('self', blank=True, default=None,
 null=True)

 def __unicode__(self):
 return self.name
 }}}

 This query should work
 [https://docs.djangoproject.com/en/1.6/ref/contrib/gis/geoquerysets/#std
 :fieldlookup-dwithin according to the docs]:

 {{{
 #!python
 touching_locations =
 Location.objects.filter(geometry__dwithin=(location.geometry, D(km=5)))
 logging.debug(type(touching_locations))
 logging.debug(len(touching_locations))
 }}}

 But it doesn't. The first debug call works, but the second throws a
 `ValueError`:

 {{{
 
 ValueError: Only numeric values of degree units are allowed on geographic
 DWithin queries.
 }}}

 If I make a small change by changing `D(km=5)` to `5`:

 {{{
 #!python
 touching_locations =
 Location.objects.filter(geometry__dwithin=(location.geometry, 5))
 logging.debug(type(touching_locations))
 logging.debug(len(touching_locations))
 }}}

 All of a sudden it works. The output I get is this:

 {{{
 
 54
 }}}

 Is there a bug somewhere in Django? Am I misunderstanding how to use `D`?
 Are the Django docs incorrect? Is something else going on here? I
 appreciate any help I can get. Thanks!

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.4fa2f190eff13fe5715fd102517e0e40%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.