﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28738	Add support for PostGIS <-> operator	Matthew Somerville	Francisco Couzo	"https://postgis.net/docs/geometry_distance_knn.html – this function is so much quicker when looking up the nearest neighbour of an index, and it'd be great to be built into Django. For example, on a dataset of c. 1.8 million rows:
{{{
postcode = Postcode.objects
    .filter(location__distance_gte=(location, D(mi=0)))
    .distance(location)
    .order_by('distance')[0]
}}}
took 5 seconds, whereas:
{{{
postcode = Postcode.objects
    .annotate(centroid_distance=GeometryCentroidDistance('location', location))
    .filter(centroid_distance__gte=0)
    .distance(location)
    .order_by('centroid_distance')[0]
}}}
is pretty instantaneous.

(Where GeometryCentroidDistance is a Func subclass that sets` function=''`, `arg_joiner =  '<-> '`, output_field FloatField.)

(There is also `<#>` https://postgis.net/docs/geometry_distance_box.html)"	New feature	closed	GIS	1.11	Normal	fixed			Ready for checkin	1	0	0	0	0	0
