Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12390 closed (fixed)

distance query doesn't support * operand type

Reported by: dingle Owned by: nobody
Component: GIS Version: master
Severity: Keywords: geodjango distance
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Example:

>>>d1 = D(mi=10)
>>>d2 = D(mi=20) 
>>>qs = SouthTexasCity.objects.filter(point__distance_gte=(pnt, 0.5*d1 + 0.5*d2))

It raised:

TypeError: unsupported operand type(s) for *: 'float' and 'Distance'

But obviously it works fine with addition and subtraction. I think it will be nice that

multiplication be implemented as well.

Change History (3)

comment:1 Changed 5 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Mutiplication is supported, but only in right form: d1*0.5 would work. But yes, rmul seem to be forgotten at Distance class.

comment:2 Changed 5 years ago by jbronn

  • Resolution set to fixed
  • Status changed from new to closed

(In [11898]) Fixed #12390 -- Distance and Area objects now support multiplication when they are the right-hand side.

comment:3 Changed 5 years ago by jbronn

(In [11899]) [1.1.X] Fixed #12390 -- Distance and Area objects now support multiplication when they are the right-hand side.

Backport of r11898 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top