Example #1
0
 def test_center_from_points_qs(self):
     qs = Address.objects.all()
     centre = centre_from_points_qs(qs)
     self.assertEqual(
         centre.wkt,
         "POINT (0.7195476867864934 52.0965233704130242)"
     )
Example #2
0
def geocode_point_only(postcode):
    """
    Try to get centre of the point from AddressBase, fall back to MapIt
    """
    addresses = Address.objects.filter(postcode=postcode)
    if not addresses:
        time.sleep(1.3)
        return geocode(postcode)

    centre = centre_from_points_qs(addresses)
    return {
        'wgs84_lon': centre.x,
        'wgs84_lat': centre.y,
    }