私はオブジェクトのコレクションを持っていPoint
ます。任意の 2 点間の最も遠い距離を見つけたいです。これらすべての点を囲む円を想像してください。その円の直径が知りたいです。GeoDjangoでこれを行うにはどうすればよいですか?
編集:これは私がこれまでに持っているものです:
>>> r=Route.objects.get(pk=1)
>>> a=Airport.objects.filter(routebase__route=r)
>>> # this route represents a few hundred miles flight into mexico and back
>>> a
[<Airport: MMDO>, <Airport: KELP>, <Airport: KELP>, <Airport: MMCU>]
>>> # a multipoint object with all the airports
>>> mpoint = a.collect()
>>> # a polygon that represents a ring around the multipoint
>>> p = mpoint.envelope
>>> #now I just need to get the diameter of this envelope
>>> p.length
19.065994262694986
???
それは何の単位ですか?これは私が求めている価値でもありますか?
edit2: OK、別の方法で試してみます:
>>> r=Route.objects.get(pk=1)
>>> a=Airport.objects.filter(routebase__route=r)
>>> # this route represents a few hundred miles flight into mexico
>>> a
[<Airport: MMDO>, <Airport: KELP>, <Airport: MMCU>]
>>> # a multipoint object with all the airports
>>> mpoint = a.collect()
>>> # get the center point of the route polygon and get the
>>> # distance between each point and the centroid
>>> # the largest should be the diameter of the ring, right?
>>> cen = mpoint.centroid
>>> dist = []
>>> for p in mp:
dist.append(LineString(p, cen).length)
>>> dis
[0.54555421739245946,
0.61638306853425906,
0.53442640535933494,
0.54555421739245946]
>>> max(dist)
0.61638306853425906
?? 繰り返しますが、これらの単位は何ですか?