Esempio n. 1
0
    def test_add_coordinates(self, geocode_update):
        """
        Test adding extra details.
        """
        from geocode import geocode_address, add_coordinates
        from uuid import uuid4

        point_uuid = uuid4()
        geocode_address(point_uuid, 'Eiffel Tower, Paris, France',
                        cluster='test')
        geocode_update.reset_mock()

        add_coordinates(point_uuid, [48.8582653, 2.2944946], tags=['ios', ])

        match_coordinates = Matcher(compare, [48.8582653, 2.2944946], 4)
        geocode_update.assert_called_once_with(sender=ANY,
                                               cluster='test',
                                               point_uuid=point_uuid,
                                               coordinates=match_coordinates)
Esempio n. 2
0
    def test_initial_geocode(self, geocode_update):
        """
        Test GEO coding of initial address.
        """
        from geocode import geocode_address
        from uuid import uuid4

        point_uuid = uuid4()
        geocode_address(point_uuid, 'Eiffel Tower, Paris, France')

        match_coordinates = Matcher(compare, [48.8582653, 2.2944946], 6)
        geocode_update.assert_called_once_with(sender=ANY,
                                               cluster=None,
                                               point_uuid=point_uuid,
                                               coordinates=match_coordinates)

        self.assertEqual(len(self.geocoders), 2)
        for geocoder in self.geocoders:
            geocoder.assert_called_once_with('Eiffel Tower, Paris, France')
Esempio n. 3
0
def address_search(query):

        geocode_result = geocode.geocode_address(query)

        if geocode_result is None:
            return Vendor.objects.none()
        latitude, longitude, neighborhood = geocode_result

        point = Point(x=longitude, y=latitude, srid=4326)
        vendors = Vendor.objects.approved().filter(
            location__dwithin=(point, .004))

        return vendors
Esempio n. 4
0
def perform_address_search(initial_queryset, query):
    vendors = initial_queryset

    # todo this is a mess!
    geocode_result = geocode.geocode_address(query)

    if geocode_result == None:
        return []
    latitude, longitude, neighborhood = geocode_result

    point = Point(x=longitude, y=latitude, srid=4326)
    vendors = Vendor.objects.filter(location__dwithin=(point, .004))

    return vendors
Esempio n. 5
0
def perform_address_search(initial_queryset, query):
        vendors = initial_queryset

        # todo this is a mess!
        geocode_result = geocode.geocode_address(query)

        if geocode_result == None:
            return []
        latitude, longitude, neighborhood = geocode_result

        point = Point(x=longitude, y=latitude, srid=4326)
        vendors = Vendor.objects.filter(location__dwithin=(point, .004))

        return vendors
Esempio n. 6
0
    def apply_geocoding(self):

        geocode_result  = geocode.geocode_address(self.address)
        latitude, longitude, neighborhood = geocode_result

        if neighborhood:
            neighborhood_obj = None
            try:
                neighborhood_obj = Neighborhood.objects.get(name=neighborhood)
            except:
                pass

            if not neighborhood_obj:
                    neighborhood_obj = Neighborhood()
                    neighborhood_obj.name = neighborhood
                    neighborhood_obj.save()

            self.neighborhood = neighborhood_obj

        self.location = Point(x=longitude, y=latitude, srid=4326)